I have the use case:
Build a PDF template and populate with variables with Java API iText.
But, I only saw examples with Acro Forms and my PDF it's not a form, it is a contract, like:
Rent to Own Contract
Whereas, ___________________ (hereafter Renter) desires to possess and have the use of certain property owned by
____________________ (hereafter Owner) and described in Attachment A, (...)
I need to build this template and populate with an Object, where '____________' is the place of variables.
The document template it can be constructed with HTML or XML too!!
Any Ideas or help?
Related
I have a Word template, complete with fonts, colors, etc. I am querying a database and retrieving information into a POJO. I want to extract the relevant info from said POJO and create a Word document as per my template's directives.
The doc will have tables and graphs so I need to use Content Control Data Binding. As I understand it, I'll have to do the following to achieve this
Modify the Word template to add content controls
Transform the POJO into an XML object (template?)
Use ContentControlMergeXML to bind the XML data to the Word template
Unfortunately, I can't find a good step-by-step example of this anywhere. Nearly all of the links in the docx4j forum lead to broken GitHub pages
My questions
How can I use OpenDoPE to add tags to my Word template? I'll need to preserve style, so I want the correct OpenDoPE version
Should the POJO be converted into an XML object or document?
Is there an end to end example of this entire process so I can follow along? (preferably with source code)
Content control data binding essentially injects an XPath value into a content control in the Word document.
That XPath is evaluated against an XML document, so yes, you need to convert your POJO into XML.
Authoring
Now, there are 3 different OpenDoPE Word AddIns which you can use to add content controls to your Word document. See the links at https://opendope.org/implementations.html
The most recent one assumes a fixed XML format. So to use that, you'd need to transform your POJO to match that format. (ie use the AddIn to author your docx, then inspect the resulting XML (embedded in the docx), then figure out how to transform your POJO to that).
The older AddIns support arbitrary XML, but are cruder. To use one of these, first convert your POJO to XML (eg using JAXB), then feed the AddIn your sample XML.
Runtime
To bind your XML to a docx "template" to create an instance docx, see https://github.com/plutext/docx4j/blob/master/docx4j-samples-docx4j/src/main/java/org/docx4j/samples/ContentControlBindingExtensions.java
You can run that sample code against the sample docx + data; you can take a look at the docx to see what the content controls look like (they bind a custom xml part in the docx, so unzip it to see that)
ps the GitHub links broke as a result of a recent code re-org. GitHub isn't smart enough to dynamically maintain them :-( See https://www.docx4java.org/downloads.html for downloadable sample code.
My Spring application needs to create different types of PDF documents like invoices and certificates each having dynamic data .I would like to have some predefined templates(html/text file) from which I can generate the full PDF content. The predefined template holds the full content of the PDF document including the font size, alignments of each section etc and also have key values that need to be replaced with actual values form database. I know it is easy to create PDFs from html. Is anyone having any idea on how to accept an html template as input in a java program and then hook in the keys defined in it with actual values and finally creating the PDFs?
I have a requirement of developing a functionality where user can dynamically define a template (labels, textboxes, labels, rows, columns, parent child relationships among above elements etc). These elements(such as combo boxes) may be bound to different database tables.
For example, the user may define a template T1 for a specific use case U1. But this template is not restricted to U1 only. It may be needed to be used in another use case U2, where it is a sub part of a bigger template.
Once the templates are defined, another user may load the templates (HTML form) and enter data into it. At a later stage, I need to reuse this data and template to generate PDF reports. Since PDF reports may sometimes need to have a different layout than the HTML form, I would need parent child relationships between elements as well.
As of now, we are achieving by generating an XML from a user interface where a user can select elements from a dropdown and specify properties. At run time, these XML are transformed to HTML using XSLT. Another XSLT is used for generating PDFs. The limitation of this scheme is that it is very tedious to incorporate any user requests (such as multiple columns, add tables into forms etc).
I was wondering how other people achieve this and is there an API/Library for doing the same ?
I have looked at HTML5 and JQuery drag and drop features, but it would require me to add everything from scratch (such as dynamically add columns,rows etc.)
The best thing to create dynamic form is using angular js.
It is very good framework for front end development
Here is the working link for
angular js form
Sorry, I only gave example form dynamic forms here are some example for drag and drop
Angular drag and drop 1
Angular drag and drop 2
http://angular-js.in/dragular/
I hope this will help.
There are libraries out there for dealing with databases, such as JDAL,jOOQ and many many others.
For creating forms and reports, however, Oracle does have their Oracle Forms and Reports suite. There are also alternatives, such as OpenXava, that can also do these things (and probably better, I've worked with 10g/11 and it can be a pain sometimes). If you're more interested in using XML and other markup languages, you might like FOXopen.
All of these can output to PDF and other types of documents.
Where I work, we use Oracle Forms and internally written programs to craft our reports.
here is my issue.
I need to read an RTF document and render to a webpage (some sort of google docs) but these documents are templates, the idea, is that user can only edit certain text and not the text that is marked to be "template logic".
So far I've seen a bunch of RTF libraries that performs only rendering but wont let you access an object that can be iterated dynamically to go over the structure of the RTF document.
My idea is to determine what can be editable and what can not, put all that info (images, text, tables, headers, footers) into a json and send it to my JS client.
Maybe this is a crazy idea, any suggestions?
When I read "template", I think "Velocity". I wonder if you can solve this by separating template from dynamic data. I wonder if you can solve this by letting users modify dynamic data and only marry it with the static, unedited template at the last minute.
It's possible that Docmosis can help because it lets you use documents and templates and you can extract from Docmosis an "analysis" of the template (eg a list of fields). It's hard to be sure if it will fit your purpose though from your description. Please note I work for the company that produces Docmosis.
I need to generate report in HTML for my Swing based application.
Is it possible to convert JTable into HTML code (HTML table)?
If yes, how can I convert JTable into HTML table, or is there any alternative way to generate HTML for reporting?
Ok. I've come to three solutions over night (you can combine them if possible):
The basic - the most control and flexibility - you generate HTML by iterating over rows wrapping data with table, td, tr. For better visual effect you must manually include it in the generated output.
Create a model with JAXB or Jackson annotations (or any library that provides you with easy JSON/XML creation) and save your model to/with a "html template" with fancy stuff like CSS and cool visual effects provided by for example jQuery UI (and extensions: Heatbox, etc.) DataTables, KendoUI, Flexigrid, or even Google Charts. To adapt to particular "visual-effects provider" you probably must manipulate a little your generated XML/JSON data but with JAXB you can even produce strict HTML table snippet.
Data generation like in 2. - but you use this data with external tool/application that can read XML/JSON (or any format that you provided). You can try to use Jasper reports (here and here, iReport, Eclipse BIRT) - the report tools should have option to Save as..->HTML Page.
In case of charts (and if you don't want above JavaScript based solutions) you can also generate images (that you will display in HTML page) with some java library that gives you the possibility to save generated images (for example JFreeChart etc. or Swing's paint components trick).