function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
G10G10 

Generate PDF file of specific format with Dynamic details on a button click

Hi Champs,

Recently I got a business requirement where I need to generate a complex pdf file. PDF file format is static (logo, signature, few static questions) but it has some dynamic content that needs to be replaced by real-time values (stored in Salesforce object). 

I thought about a few approaches as listed below - 

1. https://stackoverflow.com/questions/24944404/fill-pdf-form-with-javascript-client-side-only

this is my preferred option but couldn't work out in my scenario - I uploaded my pdf file into static resource and read in the Javascript code but couldn't pass the content to the method listed on the above link to replace the content. I'm getting error - 'parameter 1 is not of type 'Blob''

Let me know if anyone of you has tried this approach and have a workable solution?

 2. http://santanuboral.blogspot.com/2020/10/lwc-generate-pdf.html 

this is my second approach but it sounds complex as pdf is very complex to generate in HTML form plus end-user can modify the content which I don't want.

 3. https://medium.com/@ToAnshulVerma/lightning-generate-pdf-within-lightning-experience-with-salesforce-data-cd82ae626cc3 

the Third option is the traditional Vf page with render as pdf option, but again it's time-consuming and required a lot of front-end work.

I'm still keen to get my first solution working as it required less front-end work and can replace few values on the pdf file and regenerate the pdf file.

Let me know what you guys think? 

Cheers