1
writeText(cb, drItem["itemId"].ToString(), left_margin, top_margin, f_cn, 10);
writeText(cb, "LOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOOOOOOOO
NNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNN
GGGGGGGGGGGGG GGGGGGGGGGGGGGGG TEXT, left_margin + 70, top_margin, f_cn, 10);
writeText(cb, drItem["itemDate"].ToString(), left_margin + 300, top_margin, f_cn, 10);
cb.ShowTextAligned(PdfContentByte.ALIGN_RIGHT, drItem["invoicedQuantity"].ToString(), left_margin + 400, top_margin, 0);
writeText(cb, drItem["unit"].ToString(), left_margin + 410, top_margin, f_cn, 10);
cb.ShowTextAligned(PdfContentByte.ALIGN_RIGHT, drItem["price"].ToString(), left_margin + 480, top_margin, 0);
writeText(cb, drItem["currency"].ToString(), left_margin + 490, top_margin, f_cn, 10);

write text method is like:

private void writeText(PdfContentByte cb, string text, int x, int y, BaseFont font, int size)
        {
            cb.SetFontAndSize(font, size);
            cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, text, x, y, 0);
        }

but the problem is that "long text" is too long. How can I add break line after 60 characters?

I am using iTextSharp and I have no idea. I try with Chunk and Phrase but not working

Bruno Lowagie
  • 75,994
  • 9
  • 109
  • 165
mbrc
  • 3,523
  • 13
  • 40
  • 64
  • 2
    As [I said in your previous question](http://stackoverflow.com/q/27365627/231316), you are working in "manual placement mode" which pretty much assumes you've read at least part of the PDF spec. In the spec you'll find that "line breaks" in this context don't exist at all. You literally need to manually count characters on your own and issue your custom `writeText()` function once per your own definition of a "line". This is why the abstractions are so helpful. However, there is an "in-between" mode call [`ColumnText`](http://stackoverflow.com/q/15165357/231316) that you might be able to us. – Chris Haas Dec 10 '14 at 02:03
  • Maybe @mbrc should use `ColumnText`. This way, he could combine manual placement with some abstraction. See for instance: http://stackoverflow.com/questions/13526043/itext-string-fitting – Bruno Lowagie Dec 10 '14 at 12:15

0 Answers0