Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 46379

Download CRM Form as PDF

$
0
0

Hi, Recently I had been asked by a client that they require to download a complete CRM Form as PDF.

I tried with html2canvas and jspdf libraries , but i was not able to download the form completely.

Please guide me if i am doing something wrong in the below code or there is any other way to do so.

      function createPDF() {
        var a4 = [595.28, 841.89];

            var div = $('#HeaderTilesWrapperLayoutElement', window.parent.document);

            var xxxx = $($(div.context).find('iframe')[0]).contents().find("body");

            var xxx = xxxx.find("#tdAreas");
            var cache_width = xxx.width();

            $('body').scrollTop(0);
            getCanvas().then(function (canvas) {
                var
                 img = canvas.toDataURL("image/png"),
                 doc = new jsPDF({
                     unit: 'px',
                     format: 'a4'
                 });
                doc.addImage(img, 'JPEG', 20, 20);
                doc.save('techumber-html-to-pdf.pdf');
                 xxx.width((a4[0] * 1.33333) - 80).css('max-width', 'none');
            });
        }

        // create canvas object
        function getCanvas() {
            xxx.width((a4[0] * 1.33333) - 80).css('max-width', 'none');
            return html2canvas(xxx, {
                imageTimeout: 2000,
                removeContainer: true
            });
        }



Viewing all articles
Browse latest Browse all 46379

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>