PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

How to get all page level information from PDF document
https://forum.pdfsharp.net/viewtopic.php?f=2&t=1482
Page 1 of 1

Author:  Gaurav Dixit [ Wed Dec 22, 2010 8:13 am ]
Post subject:  How to get all page level information from PDF document

Hello,

Can anyone please tell me how can i get following information from indivdual pdf pages.

- page is BW,grayscale or color
- page size
- DPI
etc...


Thanks
Gaurav Dixit
Software Engineer,
Pune, India

Author:  () => true [ Fri Dec 24, 2010 9:05 am ]
Post subject:  Re: How to get all page level information from PDF document

PDF pages have no DPI (all vector). You can calculate the DPI for every raster image on a page.

BW or colour: you must look at every item on that page.

Page size: it's there, just use it.

Author:  Marcin Zebrowski [ Tue Jan 13, 2015 8:08 pm ]
Post subject:  Re: How to get all page level information from PDF document

Hi!
I've a question to the current post. How can I check DPI of images contained by pdf file?
I'm trying to do something like this:

using (PdfDocument pdf = PdfReader.Open(sourcePdf))
{
for (int i = 0; i < pdf.Pages.Count; i++)
{
XGraphics xGraphics = XGraphics.FromPdfPage(pdf.Pages[i]);
float dpi = xGraphics.Graphics.DpiX;
}
}

but DPI is not correct.(For example it shows 96dpi while it should be 150dpi).

I've also tried to get such info from XObject dictionary but there're no such property like DPI :(
PdfDocument pdf = PdfReader.Open(sourcePdf);
PdfDictionary pg = pdf.Pages[0];
PdfDictionary res = pg.Elements.GetDictionary("/Resources");
PdfDictionary xobj = res.Elements.GetDictionary("/XObject");// there're width, height and so on but no dpi :(

Author:  Thomas Hoevel [ Wed Jan 14, 2015 8:49 am ]
Post subject:  Re: How to get all page level information from PDF document

PDF pages have no DPI (all vector).
If you have an image with a width of 300 pixels and you draw it in the PDF file with a width of one inch, the image will have 300 DPI when printed.
If you have an image with a width of 300 pixels and you draw it in the PDF file with a width of three inches, the image will have 100 DPI when printed.
Take the width in pixels, take the width in inches and calculate the DPI.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/