I work in WinForms and iTextSharp. Create a new PDF document put on the background jpg image. So far so good. But when I try to add more text: nothing happens - there is no text, if you remove the background image, the text appears. Moreover, if you add a new picture to the background image, then everything works correctly. only text overlaps. The question is how to fix it? Code :

var document = new Document(PageSize.A4, 120, 20, 110, 10); var FONE = iTextSharp.text.Image.GetInstance(new FileStream(@"EmptyBlank72dpi.jpg", FileMode.Open)); FONE.SetAbsolutePosition(0,0); using (var writer = PdfWriter.GetInstance(document, new FileStream(path, FileMode.Create))) { document.Open(); writer.DirectContent.AddImage(FONE); for (int i = 0; i < OD.OrdersData().Count; i++) { document.Add(new Paragraph("_" + OD.OrdersData()[i], font)); //writer.Add(new Paragraph("_" + OD.OrdersData()[i], font)); так тоже не работает } document.Close(); writer.Close(); } 

Through PdfContentByte displays the text in the right place but in one line. enter image description here

  • did not try to do as advised here - Bald
  • @Bald Through PdfContentByte yes, the output of the string works, but I need to print several lines through for "\ r \ n" does not put the caret at the beginning of the line. - Sergey
  • do not quite understand. and what if the line is pre- prepared : string.Join("\r\n", src) and output the result in a paragraph? - Bald
  • which paragraph you are talking about, such pdfcontentbyte.Add (new Paragraph ("text", font)); ? - Sergey
  • No, it's about Document.Add(new Paragraph()) , which prevents you from inserting a string with several substrings glued in \r\n ? - Bald

1 answer 1

If you have the opportunity to go to iText7, please do it. iText7 makes the layout a lot easier and intuitive. There is a quick start guide which shows you how to work with iText7 is available at http://developers.itextpdf.com/content/itext-7-jump-start-tutorial/examples