Skip to content

PyPDFConvert is a Python script used for creating dynamic PDFs. It enables us to generate PDF documents from web links and HTML files. With PyPDFConvert, We can easily transform online content into interactive and customizable PDFs, making it ideal for various dynamic document needs.

Notifications You must be signed in to change notification settings

B2-krunalrana/PyPDFConvert

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

html to pdf

Description

This is a script to convert a web page to a PDF file. It utilizes Puppeteer and WeasyPrint for the conversion process.

How it Works

When converting a URL to PDF, we use Puppeteer and WeasyPrint. Since WeasyPrint does not support JavaScript execution , we first fetch the loaded HTML, CSS, and content using Puppeteer. We then create an HTML file from that fetched content, preserving the same structure. Finally, we convert this HTML file to a PDF file using WeasyPrint.

Installation

To run this script, we need to install WeasyPrint and Puppeteer also we need path of chrome.exe

Step 1 :

git clone https://github.com/B2-krunalrana/python_pdf_conversion.git

Step 2 :

pip install WeasyPrint
pip install pyppeteer

Reference links

Tips :

When dealing with images, we need to convert them into data URLs and then include them in HTML files. This helps improve the layout and ensures that everything looks right.

Defuault path of chrome.exe

64-bit Windows :

    C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

32-bit Windows :

    C:\Program Files\Google\Chrome\Application\chrome.exe

Xubuntu 20.04 :

    /opt/google/chrome/chrome

Quick Note:

Just a heads up, we're avoiding CSS frameworks like Bootstrap that heavily depend on JavaScript. Sometimes, these frameworks can cause compatibility issues with WeasyPrint. Therefore, we're committed to steering clear of any frameworks, like Bootstrap, that rely on JavaScript to apply CSS styles.

About

PyPDFConvert is a Python script used for creating dynamic PDFs. It enables us to generate PDF documents from web links and HTML files. With PyPDFConvert, We can easily transform online content into interactive and customizable PDFs, making it ideal for various dynamic document needs.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages