PDF File Parsing - Page Setup Retrieval (and Manipulation)

Steve Marshall
Steve Marshall used Ask the Experts™
on
I was wondering if anyone knows of a method using VB.Net that means that a large library (1000's of PDF files) of PDF files can be opened and parsed prgrammatically to extract the current Page Settings (primarily the Paper/Page Size) ??

We have a large number of files that have been generated out of CAD software and sometimes they have been reformatted to A4 paper size, and sometimes not (sometimes printing to paper 65" square!!). When these latter files are sent to the printer (an HP Printer in this case) the printer does not cope at all well with the paper-size and just errors the job and blocks the print queue.

What I would like to do is to programmatically run through the entire library and extract the page size and generate an excel spreadsheet (this last bit is easy once I have the details from the PDF!) that gives the document name and the page size setting.

Ideally I would like to be able to manipulate the page size to be A4 also, but this last step is not critical.

Any help/suggestions would be appreciated.

Thanks,
Steve
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
I have used PDFSharp library to create and join PDF's.

http://pdfsharp.com/PDFsharp/index.php?option=com_content&task=view&id=35&Itemid=46

when you open a PDFDocument, get Page 0 (most of your cad output is likely single page), then you can return the [age size and check it against an enumeration or just the known pages sizes A0-A3, B1-B3

most examples are C# but does work in VB as well.
'Open the file
Dim inputDocument as PdfDocument = PdfReader.Open(filename, PdfDocumentOpenMode.ReadOnly);
dim  page as PdfPage = inputDocument.Pages(0)
dim ht as integer = page.Height
dim wdth as integer = page.Width 

Open in new window

Steve MarshallIT Manager

Author

Commented:
Thanks Robberbaron. I will give this a try and report back.

Steve
Steve MarshallIT Manager

Author

Commented:
This has solved the initial dilemma. I have now generated a CSV of all PDF files that have one or other dimension (caters with page orientation as well) that exceeds A4. JUst need to work out the next step now, and PDFSharp may wee be able to deal with this as well.

Only issue is the popup message about a non-parseable Acrobat 6 iRef .... whatever that is!

Steve
see http://forum.pdfsharp.net/viewtopic.php?f=2&t=693  for a known issue & a workaround...

i borrowed a method that uses a different PDF class (iTextSharp) to create bypass method in c#.
you need to find the old open-source version of iTextSharp.

check the bottom of the thread.
Steve MarshallIT Manager

Author

Commented:
Thanks Robberbaron. Will look into this. My ultimate aim is to have a function available within my application that pre-checks any PDF before printing to ensure that the page settings are suitable and to then auto-scale if necessary before printing.

Thanks again,
Steve

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial