Build a Custom WordPress PDF Generator Plugin
Act as a senior WordPress plugin developer.
Create a production-ready WordPress plugin that generates branded PDF files dynamically from WordPress posts using the mPDF library.
Project Context
Website: Atlas Agni Taj
Stack:
- WordPress
- Elementor
- Custom Post Type: Insights (or standard Posts)
- PHP 8+
- mPDF library
Objective
When a visitor clicks the “Download PDF” button on an article page, the system should generate a professional PDF automatically from the article content.
No static PDFs should be uploaded manually.
The PDF should be generated in real time from the current article.
Functional Requirements
PDF Header
Include:
- Atlas Agni Taj Logo
- Article Title
- Publication Date
- Category
Header should appear on every page.
PDF Footer
Include:
London ยท Dubai ยท Riyadh ยท Gurgaon
atlasagnitaj.com
Page Number
Footer should appear on every page.
Article Content
Pull dynamically from WordPress:
- Post Title
- Featured Image
- Post Content
- Categories
- Tags
Render Elementor content correctly.
Support:
- Headings
- Paragraphs
- Lists
- Tables
- Images
- Blockquotes
PDF Styling
Create professional enterprise styling:
- White background
- Dark navy headings
- Gold accent lines
- Responsive image sizing
- Clean typography
- Proper page breaks
WordPress Integration
Create endpoint:
/pdf/{post-id}
Example:
When accessed:
- Load post
- Build PDF
- Stream PDF download
Download Button
Provide shortcode:
[pdf_download_button]
Automatically detect current post ID.
Admin Settings Page
Create WordPress admin page:
Settings โ Atlas PDF
Options:
- Upload Logo
- Company Name
- Footer Text
- Primary Colour
- Secondary Colour
Store settings using WordPress Settings API.
Security
- Validate post ID
- Sanitize output
- Escape all fields
- Restrict unpublished posts
Performance
- Cache generated PDFs
- Regenerate only when article updates
- Store cached PDFs in wp-content/uploads/pdf-cache/
Deliverables
Generate:
- Complete plugin folder structure
- All PHP files
- Plugin bootstrap file
- mPDF integration
- Admin settings page
- Shortcodes
- Endpoint registration
- CSS styling
- Installation instructions
- Example Elementor button configuration
Use WordPress coding standards and OOP architecture.
Output complete code files with explanations.
[pdf_download_button text=”Download Article PDF”]
One Comment
Hi, this is a comment.
To get started with moderating, editing, and deleting comments, please visit the Comments screen in the dashboard.
Commenter avatars come from Gravatar.