Free Support Forum - aspose.com

Pdf.save is getting stuck for a huge XML file

Hi,
I am reading a xml file and creating a pdf from it. When the line number of the file is more than 6,00,000 (approx) the pdf.save getting stuck without any exception.

Do you have any limit of the file size which Aspose can support to generate the PDF ? If Yes please let me know the line numbers or the file size.

Code template :

Pdf pdf = new Pdf();
String inputFile = “C:\ziptest\jira1271\bulk-xml-1271.xml”;
String data = readFile(new File(inputFile));
pdf.bindXML(new StringBufferInputStream(data), null);
pdf.save(“C:\AsposeTest\config\test\My_TEST_PDF_12.pdf”);

I am using Java Aspose 2.7.0. Here is a small stats about the time taken for pdf generation. Is the time taken Ok as per Aspose standard ?

No. of Lines in xml file Time taken to Bind Xml (in Secs) Time taken to save the Pdf (in Secs) No. of Pages in the generated Pdf
48853 1.766 17.735 172
97435 4.485 44.597 343
162211 11.939 101.211 571
307957 47.16 873.286 1084
405121 124.978 2117.553 1427
502285 194.093 2524.053 1769
615643 Got Stuck

Hello Sriman,

Thanks for using our products.

I have tested the scenario using following XML file and code snippet and as per my observations when using Aspose.Pdf for Java 2.9.0, I am getting StackOverflowError when placing around 32000 rows inside PDF document. For the sake of correction, I have logged it as PDFJAVA-29159 in our issue tracking system. We will further look into the details of this problem and will keep you updated on the status of correction.

However, can you please share the XML file and code snippet that you are using so that we can also test it in our environment. We are really sorry for this inconvenience.

[Java]

Pdf pdf = new Pdf();
pdf.bindXML("d:/pdftest/XMLFile1.xml", null);
long begin = System.currentTimeMillis();
Section sec1 = pdf.getSections().getSection("Section1");
Table Section_Table = (Table) sec1.getParagraphs().getParagraph("Table1");
for(int i=0; i<=32000; i++)
{
Row New_Row = new Row(Section_Table);
Cell Temp_Cell1 = New_Row.getCells().add("Sample Line..." +i );
Section_Table.getRows().add(New_Row);
}

pdf.save("d:/pdftest/LargePDF_result.pdf");
long end = System.currentTimeMillis();
System.out.println("Document generated.....Total Time taken = " +(end-begin));

[XML]

<?xml version="1.0" encoding="utf-8" ?>
<Pdf xmlns="Aspose.Pdf">
<Section ID="Section1">
<Table ColumnWidths="7inch" IsBroken="False" DefaultCellPaddingTop="2" DefaultCellPaddingBottom="2" FontSize="11" ID="Table1">
</Table>
</Section>
</Pdf>