PDFsharp & MigraDoc Forum

PDFsharp - A .NET library for processing PDF & MigraDoc - Creating documents on the fly
It is currently Wed Nov 05, 2025 10:24 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules

Also see our new Tailored Support & Services site.



Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Mon Jun 04, 2012 10:54 pm 
Offline

Joined: Mon Jun 04, 2012 10:00 pm
Posts: 2
Good evening everyone. I am working on a project where we will be resampling the images in an existing PDF document. Our goal is to reduce the overall file size.

I have poured over the forum and the wiki, and have seen the examples for extracting the image from the file. I even have some working code that replaces the JPEGs (streams) in my test document. However, I also need the image's height and width so that I can resample the image to the "native" document DPI.

What is the best way to find the XY coordinates and more importantly, the Height and Width of an image when opening the document in SharpPDF?

Thank you in advance!


Top
 Profile  
Reply with quote  
PostPosted: Mon Jun 04, 2012 10:57 pm 
Offline

Joined: Mon Jun 04, 2012 10:00 pm
Posts: 2
Oh, just to clairify; I am looking for the layout height/width and position, and not the image's native resolution.

Thanks!


Top
 Profile  
Reply with quote  
PostPosted: Tue Jun 05, 2012 7:55 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3136
Location: Cologne, Germany
Hi!
Equusoft wrote:
What is the best way to find the XY coordinates and more importantly, the Height and Width of an image when opening the document in SharpPDF?
I don't know. Maybe you should ask in the SharpPDF forum (if there is any).

Position and dimensions are specified when the image is actually drawn on a page. AFAIK PDFsharp does not parse the drawing instructions for you. PDFsharp gives you the stream of drawing instructions, but you have to do the parsing.

Probably not a simple task, IIRC PDF files can contain various transformations that affect position, dimensions, and even shape of images.
See page 5 of the Graphics sample:
http://www.pdfsharp.net/wiki/Graphics-sample.ashx

_________________
Regards
Thomas Hoevel
PDFsharp Team


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

All times are UTC


Who is online

Users browsing this forum: Google [Bot], mfois and 162 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