Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Download CRM Form as PDF

Posted on by 85

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
            });
        }


*This post is locked for comments

  • Suggested answer
    Rahul-Waghmare Profile Picture
    Rahul-Waghmare 990 on at
    RE: Download CRM Form as PDF

    Hi Mahesh,

    One more solution is,

    1. Create HTML web-resource, fetch all the fields based on record id.

    2. Create Ribbon Button "Download".

    3. Download PDF format from that HTML.

    For downloading use your method, rather than downloading from CRM form directly try to download from HTML Page then html2canvas and jspdf libraries will support.

    Regards,

    Rahul

  • Mahesh 1992 Profile Picture
    Mahesh 1992 85 on at
    RE: Download CRM Form as PDF

    Hi Rahul,

    Problem is that I dont have to give this feature only for one entity, but all entities accross CRM.

    Thanks

  • Suggested answer
    Rahul-Waghmare Profile Picture
    Rahul-Waghmare 990 on at
    RE: Download CRM Form as PDF

    Hi Mahesh,

    You need to create single SSRS Report for your entity by passing "RecordId" as parameter. Create a report in a such away that it will get all the field values of an entity based on your RecordId.

    Regards,

    Rahul.

  • Mahesh 1992 Profile Picture
    Mahesh 1992 85 on at
    RE: Download CRM Form as PDF

    Hi Aluge,

    Same goes for document templates too, i cant create document templates for each and every form. I need a generic solution.

    Thanks

  • Mahesh 1992 Profile Picture
    Mahesh 1992 85 on at
    RE: Download CRM Form as PDF

    HI Rahul,

    Thanks for your reply, but client want to download each and every form in CRM , let us suppose i have around 1000 forms, if i go ahead and create ssrs reports for each and every one, then my whole development time will be gone in developing ssrs reports.

  • Suggested answer
    Alagunellaikumar Profile Picture
    Alagunellaikumar 6,210 on at
    RE: Download CRM Form as PDF

    Hi

    Why don't you try the below the way?

    We can use ssrs report and download it as pdf from CRM form.

    You can also use document template.

  • Suggested answer
    Rahul-Waghmare Profile Picture
    Rahul-Waghmare 990 on at
    RE: Download CRM Form as PDF

    Hi Mahesh,

    You can achieve this my creating SSRS report and download it as pdf. Please follow below link-

    www.c-sharpcorner.com/.../generate-pdf-file-using-javascript-in-microsoft-dynamics-crm-2015

    Regards,

    Rahul

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans