0

If a pdf has it's Kids metadata defined based on an inline object instead of an object reference then Itextsharp does not recognize any pages.

Example:

/Kids [
<< /Type /Page /Parent 2 0 R /MediaBox [0 0 595 842] /Contents 00007 0 R >>
]

Is there any fix for this?

5
  • You can either fix your file so that it is in compliance with the PDF specification, or you can ask Tech Support at iText Group to provide a fix. Tech Support at iText is only available for paying customers. On StackOverflow, you'll only find volunteers. If you ask volunteers to do something that goes against the spec for free, they'll say: "No can do! Why would we have to fix something that was broken by someone else?" Mar 3, 2016 at 11:07
  • Or IMO more to the point, Why would we have to fix something that is not broken?
    – mkl
    Mar 3, 2016 at 13:31
  • @mkl to help out a customer so that he can solve a very specific problem. It's a service that people provide in a business relationship. I agree with you that we shouldn't care about this "non-issue" in case the user isn't a customer. Mar 3, 2016 at 13:55
  • 1
    @BrunoLowagie I particularly was thinking about the On StackOverflow case in your original comment. Paying customers are a different case altogether...
    – mkl
    Mar 3, 2016 at 14:12
  • 1
    I'd be curious to know what "big companies" aren't following the PDF spec. Most companies I know, regardless of size, use a 3rd-party library for PDF generation so I'd blame the library and not the company. Regardless, I'd bark it up the chain to someone to have them fix this at the source instead of you fixing it at the end. Wishful thinking, I know.
    – Chris Haas
    Mar 3, 2016 at 14:54

1 Answer 1

2

The PDF specification describes the Kids array as:

(Required) An array of indirect references to the immediate children of this node. The children shall only be page objects or other page tree nodes.

This is required to allow other objects to refer to specific pages (e.g. Destinations or a P entry of an annotation).

5
  • Unfortunately some big companies don't follow this spec so I have to cope with it somehow. I hope my only solution is not to write a script that converts the pdf before handling it with itextsharp?
    – MichaelD
    Mar 3, 2016 at 11:04
  • Also, adobe pdf viewer does open the pdf, so they do support it
    – MichaelD
    Mar 3, 2016 at 11:05
  • 1
    @MichaelD There are people who drive through red lights, so why wouldn't it be allowed? Because there are rules and you are supposed to follow them! This being said: it can be fixed if you're a customer of iText Group. If you're not a customer of iText Group, there is no reason for anyone to fix this. Mar 3, 2016 at 11:10
  • 2
    @MichaelD Adobe supports this by repairing the page tree structure, I guess. Technically it would be very hard to support this structure without repairing it... and wouldn't make sense at all.
    – Jan Slabon
    Mar 3, 2016 at 11:23
  • 1
    @MichaelD "Also, adobe pdf viewer does open the pdf, so they do support it" - Adobe Reader is extremely lax considering the interpretation of the PDF specification; in some cases they repair the PDF (prompting you to save the PDF when closing the document), in some cases they simply ignore the issue. Up to a certain degree, viewers and PDF processors with a GUI can afford to be a bit lax because the user immediately sees if something goes wrong. Libraries for automatic PDF processing, on the other hand, cannot allow invalid content to pass.
    – mkl
    Mar 3, 2016 at 13:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.