How to move the content inside a rectangle inside an existing PDF?
My goal is to move text in a PDF around, which is within a certain rectangular area. All content matching the area in the original PDF should be shifted somewhat in the x and y direction. I have no influence on how the PDFs are created and I can accept a solution that only vaguely works.
Posted on StackOverflow on Feb 6, 2015 by tom_ink
Suppose that you have a PDF document like this:

Original PDF
I also have the coordinates of a rectangle: new Rectangle(100, 500, 100, 100); and an offset: move everything in that rectangle 10 points to the left and 2 points to the bottom, like this:

Manipulated PDF
That is fairly easy to achieve. Take a look at the CutAndPaste example adapted for iText 7:
##GITHUB:https://github.com/itext/itext-publications-examples-java/blob/master/src/main/java/com/itextpdf/samples/sandbox/merge/CutAndPaste.java##
##GITHUB:https://github.com/itext/itext-publications-samples-dotnet/blob/master/itext/itext.samples/itext/samples/sandbox/merge/CutAndPaste.cs##
Take into account that PdfImportedPage, PdfContentByte and PdfTemplate classes don’t exist in iText 7. We use PdfFormXObject and PdfCanvas now. As you see in the code above, t_canvas1 contains the whole first page, but with the clipped rectangle area; t_canvas2 is that clipped area and we add it to the main canvas with an offset -20, -2 to make the resulting PDF more demonstrative.
Click How to move the content inside a rectangle inside an existing PDF? | iText 5 PDF Development Guide if you want to see how to answer this question in iText 5.