I would like to create a copy of the original PDF with the modified page, and not update the existing one, it will be easier to work in iText, and you can always rename the aftwarads file.
Take a look at the HelloWorldCopy example here .
The only thing you need to change is the call to split the wide page into two pages. Just like the HelloWorldCopy example for all pages except the one you want to split, for this page we will consider an alternative method PDfCopy.addPage() , which allows you to specify the rectangle that defines the page size just created.
Thus, this will allow you to split the wide page into two new pages with the appropriate size. Now you need to make sure that the left part of the wide page is included in the first new page, and the right part goes to the second new page. To do this, you should look at the PdfImportedPage.setMatrix method ( PdfImportedPage is the object returned from copy.getImportedPage() in the example.
Steve claridge
source share