Skip to main content

Hi Folks,

I am wondering if anyone knows of a way to access the Print to PDF feature programmatically? Ideally, here is what I want to do.

I have a form that will be filled out iteratively over time as data comes in. Once the content manager is done with it (usually about a day of work), he will click a button and the form will be "printed to PDF", the PDF will be named using some form data, and the PDF will be saved into a library on the same site where I will have a workflow that will attach the file to an email sending it to a distribution list that includes our customer, some of whom do not have access to our SharePoint site.

Based on some things I have recently learned from @MegaJerk in responses to previous posts, I suspect that this should most elegantly be accomplished by using JavaScript in the Client Click formula of a button control on the form. While I am starting to get more familiar with both JS and how to apply it to Nintex projects, I do not know where to start here or even if it can be done.

 

Thanks and Best Regards,

Patrick

About as far as you can take it with PDFs out of the box is just "clicking" the button via js to initiate the generation of a pdf as if you / a user had done it. Actually controlling the contents of the pdf or where it goes is not something that at least I know how to do. 



 



Not to mention, the PDF documents generated from the built in PDF creator, while better than nothing, leave a lot to be desired as it's essentially just as if you had printed the HTML page which isn't always desired (because it lacks all sort of formatting and other such "branding" typical of what most businesses want). 



 



I personally went down the route of using a third party pdf gen javascript library called PDFMake (http://pdfmake.org/#/) which can be used to generate pdfs however you may desire but requires some work to get setup in such a way that it's making them to your exact specifications. And while I am not currently doing something like generating a pdf to a stream and then automagically uploading it into sharepoint at the click of a button, I believe that it *can* be done in a straight forward way using the SharePoint REST API (or better yet, something like SPServices https://github.com/sympmarc/SPServices).



 



The only other option I could think of would be to go down the Nintex DocGen route https://www.nintex.com/process-automation/document-generation/



 



So yeah. It's a "build it yourself" or "find an existing product that works and buy it" kinda situation! 



 



 



 


Here is another idea to consider.  Use the Document Generation workflow steps to do the conversion in the workflow instead of the form.   


I use a product called SharePoint Convert to PDF by Muhimbi: https://www.muhimbi.com/products/pdf-converter-for-sharepoint/

It integrates with Nintex Workflow perfectly and generates nice looking PDFs.


Reply