The plugin adds a "Save as PDF" button to your WordPress website, enabling your site visitors to save a webpage as a PDF or send it via email with just one click. This provides the option to read your content offline or share it easily with others. Whether it's articles, posts, or product pages, "Save as PDF" ensures your website's content is accessible in a widely used format.
The plugin is hosted on WordPress.org as Save as PDF by PDFCrowd. Installing the plugin is straightforward and can be done in a few simple steps. Choose the method that works best for you:
`Plugins > Add New`
.`Save as PDF by PDFCrowd`
and press Enter.Plugins > Add New > Upload Plugin`
.By default, the plugin operates in demo mode, which, while fully functional, adds a watermark and PDFCrowd branding to the content.
To remove the demo watermark and PDFCrowd branding, you can purchase an API license. Activate the license by entering your PDFCrowd username and API key in the plugin settings under the License tab.
A PDFCrowd API license is versatile, allowing use across multiple WordPress websites for our plugins. Additionally, the API license grants direct access to the PDFCrowd API for a broader range of applications.
Once activated, the "Save as PDF" button will automatically appear on all eligible content according to your settings. Users can click this button to save the current page as a PDF file.
To manually add the "Save as PDF" button to specific pages or posts, you can use either shortcode or PHP function.
The plugin offers various customization options accessible through the WordPress admin panel. You can change the PDF generation settings and button appearance. For more detailed customization, please refer to Customization, and to the Option reference.
You can add the button using either a plain or block shortcode.
[save_as_pdf_pdfcrowd]
saves the entire webpage as PDF.
[block_save_as_pdf_pdfcrowd]
saves only the
enclosed code block as PDF. To style the block,
include CSS rules within the shortcode.
The examples below demonstrate how to use the shortcodes and override the default settings configured in the plugin.
<h3>Save the print version of the page</h3> The button is placed in the middle [save_as_pdf_pdfcrowd \ use_print_media=1 \ output_name='inline.pdf' \ button_text='Save print version to PDF'] of this sentence. <h3>Save the screen version of the page</h3> [save_as_pdf_pdfcrowd \ use_print_media=0 \ output_name='browser.pdf' \ button_text='Save screen version to PDF'] <h3>Save only a code block</h3> [block_save_as_pdf_pdfcrowd \ output_name='just_div.pdf' \ button_text='Download just this section as PDF' \ page_size='letter' \ button_background_color='green' \ button_alignment='left'] <style> .invoice { font-size: 150%; } </style> <div class="invoice"> Save only this div and its descendants. </div> [/block_save_as_pdf_pdfcrowd] <h3>Convert any web page</h3> [save_as_pdf_pdfcrowd \ url='https://wikipedia.org' \ output_name='wikipedia.pdf' \ button_text='Save Wikipedia as PDF']
You can add the conversion button directly within your PHP code using the following helper function:
create_save_as_pdf_pdfcrowd_button($options = array())
Here, the $options argument is an array that contains settings to override the plugin's default configuration. For example:
echo create_save_as_pdf_pdfcrowd_button(array( 'page_size' => 'Letter', 'button_text' => 'Save as Letter' ));
For scenarios where you need to initiate a conversion synchronously - perhaps in response to an event other than a button click - the plugin provides a PHP function.
pdfcrowd_save_as_pdf($options = array())
In this case, the $options argument is an array of conversion settings that are independent of the plugin's default settings. This array must at least include your PDFCrowd username and API key. For example:
<?php $output = pdfcrowd_save_as_pdf(array( 'username' => '', 'api_key' => '', 'page_size' => 'Letter', 'url' => 'https://www.example.com/' )); if(!is_wp_error($output)) { echo $output; } ?>
The table below highlights the most common customizations you might find useful. Refer to the Option Reference for a detailed description of all available options. For an interactive experience, explore these options in the API Playground. You can also test out different PDF layouts in our PDF Layout Preview tool.
For additional customization options and Troubleshooting, please visit the FAQ section of our website where you can find answers and help related to frequent queries and common issues.
Page Size | Adjust the page size using Page Size. To create a single-page PDF with page height automatically adjusted to the HTML content, set -1 to Page Height. |
Page Orientation | Change the page orientation to landscape using Orientation. |
Page Margins | Adjust the page margins with Page Margins. To eliminate all margins use No Margins. |
Headers and Footers |
Add custom headers and footers using
Header Html and
Footer Html.
To adjust the height of headers or footers, use Footer Height
and Header Height respectively.
|
HTML Content Fitting |
Set the viewport width for formatting the HTML content using
Content Viewport Width.
Use
Content Fit Mode to control how the content is fitted into the PDF page.
You can also adjust the zoom level of HTML content by using Scale Factor, which allows you to scale the content up or down. |
Per-page Settings | Use Conversion Config to specify the PDF page size, orientation, margins, and the presence and appearance of headers and footers on a per-page basis. |
Hide or Remove Contents |
Use the following classes in your HTML code to hide or remove
elements from the output:
|
Custom CSS Styling |
To customize CSS styling specifically for the conversion, use
Custom Css to inject additional styles.
Alternatively, you can directly incorporate conversion-specific styling into your main stylesheet. Just prefix your CSS selectors with `.pdfcrowd-body` to ensure
the styles apply only during the conversion process. For
example:.pdfcrowd-body h1 { font-size: 48px; } .pdfcrowd-body footer { display: none; }
|
Avoid Page Break | To prevent page breaks within specific elements, use the
`page-break-inside:avoid;` CSS property. Apply this
property to elements where you do not want a page break, such as tables,
table cells, and images. Here is an example:th, td, img { page-break-inside:avoid }
|
Force Page Break |
You can force a page break in your document by incorporating a specific
style in an HTML div tag. Insert the following code where you want the
page break to occur:<div style="page-break-before:always"></div>
|
Use `@media print` |
Activate the print version of a webpage (if
available) using Use Print Media.
This function instructs the plugin
to apply the CSS rules defined within the `@media print`
stylesheet, ensuring the output mirrors the print-optimized version of the webpage.
|
Inject Custom JavaScript | Use Custom Javascript or On Load Javascript to modify HTML content using custom JavaScript scripts. These scripts run when the page loads, allowing you to dynamically alter elements, styles, or behavior. In addition to the standard browser JavaScript APIs, your scripts can leverage helper functions provided by our JavaScript library. |
If the default plugin output does not meet your requirements, consider adjusting the following settings individually. You may need to activate the "Expert Settings" option to access some of these features.
Other troubleshooting steps:
Refer to the Save as PDF WordPress Plugin Reference for a description of all options.