Skip to content

how to use pymudpdf to convert html (with page break div and customized font ttf font fact) or epub to pdf? #2114

Answered by JorjMcKie
nissansz asked this question in Q&A
Discussion options

You must be logged in to vote
  1. Images embedded in the HTML (as base64) are not supported.
  2. If referring to font or image resources you must use the Archive class - a generalized container concept: you can mix file folders and ZIP or TAR archives in one fitz.Archive.
  3. When defining the fitz.DocumentWriter you can use "compress" to reduce the resulting PDF file size. In addition, instead of a file, you can let DpcumentWriter write to a Python file pointer and reopen the resulting memory PDF for your own post processing. This is an example which builds font subsets and other methods for size reduction:
import io
import fitz

fileptr = io.BytesIO()
writer = fitz.DocumentWriter(fileptr)
# story processing here ...
...
writer.

Replies: 7 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by JorjMcKie
Comment options

You must be logged in to vote
1 reply
@JorjMcKie
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants