Skip to content

[Question] How to keep highlight when converting pdf to image #1413

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

You must be logged in to vote

Page pixmap creation by default is with annotations included. So you should see them.
The only possible hickup is that right after an annot.update() MuPDF won't always have become aware of the changes PyMuPDF has inserted in the annotation.
So it is best to reload the page before taking the pixmap: page = doc.reload_page(page).
But after going to a different page, or after opening the PDF after such changes will do the same job.
If you save the document, all outstanding changes should be saved as well.

BTW: If you save a pixmap, you cannot directly use JPEG as output format: MuPDF doen't support this. But you could use pil_save() instead.

But the following does work as desired:

>>> doc=fitz.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@CarolinaRDC
Comment options

@JorjMcKie
Comment options

Answer selected by CarolinaRDC
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