Print Page | Close Window

GetPageText returns an empty string...

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=1236
Printed Date: 29 Jun 24 at 1:17AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: GetPageText returns an empty string...
Posted By: jdupond
Subject: GetPageText returns an empty string...
Date Posted: 13 Oct 09 at 8:51PM
Hello,

We are using Delphi 5 and QuickPDF v. 5.22.

When we run the code below, on most 'pdf,' we do get the correct result in the 'iText' variable. But we have a few 'pdf' [not created with PrimoPDF] for which a call to 'GetPageText' always returns an empty string even though it should not [the underlying text can be viewed when the file is opened with PrimoPDF].

We have tried the latest version of QuickPDF (as a demo). The results are the same.

Does anybody may have an idea of what the problem might be?


// Let's 'create' the component used to read the 'pdf' file
iPDFSource:= TQuickPDF.Create(Self);
try
    // Let's unlock the access to the component's properties
    iPDFSource.UnlockKey('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
    iPDFSource.LoadFromFile(aPDFFileName);
    // Let's decrypt the 'pdf' file if it is encrypted
    if (iPDFSource.Encrypted > 0) then
      iPDFSource.Unencrypt;
    // Let's determine the number of pages found within the 'pdf' file
    iNbPages := iPDFSource.PageCount();
    // If the file is not empty,
    if (iNbPages > 0) then begin
      // let's read the content of the 'pdf' file
      for iCpt := 1 to iNbPages do begin
        Application.ProcessMessages;
        iPDFSource.SelectPage(iCpt);
        iPDFSource.CombineLayers;
        iText := iPDFSource.GetPageText(0);
        if (Trim(iText) <> '') then
          ShowMessage(iText);
      end;
    end;
finally
    // Let's dispose of our 'pdf' reader
    iPDFSource.Free;
end;



Replies:
Posted By: Ingo
Date Posted: 13 Oct 09 at 9:42PM
Hi!
This has nothing to do with your code.
I'm stumbling over this problem for years now.
There are problems with documents which were created by a pdf-printer-driver in combination with the ghostscript library up to version 8.14 (since 8.15 it's okay).
So i think it will be always old documents with the described problems.
My work around in this case:
First extracting with option 3 and if there isn't content then a second run with option 0.
Cheers and welcome here,
Ingo
 


Posted By: jdupond
Date Posted: 14 Oct 09 at 7:16PM
Thanks for the tip.

I tried it but GetPageText still returns only empty strings.


Posted By: Ingo
Date Posted: 14 Oct 09 at 7:23PM
Hi!
It would be good to know author, creator, encryption strength and used pdf-specs of these files ...
Can you upload these files anywhere for us to check them?
Cheers, Ingo



Posted By: jdupond
Date Posted: 14 Oct 09 at 8:30PM
Hello,

I posted the file for download at the following url: http://www.4shared.com/file/140900891/c80d3106/Test.html - click here.

Nevertheless, I don't know if it worth spending any time working on it since I just found out that our customer would like us to change one of the font used within the 'pdf.' As far as I understand, that is not possible with QuickPDF.


Posted By: Ingo
Date Posted: 14 Oct 09 at 8:43PM
Hi!

I've no problems with this file.
Option 0 and option 3 are working fine.

Your code is okay, too... but this line
 " ... if (iNbPages > 0) then begin ... "
you don't need. A pdf has minimum one page.
If there's no page then the dictionary is corrupt.

This here is only a user-user-forum so please send your code and file to this location:
http://www.quickpdflibrary.com/support/index.php

Cheers, Ingo



Posted By: AIM
Date Posted: 15 Oct 09 at 9:32AM
I have tried this file here too and I'm also not able to extract text. Using v7.16 and Delphi 2009.


Posted By: Ingo
Date Posted: 15 Oct 09 at 9:39AM
This here is only a user-user-forum so please send your code and file to this location:
http://www.quickpdflibrary.com/support/index.php

Cheers, Ingo



Posted By: AIM
Date Posted: 15 Oct 09 at 12:14PM

Quote This here is only a user-user-forum so please send your code and file to this location:

I understood that, but since you (as user) could extract text from the provided file I just wondered how you did that while it doesn't work for at least two other users ("jdupond" and "AIM")? Since you didn't have a problem with that file, did it work with the code from "jdupond", or have you used another code? A tip from a user with success to users without success would be highly appreciated! :)



Posted By: Ingo
Date Posted: 15 Oct 09 at 1:07PM
Hi AIM!

I've a source license with personal changes and so i can extract...
So i think this problem from the compiled version can be solved...
and so i suggest to send it to the owners of the library - they'll solve the bug.

Cheers, Ingo


Posted By: AIM
Date Posted: 15 Oct 09 at 1:33PM
Thanks for clarification, Ingo.



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