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

Free Support Forum - aspose.com

Unable to generate PDF for nested XML containing <![CDATA[ ]]>

Hi Team,

Issue 1

I’m unable to generate PDF for nested XML containing <![CDATA[ ]]>.
Please refer to the attached files.
PDF Generation.zip (1.7 MB)

Among the files there are two types of XML’s

  1. Flat.xml
  2. Nested.xml

Issue 2

Both has 2 templates each with different properties

For Flat1.rtf and Nested1.rtf, i have set

Table table = builder.startTable();

output doesn’t seem right when i set this
A t e l i e r g r a p h i q u e


Flat2.rtf and Nested2.rtf doesn’t contain the above attributes
Atelier graphique

Please let me know if there are any issues in template generation.

Thanks & Regards

Thanks for your inquiry. [quote=“sukesh.kotian.eistec, post:1, topic:160101”]
I’m unable to generate PDF for nested XML containing <![CDATA[ ]]>.
Please remove the following tags from the template document or add REPORT_DATA in XML to get the desired output.
{{#foreach REPORT_DATA}}
{{/foreach REPORT_DATA}}

Please do not set the FitText property of cell. We have modified the document and attached it with this post for your kind reference. Flat1.zip (9.6 KB)
Please see the attached image for detail. FitText.png (11.2 KB)

Best Regards,
Tahir Manzoor

Hi Tahir,

Thank you for providing the solution.
Also, can you please let me know how can i provide alignment to data for a particular column?

I tried using


But this set the whole row alignment to right.

P.S It would be even better if we were able to set alignment through XML.

Thanks & Regards


Thanks for your inquiry. Yes, you can set the alignment of text in particular table column. In this case, we suggest you please implement IFieldMergingCallback interface to achieve your requirement. Please check the following code snippet. Hope this helps you.

class HandleMergeFieldAlignment implements IFieldMergingCallback {

    public void fieldMerging(FieldMergingArgs e) throws Exception {
        if (mBuilder == null)
            mBuilder = new DocumentBuilder(e.getDocument());

        // This way we catch the beginning of a new row.
        if (e.getFieldName().equals("CUSTOMERNAME")) {


    public void imageFieldMerging(ImageFieldMergingArgs args) throws Exception {
        // Do nothing.

    private DocumentBuilder mBuilder;

Best Regards,
Tahir Manzoor

Hi Tahir,

Thank you for the information regarding alignment :slightly_smiling_face:.
Have one more issue. Please check the attached image
2017-07-14_18-30-08.png (174.6 KB)

How do i make the columns auto adjust according to the data?

Thanks & Regards


Thanks for your inquiry. You may check following documentation link for AutoFit setting of a table. You may access the table object in the document and apply Autofit to content options. It will help you to accomplish the task.

Best Regards,


The link you provided me is of dot net. Can you please provide java link.

Thanks & Regards


We are sorry for your inconvenience. Please check following documentation link for Aspose.Words for Java.

How to Apply Different AutoFit Settings to a Table

Best Regards,

Hi Tilal,

The solution you provided works on .doc files. But it doesn’t work on PDF.

Please let me know how do i auto fit data in PDF.

Thanks & Regards


Thanks for your inquiry. Please call the Document.UpdatePageLayout method before saving the document. This method is automatically invoked when you first convert a document to PDF, XPS, image or print it. However, if you modify the document after rendering and then attempt to render it again - Aspose.Words will not update the page layout automatically. In this case you should call UpdatePageLayout before rendering again.