0

I'm working on a pdf file, trying to put some information over an image, I think using a table is the best way to do it. I tried to do the method described on this other question. I'm trying to achieve exactly what is described on the answer, but it seems like that is for an older version of iText and it's not exactly straight forward to update the methods and classes used there.

To further specify, I have something like this example image where the "XXXX" is a variable Text, and I want to add this same thing, including the background image, to a pdf document. I have to add multiple of these, so I was thinking on making a table, use multiple cells with the background image and then add the info on another table over each image. Please let me know if there's a better way to do this.

Sir Rufo
  • 18,395
  • 2
  • 39
  • 73
Paúl
  • 1
  • 2
  • If I understand you correctly, you have an image to use as background and want to add foreground text at specific positions. The text in your example, though, to me does not really look tabular in nature but more like "at position x, y write a string." Thus, I'd propose you simply do this by drawing the image first (at a fixed position) and then add text at fixed positions on it. Would that approach be ok for you? – mkl Feb 18 '22 at 13:59
  • The thing is that the text doesn't have a fixed position, it has to be centered in two columns and since the text is variable, then I would have to determine the position of the text every time, which seems harder to me than just using a table. – Paúl Feb 18 '22 at 15:48
  • If the text doesn't have fixed positions, you can simply put the image into the background and add text normally to the document. If you need two columns, use the `ColumnDocumentRenderer`. Another question, you mention you have to create multiple such text-on-image thingies - how large are they? Will you need one document page per image or will multiple images fit on one page? Or are there even differently sized possible images, sometimes with only one per page, sometimes more? – mkl Feb 18 '22 at 17:07
  • The images on the pdf have a constant size, in a way that 6 of them can fit into a single page. They always have a size of around 8x9 cm – Paúl Feb 21 '22 at 18:18

0 Answers0