I have a pdf file with no source code. (Possibly generated from a series of scans with no OCR or some WYSIWYG text processor, or even drawn in Gimp.) Clarification: The pages are not necessary image-only, but for simplicity, even solving the problem for image-only pdfs would be a good start. If it would be possible to solve the problem and still keep more complicated pdf-components, the better.
Without loss of generality, let's assume that this document is a mathematical paper/article, containing some theorems with omitted proofs. Also assume that every page is DIN A4.
I need the following:
Import pages 1...X verbatim
Cut page X+1 along a line with coordinates (x,y): (0, 0.5)-(0.1, 0.4)-(0.2, 0.4)-(0.3, 0.5)-(1.0,0.5) and insert the upper part at the page X+1.
- Append the proof of the theorem, that is a latex-formatted block with sections, paragraphs and figures to the page X+1.
- Append the lower part of the cut made at step 2 to page X+1 thus increasing the vertical dimension of the page from height(A4) to roughly 2*height(A4).
- Import pages X+2...end verbatim.
- Save the file as a pdf.
- Auto-magically cut page X+1 into as many A4 pages as required to avoid overfilling when printing.
- Recompute all references to pages which may have been produced by a notorious text processor which had generated the original pdf for e-book reading.