PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Fri Apr 26, 2024 2:40 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Center an Image on Page
PostPosted: Mon Apr 21, 2008 7:32 am 
Offline

Joined: Mon Apr 21, 2008 7:23 am
Posts: 4
Hello Everybody,

I'm having trouble centering a loaded jpg-file (72dpi) on the DIN A4 page. I mean i could calculate its position but there's the issue with page size in Point s or millimeters and Image size in pixels. Is there a way to put it in a Table or similar and center it vertically and horizontally?

Another thing: am I just a bit dumb or isn't there really a doumentaion/reference on pdfsharp? i checked all the links like sourceforge, pdfsharp.org and the wiki.

Thx for any hints.

Cheers,
Poly


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Apr 21, 2008 8:04 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3096
Location: Cologne, Germany
Hello, Poly,

Calculating the image position should be no problem since XUnit can do all the conversions.
This also allows you to resize images (make 'em smaller, maybe even make 'em larger).

Documentation is a weak point. But the samples give you an idea how PDFsharp works in general, and Intellisence will show you the available methods.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Apr 21, 2008 8:45 am 
Offline

Joined: Mon Apr 21, 2008 7:23 am
Posts: 4
Hello Thomas,

Thanks a lot for the quick reply. I thought XUnit could be the way but didn't know it can handle pixels as well, i'll give it a try.

A nice reference would be really nice, the only thing i'm missing - but i can imagine how much work that is.

By the way: You guys are doing a really great job on PDFsharp - it's a really cool piece of software and works really nice and fast so far.

Thanks,
poly


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Apr 21, 2008 4:28 pm 
Offline

Joined: Mon Apr 21, 2008 7:23 am
Posts: 4
Hello again,

sorry, i can't figure out how i can get the pixel-to-point-conversion using XUnit.

Can someone give me a hint?

XUnit has only .fromCentimeter .fromMillimeter .fromInch .fromPoint

Thanks for any help,
Poly


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Apr 22, 2008 7:52 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3096
Location: Cologne, Germany
Hello!
polygonwindow wrote:
sorry, i can't figure out how i can get the pixel-to-point-conversion using XUnit.

Sorry, my mistake (will be included in PDFsharp 1.1).

Here's how to get it done with PDFsharp 1.0:
Quote:
XImage img = XImage.FromFile(filename);
Unit height = Unit.FromInch(img.PixelHeight / img.VerticalResolution);
Unit width = Unit.FromInch(img.PixelWidth / img.HorizontalResolution);

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Apr 22, 2008 12:15 pm 
Offline

Joined: Mon Apr 21, 2008 7:23 am
Posts: 4
Ahh super! this will work..

Thanks a lot for the help.

Poly


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 387 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