Q: I am trying to create code that will determine if a text element is
visible or not and so far it's going alright. Problem I have is that
in some cases the PDF uses a path consisting of a move followed by
three line to commands to create a path (rectangle). Now when I look
at those values, the move to always start at 0, 0. Are move to and
line to commands relative to the bounding box of the element (unlike
rectangle command that seems to work
fine)? Or is there another transform I have to apply?
I need to solve this rather quickly, I have tried looking on the net
and in your forums, but I guess since you provide a draw function, the
sample code on how to draw a PDF has been removed. That code of course
would have helped me a lot to understand how elements are placed on
top of each other etc.
-----
A: You would need to transform all the path points using the Current
Transformation Matrix (CTM).
You can obtain the CTM (Current Transformation Matrix) as follows:
pdftron.Common.Matrix2D ctm = element.GetCTM();
You can transform each point as follows:
In C# / VB.NET
ctm.Mult(ref x, ref y);
in C/C++
ctm.Mult(x, y);
For an example of how to access path data, please see ElementReaderAdv
sample project (http://www.pdftron.com/net/
samplecode.html#ElementReaderAdv).