This script allows users to convert a sequence of web pages to PDF format. It navigates through pages by following a "next" link on each page and converts each page to a PDF. The PDFs are then merged into a single PDF file.
The script is executed from the command line. It accepts a URL as an argument.
python ownCloudDocPdf.py [URL]python ownCloudDocPdf.py https://doc.owncloud.com/webui/next/classic_ui/Python (developed and tested with version 3.10)
wkhtmltopdf
pdftk
requests
Install the Python requests library:
pip install requestsOn Debian-based systems, install wkhtmltopdf and pdftk using:
sudo apt-get install wkhtmltopdf pdftkOn other systems, please refer to the documentation for wkhtmltopdf and
pdftk for installation instructions.
Output The script will output a PDF file named output.pdf in the current directory. If a file with that name already exists, the script will increment a number in parentheses until it finds an unused filename (like output(1).pdf, output(2).pdf, etc.).
Notes The temporary PDF files generated for each page are stored under /tmp/ and are deleted after the final PDF is merged. Ensure that you have write permissions in the directory where the script is run, as it will attempt to save the output PDF in that location.