Print Page | Close Window

LoadFromFile failed (Delphi 2007) .. why?

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=1033
Printed Date: 22 Nov 24 at 7:30PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: LoadFromFile failed (Delphi 2007) .. why?
Posted By: ZarkoGajic
Subject: LoadFromFile failed (Delphi 2007) .. why?
Date Posted: 18 Mar 09 at 8:56AM
Hi,
 
I have a PDF file that refuses to be loaded using TQuickPDF0712 (Delphi 2007) LoadFromFile method.
 
The result of the function is "0 - The file could not be read or processed".
 
The PDF is not password protected. It loads in Adobe Reader and FoxIt.
 
p.s.
Other documents load with no problems.
 
How to determine the cause of this problem? Can I upload this PDF somewhere for a test?
 
-zarko gajic



Replies:
Posted By: Ingo
Date Posted: 18 Mar 09 at 9:30AM
Hi Zarko!

You can send it to me at
ingo -dot- schmoekel -at- ewetel -dot- net
BTW: Are you the Zarko from delphi.about.com?

Welcome here!

Cheers, Ingo



Posted By: ZarkoGajic
Date Posted: 18 Mar 09 at 10:59AM
Ingo,
 
Thanks for the offer.
 
I "know" that the file is corrupted .. I just am not sure why it loads with Acrobat Reader with no problems .. plus it would be great if when LoadFromFile fails .. a more descriptive error is provided.
 
p.s.
PDF sent to your email..
 
p.s.
Yes, Zarko Gajic from delphi.about.com :)


Posted By: DELBEKE
Date Posted: 18 Mar 09 at 11:05AM
Hi Zarko
 
The most frenquetly corrupted pdf are corrupted in the cross reférence (generaly at the end of the file). When Acrobat reader find this kind of corruption, he corrects the problem with a complete reconstruction of cross reference.
 
I suppose QuickPdf library will do it in a near future.
 
Cheers
 


Posted By: ZarkoGajic
Date Posted: 18 Mar 09 at 11:21AM
Hi,
 
How about some kind of descriptive (error) message to why the LoadFromFile has failed?
 
-zarko


Posted By: DELBEKE
Date Posted: 18 Mar 09 at 12:10PM
Of course, these would be kind ;)
 
But not easy to implement I think. A easyer way should be a return value more significant, actualy 0, all is correct and 1, load has fail.


Posted By: Ingo
Date Posted: 18 Mar 09 at 3:03PM
Hi Zarko!

I've looked inside with PSPad (you can use any other editor as well).
The first content you can see below.
I've deleted the string "%%EOF", made a new save and then QuickPDF had no problem to read/load the file! It's a distiller document initially created with Word. Where this E(nd)O(f)F(ile) comes from... i don't know? A real accident ;-)
A 100 mb adobe reader installation can handle this - for the 2 mb of QuickPDF it's not so easy i fear.

Cheers, Ingo

%PDF-1.5
%âãÏÓ
10 0 obj
<</Linearized 1/L 6181/O 12/E 1733/N 1/T 5934/H [ 456 163]>>
endobj
                    
xref
10 8
0000000016 00000 n
0000000619 00000 n
0000000731 00000 n
0000000927 00000 n
0000001075 00000 n
0000001413 00000 n
0000001656 00000 n
0000000456 00000 n
trailer
<</Size 18/Prev 5923/Root 11 0 R/Info 9 0 R/ID[<CA83DDF33197EBFD70368E5A30920D4E><900CDB0B84391E449A21F582F7E253EB>]>>
startxref
0
%%EOF
               
17 0 obj
<</Length 73/Filter/FlateDecode/I 101/L 85/O 69/S 38>>stream
xÚb```e``²`


Posted By: ZarkoGajic
Date Posted: 18 Mar 09 at 3:19PM
Ingo,
 
Thanks for the info.
 
I do not have any idea what this EOF is doing there :(
 
p.s.
Need to process a bunch of PDFs in my application and this file failed to load.
 
What is important here is that this file IS corrupted - the fact that AdobeReader can read it .. who cares .. for me it would be enough to report as "cannot open file".


Posted By: DELBEKE
Date Posted: 18 Mar 09 at 3:59PM
Hi zarko
 
In fact it does indicate you that the file can' be laoded.
Here is a sample writen in vb6
 
    On Error Resume Next
    lRet = m_oDoc.LoadFromFile(Value)
    On Error GoTo 0
    If lRet = 0 Then
        MsgBox "File can not be opened", vbCritical
        Exit Sub
    End If
 
 


Posted By: ZarkoGajic
Date Posted: 18 Mar 09 at 6:48PM
Delbeke,
 
I am aware of the function result value ... my question was initially related to "why" does it fail to load - since AReader can open it.
 
The answer was provided by Ingo.


Posted By: deabrew
Date Posted: 18 Mar 09 at 7:56PM
Zarko, Delbeke, and Ingo (plus readers),

We're working on providing a solution for this problem to include in an upcoming version (7.13) of Quick PDF Library.

Today, the production version of 7.12 will be released.

And thanks all.

Cheers, -Karl

-Karl


Posted By: DELBEKE
Date Posted: 19 Mar 09 at 2:35AM
The problem don't come with this %%EOF. This is a linearized pdf. A pdf can contain more than one %%EOF in 2 cases : linearisation and incremental save. The real problem come with startxref 0. That QuickPdf can not handle at the momment.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk