Blog
Generate PDFs from Salesforce Apex
We released the full code and documentation on GitHub. See full details on how to generate PDFs using Salesforce.
Many developers moving to Salesforce are used to the power of .NET or Java and have their favorite way of generating PDFs from HTML. Api2Pdf is a wrapper for wkhtmltopdf, Headless Chrome, and LibreOffice and proudly runs on AWS Lambda to allow for extremely low cost PDF conversions with no rate limits or file size limits. You can also generate bar codes and qr codes using ZXING.
In addition to our github code we have created an open source, unmanaged package, to allow you to quickly add the Api2Pdf libraries into your application. In one click you can install all of the necessary apex codes and test pages to jump start any project you might be working on.
- Read the full install steps here
- Install the unmanaged package
- Add / modify the code to suit the needs of your custom app
- Include the api2pdf library in any managed package you wish to redistribute, this is an open source MIT licensed package
Once you have the library installed, the library is as easy to use as:
Api2PdfClient a2pClient = new Api2PdfClient("your-api-key"); Api2PdfResponse response = a2pClient.headlessChromeFromHtml('<p>test</p>', true, 'test.pdf'); String pdfUrl = response.getPdf();