Whats the best way to process only selected pages from PDF #1283
-
I'm working on an app that needs to add highlights, links, extract text and process. But most of the times this is done only for a few selected pages from a large pdf. So what i'm currently doing is this: doc = fitz.open(pdfPath)
selectedPages= [3,4,5,10,13,14,18]
for page in doc:
if page.number in selectedPages:
# do something
doc.save(newFile garbage=4, deflate=True, clean=True) But, even though only few pages are selected, this method still need to write all other pages to the Is there a way to only process the selectedPages and quickly replace those pages in the original PDF and save it as newFile?For Example, one the features in "Blubeam Revu" - a PDF editor is to replace selected pages with another PDF, which is like this
So in this above process, we are only editing the selected pages, which reduces the overall time it takes to save the PDF. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
If you save to a new file, then obviously all page must be written. This is the same for all tools. There are a few things you can do:
|
Beta Was this translation helpful? Give feedback.
If you save to a new file, then obviously all page must be written. This is the same for all tools.
There are a few things you can do:
garbage=3
or evengarbage=1
.clean=True
.