PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu Mar 28, 2024 8:56 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Tue Apr 13, 2010 8:49 pm 
Offline

Joined: Tue Apr 13, 2010 8:39 pm
Posts: 2
My client has asked that we use the the currently selected paper size when we print a PDF file.

The problem is that the source value is of the type System.Drawing.Printing.PaperSize, and PdfPage.Size is of the type PdfSharp.PageSize. There doesn't seem to be any way to convert between the two that I can see.

Am I missing something? I guess I can write a big switch statement or use a map, but I'd rather not bother if this feature is already present.

Thanks in advance.


Top
 Profile  
Reply with quote  
PostPosted: Wed Apr 14, 2010 8:20 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3095
Location: Cologne, Germany
scotchfaster wrote:
Am I missing something?

You have papersize.Height and papersize.Width.

Use Unit.FromInch(papersize.Height / 100d) to set the Height of the PdfPage (with PageSize.Undefined). Same formula for Width.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Wed Apr 14, 2010 5:59 pm 
Offline

Joined: Tue Apr 13, 2010 8:39 pm
Posts: 2
Thanks, that was helpful. Here's my actual code:

Code:
PdfPage page = document.AddPage();
page.Width = XUnit.FromInch(((double)printDoc.PrinterSettings.DefaultPageSettings.PaperSize.Width) / 100d);
page.Height = XUnit.FromInch(((double)printDoc.PrinterSettings.DefaultPageSettings.PaperSize.Height) / 100d);


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: No registered users and 37 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