# How to insert a TeX(LaTeX)-formatted block inside a pdf-file, enlarging the page in which this block in inserted?

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:

1. Import pages 1...X verbatim

2. 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.

3. Append the proof of the theorem, that is a latex-formatted block with sections, paragraphs and figures to the page X+1.
4. 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).
5. Import pages X+2...end verbatim.
6. Save the file as a pdf.

Desirably:

1. Auto-magically cut page X+1 into as many A4 pages as required to avoid overfilling when printing.
2. 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.
• Just to clarify 1-end appears from description to be an Image only PDF thus no need to preserve hyperlinks JavaScript forms data Page Numbers etc etc thus a good candidate for splitting (parting in two) in such a case I would generate the required insert in TeX as required including page numbers etc. with an \include pdfpages (crop if necessary) before and after, What is confusing in your description is the need for oversize and automation IF this is a batch workflow it would be best driven by a parametric system where the cuts are in a database with calculated before and after parameters – user170109 May 14 at 20:26
• Perhaps the pdfpages package will help? – Andrew May 14 at 20:55
• KJO, I added a clarification. @Andrew, I didn't find an option to cut pages there. Maybe I didn't understand really, but I didn't find how to input the cutting curve/polygon. – Vladimir Nikishkin May 15 at 6:39