Yes it's definately possible to generate documents in Java. There are multiple document generation modules in the AppStore which do this. Like Kathryn says, you could do it with pdfbox, but the modules I mentioned use the Aspose library. I have also seen document generation based on Thymeleaf and FlyingSaucer. There are probably other Java libraries which are able to generate PDF documents.
Here is a complete list of java libraries for PDF generation from https://java-source.net/open-source/pdf-libraries
iText is a library that allows you to generate PDF files on the fly. The iText classes are very useful for people who need to generate read-only, platform independent documents containing text, lists, tables and images. The library is especially useful in combination with Java(TM) technology-based Servlets: The look and feel of HTML is browser dependent; with iText and PDF you can control exactly how your servlet's output will look.
gnujpdf is a Java package (gnu.jpdf.*) licensed under the LGPL. It provides a simple API to create pdf files and print using subclasses of java.awt.Graphics and java.awt.PrintJob. The PDF classes write to an OutputStream in pdf format instead of a typical Graphics object, but the method calls are the same as they would be in any Applet or Application drawing to a canvas.
PDFBox is a Java PDF Library. This project will allow access to all of the components in a PDF document. More PDF manipulation features will be added as the project matures. This ships with a utility to take a PDF document and output a text file.
FOP is an XSL formatter written in Java. It is used in conjunction with an XSLT transformation engine to format XML documents into PDF.
Java reporting tool for formatting PDF reports. It is possible to simply hand off a swing TableModel to JFreeReport and get a paginated pdf as a result.
PJX is a general purpose PDF programming library for Java; with support for reading, combining, manipulating, and writing PDF documents.
PDF Clown for Java (PDF Jester)
PDF Clown for Java (PDF Jester) is a Java 1.5 library for reading, manipulating and writing PDF files, with multiple abstraction layers to satisfy different programming styles: from the lower level (PDF object model) to the higher (PDF document structure and content streaming).
Go To PDF Clown for Java (PDF Jester)
JPedal is an application for viewing and printing of pdf files. Features of JPedal: * JPedal supports a wide variety of different font technologies. * Jpedal supports the following colour spaces: DeviceRGB, CalRGB, DeviceGRAY, CalGRAY, ICC, indexed, DeviceCMYK and DeviceN. * Jpedal also reads and displays raw tiff, jpg and gif file formats. * Text can be extracted from an entire document, a single page, from within page co-ordinates or from tables. Font information and metadata can also be extracted. * JPedal can extract any image from a pdf with a choice of output options. * View, edit, print and extract content from interactive FDF forms. * JPedal includes an interactive search function that allows you to search either the current page or the entire pdf document for occurrences of a word or a phrase.
PDFjet Open Source Edition is a library for dynamic generation of PDF documents from Java and .NET. The PDFjet Open Source Edition has the following features: * Drawing support for: points, lines, boxes, circles, bezier curves, polygons, stars, complex paths and shapes. * Text: unicode support, text kerning when using the Helvetica and Times-Roman families of core fonts, embedding hyperlinks.
jPod is a mature PDF manipulation and rendering library. It supports COS and PD level manipulation of PDF documents, AFM and TrueTypes fonts, incremental writing of files, and parsing of files that slightly deviate from the specification.
ICEpdf is an open source Java PDF engine for viewing, printing, and manipulating PDF documents. The ICEpdf API is 100% Java-based, lightweight, fast, efficient, and very easy to use.
The PDF Renderer is all Java library which renders PDF documents to the screen using Java2D. Typically this means drawing into a Swing panel, but it could also draw to other Graphics2D implementations
The Community Commons module packs the PDFBox library - it uses it for some of its Java actions like overlay/merge PDFs. You can use that library to write your own custom PDF-related Java actions if needed. For example, I’ve used it to make my Mendix app fill existing PDF forms that would have been hard to recreate exactly as templates. https://pdfbox.apache.org/