PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sun Apr 28, 2024 2:12 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: Page Size = massive
PostPosted: Sat Mar 13, 2010 4:55 am 
Offline

Joined: Sat Mar 13, 2010 4:15 am
Posts: 6
I'm trying to figure out how to stick some JPGs into a PDF. The source files are 3000x2000 or so, that sort of size. When I stick them into a PDF, the resultant PDF says it's 24 x 31 inches. And when you go to print, it's multitudes of pages. This happens even if I set the page size to A4 or Letter.

But if I rescale the image, it looks bad.

Is there a way to keep a high resolution image but have it stay on one A4 page? A DPI setting or something?

Thanks in advance.


Top
 Profile  
Reply with quote  
 Post subject: Re: Page Size = massive
PostPosted: Mon Mar 15, 2010 1:46 pm 
Offline

Joined: Sat Mar 13, 2010 4:15 am
Posts: 6
If I set page size and use:

xgr.DrawImage(img, 0, 0, page.Width, page.Height);

instead of
xgr.DrawImage(img, 0, 0);

I get a page with the right size and the image still looks good. Only problem now is that it distorts when drawing, since the images aren't always the same ratio as page.

I see a few other threads where people are talking about aspect ratio, but no good solution. Basically I want an image to fit a PDF page as full as possible, and be in landscape when appropriate. Anyone ever done this?

thanks


Top
 Profile  
Reply with quote  
 Post subject: Re: Page Size = massive
PostPosted: Mon Mar 15, 2010 3:26 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3096
Location: Cologne, Germany
Minimalist360 wrote:
Basically I want an image to fit a PDF page as full as possible, and be in landscape when appropriate.

We scale images (without changing orientation) while maintaining the aspect ratio.

Should be simple:
For portrait: calculate width for available height and calculate height for available width - at least one of those will fit.
Keep aspect ratio while calculating.
Do the same for landscape.

Now take the bigger of the two pairs that will fit and rotate the page.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
 Post subject: Re: Page Size = massive
PostPosted: Mon Mar 15, 2010 3:53 pm 
Offline

Joined: Sat Mar 13, 2010 4:15 am
Posts: 6
Should be simple.

I notice unless I draw into an area that's 750 pixels tall, the page size goes berzerk. Is this the way PDF is? Page has to be 72dpi? Is there a DPI setting for the document or for pages? I don't see it.


Top
 Profile  
Reply with quote  
 Post subject: Re: Page Size = massive
PostPosted: Tue Mar 16, 2010 9:19 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3096
Location: Cologne, Germany
Minimalist360 wrote:
Is there a DPI setting for the document or for pages? I don't see it.

PDF is vector - there is no DPI for PDF.

viewtopic.php?p=2193#p2193
viewtopic.php?p=2497#p2497

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
 Post subject: Re: Page Size = massive
PostPosted: Tue Mar 16, 2010 3:46 pm 
Offline

Joined: Sat Mar 13, 2010 4:15 am
Posts: 6
Thanks for the reply.

I understand that, but page.Width and page.Height are in some kind of unit, and I can set position based on that unit. Is there a way to get more of said unit crammed into the same page size? Or is this unit "points?"

i.e. If I want to create a page with 1/2 inch margins, what do I add/subtract form the left/right/top/bottom? 36? Or do I always have to know the page size, get the units back from page.Width and page.Height and take a percentage?

I have this all working fine for Letter/A4 based on some hardcoded values, the biggest problem I seem to be having now is getting unicode strings into doc.Info.Title and doc.Info.Keywords, which apparently isn't possible.

thanks again


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 211 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:  
cron
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group