Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

How To Convert to PDF

Jorj X. McKie edited this page Aug 4, 2018 · 9 revisions

Convert arbitrary documents to PDF

A new feature introduced with PyMuPDF v1.13.3 and extended in v1.13.4, is conversion of arbitrary documents to PDF.

This works using method Document.convertToPDF(from_page=0, to_page=-1, rotation=0). The parameters control the input page range and sequence, and page rotation.

If from_page > to_page >= 0, page sequence is reversed. Default parameters will convert the complete document.

The result is a Python bytes object. Open it as a new PyMuPDF PDF document, or save it to disk using the ".pdf" file extension.

How well does it work?

  • Image files (raster) are fully supported.
  • XPS, EPUB, CBZ files work very well, too. Other types like FB2 should also work. See demo script xps-converter.py.
  • SVG images do also work (inaccuracies in some cases).

How can you use it?

  • You cannot change an XPS with MuPDF. But you can convert it to PDF and then change that.
  • See above demo script.
  • Batch-convert images to PDF documents.

Recipes

HOWTO Button annots with JavaScript

HOWTO extract images

HOWTO join PDFs

HOWTO work with PDF embedded files

HOWTO Convert Images

HOWTO extract text from inside rectangles

HOWTO extract text in natural reading order

HOWTO add PDF form fields

HOWTO deal with annotations

HOWTO convert to PDF

HOWTO show PDF Form fields

HOWTO work with vector images

HOWTO create or extract graphics

HOWTO create your own PDF Drawing

HOWTO add pages, images, text

HOWTO extract fonts

HOWTO rearrange pages

HOWTO GUI PDF display

Algebra with geometry objects

Rectangle inclusion & intersection

Hyperlink maintenance

Visual table extraction

Incremental saves

Metadata & bookmark maintenance

Wrapping FileOptimizer

Installation

Ubuntu

Ubuntu Installation Experience

Windows Binaries

Windows Binaries Generation

Windows Binaries Installation

Clone this wiki locally

AltStyle によって変換されたページ (->オリジナル) /