Create document templates in Java

Asked

Viewed 225 times

3

I am creating a Java system with Swing, where I would have templates of documents, and fill with data informed by the user in a form that I have already created, so that it generates a PDF of the template filled with data.

I tried to do it "raw", saving the standard text in TXT, putting "jokers" type, where date, I entered $data$ and then I would filter using Pattern, however, I see that in this way it has become unviable.

How to make these templates more functional?

  • https://pastebin.com/2X34a1jb

1 answer

3


Best solution is to use a reporting component such as Jasper.

It allows the creation of templates, either at runtime or development time. It is quite powerful, and allows reports to be exported in various formats, including PDF or other format you develop.

Follow his website:

Jasper Reports

  • 1

    Why not include an example of how to use it? :)

  • Does this tool work with java and swing or is it for java EE? I say why the application is desktop.

  • 1

    I honestly only used it in EE, but I see no reason why it should not work in desktop applications. The only difference will be in data sources, which will not be normal sources, but normal sources. Looking on the Internet, I haven’t found anything to indicate otherwise either, so I assume it does. Anyway, it’s not hard to test and find out.

  • I’m in doubt, I should only use the library without the server, and it will work normally?

  • I don’t understand the question. You should only include the package classes net.sf.jasperreports.engine. At least these are the classes I use.

  • In the link you sent, it says you have to set up a server for the API to work, but my app cannot use server, it is standalone, to using HSQLDB precisely for this reason.

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.