Skip to main content

A tool to convert XML files to PDF

Project description

XML2PDF Converter

A Python library to convert XML files to PDF format. This tool can download XML files from URLs, clean them, and convert them to well-formatted PDFs.

Features

  • Download XML files from URLs
  • Clean and normalize XML content
  • Generate dynamic XSLT templates
  • Convert XML to PDF with customizable styling
  • Support for both local files and URLs

Installation

Using pip

pip install xml2pdf

Using conda environment

# First install dependencies
conda install requests lxml weasyprint

# Then install xml2pdf
pip install xml2pdf

Usage

Converting XML from URL

from xml2pdf import XMLToPDFConverter

# Initialize the converter
converter = XMLToPDFConverter()

# Convert XML from URL to PDF
url = "https://example.com/file.xml"
output_pdf = "output.pdf"
converter.url_to_pdf(url, output_pdf)

Converting Local XML File

from xml2pdf import XMLToPDFConverter

converter = XMLToPDFConverter()

# Convert local XML file to PDF
input_xml = "input.xml"
output_pdf = "output.pdf"
converter.file_to_pdf(input_xml, output_pdf)

Dependencies

  • Python 3.6+
  • requests
  • lxml
  • weasyprint

Error Handling

The library includes comprehensive error handling for:

  • Network issues during XML download
  • XML parsing errors
  • File system operations
  • PDF generation issues

Contributing

Feel free to open issues or submit pull requests on GitHub.

License

MIT License

Author

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xml2pdf-0.2.1.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xml2pdf-0.2.1-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file xml2pdf-0.2.1.tar.gz.

File metadata

  • Download URL: xml2pdf-0.2.1.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for xml2pdf-0.2.1.tar.gz
Algorithm Hash digest
SHA256 9df4af8da240c1d5ff2ad82b4b68a92cbfef2366fa45ab1e304958f839c74412
MD5 efd5cb299b854f926851bea9800fd949
BLAKE2b-256 613c9c4bce7d29b11038471f1496634cfd8b1e40bef8997622311e026d65a9ab

See more details on using hashes here.

File details

Details for the file xml2pdf-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: xml2pdf-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for xml2pdf-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5bd186f678037e54cc4ee1445d6593c1af6f5afebbe40ea369a2c4582028e8bb
MD5 61e8be1ba31d0a21217e0b27bd52ffc2
BLAKE2b-256 1b6f5132e52fa6943c495ddb6722fc0d8fba1b4f09d1cf289e3ce94dd4c13c15

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page