How to find current (X, Y) position in iTextSharp?

后端 未结 4 582
鱼传尺愫
鱼传尺愫 2021-01-06 12:04

I need to create a PDF with several sections, and after each section need to add a line, but I don\'t know where to draw this line.

I need to find the exact coordin

4条回答
  •  独厮守ぢ
    2021-01-06 12:46

    There is indeed only the y-position.

    But if one needs to render some simple text and after that put a picture or draw a line, he can always count the size of the text rendered:

    var chunk = new Chunk(String.Format("Sample text {0}", ));                                                             
    document.Add(new Paragraph(t));
    float curY = writer.GetVerticalPosition(false);
    float x = document.Left + chunk.GetWidthPoint();
    

提交回复
热议问题