PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sat Apr 27, 2024 4:56 pm

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: Sun Feb 24, 2013 12:03 pm 
Offline

Joined: Sun Feb 24, 2013 11:44 am
Posts: 3
I searched and searched, but could not find any samples nor any forum posts revealing what I need to do. :(

I am working with a tool to create cards for games. Each card needs to be its own page. But I can't find out how to do code to get this to happen. I need each PDF page to be 59 x 89 mm in size.

Basically, this is what I want to do
Code:
        Dim page As PdfPage = document.AddPage()
        page.Size = PageSize.Undefined
        page.Width.Millimeter = 59
        page.Height.Millimeter = 89

But on the second line I directly get an Invalid PageSize ArgumentException thrown at me. All the other size enumerators works perfectly. The last two line won't even get through the compiler. I can only touch page.Width and page.Height to set a size, but were do I then tell them it's millimeter I use.

Anyone know what I missed? I guess it must be basic, but it keeps eluding me


Top
 Profile  
Reply with quote  
PostPosted: Mon Feb 25, 2013 9:08 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3096
Location: Cologne, Germany
Hi!

How about this:
Code:
page.Width = "59mm"
page.Height = XUnit.FromMillimeter(89)
Using "FromMillimeter" will be more efficient, but both ways will work.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Mon Feb 25, 2013 9:20 am 
Offline

Joined: Sun Feb 24, 2013 11:44 am
Posts: 3
Thank you!

I knew I missed something basic. The XUnit.Fromxxx was exactly what I needed.

And I guess that by setting the Width amd Height of the page it becomes PageSize.Undefined by itself.

Super! Now back to coding... :)


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] and 339 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