This question is for Java platform.
I am evaluating Aspose.Pdf for Java. Download the latest version and found only one sample xml SalesByCategory.xml. Can I have more sample XML which covers some complex layouts?
Hello Venkat,
Thanks for considering Aspose.
Please find attached an XML document which contains Text, Heading, Table, Labeled list and Bulleted List items. The text objects also contain formatting information. For your reference, I have attached the resultant PDF generated with this XML file using Aspose.Pdf for Java 2.7.0. In case it does not satisfy your requirement, please share some details regarding the source XML file that you would like to have. We are sorry for your inconvenience.
I would also recommend you to visit the following links for more information on
- Introduction to XML Technologies
- Aspose.Pdf Document Object Model (DOM)
- Create a Hello World PDF document through XML
I have used the following code snippet to test the scenario
[Java]
try{
aspose.pdf.License lic = new aspose.pdf.License();
lic.setLicense(new FileInputStream(new File("D:/ASPOSE/Aspose.Total.Java.lic")));
}catch(Exception ex)
{}
Pdf pdf = new Pdf();
pdf.bindXML("D:/pdftest/samplesource.xml",null);
// Save the document
pdf.save("d:/pdftest/Java_HelloWorld.pdf");
Thanks. I want to see an example where table rows are populated with dynamic data.
Hello Venkat,
We are working over this requirement and will get back to you soon. We are sorry for the delay and inconvenience.
Hello Venkat,
Thanks for your patience.
You can use the following code snippet to use an XML file as a template and populate data in table cell elements and generate a PDF document. But I am afraid there is an issue while accessing Section object when using XML file. The problem is already logged in our issue tracking system and the development team is looking into the details of this problem. We hope to get this problem resolved in our upcoming release version 2.8.0. As soon as the version becomes available, we would be pleased to update you with the status of correction. We apologize for your inconvenience.
[Java]
Pdf pdf = new Pdf();
pdf.bindXML("D:/pdftest/Template_new.xml",null);
//Get the section and then table from the obtained section of the Pdf that
//is built from the XML template
Section section1 = pdf.getSections().getSection("Section1");
Table table1 = (Table)section1.getParagraphs().getParagraph("Table1");
//Clone a new table
Table table2 = (Table)table1.completeClone();
//Change the ID of table2 to "Table2" to make it different from table1
table2.setID("Table2");
//Add table2 into the section
section1.getParagraphs().add(table2);
//Now there are 2 segments with ID "Item",
//We change the IDs to make sure they are different
Segment item = (Segment)section1.getObjectByID("Item");
item.setID("Item1");
item = (Segment)section1.getObjectByID("Item");
item.setID("Item2");
//Change the content
item.setContent("item 2");
//Now clone section1
Section section2 = (Section)section1.completeClone();
//Add a cloned section to the Pdf and change the contents of the text segments
//in the section2 of the Pdf object
pdf.getSections().add(section2);
item = (Segment)section2.getObjectByID("Item1");
item.setContent("item1 sec2");
item = (Segment)section2.getObjectByID("Item2");
item.setContent("item2 sec2");
// Save the document
pdf.save("d:/pdftest/XML_As_Template.pdf");
The issues you have found earlier (filed as 22813) have been fixed in this update.
This message was posted using Notification2Forum from Downloads module by aspose.notifier.