This is a Python script that converts HTML files to PDF made for conversion of .html EPUB
with markers template using the wkhtmltopdf
tool and the pdfkit
library. The script allows for customization of page size and file paths via command-line arguments.
- Converts HTML files to PDF
- Supports custom page sizes (default is A4)
- Flexible options via command-line arguments
- Uses
wkhtmltopdf
for high-quality PDF rendering
- Python 3.x
wkhtmltopdf
installed on your system
The required Python libraries are listed in the requirements.txt
file. Install them using the following command:
pip install -r requirements.txt
git clone https://github.com/GladistonXD/html2pdfconverter.git
cd html2pdfconverter
pip install -r requirements.txt
- Download and install wkhtmltopdf from the official website:
- https://wkhtmltopdf.org/downloads.html
- After installation, note the path to the wkhtmltopdf executable.
- python html2pdfconverter.py -p <path_file> -i <input_html_file> -o <output_pdf_file> -s <page_size>
python html2pdfconverter.py --path "C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf.exe" --input perlego.html --output perlego.pdf --page-size A4
- -i, --input: Path to the input HTML file (required)
- -o, --output: Path to the output PDF file (required)
- -s, --page-size: Page size for the PDF (default is A4)
- -p, --path: Path to the wkhtmltopdf executable (required)
python html2pdfconverter.py -p "C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf.exe" -i perlego.html -o perlego.pdf -s A3
- Page size defaults to A4.
- A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, B0, B1, B10, B2, B3, B4, B5, B6, B7, B8, B9, C5E, Comm10E, DLE, Executive, Folio, Ledger, Legal, Letter, Tabloid