Java / Groovy library for overlaying text on an image

I am working on a web application (using Grails) that will generate a gift certificate. I think of the workflow as follows:

  • The user will select a template that will be saved as an image.

  • Then the text (name, date, amount, etc.) will be superimposed on the image to make the final certificate. There is a set of coordinates associated with each template that describes where to put each bit of text.

  • The browser has a “preview” that shows the user what the final certificate will look like.

  • When the user is satisfied with the results, they download the certificate in PDF format and print it.

Can anyone recommend a library for Java (or Groovy) that will simplify this? I'm not particularly worried about speed, as I suspect that the webapp will only be used by a few people at a time.

UPDATE: at the end, I used the iText PDF library to overlay text on a PDF template using PDFStamper.

+3
source share
3 answers

You can use Batik to do this as an SVG. Your image will be <img> and your text will be one or more characters of the <text> tag. There is a converter (called FOP, I think) that gives you PDF output.

0
source

Java- Java - BufferedImage , drawString(), . , PDF . ​​

+4

In addition to the answers above, I came across the groovy GraphicsBuilder library and the Grails j2D plugin , which are also potential solutions.

+1
source

Source: https://habr.com/ru/post/1721293/


All Articles