PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sun Jun 30, 2024 2:28 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Wed Dec 22, 2010 8:13 am 
Offline

Joined: Wed Dec 22, 2010 8:05 am
Posts: 2
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


Top
 Profile  
Reply with quote  
PostPosted: Fri Dec 24, 2010 9:05 am 
Offline
PDFsharp Expert
User avatar

Joined: Wed Dec 09, 2009 8:59 am
Posts: 343
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.

_________________
Öhmesh Volta ("() => true")
PDFsharp Team Holiday Substitute


Top
 Profile  
Reply with quote  
PostPosted: Tue Jan 13, 2015 8:08 pm 
Offline

Joined: Tue Jan 13, 2015 7:43 pm
Posts: 1
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 :(


Top
 Profile  
Reply with quote  
PostPosted: Wed Jan 14, 2015 8:49 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3100
Location: Cologne, Germany
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.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: Bing [Bot] and 13 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group