PdfDocumentSource can't load the document

3 posts, 1 answers
  1. Dzmitry
    Dzmitry avatar
    3 posts
    Member since:
    Dec 2013

    Posted 03 Nov 2015 Link to this post

    Hello everybody

     I have a problem with pdf file loading into PdfDocumentSource.

    In the OnException handler I have next information:
    Value cannot be null.
    Parameter name: Pages

       at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.PdfFormatProvider.Import()
       at Telerik.Windows.Documents.Fixed.PdfDocumentSource.CreateDocumentFromStreamOverride(Stream stream, FormatProviderSettings settings)
       at Telerik.Windows.Documents.Fixed.FixedDocumentStreamSource.CreateDocumentFromStream(Stream stream, FormatProviderSettings settings)

    This file is a scan of a document and has one page. I can open it in PDF readers.
    Unfortunately ​I can't attach the file because it's confidential (and I don't have such problem with any other file).

    Here is it's header and ending:
    header:
    %PDF-1.3
    1 0 obj
    <</Type /XObject /Subtype /Image /Name /Im1 /Width 1654 /Height 2338 /Length 315069/ColorSpace /DeviceRGB /BitsPerComponent 8 /Filter [ /DCTDecode ] >> stream

    -------------------------------------------------------------------------------------------------------------------------
    ending:

    endobj
    2 0 obj
    << /Length 47 
    >>
    stream
    q 595.44 0 0 841.68 0.00 0.00 cm 1 g /Im1 Do Q
    endstream
    endobj
    3 0 obj
    <<
    /Type /Page
    /MediaBox [0 0 596 842]
    /Parent 4 0 R 
    /Rotate 0 /Resources <<
    /ProcSet [/PDF /ImageC /ImageB /ImageI]
    /XObject <<
    /Im1 1 0 R
     >>
     >>
    /Contents [ 2 0 R
    ]
    >>
    endobj
    4 0 obj
    <<
    /Type /Pages
    /Kids [ 3 0 R]
    /Count 1
    >>
    endobj
    5 0 obj
    <<
    /Type /Catalog
    /Pages 4 0 R  
    >>
    endobj
    6 0 obj
    << /Creator ()
    /CreationDate ()
    /Author ()
    /Producer ()
    /Title ()
    /Subject ()
    >>
    endobj
    xref
    1 7
    0000000000 65535 f 
    0000000009 00000 n 
    0000315262 00000 n 
    0000315359 00000 n 
    0000315546 00000 n 
    0000315604 00000 n 
    0000315655 00000 n 
    trailer
    <<
    /Size 7
    /Root 5 0 R
    /Info 6 0 R
    >>
    startxref
    315751
    %%EOF

     

    Is there any possibility to load this document source?

     

    Thanks,

    Dzmitry

  2. Answer
    Tanya
    Admin
    Tanya avatar
    405 posts

    Posted 06 Nov 2015 Link to this post

    Hello Dzmitry,

    From the provided information I can see that there is an invalid cross-reference table in the document. After the xref keyword, the start index of the cross-reference table is 1 while the correct and expected value is 0.

    At this point, this kind of invalid documents cannot be opened with RadPdfViewer and we have already logged a task to implement a mechanism to change this behavior. You could subscribe to the related public item in order to receive updates about our progress on it.

    To work around this behavior, you could change the value manually to 0 or use the attached project. The demo modifies the original file stream if necessary and creates a new memory stream that has valid start index of the cross-reference table.

    Hope this helps.

    Regards,
    Tanya
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. Dzmitry
    Dzmitry avatar
    3 posts
    Member since:
    Dec 2013

    Posted 06 Nov 2015 in reply to Tanya Link to this post

    It works for me. Thanks a lot!
Back to Top