Save as PDF WordPress Plugin

The plugin adds the "Save as PDF" button to your WordPress web site. The button allows to save a web page as PDF or send it by email in one click.

Installation

  • You can install the plugin using one of the following options:
  • Activate the plugin in the dashboard.

You can also directly use our HTML to PDF API for PHP which offers greater control over conversion.

License

The plugin runs in a demo mode by default, you do not need to register to try it out. The demo mode is fully functional, it just adds a watermark to the output PDF.

If you want to remove the watermark, you can purchase our API license.

A single API license can be used for both our plugins on multiple WordPress web sites. The API license also allows you to use our Conversion API directly.

How to Use

There are three ways to add the button to your web site.

Automatic

The button is added to your pages automatically after the plugin is installed. The Appearance tab in the plugin settings allows you to select the pages to which you want to add the button.

Shortcode

The button can be added to your pages with a plain or block shortcode.

  • [save_as_pdf_pdfcrowd] - Saves the entire web page as PDF.
  • [block_save_as_pdf_pdfcrowd] - Saves the enclosed code block as PDF.

The examples below show how to use the shortcodes and override the defaults set in the plugin settings.

<h3>Save the print version of the page</h3>

The button is put in the middle
[save_as_pdf_pdfcrowd \
    use_print_media=1 \
    output_name='inline.pdf' \
    button_text='Save printable 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 browser page to PDF']


<h3>Save only a code block</h3>

[block_save_as_pdf_pdfcrowd \
    output_name='just_div.pdf' \
    button_text='Save just a part of the page' \
    page_size='letter' \
    button_background_color='green' \
    button_alignment='left']
<style>
 .invoice {
     font-size: 150%;
 }
</style>
<div class="invoice">
 Save this div and its descendants only.
</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']

Function

The conversion button can be added directly from your PHP code with this helper function:

create_save_as_pdf_pdfcrowd_button($options = array())

The $options argument is an array containing settings which override the defaults set in the plugin settings. An example:

echo create_save_as_pdf_pdfcrowd_button(array(
         'page_size' => 'Letter',
         'button_text' => 'Save as Letter'
));

Footnote

The plugin offers a PHP function that runs a conversion synchronously. This may be useful if your want to initiate a conversion based on an event other than a plugin button click.

pdfcrowd_save_as_pdf($options = array())

The $options argument is an array containing conversion settings independent of the settings set on the plugin settings page. It must contain at least your Pdfcrowd username and the API key. An 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;
    }
?>