Giter Site home page Giter Site logo

b2-krunalrana / pypdfconvert Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 1.51 MB

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.

HTML 99.12% Python 0.87% CSS 0.01%
dynamic-pdf-generation htmltopdf html-to-pdf html-to-pdf-api html-to-pdf-converter

pypdfconvert's Introduction

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.

pypdfconvert's People

Contributors

b2-krunalrana avatar krunal-ahaguru avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.