PDFsharp & MigraDoc Foundation
http://forum.pdfsharp.de/

PDFSharp Custom Page Size
http://forum.pdfsharp.de/viewtopic.php?f=2&t=2339
Page 1 of 1

Author:  spindisc [ Sun Feb 24, 2013 12:03 pm ]
Post subject:  PDFSharp Custom Page Size

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

Author:  Thomas Hoevel [ Mon Feb 25, 2013 9:08 am ]
Post subject:  Re: PDFSharp Custom Page Size

Hi!

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

Author:  spindisc [ Mon Feb 25, 2013 9:20 am ]
Post subject:  Re: PDFSharp Custom Page Size

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... :)

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/