How to create a PDF/DOCX files in Java/Scala?
<p>I am creating a web application which will accept some inputs from user (like name, age, address etc) and generate some predefined forms with filled information for user to download and print.</p>

<p>For example, an Application Form for driving license or something along those lines. The backend will have the format information about the document to be generated and other information will be gathered from user from front-end.</p>

<p>I am going to use <strong>Play Framework 2.5</strong> for this and <strong>Java/Scala</strong> as programming language. But right now I am not aware if there are any free libraries/APIs that I can use to achieve this document generation.</p>

<p>I should be able to manipulate the <strong>font size, style, indentations, paragraphs, page borders, page numbers, alignments, document headers and footers, page size (A4, Legal etc)</strong> some other basic stuff. And I need documents in format that are widely supported for editing and printing purposes. Like <strong>PDF, DOCX</strong> for example. DOCX is preferred so user can edit something after downloading the document before taking a print out.</p>