I have a PDF document that I just received via file upload (InputFile).
I'd like to use iTextSharp to check it's page size before proceeding. For example, the size of a pdf when you go to file > Properties > Description Tab > Page Size (in acrobat).
Any advice on how I can do that?
THANKS!
Once downloaded, simply open your pdf file in Adobe Acrobat Reader, press Ctrl+D or File > Properties (Document Properties). And voilà! In the Advanced Information section, you will find 'Page size'. Now, if you want to know your dimensions in units other than inches, simply convert it (1 inch -> 2.54 cm).
By default, a chart is rendered as 500 pixels wide by 400 high. If you set a chart to have a specific width and height, like 5 inches wide by 2 inches high, it will be rendered in PDF as 480 pixels wide and 192 pixels high, and in HTML it would also be displayed at that pixel size.
Most of us are familiar with typical document sizes such as letter (8.5″ by 11″), legal (8.5″ by 14″) and ledger/tabloid (11″ by 17″).
Note that iTextSharp defaults to a page size of A4 - which is 8.27 inches x 11.69 inches (slightly more elongated that the US Letter standard). This equates to 595 x 841 in points and 794 x 1122 in pixels.
You need to read the pdf from your input stream (m).
PdfReader reader = new PdfReader(m);
// Page size
Rectangle pagesize = reader.GetPageSize(1);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With