How to get correct 'line width' attribute (in PDF user space) for path elements?


I am getting very large 'line widths' when extracting content from one
PDF document. There are only a few lines (mostly text), but gs-

GetLineWidth() is returning very large values. How can I get correct

line width?

We tested the file and everything seems to be correct. One thing you
may want to keep in mind is that line width is influenced by the
current transformation matrix (CTM). For example, is the Current
Transformation Matrix (element.GetCTM()) returns the following

Matrix2D m(10, 0, 0, 10, 0, 0)

It means that you also need to scale line with by 10 (the
transformation 'scale' factor).

Given a PDF matrix you can compute scaling component as follows:

double GetScale(Common::Matrix2D& m) {
  double x = 0.707106781 * m.m_a + 0.707106781 * m.m_c;
  double y = 0.707106781 * m.m_b + 0.707106781 * m.m_d;
  return sqrt(x*x + y*y);

So the actual line width (in PDF user coordinate system) is:

double line_width = GetScale(element.GetCTM()) *