Convert WordPress Posts to PDF Automatically
Convert WordPress posts and pages to downloadable PDFs automatically. Plugin setup guide with customization options for themes and layouts.
Convert WordPress Posts to PDF Automatically
WordPress powers over 40% of the web, and a surprising number of those sites need to offer content as downloadable PDFs. Educational sites want course materials in portable format. News outlets want printable articles. Membership sites want gated content that users can take offline. Government agencies need accessible document versions. Recipe blogs want printable recipe cards.
The problem is that WordPress was not built for PDF output. The content is stored as blocks in a database, rendered to HTML by your theme, and displayed in a browser. Getting that same content into a well-formatted PDF requires a rendering step that most WordPress hosting environments are not equipped to handle efficiently.
Most existing WordPress PDF solutions try to render the PDF on your server using PHP libraries like mPDF or DOMPDF. This works for simple pages but falls apart quickly: they consume 50 to 200 megabytes of memory per render, they choke on modern CSS like flexbox and grid, they cannot handle web fonts reliably, and they time out on shared hosting. If you have ever seen a "Fatal error: Allowed memory size exhausted" message after installing a PDF plugin, this is why.
The LightningPDF approach is different. Your WordPress server sends the post content to a cloud API, the API renders the PDF using a proper engine, and your server passes the file back to the visitor. Your server does almost no work. It works on shared hosting, it works on managed WordPress, and it produces PDFs that actually look like your content.
This guide covers everything you need to convert WordPress posts and pages to downloadable PDFs using the LightningPDF WordPress plugin.
Why Convert WordPress Posts to PDF
Here are the common reasons WordPress sites need PDF export:
Content distribution. Users email them, print them, store them in Dropbox, reference them offline. A downloadable PDF extends the reach of your content beyond the browser.
Lead generation. Offering a PDF version of your best content in exchange for an email address is one of the most effective lead magnets in content marketing. A gated PDF download converts 3 to 5 times better than a generic newsletter signup.
Compliance and accessibility. Government sites, educational institutions, and organizations subject to accessibility requirements often need to provide documents in multiple formats. PDF with proper tagging is an accepted accessible format under WCAG guidelines.
Print quality. Browser print dialogs produce inconsistent results across browsers and operating systems. A dedicated PDF with controlled margins, page breaks, and typography ensures every user gets the same print-quality document regardless of their browser.
Archival. PDFs are a stable archival format. Organizations that need to preserve content long-term — legal departments, research institutions, compliance teams — benefit from automatic PDF generation as part of their publishing workflow.
Installing the LightningPDF WordPress Plugin
The plugin is available from the WordPress.org repository. Installation takes about two minutes from start to first PDF.
Step 1: Install the Plugin
Navigate to Plugins > Add New in your WordPress admin. Search for "Paperbolt" and click Install Now, then Activate.
Alternatively, if you prefer manual installation:
- Download the plugin ZIP from WordPress.org
- Go to Plugins > Add New > Upload Plugin
- Upload the ZIP and activate
Step 2: Get Your API Key
You need a LightningPDF API key to connect the plugin to the rendering service. Sign up for a free account — it takes 30 seconds, no credit card required, and includes 50 PDF credits per month.
Once registered, copy your API key from the dashboard.
Step 3: Connect the Plugin
Go to Paperbolt > Settings in your WordPress admin. Paste your API key into the API Key field and click Test Connection. You should see a green success message confirming the connection.
That is the entire setup. The plugin is now ready to generate PDFs.
Step 4: Enable PDF Buttons
Under Paperbolt > Settings > Post Types, toggle on the content types you want to enable. Options include:
- Posts — Blog articles
- Pages — Static pages
- Custom Post Types — Any registered CPT (products, courses, recipes, etc.)
Once enabled, a "Download PDF" button automatically appears below the content on every enabled post type.
For the full setup reference including WooCommerce integration, see our complete WordPress plugin guide.
Configuring the Plugin
The settings panel gives you control over how PDFs are generated and presented.
General Settings
| Setting | Description | Default |
|---|---|---|
| API Key | Your LightningPDF API key | — |
| Paper Size | A4, Letter, Legal, or custom | A4 |
| Orientation | Portrait or Landscape | Portrait |
| Margins | Top, right, bottom, left in mm | 20mm all |
| Button Text | Text shown on the download button | "Download PDF" |
| Button Position | Above content, below content, or both | Below |
| Cache Duration | How long generated PDFs are cached | 1 hour |
Content Settings
These control what gets included in the PDF:
- Include Featured Image — Adds the post's featured image at the top of the PDF
- Include Author — Shows the author name and avatar
- Include Date — Shows the publication date
- Include Categories/Tags — Appends taxonomy terms
- Exclude Elements — CSS selectors for elements to hide (e.g.,
.sidebar, .comments, .share-buttons)
Header and Footer
You can add custom headers and footers that appear on every page of the PDF:
- Header Left/Center/Right — Supports variables:
{title},{author},{date},{site_name} - Footer Left/Center/Right — Supports variables:
{page},{pages},{url},{site_name} - Header/Footer Font Size — Separate from body text size
A common configuration:
- Header Center:
{site_name} - Footer Left:
{title} - Footer Right:
Page {page} of {pages}
Customizing PDF Output
The default output uses your post content with clean, readable styling. But most sites want more control over how the PDF looks.
Custom CSS
The plugin has a Custom CSS field that lets you add styles that apply only to the PDF output. This is the fastest way to customize without touching templates.
Common customizations:
/* Change body font */
body {
font-family: Georgia, serif;
font-size: 11pt;
line-height: 1.7;
}
/* Hide navigation and sidebar in PDF */
nav, .sidebar, .comments-area, .share-buttons, .related-posts {
display: none !important;
}
/* Style headings */
h1 { font-size: 22pt; color: #1a1a1a; }
h2 { font-size: 16pt; border-bottom: 1px solid #e5e5e5; padding-bottom: 0.3em; }
/* Ensure images don't overflow pages */
img {
max-width: 100%;
height: auto;
page-break-inside: avoid;
}
/* Keep code blocks together */
pre {
page-break-inside: avoid;
background: #f5f5f5;
padding: 1em;
font-size: 9pt;
}
/* Add your logo as a header */
@page {
margin-top: 3cm;
@top-center {
content: url('https://yoursite.com/logo.png');
}
}
For deep control over page break behavior, refer to our guide to fixing PDF page breaks.
Using Templates
For complete control over the PDF layout, use a custom HTML template. Templates let you restructure the content entirely — different from CSS overrides which only restyle the existing structure.
The plugin syncs with templates from your LightningPDF account. You can create templates using the template designer or write them by hand.
Templates use variable substitution:
<!DOCTYPE html>
<html>
<head>
<style>
body { font-family: 'Helvetica Neue', sans-serif; margin: 0; }
.header { background: #2563eb; color: white; padding: 2cm; }
.header h1 { margin: 0; font-size: 28pt; }
.meta { color: rgba(255,255,255,0.8); margin-top: 0.5em; }
.content { padding: 1.5cm 2cm; font-size: 11pt; line-height: 1.8; }
.footer { text-align: center; color: #999; font-size: 9pt; padding: 1cm; }
</style>
</head>
<body>
<div class="header">
<h1>{{title}}</h1>
<div class="meta">By {{author}} | {{date}} | {{categories}}</div>
</div>
<div class="content">
{{content}}
</div>
<div class="footer">
Downloaded from {{site_url}} | {{current_date}}
</div>
</body>
</html>
Available template variables:
| Variable | Description |
|---|---|
{{title}} |
Post title |
{{content}} |
Full post content (HTML) |
{{excerpt}} |
Post excerpt |
{{author}} |
Author display name |
{{date}} |
Publication date |
{{modified_date}} |
Last modified date |
{{categories}} |
Comma-separated category names |
{{tags}} |
Comma-separated tag names |
{{featured_image}} |
Featured image URL |
{{permalink}} |
Post URL |
{{site_name}} |
Site title |
{{site_url}} |
Site URL |
{{current_date}} |
Generation date |
Browse the template marketplace for pre-built WordPress post templates you can import and customize.
Using Shortcodes
The automatic button placement works for most sites, but sometimes you need the download button in a specific location — inside the content, in a sidebar widget, or on a landing page that references a different post.
Basic Shortcode
[lightningpdf]
Place this anywhere in your post or page content to render a download button at that position. When used inside a post, it generates a PDF of that same post.
Shortcode with Options
[lightningpdf text="Get the PDF" template="your-template-id" post_id="42"]
Parameters:
| Parameter | Description | Default |
|---|---|---|
text |
Button text | "Download PDF" |
template |
Template ID from your LightningPDF account | Default template |
post_id |
Generate PDF of a different post | Current post |
class |
CSS class for the button | lightningpdf-button |
format |
Paper size (A4, Letter, Legal) | From settings |
orientation |
Portrait or Landscape | From settings |
Gutenberg Block
If you use the block editor, there is a dedicated LightningPDF block. Search for "LightningPDF" in the block inserter. It provides the same options as the shortcode but with a visual interface.
Bulk Generation
Need to generate PDFs for many posts at once? Go to Posts > All Posts, select the posts you want, choose "Generate PDFs" from the Bulk Actions dropdown, and click Apply. The plugin generates all selected posts as PDFs and downloads them as a ZIP file.
This is useful for:
- Creating an offline content archive
- Generating print-ready versions of a series
- Producing downloadable course materials from multiple posts
Caching and Performance
The plugin caches generated PDFs so the API is not called on every download. The first visitor to download a post triggers the API call. Every subsequent download within the cache window serves the cached file instantly.
How caching works:
- Visitor clicks "Download PDF"
- Plugin checks for a cached PDF (stored as a WordPress transient)
- If cached and not expired, serves the cached file (no API call)
- If not cached, calls the LightningPDF API, caches the result, serves the file
- A daily cron job clears stale cache entries
Cache invalidation: The cache automatically clears when you update a post, so changes to content are reflected in the next PDF download.
Credit usage: A post downloaded 500 times uses 1 API credit (the first download), not 500. This makes the free tier's 50 credits per month go much further than you might expect.
Advanced: Programmatic Generation
If you need to generate PDFs from custom code — a plugin, a theme function, or a REST API endpoint — the plugin exposes PHP functions:
// Generate PDF for a specific post
$pdf_url = lightningpdf_generate_post_pdf( $post_id, array(
'template' => 'your-template-id',
'format' => 'A4',
'orientation' => 'portrait',
) );
// Generate PDF from custom HTML
$pdf_url = lightningpdf_generate_html_pdf(
'<h1>Custom Content</h1><p>This is custom HTML.</p>',
array( 'format' => 'Letter' )
);
You can also call the LightningPDF API directly from any custom code:
$response = wp_remote_post(
'https://api.lightningpdf.dev/api/v1/pdf/generate',
array(
'headers' => array(
'X-API-Key' => get_option( 'lightningpdf_api_key' ),
'Content-Type' => 'application/json',
),
'body' => wp_json_encode( array(
'html' => $html_content,
'options' => array(
'format' => 'A4',
'print_background' => true,
),
) ),
'timeout' => 30,
)
);
if ( ! is_wp_error( $response ) ) {
$body = json_decode( wp_remote_retrieve_body( $response ), true );
$pdf_bytes = base64_decode( $body['data']['pdf'] );
// Save or serve the PDF
}
Comparison with Other WordPress PDF Plugins
| Feature | LightningPDF | mPDF-based plugins | DOMPDF-based plugins | PDFCrowd |
|---|---|---|---|---|
| Rendering engine | Cloud (native + Chromium) | PHP (server-side) | PHP (server-side) | Cloud |
| CSS Grid/Flexbox | Yes | No | No | Yes |
| Web fonts | Yes | Partial | Partial | Yes |
| Shared hosting friendly | Yes | Risky (memory) | Risky (memory) | Yes |
| Memory usage on server | Minimal (API call only) | 50-200MB per render | 50-150MB per render | Minimal |
| Generation speed | <100ms (API) | 3-7 seconds | 2-5 seconds | 1-3 seconds |
| Custom templates | Yes (HTML + designer) | Limited | Limited | No |
| WooCommerce invoices | Yes | No | No | No |
| Batch generation | Yes (100/call) | No | No | No |
| Free tier | 50 PDFs/month | Unlimited* | Unlimited* | 10 PDFs/month |
| Paid plans | From $9/month | Free* | Free* | From $12/month |
*Free but unbounded server resource usage; costs are hidden in hosting bills and performance degradation.
The PHP-based solutions look free on paper, but the server resources they consume are not free. A site generating 100 PDFs per day with mPDF needs significantly more hosting resources than one using a cloud API. For a more detailed analysis, see the LightningPDF vs self-hosted rendering comparison.
For a broader comparison of PDF plugins, read our full WordPress PDF plugin writeup which covers installation, WooCommerce integration, and WP-CLI usage in depth.
Troubleshooting Common Issues
Button not appearing. Check that the post type is enabled in Paperbolt > Settings > Post Types. Also verify your theme is calling the_content() — the button hooks into this filter.
PDF looks different from the website. The PDF renders your post content, not a screenshot of your page. Theme-specific styles (sidebar layouts, nav menus) are not included by default. Use the Custom CSS field to add any theme styles you want in the PDF, or create a dedicated template.
Timeout on large posts. Posts with many high-resolution images can take longer to render. Ensure images are reasonably sized (under 2MB each) and use JPEG or WebP instead of uncompressed PNG where possible. The plugin has a configurable timeout (default 30 seconds).
Cache not clearing. If you update a post and the PDF still shows old content, go to Paperbolt > Settings and click "Clear Cache." The automatic cache invalidation relies on the save_post hook, which some page builders bypass.
Getting Started
- Install the Paperbolt plugin from Plugins > Add New
- Create a free account and grab your API key
- Paste the key in Paperbolt > Settings and test the connection
- Enable PDF buttons for your post types
- Customize with CSS or a template from the marketplace
For higher volumes, the Starter plan at $9/month covers 2,000 PDFs and the Pro plan at $29/month covers 10,000. Check the full API documentation for advanced options.
If you are also looking to generate PDFs programmatically outside WordPress, see our tutorials for Python, Node.js, and Go.
Frequently Asked Questions
How do I add a PDF download button to my WordPress posts?
Install the Paperbolt plugin, enter your API key in settings, and enable PDF buttons for your desired post types. A download button automatically appears on every enabled post. You can also place buttons manually using the shortcode or Gutenberg block.
Does the Paperbolt WordPress plugin work on shared hosting?
Yes. Unlike plugins that render PDFs on your server using mPDF or DOMPDF, LightningPDF renders in the cloud. Your server makes a lightweight API call that uses minimal memory and CPU, so it works reliably on shared hosting, managed WordPress, and any other hosting environment.
Can I customize how my WordPress posts look as PDFs?
You have several customization options: custom CSS that applies only to PDF output, configurable headers and footers with dynamic variables, full HTML templates with variable substitution, and control over paper size, margins, and orientation. Browse the template marketplace for pre-built designs.
Related Reading
- We Built a WordPress PDF Plugin — Full plugin guide with WooCommerce
- HTML to PDF: The Complete Guide — All conversion approaches compared
- How to Fix PDF Page Breaks — Solve pagination in PDFs
- Best PDF APIs in 2026 — Full API comparison
- Generate PDFs in Python — Python API integration
- Generate PDFs in Node.js — Node.js API integration
- LightningPDF vs Puppeteer — Build vs buy analysis
- PDF Invoice API Guide — Invoice generation patterns
Additional Resources
LightningPDF Team
Building fast, reliable PDF generation tools for developers.