PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Fri Mar 29, 2024 2:30 am

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 
Offline

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:

Code:
      // 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'.


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

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3095
Location: Cologne, Germany
Answered on SO:
http://stackoverflow.com/a/40015845/162529


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.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
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: Google [Bot] and 140 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