We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Problem creating PDF for nested templates

Hi Team,

I’m facing some issues while creating the PDF for the attached RTF and XML files.
Below is the sample code i tried. I’m using the latest Aspose.words jar. While running the code, it gets stuck in readXml as i have mentioned in the code comment. Please let me know if i’m doing anything wrong in the code.

<pre style=“background-color: rgb(255, 255, 255); font-family: “Courier New”; font-size: 9pt;”>import java.io.File;
import java.io.FileInputStream;

import java.io.InputStream;

import com.aspose.words.*;
import com.aspose.words.net.System.Data.DataSet;

public class AsposeWordTest {
public static void main(String[] args) {
try {
File rtfFile = new File(“D:\tmp\Nested Template.rtf”);
InputStream rtfStream = new FileInputStream(rtfFile);
Document doc = new Document(rtfStream);
DataSet ds = new DataSet();
ds.readXml(“D:\tmp\6124_grouped_Nested Template.xml”); // Code gets stuck here
doc.getMailMerge().setCleanupOptions(MailMergeCleanupOptions.REMOVE_UNUSED_REGIONS | MailMergeCleanupOptions.REMOVE_UNUSED_FIELDS);
String outputFile = “D:\tmp\Nested Template output.pdf”;
File file = new File(outputFile);
if (!file.exists())
doc.save(outputFile, SaveFormat.PDF);
} catch (Exception e) {

Hi Sukesh,

Thanks for your inquiry. You are using incorrect XML. This is the reason DataSet.readXml does not read it. Your XML contains the parent and child tables with same name REPORT_COLUMNS. Please change it.

Moreover, the parent child relationship must be correct in your XML and template. We suggest you please read following article. Hope this helps you.
Ensure Correct Table Names and Relationships Exist Between Tables