1

I have an aspx page that has a button:

<input type="button" class="create_pdf" id="create_pdf" value="Generate PDF" /> 

that generates a pdf file from html using jspdf. Everything works perfectly from a desktop and laptop computer but for some reason clicking the button on Chrome ios from an ipad does nothing. Any suggestion on a resolution? Below is the code:

<script src="https://code.jquery.com/jquery-1.12.4.min.js" integrity="sha256-ZosEbRLbNQzLpnKIkEdrPv7lOy9C27hHQ+Xp8a4MxAQ=" crossorigin="anonymous"></script>  

<script>
    (function () {
        var
         form = $('.form'),
         cache_width = form.width(),
         legal = [612.00, 1008.00]; // for legal size paper width and height  

        $('#create_pdf').on('click', function () {
            $('body').scrollTop(0);
            createPDF();
        });
        //create pdf  
        function createPDF() {
            getCanvas().then(function (canvas) {
                var
                 img = canvas.toDataURL("image/png"),
                 doc = new jsPDF(
                    {
                        orientation: "p",
                        unit: 'px',
                        format: 'legal',
                    }
                 );

                var position = 0;
                var imgWidth = 790;
                var pageHeight = 1296;
                var imgHeight = canvas.height * imgWidth / canvas.width;
                var heightLeft = imgHeight;

                doc.addImage(img, 'PNG', 0, position, imgWidth, imgHeight);

                window.open(doc.output('bloburl'), '_self');
                form.width(cache_width);
            });
        }

        // create canvas object  
        function getCanvas() {

            return html2canvas(form, {
                imageTimeout: 2000,
                removeContainer: true
            });
        }

    }());
</script>  
Dr.Prog
  • 229
  • 3
  • 13
  • this says you can just give your #create_pdf `cursor: pointer;`, seems too easy but worth a shot (might just work on divs you want clickable) - https://stackoverflow.com/questions/3705937/document-click-not-working-correctly-on-iphone-jquery – IrkenInvader Nov 15 '17 at 17:33
  • @IrkenInvader I've tried that solution but got the same results unfortunately... – Dr.Prog Nov 15 '17 at 18:30
  • Were you able to solve this issue? For me the PDF download is crashing in chrome – Mumzee Dec 12 '19 at 11:21

0 Answers0