You need to create a PDF file with a background image that will display several lines of text. Paragraph do not use it, it is overlapped with a background image. I found this option through PdfContentByte, but it outputs ALL on one line, without transferring the caret to a new one.

PdfContentByte cb = writer.DirectContent; cb.BeginText(); cb.SetFontAndSize(baseFont, 14); cb.SetTextMatrix(35, 615); cb.ShowText(string.Join("\r\n", ListName<string>)); cb.EndText(); 

2 actual questions - how to display the contents of ListName line by line, or option 2 how to set the background image layer so that it does not overlap the text? This overlap only works when I add text, new pictures on the background are displayed correctly.

    1 answer 1

    I never found a direct answer, but this code is quite working. And can be used if you want to impose text on the image - background. If you just use the Paragraph, the picture will block the text.

      PdfContentByte cb = writer.DirectContent; int fontSize = 14; cb.BeginText(); cb.SetFontAndSize(baseFont, fontSize); for (int i=0; i<OD.OrdersData().Count; i++) { cb.SetTextMatrix(135, 615 - i * fontSize); cb.ShowText(OD.OrdersData()[i]); } cb.EndText(); 
    • Would you comment on the magic numbers - Bald
    • The new ShowText is lowered by 14px on the Y-axis. For each row, SetTextMatrix changes. I do not even know what to comment here. - Sergey
    • Well, I see the connection between the size of the font and the size of the offset - Bald
    • font size does not change. 14 is both size and offset. - Sergey
    • one
      You did not understand me, I meant that the size of the string in this case is the offset. I would probably create a variable above the code that, in case of anything, change in one place and not in 2. but this is so nagging - Bald