Hello,

I am new to iText and I have the problem that I want to convert xml files to pdf. I have seen that there is a possibility to do this. However the problem is that my xml describes forms. So I wanted to add acro forms to the pdf. I have read in the mail archive that STOKES Mark NGPS7 has got the same problem and bruno wrote that there is no support to genarte forms directly form xml.

First Question:
Since this mail is half a year old I want to ask if there has something changed since that time.

Second Question:
If I have to write my own handler, where is the best way to start?

I have got this simple xml:

<?xml version="1.0"?>
<formTag>
        <setTag>
                <textField/>
        </setTag>
</formTag>

and i want to convert it to pdf.

I have written this tagmap:
<tagmap>
        <tag name="itext" alias="formTag"/>
        <tag name="paragraph" alias="setTag" />
</tagmap>

Now I want the PDF - File!!!!! ;-)

Is it possible to use the existing parser and simply add the text - field functionality or do I have to start from scratch?



If I simply write this, I get a class cast Exception:

public class MWSHandler extends SAXmyHandler {

                protected PdfWriter writer;

                public MWSHandler(DocListener document, HashMap map, PdfWriter 
writer) {
                        super (document,map);
                        this.writer = writer;
                }

                public void endElement(String uri, String lname, String name) {
                        System.out.println("name:: " + name);
                        if (name.equals("textField")){
                                System.out.println("Handling TextField");
                                String fieldName = "Text";

                                System.out.println("Generating Field");

PdfFormField field = PdfFormField.createTextField(writer,false,false,30);
                                field.setFieldName(fieldName);
                                field.setValueAsString(fieldName);
field.setBorderStyle(new PdfBorderDictionary (2,PdfBorderDictionary.STYLE_SOLID));

                                System.out.println("adding field to stack");
                                stack.push(field);
                        }
                        else{
                        super.endElement(uri, lname, name);
                        }
                }


        }


Since I have not completely understood the iText mechanism I am quite sure that this code is nonsens. Perhaps you have a link where I can find more information about the parser and/or forms? As far as i have seen, the elements which are added to the document are stored in a stack, but when are they added?




-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to