PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Wed Mar 20, 2019 5:12 pm

All times are UTC

Forum rules

Please read this before posting on this forum: Forum Rules

Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Wed Oct 12, 2016 3:11 pm 

Joined: Wed Oct 12, 2016 1:48 pm
Posts: 1
I am using PdfSharp to read / write pdf in our application. I am trying to get the paper size of the page to show in metadata window. I am using following code to do the same:

      // read PDF document into memory
      var pdfDocument = PdfReader.Open(pdfPath);

      // if PDF document have more than one page, then try to get the page size from first page
      if (pdfDocument.Pages.Count > 0)
        var pageSize = pdfDocument.Pages[0].Size.ToString();
      } // if

But every time it returns 'Undefined', I even tried to create A4 page document for MS Word. But still, it returns 'Undefined'.

Reply with quote  
PostPosted: Thu Oct 13, 2016 8:33 am 
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 2918
Location: Cologne, Germany
Answered on SO:

The properties you have to use are Width and Height. Convert them to millimeter or inch if you do not want to show the size in points.

The property Size is a convenient way to set standard page sizes for new pages as you can specify A4 or Letter. It will not be set for imported PDF files.

Thomas Hoevel
PDFsharp Team

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

All times are UTC

Who is online

Users browsing this forum: Baidu [Spider], Google [Bot] and 12 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