Re: [SPAM] Re: [SPAM] Re: Detect Lines in PDF

FDnC Red <[email protected]>
Newsgroups gmane.comp.java.lib.itext.general
Message-ID <[email protected]>
Thanks for the input Michael.  Everything you wrote makes sense to me.  It seems that I am not looking at the right moment when the translation is actually happening.  I've stepped through the code for several hours today trying to find that moment and it escapes me.

I'm attaching the sample PDF that I'm parsing, the Program.cs that I'm using, and an XML file which is the output of MuPDF's mudraw.exe which I'm using as "ground truth" data because the stroke_path matrix exactly matches where the lines are in the PDF.

I sincerely appreciate your time working with me.

Thanks,
Darren


On Wednesday, September 3, 2014 2:10 AM, mkl <[email protected]> wrote:
 


Darren,

FDnC Red wrote
> The problem is that gs.ctm is always the identity matrix so the
> matrix.Multiply just sets it to whatever operands were parsed out.  I was
> expecting some actual translation.

Well, so it is not "always the identity matrix" but instead contains the
translation given by those parsed parameters. In case of your sample content
stream, though, there never is a more interesting matrix multiplication:

   [Current graphic state CTM: Identity. No graphic state saved.]
q
   {Save graphic state}  
   [Current graphic state CTM: Identity. One graphic state saved with CTM:
Identity.]
1 0 0 1 19.96 538.9747 cm
   {Update CTM}
   [Current graphic state CTM: Translation by (19.96, 538.9747). One graphic
state saved with CTM: Identity.]
0 0 m
   {Start path, move to (0, 0) translated by current CTM, i.e. move to
(19.96, 538.9747)}
   [Current graphic state CTM: Translation by (19.96, 538.9747). One graphic
state saved with CTM: Identity.]
716.89 0 l
   {Continue path, line to (716.89, 0) translated by current CTM, i.e. line
to (736.85, 538.9747)}
   [Current graphic state CTM: Translation by (19.96, 538.9747). One graphic
state saved with CTM: Identity.]
S
   {Finish path, stroke, i.e. draw a line from (19.96, 538.9747) to (736.85,
538.9747)}
   [Current graphic state CTM: Translation by (19.96, 538.9747). One graphic
state saved with CTM: Identity.]
Q
   {Restore saved graphic state}
   [Current graphic state CTM: Identity. No graphic state saved.]
...

Thus, the IContentOperator instances registered for m and l see non-trivial
CTMs when they are called, i.e. when their parameter coordinates are
transformed into device space

> I guess that is happening somewhere else at a later time.  Perhaps after
> all streams are parsed.
> Am I just missing the boat here and looking in the wrong place or is this
> just not possible with iText since it's almost more of a rendering thing -
> translating what is in the PDF to actual coordinates after all
> translations are applied?

The translation is there in time. Probably, though, you are looking at the
wrong moment. You have to look at the very moment the CTM is applied, i.e.
when operations with (explicit or implicit) coordinates are handled.

If you still have problems, please post your code for detailed analysis.

Regards,   Michael



--
View this message in context: http://itext-general.2136553.n4.nabble.com/Detect-Lines-in-PDF-tp4660295p4660323.html
Sent from the iText - General mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: http://itextpdf.com/themes/keywords.php
081114_DFW_SG_PG3_V01.pdf (application/pdf, 731.2 KB) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.