Print Page | Close Window

How to distinguish between hidden text and display

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=3976
Printed Date: 04 May 24 at 10:23PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: How to distinguish between hidden text and display
Posted By: BJhuizhi
Subject: How to distinguish between hidden text and display
Date Posted: 25 Mar 22 at 8:45AM
Hi,
  In PDF, some text is hidden and not displayed, but can be obtained by “DAGetTextBlockText". How to distinguish which text is displayed and which is hidden?


thank!



Replies:
Posted By: tfrost
Date Posted: 26 Mar 22 at 12:22PM
It all depends on how it is hidden. For example you could retrieve the text block bounds and determine if it is outside the Media, Crop or Trim box (depending on the type of PDF), or it might be hidden by setting the text colour to the same as the background colour, or hidden by an overlaid image or shape. Unless you control the PDFs yourself, you might have to test multiple things.


Posted By: Ingo
Date Posted: 26 Mar 22 at 2:03PM
Hi,

first a CombineContentstream... then a NormalizePage... Then the extraction.
Try the the normal GetPageText with option "csv-extraction" - Then you can see the textboundings/-positions and then you'll know why the extract works or not.

Cheers and welcom here,
Ingo


-------------
Cheers,
Ingo



Posted By: BJhuizhi
Date Posted: 28 Mar 22 at 2:47AM
hello, Ingo

Using the method you mentioned, the text blocks DAGetPageText with option "csv-extraction" are also overlapped in position and have the same text color. There is no information that can distinguish extract works or not


Posted By: Ingo
Date Posted: 28 Mar 22 at 4:28PM
You should upload the relevant pdf anywhere on a free webhoster-space, Dropbox or anywhere else and post the link here.
Then we can try ourself.
Before you should explain detailed what's the result you need and what's the one you get.



-------------
Cheers,
Ingo



Posted By: BJhuizhi
Date Posted: 29 Mar 22 at 9:05AM
Hello,
https://pan.baidu.com/s/1XRCgJAk6nLE6Sll_6HxXmw?pwd=1234%20" rel="nofollow - http://124.205.131.133 :8084/test.pdf
https://pan.baidu.com/s/1XRCgJAk6nLE6Sll_6HxXmw?pwd=1234%20" rel="nofollow - http://124.205.131.133 :8084/test.png
https://pan.baidu.com/s/1XRCgJAk6nLE6Sll_6HxXmw?pwd=1234%20" rel="nofollow - http://124.205.131.133 :8084/test2.pdf
test. Pdf  cannot distinguish hidden text. the text blocks DAGetPageText with option "csv-extraction" are also overlapped in position and have the same text color.
When extracting text content (test.png), there is text content in the yellow area, and the Yellow blocks overlap.

test2.pdf can't get text content with DAGetPageText








thank!




Posted By: Ingo
Date Posted: 29 Mar 22 at 9:50AM
Sorry.
Nothing readable for me on the download-site.
Finally ... doing all blind ... i should install a baidu.exe.
Perhaps another one here is able to read it and act in a safe way.


-------------
Cheers,
Ingo



Posted By: BJhuizhi
Date Posted: 29 Mar 22 at 10:50AM
Hello,



https://pan.baidu.com/s/1XRCgJAk6nLE6Sll_6HxXmw?pwd=1234%20" rel="nofollow - http://124.205.131.133 :8084/test.pdf
https://pan.baidu.com/s/1XRCgJAk6nLE6Sll_6HxXmw?pwd=1234%20" rel="nofollow - http://124.205.131.133 :8084/test.png
https://pan.baidu.com/s/1XRCgJAk6nLE6Sll_6HxXmw?pwd=1234%20" rel="nofollow - http://124.205.131.133 :8084/test2.pdf
test. Pdf  cannot distinguish hidden text. the text blocks DAGetPageText with option "csv-extraction" are also overlapped in position and have the same text color.
When extracting text content (test.png), there is text content in the yellow area, and the Yellow blocks overlap.

test2.pdf can't get text content with DAGetPageText








thank!


Posted By: Ingo
Date Posted: 29 Mar 22 at 9:04PM
Hi,

my first quick shot shows me all these (for me) standard characters and the chinese characters as well.
Which extract-option are you using?
I think that's the problem.
There are many ... try the options 7 and 8 - result should be better.



-------------
Cheers,
Ingo



Posted By: BJhuizhi
Date Posted: 30 Mar 22 at 10:15AM
hello,

Because the PDF file is relatively large, use Direct access functionality to read the PDF file content

  QukPdf.DASetTextExtractionOptions(1,0); 
  QukPdf.DASetTextExtractionOptions(2,0); 
  QukPdf.DASetTextExtractionOptions(3,0); 
  QukPdf.DASetTextExtractionOptions(4,0); 
  QukPdf.DASetTextExtractionOptions(5,0); 
  QukPdf.DASetTextExtractionOptions(6,1); 
  QukPdf.DASetTextExtractionOptions(7,1); 
  QukPdf.DASetTextExtractionOptions(8,1); 
  QukPdf.DASetTextExtractionOptions(9,0); 
  QukPdf.DASetTextExtractionOptions(10,0);
  QukPdf.DASetTextExtractionOptions(11,1);
  QukPdf.DASetTextExtractionOptions(12,0);
  QukPdf.DASetTextExtractionOptions(13,1);
  QukPdf.DASetTextExtractionOptions(14,0);
  QukPdf.DASetTextExtractionOptions(15,1);

  qukpdf.DASetTextExtractionArea(cpdfXy.Left,cpdfXy.Top,cpdfXy.Width,cpdfXy.Height);
  Pid:=qukpdf.DAExtractPageTextBlocks(FileHandle,PgRef,4);
  qukPdf.DASetTextExtractionWordGap(0.2);
  Pm:=qukpdf.DAGetTextBlockCount(Pid);
  if Pm>0 then
    Begin
      SetLength(AXFInfoLst(InfS),Pm);
      Qid:=0;
      While Qid<Pm DO
        Begin    
          Inc(Qid);
          AXFInfoLst(InfS)[Qid-1].fnt.fSiz:=Round(qukpdf.DAGetTextBlockFontSize(Pid,Qid));
          AXFInfoLst(InfS)[Qid-1].fnt.fNam:=qukpdf.DAGetTextBlockFontName(Pid,Qid);
          AXFInfoLst(InfS)[Qid-1].XYPt.Left:=Round(qukpdf.DAGetTextBlockBound(Pid,Qid,7)/RateW);
          AXFInfoLst(InfS)[Qid-1].XYPt.Top:=Round(qukpdf.DAGetTextBlockBound(Pid,Qid,6)/RateH);
          AXFInfoLst(InfS)[Qid-1].XYPt.Right:=Round(qukpdf.DAGetTextBlockBound(Pid,Qid,5)/RateW);
          AXFInfoLst(InfS)[Qid-1].XYPt.Bottom:=Round(qukpdf.DAGetTextBlockBound(Pid,Qid,2)/RateH);
          AXFInfoLst(InfS)[Qid-1].WStr:=qukPdf.DAGetTextBlockText(Pid,Qid));
        End;
    End;


Posted By: Ingo
Date Posted: 30 Mar 22 at 1:04PM
The PDF is small.
test1.pdf with 1 page, 722 embedded objects and 1,8 mb
test2.pdf with 1 page, 522 embedded objects and 0,8 mb



-------------
Cheers,
Ingo



Posted By: BJhuizhi
Date Posted: 31 Mar 22 at 7:19AM
In the test.pdf  in quick PDF library 18, how to make dagettextblocktext not extract the content that is not displayed?

In the test2.pdf in quick PDF library 18, how to make dagettextblocktext extract the display content or dagetpageimagelist extract as an image?


Posted By: Ingo
Date Posted: 01 Apr 22 at 2:25PM
I doesn't come to an end.
For my opinion test.pdf is okay.
There are different characters... standard and chinese... and extraction works.

test2.pdf has only this extractable content:
fontname;hex-color;font height;row;col;text
"AGXXCW+Arial-BoldMT";231F20;9;-520/769;"6"
"AGXXCW+HYb1gj";231F20;7;-495/766;"《税务研究》"
"BOHDQU+ArialMT";231F20;7;-453/767;"2020"
"AGXXCW+HYb1gj";231F20;7;-437/766;"年第"
"BOHDQU+ArialMT";231F20;7;-423/767;"12"
"AGXXCW+HYb1gj";231F20;7;-415/766;"期 "
The problem can be the negative row-values as well...

Starting both pdf-files with Sumatra, Foxit or Adobe shows me a long index on the left with more than 140 pages.
But the readers offers only 1 single page to read - the index goes into nowhere.

I'll stop here perhaps there's another guy to help. Sorry.




-------------
Cheers,
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