PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Mon Feb 24, 2020 3:22 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Extra paper sizes
PostPosted: Sun Mar 27, 2011 3:29 pm 
Offline

Joined: Sun Mar 27, 2011 3:16 pm
Posts: 2
I needed A6 paper, this is not yet supported. The obvious workaround is to just halve A5, but it would be good to have a full compliment of paper sizes.

_________________
Tom Garrard
www.tgcreate.com


Top
 Profile  
Reply with quote  
 Post subject: Re: Extra paper sizes
PostPosted: Wed May 25, 2011 9:20 pm 
Offline
Supporter
User avatar

Joined: Thu May 27, 2010 7:40 pm
Posts: 59
Location: New Hampshire, USA
Try something like this...

Code:
   
MigraDoc.DocumentObjectModel.PageFormat
in PageFormat.cs:
 
public enum PageFormat
    {
        Letter,  // Ansi
        Legal,
        Ledger,
        C,
        D,
        E,
        A0,  // ISO
        A1,
        A2,
        A3,
        A4,
        A5,
        A6,
        A7,
        B0,
        B1,
        B2,
        B3,
        B4,
        B5
    }

In MigraDoc.DocumentObjectModel.PageSetup   ->  PageSetup.cs
        /// <summary>
        /// Gets the page's size and height for the given PageFormat.
        /// </summary>
        public static void GetPageSize(PageFormat pageFormat, out Unit pageWidth, out Unit pageHeight)
        {
            switch (pageFormat)
            {
                case PageFormat.Letter:
                    pageWidth  = "8.5in";
                    pageHeight = "11.0in";
                    break;
                case PageFormat.Legal:
                    pageWidth  = "8.5in";
                    pageHeight = "14.0in";
                    break;
                case PageFormat.Ledger:
                    pageWidth  = "11.0in";
                    pageHeight = "17.0in";
                    break;
                case PageFormat.C:
                    pageWidth  = "17.0in";
                    pageHeight = "22.0in";
                    break;
                case PageFormat.D:
                    pageWidth  = "34.0in";
                    pageHeight = "22.0in";
                    break;
                case PageFormat.E:
                    pageWidth  = "44.0in";
                    pageHeight = "34.0in";
                    break;
                case PageFormat.A0:
                    pageWidth  = "33.1in";
                    pageHeight = "46.8in";
                    break;
                case PageFormat.A1:
                    pageWidth  = "23.4in";
                    pageHeight = "33.1in";
                    break;
                case PageFormat.A2:
                    pageWidth  = "16.5in";
                    pageHeight = "23.4in";
                    break;
                case PageFormat.A3:
                    pageWidth  = "11.7in";
                    pageHeight = "16.5in";
                    break;
                case PageFormat.A4:
                    pageWidth  = "8.3in";
                    pageHeight = "11.7in";
                    break;
                case PageFormat.A5:
                    pageWidth  = "5.8in";
                    pageHeight = "8.3in";
                    break;
                case PageFormat.A6:
                    pageWidth  = "4.1in";
                    pageHeight = "5.9in";
                    break;
                case PageFormat.A7:
                    pageWidth  = "2.9in";
                    pageHeight = "4.1in";
                    break;
                case PageFormat.B0:
                    pageWidth  = "39.3in";
                    pageHeight = "55.6in";
                    break;
                case PageFormat.B1:
                    pageWidth  = "27.8in";
                    pageHeight = "39.3in";
                    break;
                case PageFormat.B2:
                    pageWidth  = "19.7in";
                    pageHeight = "27.8in";
                    break;
                case PageFormat.B3:
                    pageWidth  = "13.9in";
                    pageHeight = "19.7in";
                    break;
                case PageFormat.B4:
                    pageWidth  = "9.8in";
                    pageHeight = "13.9in";
                    break;
                case PageFormat.B5:
                    pageWidth  = "6.9in";
                    pageHeight = "9.8in";
                    break;
                default:
                    pageWidth  = "8.5in";
                    pageHeight = "11.0in";
                    break;
            }
        }



Top
 Profile  
Reply with quote  
 Post subject: Re: Extra paper sizes
PostPosted: Thu May 26, 2011 7:46 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3023
Location: Cologne, Germany
Where are these figures coming from?
A6 has a height of 5.9in, but A5 has a width of 5.8in - the correct value would be 5.82677165".

I'd specify the paper sizes in mm.
See here (table "ISO paper sizes (plus rounded inch values)"):
http://en.wikipedia.org/wiki/Paper_size

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
 Post subject: Re: Extra paper sizes
PostPosted: Thu May 26, 2011 7:51 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3023
Location: Cologne, Germany
Tom Garrard wrote:
I needed A6 paper, this is not yet supported.

It's already implemented in MigraDoc, but not yet in PDFsharp.

You can call PageSetup.GetPageSize to query the dimensions of A6.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
 Post subject: Re: Extra paper sizes
PostPosted: Thu May 26, 2011 3:56 pm 
Offline
Supporter
User avatar

Joined: Thu May 27, 2010 7:40 pm
Posts: 59
Location: New Hampshire, USA
Thomas Hoevel wrote:
Where are these figures coming from?
A6 has a height of 5.9in, but A5 has a width of 5.8in - the correct value would be 5.82677165".

I'd specify the paper sizes in mm.
See here (table "ISO paper sizes (plus rounded inch values)"):
http://en.wikipedia.org/wiki/Paper_size


Thomas, I used these dimensions from the following table from papersizes.org mostly. It was close enough for my needs. Sure, I maybe should have used the mm sizes, good suggestion.

With all that said, and all due respect to the MigraDoc team, I should have mentioned that I was simply supplying a template and basic guidance for him to implement his own solution, which is what he must learn to do if he needs a feature here. It does seem increasingly unlikely that we'll ever see a new version of this library released officially, so it helps one greatly to know this up front.

Size Height x Width (mm) Height x Width (in)
4A0 2378 x 1682 mm 93.6 x 66.2 in
2A0 1682 x 1189 mm 66.2 x 46.8 in
A0 1189 x 841 mm 46.8 x 33.1 in
A1 841 x 594 mm 33.1 x 23.4 in
A2 594 x 420 mm 23.4 x 16.5 in
A3 420 x 297 mm 16.5 x 11.7 in
A4 297 x 210 mm 11.7 x 8.3 in
A5 210 x 148 mm 8.3 x 5.8 in
A6 148 x 105 mm 5.8 x 4.1 in
A7 105 x 74 mm 4.1 x. 2.9 in
A8 74 x 52 mm 2.9 x 2.0 in
A9 52 x 37 mm 2.0 x 1.5 in
A10 37 x 26 mm 1.5 x 1.0 in


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


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