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

info@atlasagnitaj.com

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:

https://domain.com/pdf/123

When accessed:

  1. Load post
  2. Build PDF
  3. 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:

  1. Complete plugin folder structure
  2. All PHP files
  3. Plugin bootstrap file
  4. mPDF integration
  5. Admin settings page
  6. Shortcodes
  7. Endpoint registration
  8. CSS styling
  9. Installation instructions
  10. Example Elementor button configuration

Use WordPress coding standards and OOP architecture.

Output complete code files with explanations.

[pdf_download_button text=”Download Article PDF”]