Skip to content

Free, open-source HTML to PDF converter with perfect rendering. Built when paid converters failed with Persian fonts. Features: web fonts, RTL text, CSS gradients, PDF metadata, ATS optimization, scrollable single-page mode, batch processing. No watermarks, no limits, just flawless PDFs

License

Notifications You must be signed in to change notification settings

MatinHQ/flawless-pdf-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flawless PDF Generator

A high-quality, configurable HTML to PDF converter with perfect font rendering and styling support. Originally created for generating professional resumes when applying for jobs, as most online converters were either paid, limited, didn't support Persian fonts, or malformed the output.

📹 Showcase

See it in action! Watch how Flawless PDF Generator converts HTML to perfect PDFs

🎥 Watch Demo Video

genrator_showcase.mp4

Why This Project?

While applying for jobs, I needed to convert my HTML resume to PDF format. However, I faced several issues with existing solutions:

  • Paid Services - Most quality converters require subscriptions
  • Limited Free Options - Free tools have severe restrictions (watermarks, page limits, etc.)
  • Poor Persian Font Support - Many converters don't handle Persian/Farsi fonts properly
  • Malformed Output - CSS gradients, web fonts, and RTL text often break

This project solves all these problems with a free, open-source solution that delivers flawless PDF output.

Features

  • High-Quality PDF Generation - Uses Puppeteer (Headless Chrome) for perfect rendering
  • Perfect Font Support - Handles web fonts including Persian fonts (Vazirmatn, IRANSans, etc.)
  • No Limitations - Completely free, no watermarks, no page restrictions
  • Preserves Styling - Gradients, backgrounds, custom fonts, and modern CSS features
  • RTL Support - Perfect right-to-left text rendering for Persian, Arabic, Hebrew
  • Fully Configurable - Environment-based settings for all PDF options
  • PDF Metadata - Embed title, author, subject, and keywords in PDFs
  • Single Page Mode - Automatically scale content to fit on exactly one page
  • ATS-Friendly Mode - Optimize for Applicant Tracking Systems
  • Batch Processing - Convert multiple HTML files at once
  • Bilingual Templates - Includes both English and Persian resume examples
  • Cross-Platform - Works on Windows, macOS, and Linux

Prerequisites

  • Node.js (v14 or higher) - Download here
  • npm (comes with Node.js)

Quick Start

1. Clone the Repository

git clone https://github.com/yourusername/flawless-pdf-generator.git
cd flawless-pdf-generator

2. Install Dependencies

npm install

This will install:

  • puppeteer - For high-quality PDF generation
  • dotenv - For environment configuration

3. Configure Settings (Optional)

Edit the .env file to customize your settings:

# The .env file is already included with default settings
# Edit it to match your preferences

4. Add Your HTML Files

Place your HTML files in the input/ directory:

# The project includes two resume examples already in input/
input/modern_resume_fa.html    # Persian resume example
input/modern_resume.html       # English resume example

# Add your own HTML files to the input/ folder

5. Generate PDFs

Run the conversion:

node main.js

The script will automatically:

  • Convert all HTML files from the input/ folder
  • Save PDFs to the output/ folder with the same filenames
  • Open the output directory when done (if AUTO_OPEN_PDF=true)

Configuration

All settings are managed in the .env file:

Directory Settings

INPUT_DIR=input
OUTPUT_DIR=output
  • INPUT_DIR: Place all HTML files here
  • OUTPUT_DIR: Generated PDFs will be saved here

The converter processes all HTML files in the input directory automatically.

Page Format

PDF_FORMAT=A4

Available formats and sizes:

Format Size (Imperial) Size (Metric) Common Use
Letter 8.5in × 11in 21.59cm × 27.94cm US standard
Legal 8.5in × 14in 21.59cm × 35.56cm US legal documents
Tabloid 11in × 17in 27.94cm × 43.18cm Newspapers, posters
Ledger 17in × 11in 43.18cm × 27.94cm Accounting, spreadsheets
A0 33.11in × 46.81in 84.1cm × 118.9cm Posters, technical drawings
A1 23.39in × 33.11in 59.4cm × 84.1cm Flip charts, posters
A2 16.54in × 23.39in 42cm × 59.4cm Drawings, diagrams
A3 11.69in × 16.54in 29.7cm × 42cm Large documents
A4 8.27in × 11.69in 21cm × 29.7cm International standard
A5 5.83in × 8.27in 14.8cm × 21cm Booklets, notepads
A6 4.13in × 5.83in 10.5cm × 14.8cm Postcards, small notes

Margins

MARGIN_TOP=0
MARGIN_RIGHT=0
MARGIN_BOTTOM=0
MARGIN_LEFT=0

Set margins in millimeters. Useful for printing requirements.

Quality Settings

PRINT_BACKGROUND=true

Set to false to disable background colors and gradients (saves ink when printing).

Font Loading

FONT_WAIT_TIME=2000

Time in milliseconds to wait for web fonts to load:

  • Fast connection: 2000 (2 seconds)
  • Slow connection: 5000 (5 seconds)
  • Very slow: 10000 (10 seconds)

Timeout

PAGE_TIMEOUT=30000

Maximum time to wait for page to load (in milliseconds).

Auto Open

AUTO_OPEN_PDF=true

Automatically open the PDF after generation. Set to false to disable.

PDF Metadata

Add professional metadata to your PDFs for better searchability and organization:

PDF_TITLE=John Doe - Software Engineer Resume
PDF_AUTHOR=John Doe
PDF_SUBJECT=Professional Resume - Software Engineer
PDF_KEYWORDS=resume, software engineer, backend developer, Node.js
PDF_CREATOR=Flawless PDF Generator

This metadata is embedded in the PDF and visible in PDF readers' document properties.

Single Page Mode

Create a single scrollable page with all content:

SINGLE_PAGE_MODE=true

When enabled:

  • Creates ONE tall page containing all your content
  • Users can scroll down to see everything (like a webpage)
  • No content is cut off or split across multiple pages
  • Perfect for online viewing and uploading to job sites

Perfect For:

  • 📱 Online portfolios - LinkedIn, job sites, personal websites
  • 🌐 Digital sharing - Easy to view in browsers and PDF readers
  • 📊 Long resumes - Keeps everything on one scrollable page
  • No compression - Full-size readable text, just scroll to see more

Note: This creates a scrollable single page (like your proof of concept), not a compressed/shrunk page. The PDF will be taller than standard formats but everything stays readable.

ATS-Friendly Mode

Optimize PDFs for Applicant Tracking Systems (ATS):

ATS_FRIENDLY_MODE=true

When enabled:

  • Disables background colors and gradients
  • Uses standard Arial font as fallback
  • Removes shadows and complex styling
  • Ensures text is fully selectable and searchable
  • Improves compatibility with ATS parsing engines

Recommended for job applications where resumes are processed by automated systems.

How It Works

  1. Drop HTML files into the input/ folder
  2. Run the script (run node main.js)
  3. Get PDFs in the output/ folder with perfect styling

The script automatically processes all HTML files in the input directory and converts them to PDFs with the same filename.

Use Cases

  • Resumes/CVs - Convert HTML resumes to professional PDFs
  • Reports - Generate styled PDF reports from HTML
  • Documents - Any HTML document that needs PDF conversion
  • Multilingual Content - Perfect for Persian, Arabic, Hebrew, and other RTL languages
  • Web Pages - Archive web pages as PDFs with perfect styling
  • Batch Conversion - Convert multiple HTML files at once

Advantages Over Online Converters

Feature This Project Online Converters
Cost Free Mostly paid
Persian Fonts Perfect support Often broken
Web Fonts Full support Limited/broken
CSS Gradients Perfect Often malformed
RTL Text Native support Often broken
Page Limits Unlimited Usually limited
Watermarks None Common in free tiers
Privacy 100% local Upload to servers
Customization Fully configurable Fixed options
Metadata Full support Often missing
Single Page Auto-scaling Manual only
ATS Mode Built-in Not available

Customizing Resume Templates

Edit HTML Content

  1. Open modern_resume_fa.html (Persian) or modern_resume.html (English)
  2. Edit your information, experience, skills, etc.
  3. Save the file
  4. Run the generator script

Adjust Skill Levels

Skill bars use a 5-level system:

<div class="skill-bar">
    <div class="skill-level filled"></div>  <!-- Filled -->
    <div class="skill-level filled"></div>
    <div class="skill-level filled"></div>
    <div class="skill-level filled"></div>
    <div class="skill-level empty"></div>   <!-- Empty -->
</div>

Change filled to empty to adjust proficiency levels.

Change Colors

Modify the gradient in the CSS:

background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);

Troubleshooting

Fonts Not Loading Properly

Increase FONT_WAIT_TIME in .env:

FONT_WAIT_TIME=5000

Page Timeout Errors

Increase PAGE_TIMEOUT in .env:

PAGE_TIMEOUT=60000

PDF Layout Issues

  • Check that your HTML is valid
  • Ensure the page format matches your content
  • Try adjusting margins if content is cut off

Puppeteer Installation Issues

If Puppeteer fails to install:

npm install --save puppeteer --unsafe-perm=true --allow-root

File Structure

flawless-pdf-generator/
├── input/                        # Put your HTML files here
│   ├── modern_resume_fa.html     # Persian resume example
│   └── modern_resume.html        # English resume example
├── output/                       # Generated PDFs appear here
├── node_modules/                 # Dependencies (created after npm install)
├── .env                          # Configuration file
├── .env.example                  # Example configuration template
├── .gitignore                    # Git ignore rules
├── package.json                  # Node.js dependencies
├── package-lock.json             # Dependency lock file
├── main.js                       # Main PDF generator script
└── README.md                     # This file

Technologies Used

  • Node.js - JavaScript runtime
  • Puppeteer - Headless Chrome for PDF generation
  • dotenv - Environment configuration
  • HTML5 & CSS3 - Modern web standards

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is open source and available under the MIT License.

Acknowledgments

  • Persian font in examples: Vazirmatn by Saber Rastikerdar
  • Built out of necessity during job applications
  • Inspired by the frustration with paid and limited online converters

Free, unlimited, high-quality HTML to PDF conversion! 🚀

About

Free, open-source HTML to PDF converter with perfect rendering. Built when paid converters failed with Persian fonts. Features: web fonts, RTL text, CSS gradients, PDF metadata, ATS optimization, scrollable single-page mode, batch processing. No watermarks, no limits, just flawless PDFs

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published