Coordinate system and text movement issue in different PDFs with iTextSharp

I am working with iTextSharp and .NET 3.5 SP1 (in C #, as you might guess) and modify some existing PDFs using the class PdfStamper

. Now I have two problems:

Coordinate system transformation

As I see it, iTextSharp uses (postscript?) Points as a unit, but I would like to convert those coordinates to millimeter. Now what is the best way to achieve this?

Looking at the documentation, the following approach was discovered:

PdfContentByte cb = new PdfContentByte();
System.Drawing.Drawing2D.Matrix scale = new System.Drawing.Drawing2D.Matrix(
    0.352777778, 0, 0.352777778, 0, 0, 0); // 1 point = 0.352777778 mm
cb.Transform(scale);

      

I hope I understood the transformation matrix correctly. But the problem is that there is no System.Drawing.Drawing2D

Assembly! Has this assembly dropped or what happened to it? What can I do to convert the iTextSharp coordinates to millimeter. Am I wrong here?

PDF text is moved in another PDF using the same coordinates

I noticed that changing two different PDFs with the same content pushed out the same coordinates and the text doesn't fit in the same positions. What is causing this and how can I prevent it?

This is the first PDF:

alt text http://i41.tinypic.com/20u5tfc.gif

This is the second PDF generated using the same coordinates in iTextSharp:

alt text http://i44.tinypic.com/2qjzoex.gif

Any help is appreciated.

+1


a source to share


2 answers


But the problem is that there is no System.Drawing.Drawing2D assembly! Was this assembly dropped or what happened to it? What can I do to convert the iTextSharp coordinates to millimeter. Am I wrong here?



http://msdn.microsoft.com/en-us/library/system.drawing.drawing2d.matrix.aspx (in System.Drawing.dll)

+1


a source


Ok, I solved the second problem with moving the text despite using the same coordinates.



As it turns out, the first PDF included some invisible cropping space, the second didn't. The cropping window is not visible because the view space was cropped with the PDF creator, but it appears the cropping space was still and calculated for the coordinates.

0


a source







All Articles