Skip to main content

XDoc

This tool is for converting various document formats to PDF format. Generate PDF documents from files such as Markdown, HTML, and CSS by combining them.

Key Features

  • Generate PDFs by combining Markdown, HTML, and CSS.
  • Add custom headers and footers.
  • User-friendly Gradio web interface.

Getting started

# Install
pip install python-xdoc

xdoc -i input_*.md -o output_file.pdf # CLI: Convert markdowns to PDF 
xdoc --webui # Web UI
xdoc --help 

Usage: 
        [Examples]

        Generate:
            From local file:
                xdoc -i in_*.html --verbose

            From remote file:
                set gist https://gist.githubusercontent.com/.../gistfile.md
                xdoc -i $gist

            Styling:
                xdoc -i in_*.html --scale 0.8 --css ' h1 { color: red }' --margin 'top bottom 50mm left right 20mm'

            Load Config:
                xdoc --config config.yaml

        Modify:
            Extract pages:
                xdoc -i in.pdf --extract 2-3

            meta
                xdoc -i in.md --meta '/Title Untitled'

        Encrypt/Decrypto:
            xdoc -i demo.pdf -o demo.encrypted.pdf --encrypto --autogen
            xdoc -i demo.encrypted.pdf -o demo.decrypted.pdf --decrypto

        Share:
            python -i $gist -o out.pdf --share mega

        [Units]

        You can use the following units for width, height, and margin options:
        - px (pixels) - Default unit., in (inches)., cm (centimeters)., mm (millimeters).

        [Formats]

        The following paper formats are available for the format option:
        - Letter, Legal, Tabloid, Ledger, A0, A1, A2, A3, A4 (default), A5

        [PDF meta]

        meta format: "/Key Value" pairs separated by space.
        - /Title, /Author, /Subject, /Author, /Keyword, /Creator, /Producer, /CreateDate,  /ModDate, /Trapped
        

Generate PDF from HTML pages.

options:
  -h, --help            show this help message and exit
  -i INPUT [INPUT ...], --input INPUT [INPUT ...]
                        Input files.
  -o OUTPUT [OUTPUT ...], --output OUTPUT [OUTPUT ...]
                        Output file path.
  --scale SCALE         Scale of the printed page | 0.8 for 80 percent.
  --displayHeaderFooter
                        Display header and footer.
  --headerTemplate HEADERTEMPLATE
                        Add header template as [url|path|content].
  --footerTemplate FOOTERTEMPLATE
                        Add footer template as [url|path|content].
  --printBackground     Print background images.
  --landscape           Use landscape paper orientation.
  --pageRanges PAGERANGES
                        Page ranges to print | '1-5,8,11-13'.
  --format FORMAT       Paper format | 'A4'.
  --width WIDTH         Paper width | '10cm'.
  --height HEIGHT       Paper height | '10mm'.
  --margin MARGIN       Margin values (e.g., 'top 10mm right 10mm')
  --css CSS             Add css as [url|path|content]
  --config CONFIG       Path to the config file.
  --emulateMedia {screen,print}
                        Type of emulate media.
  --qr QR               Add QR after link.
  --merge MERGE [MERGE ...]
                        Merge PDF files into an output file
  --extract EXTRACT     Extract pages from a PDF file (e.g., '1-3')
  --split               Split a PDF file at specified pages
  --extract-text        Extract text from a PDF file
  --redact-text REDACT_TEXT [REDACT_TEXT ...]
                        Redact text in the PDF files
  --meta META           Add meta in the format '/Key: Value'. Example: '/Title
                        Document'
  --remove-meta         Remove meta from a PDF file
  --select-meta SELECT_META [SELECT_META ...]
                        Selectively remove meta fields
  --verbose             Print parameters when verbose.
  --encrypto            Encrypt PDF file.
  --autogen             Automatically generate password for encryption.
  --decrypto            Decrypt PDF file.
  --regen               Regenerate and send recovery key for decryption.
  --webui               [WIP] Launch Gradio web UI.
  --share {mega,google_drive,slideshare}
                        Specify the cloud service to use for sharing

License

This project is provided under the MIT License. See the LICENSE file for details.

Support

For inquiries regarding support, including questions and bug reports, please use GitHub Issues.

See also

There are other similar projects that you may be interested in:

Metadata

Release files for python-xdoc 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python-xdoc 0.1.1
File Size Uploaded
python_xdoc-0.1.1.tar.gz 17.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for python-xdoc 0.1.1
File Interpreter ABI Platform
python_xdoc-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 34.9 kB

Release files / python_xdoc-0.1.1.tar.gz

Download URL python_xdoc-0.1.1.tar.gz
Size 17.2 kB
Tags Source
SHA-256 checksum
How to use checksums
1f958070de4c4f63f8d89976ef5d5e9bd57c6e708d321487201c74c717e62dc9
BLAKE2b-256 checksum
How to use checksums
6a6c2a68756fdd024223fbc2ae917eeb4ff13cc77c4181f5b7706b0b1179772e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.10.13 Linux/5.15.133.1-microsoft-standard-WSL2

Release files / python_xdoc-0.1.1-py3-none-any.whl

Download URL python_xdoc-0.1.1-py3-none-any.whl
Size 17.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b4306f0bf4a8f3522c0b6702745bceb955cb46618b64b3d8b57a2cf875775976
BLAKE2b-256 checksum
How to use checksums
095b6b55fa53826658181e83418cca38cc051f0b3bbd61d6d07f32dd5b966668
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.10.13 Linux/5.15.133.1-microsoft-standard-WSL2

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page