Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To save a WordPress post as a PDF with PDFShift, prepare the post’s HTML on your server, send it to PDFShift’s https://api.pdfshift.io/v3/convert/pdf endpoint with your API key in the X-API-Key header, then deliver or store the returned PDF. The example below uses WordPress’s HTTP API and returns the PDF as a download. Keep the API key server-side; do not put it in browser JavaScript.

Choose what the PDF should contain

First decide whether you want a PDF of the public page as a visitor sees it, or a document built from the post’s stored content. Those are different inputs, and the choice affects how you prepare the request.

Use a URL for the rendered public page

Send a public page URL as PDFShift’s source when you want the converter to retrieve and render that page. This is the simpler fit when the published page is the intended document. It also means the page must be reachable by PDFShift.

Use raw HTML for controlled or private content

Send HTML directly as source when the post is private, unavailable to an outside fetch, or you want to control the PDF markup separately from the theme. PDFShift’s raw-HTML guide recommends this approach, noting that it avoids a separate fetch of the page and its assets. If your HTML references stylesheets, images, or scripts by URL, those assets still need to be available to the converter.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

The implementation below uses the stored post content, wraps it in a basic HTML document, and sends raw HTML. It does not reproduce your theme’s complete rendered page; add your own styles and any desired header, footer, or branding to the document template.

Configure the API key on the server

Store the PDFShift API key outside the plugin file and never expose it in a public page or JavaScript bundle. One simple option is to add a constant in wp-config.php, before the line that says WordPress editing should stop:

define( 'PDFSHIFT_API_KEY', 'replace-with-your-api-key' );

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

Use your actual key in the server configuration and restrict access to that file. The code below stops with an error if the constant is missing.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Add a server-side PDF export handler

Add this PHP to a small site-specific plugin or a child theme’s functions.php. A plugin is generally easier to keep active when changing themes. The handler accepts a post ID, checks a nonce and the current user’s permission to read that post, builds HTML, and sends it to PDFShift. With neither filename nor webhook included, the successful response is treated as PDF binary.

<?php
/**
 * Export a readable WordPress post as a PDFShift-generated PDF.
 * Define PDFSHIFT_API_KEY in wp-config.php; do not expose it to the browser.
 */
add_action( 'admin_post_itechguides_pdfshift_export', 'itechguides_pdfshift_export_post' );

function itechguides_pdfshift_export_post() {
    if ( ! defined( 'PDFSHIFT_API_KEY' ) || '' === PDFSHIFT_API_KEY ) {
        wp_die( 'PDF export is not configured.', 'PDF export unavailable', array( 'response' => 500 ) );
    }

    $post_id = isset( $_GET['post_id'] ) ? absint( $_GET['post_id'] ) : 0;
    if ( ! $post_id ) {
        wp_die( 'A valid post ID is required.', 'Invalid request', array( 'response' => 400 ) );
    }

    check_admin_referer( 'pdfshift_export_' . $post_id );

    $post = get_post( $post_id );
    if ( ! $post || ! current_user_can( 'read_post', $post_id ) ) {
        wp_die( 'You cannot export this post.', 'Access denied', array( 'response' => 403 ) );
    }

    // Build a deliberately simple document from stored post content.
    // Add trusted styles and any required branding here.
    $title   = esc_html( get_the_title( $post ) );
    $content = apply_filters( 'the_content', $post->post_content );
    $content = wp_kses_post( $content );
    $html    = '<!doctype html><html><head><meta charset="utf-8">'
        . '<title>' . $title . '</title>'
        . '<style>body{font:16px/1.5 sans-serif;margin:2rem}img{max-width:100%;height:auto}</style>'
        . '</head><body><h1>' . $title . '</h1>' . $content
        . '</body></html>';

    $response = wp_remote_post(
        'https://api.pdfshift.io/v3/convert/pdf',
        array(
            'headers' => array(
                'Content-Type' => 'application/json',
                'X-API-Key'    => PDFSHIFT_API_KEY,
            ),
            'body'    => wp_json_encode( array( 'source' => $html ) ),
            'timeout' => 60,
        )
    );

    if ( is_wp_error( $response ) ) {
        wp_die( esc_html( 'PDFShift request failed: ' . $response->get_error_message() ), 'PDF export failed', array( 'response' => 502 ) );
    }

    $status = wp_remote_retrieve_response_code( $response );
    $body   = wp_remote_retrieve_body( $response );
    if ( 200 !== $status || '' === $body ) {
        // Do not label an API error response as a PDF.
        wp_die( 'PDFShift did not return a PDF. Check the API response and request settings.', 'PDF export failed', array( 'response' => 502 ) );
    }

    $filename = sanitize_file_name( get_post_field( 'post_name', $post_id ) . '.pdf' );
    nocache_headers();
    header( 'Content-Type: application/pdf' );
    header( 'Content-Disposition: attachment; filename="' . $filename . '"' );
    header( 'Content-Length: ' . strlen( $body ) );
    echo $body; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- PDF binary response.
    exit;
}

To add an export link where an authorized user can see it, generate the URL with a post-specific nonce. For example, in a template that is already checking the viewer’s access:

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
<?php
$post_id = get_the_ID();
$url = wp_nonce_url(
    add_query_arg(
        array(
            'action'  => 'itechguides_pdfshift_export',
            'post_id' => $post_id,
        ),
        admin_url( 'admin-post.php' )
    ),
    'pdfshift_export_' . $post_id
);
?>
<a href="<?php echo esc_url( $url ); ?>">Export as PDF</a>

The handler checks both the nonce and the current user’s capability for the selected post. Adapt the authorization rule to your site’s membership or editorial roles; do not rely on hiding the link alone. A nonce helps defend the action from forged requests, but it is not a substitute for a permission check.

Choose whether to stream or retain the PDF

Stream a binary response to the visitor

The example omits filename and webhook, so it expects PDF binary in the response body and streams it as a download. It does not create a durable copy on the WordPress server. If the download is interrupted, the user can request a new export.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use a temporary PDFShift URL, then copy it if needed

When you include filename, PDFShift returns JSON containing a URL to a temporarily stored PDF rather than the direct binary response. PDFShift’s Make integration guide says that URL remains available for two days. Download it to your own WordPress media storage or other controlled storage if you need a persistent copy. Treat the temporary URL as temporary access, not as a permanent post attachment.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

WordPress provides a media REST endpoint, but the sources cited here do not establish a tested PHP upload routine for this integration. If you implement media-library retention, handle upload errors, choose a safe filename, and set access controls appropriate to the post’s privacy.

Handle common failures safely

  • The request returns a WP_Error: this indicates a transport-level failure such as a connection problem or timeout. Log the error server-side for diagnosis and let the user retry; do not print the API key or sensitive post content in an error page.
  • PDFShift returns a non-200 status: do not send that body with an application/pdf content type. Inspect the API’s error response in a controlled server log and verify the endpoint, API key, JSON payload, and request settings.
  • The PDF is blank or missing page styling: the example converts stored post content, not the theme-rendered page. Build a more complete HTML document and include the styles the PDF needs. For URL input, verify that the page and its assets are publicly reachable.
  • Private content cannot be fetched by URL: send authorized content as raw HTML from WordPress instead of asking PDFShift to retrieve a page that requires a WordPress session.
  • The request times out: the example sets a 60-second WordPress HTTP timeout, but that is not a guarantee the conversion will complete within that period. Consider a user-visible retry path or an asynchronous job design for large documents; the sources here do not establish a tested queue implementation.
  • A user can request another post’s PDF by changing the ID: retain the server-side post permission check and ensure the nonce is tied to that post ID. If your site’s authorization model differs from WordPress’s standard post capabilities, implement the corresponding check before sending content to the conversion API.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Performance, reliability, and cost considerations

Raw HTML can avoid PDFShift making a separate request for the page itself, and PDFShift recommends it as a conversion input. That does not guarantee a particular conversion time: document size, referenced assets, and the remote service can still affect completion. Keep the API key and request on the server, set a timeout appropriate to your hosting environment, and avoid generating PDFs on every page view unless that behavior is intentional.

No price or quota is stated in the documentation summarized here. Check PDFShift’s current plan and API documentation before estimating recurring export costs. For automatically regenerating PDFs after content changes, decide whether old files should be replaced, retained, or deleted; that retention behavior is an application choice rather than an API default established here.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

Or skip the browser setup

PDFShift converts post content or a page into a PDF; ScreenshotNeo is a separate website screenshot API, not a PDFShift replacement or a way to generate a post PDF. If your adjacent need is a screenshot image of a web page, its one-call API can return an image:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

See the ScreenshotNeo API documentation for request options. It accepts cookie banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; bot checks, blank pages, and failed loads are not billed; an MCP server lets AI agents take screenshots. The free plan includes 1,000 screenshots per month with no card, and paid plans start at $5 for 3,000. Sign up for ScreenshotNeo’s free plan.

Frequently Asked Questions

Can this export handler serve a private post?

Yes, if the requesting WordPress user is authorized by the capability check and the site’s other access rules permit the export. The handler builds raw HTML from the post rather than asking PDFShift to fetch a login-protected page.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Does the example save a copy in the Media Library?

No. It streams the binary PDF to the visitor. Persistent storage requires a separate upload or storage step.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.