ssimms / pdfapi2

Create, modify, and examine PDF files in Perl
Other
15 stars 20 forks source link

Q: Delete, discard, overwrite pages #56

Open sciurius opened 1 year ago

sciurius commented 1 year ago

While creating a PDF document I create pages sequentially. At a certain point I decide that the last couple of pages that have been written are wrong, and I want to discard these and then add new pages. Since PDF::API2 does not have a remove_page method, what would be 'the right' way to obtain this? Do I need to manually manipulate the pagestack?

sciurius commented 1 year ago

This is what I'm trying to achieve. I create the PDF document chunk-wise. Each chunk is one or more pages. Before each chunk there may be one blank pages for page alignment. Now if there is a blank page (I know that) and the chunk is two pages, I do not want the blank page. So I want to discard the last three pages, and re-process the chunk. Re-processing is necessary since the page headers and footers will be different (left/right, page numbers).

The hard way is to process each chunk to a temporary document, and then process it again to the main document, first inserting a blank page unless it is two pages.

Maybe there are other (better) ways to achieve this?

ssimms commented 1 year ago

Some thoughts:

sciurius commented 8 months ago

I did make some attempts some time ago but it turned out to be a bit more complicated than I anticipated. Given the alternatives I'll let this rest.