Can't find /Type /Page in generated PDF

PDF-XChange Drivers API (only) V4/V5
This Forum is for the use of Software Developers requiring help and assistance for Tracker Software's PDF-XChange Printer Drivers SDK (only) - VERSION 4 & 5 - Please use the PDF-Tools SDK Forum for Library DLL assistance.

Moderators: Daniel - PDF-XChange, PDF-XChange Support, Vasyl - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Stefan - PDF-XChange

callibra, inc
User
Posts: 6
Joined: Fri Apr 15, 2011 3:50 am

Can't find /Type /Page in generated PDF

Post by callibra, inc »

Hello,

I am successfully using your drive SDK to generate PDF files. One of our customers that imports our PDF files into their system needs to be able to count the number of pages in the PDF document. They say for all other PDF documents they are able to use a regular expression to determine the number of pages in the PDF: "/Type\s*/Page[^s]" . Each page of a PDF starts with a /Page object, which they count. The files generated by the PDF Driver SDK does not have any /Type /Page tags.

I know very little about the contents of PDF files. Can you help me understand why PDF files generated from your product don't have these tags? Or is there a setting I can change in the generation of the PDF so that these tags are included? Or is there an alternate regular expression they can use in the PDF document to search for the number of pages?

Thank you


FYI

They found this example of a typical /Page object online.

17 0 obj
<<
/Type /Page
/Parent 11 0 R
/MediaBox [0 0 600 810]
/Resources
<<
/Font << /F1 1 0 R /F2 2 0 R >>
/ProcSet 10 0 R
>>
/Contents [16 0 R 15 0 R ]
>>

endobj
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19846
Joined: Mon Jan 12, 2009 8:07 am

Re: Can't find /Type /Page in generated PDF

Post by Stefan - PDF-XChange »

Hello callibra, inc,

Could you please send us one sample file that your customer fails to count the pages in for us to take a look?

Best,
Stefan
Walter-Tracker Supp
User
Posts: 381
Joined: Mon Jun 13, 2011 5:10 pm

Re: Can't find /Type /Page in generated PDF

Post by Walter-Tracker Supp »

All the documents we create conform to the PDF standards outlined in the ISO standards specification.

I have checked a PDF document generated by our SDK and I can find the individual page objects as well as the page tree:

Code: Select all

1 0 obj
<<
/Type /Pages
/Count 7
/Kids [
4 0 R
13 0 R
16 0 R
19 0 R
22 0 R
25 0 R
28 0 R
]
>>
endobj
But as Stefan suggests, an example might help us sort out what is going on in your case.
callibra, inc
User
Posts: 6
Joined: Fri Apr 15, 2011 3:50 am

Re: Can't find /Type /Page in generated PDF

Post by callibra, inc »

Attached is an example we generated using your product.

Thanks for your help
You do not have the required permissions to view the files attached to this post.
Walter-Tracker Supp
User
Posts: 381
Joined: Mon Jun 13, 2011 5:10 pm

Re: Can't find /Type /Page in generated PDF

Post by Walter-Tracker Supp »

I'm referring your question to an expert on PDF structure to get a good answer to you for why this PDF is structured the way it is. The standard is pretty complex.

You could always use the SDK to get page counts - it accounts for the variations in PDF structure ;)
Walter-Tracker Supp
User
Posts: 381
Joined: Mon Jun 13, 2011 5:10 pm

Re: Can't find /Type /Page in generated PDF

Post by Walter-Tracker Supp »

I have a response for you. Essentially, this method of counting pages is not guaranteed to work on all conformant PDFs.
First of all, there can be not only one space between /Type and /Page.
By specification there can be nothing or any number of white space characters (what is white char in PDF terms is better to find in PDF spec.).

Also, this method may not work in the case of incremental updated PDF file, and will not work for sure with PDF file saved using object streams (introduced in PDF 1.5) because non stream objects can be stored inside special streams where they may be compressed.

So, simplest asnwer for the user would be link to the PDF spec ;)
The specification is available here:

http://wwwimages.adobe.com/www.adobe.co ... 0_2008.pdf
callibra, inc
User
Posts: 6
Joined: Fri Apr 15, 2011 3:50 am

Re: Can't find /Type /Page in generated PDF

Post by callibra, inc »

Is there any accurate way to retrieve the count of the pages by using opening the PDF file in an editor and looking for specific tags? That appears to be what our customer is trying to do?

Why doesn't the PDF I generated with your SDK have the /Type /Page tags in it but your tech support says the samples THEY generate with your product do? Are there any options I can use when generating the PDF using your API to make sure they are included?

I appreciate what you are saying about incrementally updated PDF documents, but we are not doing that in this case.

As a VERY last resort I can use your API to count the pages for them but this has practical problems for u in our implementation.

Thank you for your responses. I appreciate the help with this.
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19846
Joined: Mon Jan 12, 2009 8:07 am

Re: Can't find /Type /Page in generated PDF

Post by Stefan - PDF-XChange »

Hello callibra, inc,

If Walter used a 1.4 specification version for his initial file - that's why he got the "plain text" structure. If you are creating PDF files with specification 1.5 or higher - the file just uses object streams that compress the structure and your user will need much more complicated tool capable of reading PDF object streams and decoding them to count the pages, rather than the parsing of the content they are doing now.

So maybe saving your files at specification version 1.4 will help with that particular client, but the files produced could be larger and won't support some of the features added in later revisions. The ideal solution would be for your customer to obtain a copy of e.g. our PDF Tools SDK and use that to count the pages in any specification compliant PDF file.

Best,
Stefan
callibra, inc
User
Posts: 6
Joined: Fri Apr 15, 2011 3:50 am

Re: Can't find /Type /Page in generated PDF

Post by callibra, inc »

Thank you for your reply.

How do I "use a 1.4 specification version for his initial file"? Is that an option when I create the PDF?

Can you tell me what property (or properties) to set in your SDK?

Thank you
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19846
Joined: Mon Jan 12, 2009 8:07 am

Re: Can't find /Type /Page in generated PDF

Post by Stefan - PDF-XChange »

Hello callibra, inc

Take a look at page 15 of the attached document.

You need to set "Option.General.Specification" to 4 in the Drivers API.

Best,
Stefan
You do not have the required permissions to view the files attached to this post.
Walter-Tracker Supp
User
Posts: 381
Joined: Mon Jun 13, 2011 5:10 pm

Re: Can't find /Type /Page in generated PDF

Post by Walter-Tracker Supp »

callibra, inc wrote:Is there any accurate way to retrieve the count of the pages by using opening the PDF file in an editor and looking for specific tags? That appears to be what our customer is trying to do?

Why doesn't the PDF I generated with your SDK have the /Type /Page tags in it but your tech support says the samples THEY generate with your product do? Are there any options I can use when generating the PDF using your API to make sure they are included?
Stefan is correct; I have confirmed with one of the experts on PDF structure that using v1.4 specification will generate these tags, but be careful of whitespace (I'm not 100% sure the \s regexp tag exactly corresponds to PDF whitespace, you might want to dig through the pdf spec to be certain).

I guess you are using the drivers API, but in case you were using the Tools SDK you can also enforce creation of version 1.4 files (or other supported versions, for that matter) by calling one of the following functions:

PXC_SetSpecVersion(pPdf, SpecVersion14, TRUE);

or

PXCp_SetSpecVersion(pPDF, SpecVesion14);

I appreciate what you are saying about incrementally updated PDF documents, but we are not doing that in this case.

As a VERY last resort I can use your API to count the pages for them but this has practical problems for u in our implementation.

Thank you for your responses. I appreciate the help with this.
I'm not an expert on our licensing schemes (you'd have to talk to our sales team about that) but it seems to me that it would be possible to provide your client(s) with a simple command line tool to output the number of pages from an input document. Obviously this could have some platform limitations (windows) so if you're trying to grep for the tags on a linux server or something this won't help.
callibra, inc
User
Posts: 6
Joined: Fri Apr 15, 2011 3:50 am

Re: Can't find /Type /Page in generated PDF

Post by callibra, inc »

I am using Visual basic 6.0 I have the code below. I added this line:

.Option("General.Specification") = "4"

(the default value is '0 - Auto' according to the online help file I have)

I see no difference in the generated output. I'm attaching another copy after changing this setting.

Am I doing something wrong?

Code: Select all

    Set PDFPrinter = PDFPFactory.Printer("", "Discharge 1-2-3 PDF Printer", "(my key here)")


    With PDFPrinter
        ' may not exactly match base naem if there is a name conflict for any reason
        PDF_PRINTER_NAME = .name
        
        
        .ResetDefaults
        
        .Option("Security.Enabled") = True
        .Option("Security.HasUserPassword") = True
        .Option("Security.HasOwnerPassword") = True
        .Option("Security.UserPassword") = emailPassword
        If emailPassword <> "" Then
            .Option("Security.OwnerPassword") = MakePassword(12) ' make up a random owner password and then forget it.  We never save this
        End If
        .Option("Security.Type") = 2  '128 AES encryption
        .Option("Security.Perms128.Printing") = 2 ' allowed
        
        .Option("Save.File") = SaveFileName
        .Option("Save.SaveType") = "Save"
        .Option("Save.ShowSaveDialog") = "No"
        '.Option("Save.WhenExists") = "Overwrite"
        .Option("Save.WhenExists") = "Append" ' useful when printing multiple Rx reports.  They will all append to the same file now
    
        .Option("Compression.Graphics") = "Yes"
        .Option("Compression.Text") = "Yes"
        .Option("Compression.ASCII") = "No"
        .Option("Compression.Color.Enabled") = "Yes"
        .Option("Compression.Color.Method") = "Auto"
        quality = "75"
        If IsNumeric(G_SavePDF_ImageQuality) Then
            If CInt(G_SavePDF_ImageQuality) >= 10 And CInt(G_SavePDF_ImageQuality) <= 100 Then
               quality = G_SavePDF_ImageQuality
            End If
        End If
        .Option("Compression.Color.JPEGQuality") = quality
        .Option("Compression.Indexed.Enabled") = "Yes"
        .Option("Compression.Indexed.Method") = "Auto"
        .Option("Compression.Mono.Enabled") = "Yes"
        .Option("Compression.Mono.Method") = "Auto"
        .Option("Graphics.Color.Downsample.Method") = "Bicubic"
        .Option("Graphics.Color.Downsample.To") = "96"
        .Option("Graphics.Color.Downsample.IfAbove") = "128"
        .Option("General.Specification") = "4"
        .Option("Fonts.EmbedAll") = 0
        .Option("Save.RunApp") = False
        .Option("Saver.ShowProgress") = "No"
    
    
    End With
You do not have the required permissions to view the files attached to this post.
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19846
Joined: Mon Jan 12, 2009 8:07 am

Re: Can't find /Type /Page in generated PDF

Post by Stefan - PDF-XChange »

Hello callibra, inc,

You are using 128 Bit AES encryption - and that's supported from PDF specification version 1.6 and up - so this overrides the specification version you are setting manually after that.

Best,
Stefan
callibra, inc
User
Posts: 6
Joined: Fri Apr 15, 2011 3:50 am

Re: Can't find /Type /Page in generated PDF

Post by callibra, inc »

I think that did it. Thanks for your help
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19846
Joined: Mon Jan 12, 2009 8:07 am

Re: Can't find /Type /Page in generated PDF

Post by Stefan - PDF-XChange »

:)