My teammate came up with a solution to this problem. The idea is to create a
Tree of DefaultMutableTreeNode elements. Each of the DefaultMutableTreeNode
would contain a PdfStructureElement. The tree should represent the XML
hierarchy, for instance, consider the XML code snippet in the previous
comment. The first DefaultMutableTreeNode should have a
PdfStructureElement(PdfName - movies) whose parent is
writer.getStructureTreeRoot(). The child of this node should be another
PdfStructureElement(PdfName - movie) whose parent is the PdfStrucutreElement
named 'movies' and so on.

Once the steps mentioned above are completed(which is essentially structure
parsing), we get a tree of PdfStrucutreElements. Now, we have to parse the
content. As we parse the content, we need to traverse through each of the
tree nodes. If the node that is parsed is a leaf node, then we need to get
the PdfStructureElement within that node. Else, If the node that is parsed
is a non-leaf node, then we need to get the PdfName of the
PdfStructureElement within that node. In other words, we can simply use the
qName variable. The code for the following is given.


if(node is a leaf) 
    PdfStructureElement element=(PdfStructureElement)node.getUserObject();
    canvas.beginMarkedContentSequence(element); 
else 
    canvas.beginMarkedContentSequence(qName);

--
View this message in context: 
http://itext-general.2136553.n4.nabble.com/How-to-create-a-tagged-PDF-from-a-complex-XML-file-tp4412880p4416153.html
Sent from the iText - General mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference 
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: 
http://itextpdf.com/themes/keywords.php

Reply via email to