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

Free Support Forum - aspose.com

Table Performance issue

Hi,


I need to create a document with high numbers of table rows and then convert it to PDF. The issue I am facing here is performance time and memory consumption while converting to pdf for such document.

Time taken to convert 250 rows : 427

Time taken to convert 500 rows : 475

Time taken to convert 1000 rows : 622

Time taken to convert 5000 rows : 2587

Time taken to convert 10000 rows : 4615


This is just a word to pdf conversion time. You can add word creation time on top of it. Please let me know how can we improve performance in this scenario.

Is there any specific way we should create the document so that it will give me better performance?



Hi Sharon,

Thanks for your inquiry. Please note that performance and memory usage all depend on complexity
and size of the documents you are generating. While rendering a document to fixed page formats (e.g. PDF), Aspose.Words needs to build two model in the memory – one for document and the other for rendered document.

Usually,
Aspose.Words needs 10 times more memory than the original document size
to build it’s DOM in the memory and when it comes to rendering a
document to fixed page formats (e.g. PDF).

It would be great if you please share following detail for investigation purposes.


  • Please attach your input Word document.
  • Please

    create a standalone/runnable simple Java application that demonstrates the code (Aspose.Words code) you used to generate
    your output document


As soon as you get these pieces of information to
us we’ll start our investigation into your issue.

public class AsposeLoadTest {


public static void main(String[] args) {

try {

testConvert(250);

testConvert(250);

testConvert(500);

testConvert(1000);

testConvert(5000);

testConvert(10000);

} catch (Exception e) {

e.printStackTrace();

}

}


private static void testConvert(int count) throws Exception {

long time = System.currentTimeMillis();

FileInputStream fis = new FileInputStream(new File("/users/akundu/data/table_data_" + count + ".docx"));

Document doc = new Document(fis);

OutputStream outstream = new ByteArrayOutputStream();

PdfSaveOptions opt = new PdfSaveOptions();

opt.getOutlineOptions().setDefaultBookmarksOutlineLevel(9);

doc.save(outstream, opt);

System.out.println("Time taken to convert " + count + " rows : " + (System.currentTimeMillis()-time));

}

}

Hi Sharon,

Thanks for sharing the detail. I have tested the scenario using latest version of Aspose.Words for Java 14.11.0 and have not found the performance issue. I have used the following method to create the table and export final document to Pdf.


private static void testConvert(int count) throws Exception {

long time = System.currentTimeMillis();

// FileInputStream fis = new FileInputStream(new File(MyDir + "table_data_" + count + ".docx"));

Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);

builder.startTable();

for (int i = 0; i < count; i++) {

builder.insertCell();

builder.write("Row 1, Cell 1 Content.");

// Build the second cell

builder.insertCell();

builder.write("Row 1, Cell 2 Content.");

// Call the following method to end the row and start a new row.

builder.endRow();

}

builder.endTable();

OutputStream outstream = new ByteArrayOutputStream();

PdfSaveOptions opt = new PdfSaveOptions();

opt.getOutlineOptions().setDefaultBookmarksOutlineLevel(9);

doc.save(outstream, opt);

System.out.println("Time taken to convert " + count + " rows : " + (System.currentTimeMillis()-time));

}

<!–[if gte mso 9]>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:TrackMoves/>
<w:TrackFormatting/>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:DoNotPromoteQF/>
<w:LidThemeOther>EN-US</w:LidThemeOther>
<w:LidThemeAsian>X-NONE</w:LidThemeAsian>
<w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
<w:SplitPgBreakAndParaMark/>
<w:EnableOpenTypeKerning/>
<w:DontFlipMirrorIndents/>
<w:OverrideTableStyleHps/>
</w:Compatibility>
<m:mathPr>
<m:mathFont m:val=“Cambria Math”/>
<m:brkBin m:val=“before”/>
<m:brkBinSub m:val="–"/>
<m:smallFrac m:val=“off”/>
<m:dispDef/>
<m:lMargin m:val=“0”/>
<m:rMargin m:val=“0”/>
<m:defJc m:val=“centerGroup”/>
<m:wrapIndent m:val=“1440”/>
<m:intLim m:val=“subSup”/>
<m:naryLim m:val=“undOvr”/>
</m:mathPr></w:WordDocument>
<![endif]–><!–[if gte mso 10]>

/* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin-top:0in; mso-para-margin-right:0in; mso-para-margin-bottom:8.0pt; mso-para-margin-left:0in; line-height:107%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri",sans-serif; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin;}

<![endif]–>

It is quite difficult to answer such
questions because performance and memory usage all depend on complexity
and size of the documents you are generating. While rendering a document to fixed page formats (e.g. PDF), Aspose.Words needs to build two model in the memory – one for document and the other for rendered document.

Please note that the process of building layout model is
not linear; it may take a minute to render one page and may take a few
seconds to render 100 pages. Also, Aspose.Words has to create APS (Aspose Page Specification)
model in memory and this may again eat some more time for some
documents. Rest assured, we’re always working on improving performance;
but, rendering will be always running slower than simple saving to flow
formats (e.g doc/docx).