0

In iText5 it was possible to draw Graphics2D objects by starting like this

Rectangle rect = PageSize.A3.rotate();
PdfContentByte cb = writer.getDirectContent();
Graphics2D g = cb.createGraphics(rect.getWidth(), rect.getHeight());

with "writer" being an instance of "PdfWriter".

PdfContentByte doesn't exist in iText7 and I haven't found a way to get Graphics2D involved yet. Is that still possible?

I'm fully aware that there's a canvas now that you can draw circles, rectangles, lines,... on but that would mean re-writing all of the existing code, so if you can still use Graphics2D somehow, it would be the prefered way.

Neph
  • 1,823
  • 2
  • 31
  • 69

1 Answers1

1

You can use OrsonPDF as the Graphics2D translator and embed the resulting PDF into a document created with iText. An example with full instructions is given here:

https://jfree.github.io/orsonpdf/

David Gilbert
  • 4,427
  • 14
  • 22