aspose file tools*
The moose likes Other Open Source Projects and the fly likes PDF generation using iText + template + XML + XSD Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "PDF generation using iText + template + XML + XSD" Watch "PDF generation using iText + template + XML + XSD" New topic
Author

PDF generation using iText + template + XML + XSD

Anton Lunev
Greenhorn

Joined: Jan 15, 2006
Posts: 4
Hi,
I want to create XML from template.pdf, filling it's elements with data from xml.

So, what we have:
- template.pdf - this file was created using Adobe Livecycle Designer and contains data binding <PDF elemet> <-> <XSD elemet>
- data.xsd - the XSD that was is binded to template.pdf
- data.xml - XML data file conforming data.xsd

And what we want:
create template_instance.pdf based on the template.pdf filled with data from data.xml

In other words I want iText do something like this:
new PdfDocument(template.pdf, data.xsd, data.xml)

For now, I manually set fields in PDF throgh setField() with data from XML (XML is accessed using XMLBeans).

Is this kind of magic possible with iText ?

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18669
    
    8

Since this question is explicitly about iText and only tangentially about XML, let's move it to the forum which is about iText.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42289
    
  64
iText has no provisions for adding text to a PDF after it's been created, unless you're talking about filling in form fields (but it doesn't sound like you are).

In general, the things you can do with a PDF after it's been created are rather limited. You may be better off with creating RTF templates, and then performing a text search-and-replace in that. You could use a library like PODConverter to create a PDF from the RTF afterwards.


Ping & DNS - my free Android networking tools app
Redrick Shuhart
Greenhorn

Joined: Jul 16, 2004
Posts: 4
Thanks a lot for answers, I just returned here not long ago and had the wrong e-mail in my profile.
Well, better later then never, I'll just describe the way we've done it.

We just replace root element in XFA form(which holds) data. Assuming the new root element conforms to the XSD used for PDF creation it works fine. Will better post code a bit later to fix the solution.

So, although iText is great, it still can't provide full control over PDF. Some things you can do by manual editing of XFA form xml, but can't with iText.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: PDF generation using iText + template + XML + XSD