This is a migrated thread and some comments may be shown as answers.

PdfDocumentSource can't load the document

2 Answers 357 Views
PdfProcessing
This is a migrated thread and some comments may be shown as answers.
Dzmitry
Top achievements
Rank 1
Dzmitry asked on 03 Nov 2015, 02:03 PM

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 Answers, 1 is accepted

Sort by
0
Accepted
Tanya
Telerik team
answered on 06 Nov 2015, 08:20 AM
Hello ,

From the provided I can see that there is an invalid cross-reference table in the document. After the 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
0
Dzmitry
Top achievements
Rank 1
answered on 06 Nov 2015, 10:16 AM
It works for me. Thanks a lot!
Tags
PdfProcessing
Asked by
Dzmitry
Top achievements
Rank 1
Answers by
Tanya
Telerik team
Dzmitry
Top achievements
Rank 1
Share this question
or