Using the URL-to-PDF Conversion PRO Feature
Posted by Duane Roumel on 10 May 2013 07:20 PM
The URL-to-PDF Conversion PRO Feature is used to convert a URL to PDF file format.
This feature is based on the most advanced and stable PDF conversion open-source resource. However, in many cases, the formatting inside the PDF does not match the website. This is due to limitations of the rendering engine for PDF. As the community improves this utility, we will update our integration of it in order to support more websites.
On occasion, we have assisted customers who needed to provide a more accurate rendering of a URL in a PDF. We achieved this by way of converting a regular screenshot into a PDF, using ImageMagick's convert utility. The simplest example would be:
Note: As of 01/29/2016, ShrinkTheWeb PDF Capture does NOT support Flash
Start with the Sample BASIC Code:
Note: PRO features have no effect on PDF captures at this time. This feature will output a PDF with as many pages as it takes to capture the Full-Length of the web page.
• Add &stwpdf=1
Advanced Method (API Requests)
Here is some sample PHP code to download the PDF and store it locally:
Which PDF Conversion Method Should I Choose?
The method you should choose depends on how you want to use the PDF feature. The "Simple" ("Embedded") method will display the PDF in the user's browser (IF they have adobe PDF support in their browser) or will prompt them to download, if not. The other method is the advanced method (notice that the SECRET KEY is required). The advanced method will always prompt for a download, if made into a clickable link, because it will send the raw PDF data. Since you do NOT want to expose your secret key, this should link to a middleman script (like our sample code) that calls the service and returns the PDF.
However, if the page you want to convert to PDF will not change often, then your user's experience will be greatly improved if you use the advanced method behind-the-scenes and download/cache the PDF every once in awhile (linking to the cached version). This is because every user who clicks the link will have to wait, while we convert to PDF in real-time, which could take anywhere between 5 seconds to 90 seconds, depending on how slow-loading the URL is. So, if you save it locally, the users would get the PDF instantly, and you could just update it occasionally. This would also save "New Requests" and "Bandwidth" costs for your ShrinkTheWeb usage limits.
3rd Party Plugins
This is a new feature and may not yet be available in the ShrinkTheWeb Certified Plugins. Please review the plugin documentation for usage.