I am working with a series of PDF files. Many of them have fields, which I am able to populate using iTextSharp.
My issue is there is one static PDF that seems to be reporting an odd size, 9.5 X 12. The page size should be 8.5 X 11 and if opened using Acrobat reader, it prints just fine.
To get around this, I want to create a new PDF Document, using the correct page size, then read the static file into the new document, save it and print it.
I have read a number of the posts here on SO and done a number of searches for a solution, all of which seem to skirt my particular issue.
Is there a way to copy the existing PDF to a new document using the correct page size?
Thank you
UPDATE
Taking Bruno's advice, I did double check the crop box and media box. The PDF I am working with has both. The crop box array is
[28.008, 38.016, 640.008, 830.016]
And the media box array is
[0, 0, 668.016, 848.016]
I can alter the upper right corner points making the crop box and media box the same Crop box
[28.008, 38.016, 612, 792]
And media box
[0, 0, 612, 792]
But doing so shifts the "text" to the right and top too much, leaving an uneven margin.
I found by changing the lower left coordinates, of the crop box, I can shift the text. In fact setting the crop box to 40, 40, 612, 792 works, but then the top and bottom margins are very narrow.
I need the media box to be 0, 0, 612, 792. Not an issue there. But then how do I shrink the crop box and center the text on the page? I must be missing something.
I've followed Bruno's RotatePages method, in his book, and also looked at this answer, iTextSharp copy document, resize to custom size, and center
But whatever I change with the crop box seems to zoom in on it.
Any advice is greatly appreciated
Best Answer
Thank you Bruno Lowagie and mkl. With your assistance I was able to arrive at this solution.
It may be a bit overkill, but it works for my purposes.
Hopefully, this will help someone else.