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

Free Support Forum - aspose.com

JVM memory usage while exporting PDF


Hi

We are licenced version of aspose.pdf 4.5. We are running following code using either DOM or SimplePDF at a time.
And configuring it by static variables. Boolean withRowFormatting is set to true if we only need row formatting and false if we only need cell formatting.

Problem facing.

1. For large number of selection say 2000 rows and 255 columns, getting java out of bound exception.. also changed the JVM size to 2gb
2. In case of simple pdf, if we increase the number of columns more than 255, whatever the row count is ,
the downloaded pdf file shows 0 kb

Could you suggest , why PDF creation is consuming large amoumt JVM memory just to generate a PDF file of few Mbs
Here is snippet code, and its consuming large amount of memory to generate PDF for the both the cases
public class Test {
static int ROW = 2000; // Number of ROWS
static int COL = 300;// Number of COLUMNS
static Boolean withRowFormatting = true;

public static void main(final String[] args) throws Exception
{
SimplePDFAspose(); //PDF
DOMPDFAspose(); // Document
}

public static void DOMPDFAspose() throws Exception
{
com.aspose.pdf.Document doc = new com.aspose.pdf.Document();
doc.getPages().add();
doc.getPages().get_Item(1).getPageInfo().setMargin(new com.aspose.pdf.MarginInfo(50.0f, 50.0f,50.0f, 50.0f));
final com.aspose.pdf.Table table = new com.aspose.pdf.Table();
final com.aspose.pdf.Rows rows = table.getRows();
doc.getPages().get_Item(1).getParagraphs().add(table);

Boolean a = withRowFormatting;
final com.aspose.pdf.MarginInfo mi = new com.aspose.pdf.MarginInfo(3.0f,3.0f,3.0f,3.0f);
for (int j=0; j<ROW; j++)
{
System.out.println("Row number : " + (j + 1));
final com.aspose.pdf.Row row = rows.add();

if (a) {
row.setBackgroundColor(com.aspose.pdf.Color.getLightGray());
row.setBorder(new com.aspose.pdf.BorderInfo(
com.aspose.pdf.BorderSide.All));
}

final com.aspose.pdf.Cells cells = row.getCells();
for (int i = 0; i < COL; i++) {

com.aspose.pdf.Cell cell = cells.add("Row->" + (j + 1)
+ ":Column->" + (i + 1));

if (!a) {
cell.isWordWrapped(true);
cell.setBackgroundColor(com.aspose.pdf.Color.getAqua());
cell.setBorder(new com.aspose.pdf.BorderInfo(
com.aspose.pdf.BorderSide.All));
cell.setVerticalAlignment(VerticalAlignmentType.Center);
cell.setAlignment(AlignmentType.Center);
cell.setMargin(mi);
}

cell.isWordWrapped(true);
cell.setBackgroundColor(com.aspose.pdf.Color.getLightGray());
cell.setBorder(new com.aspose.pdf.BorderInfo(
com.aspose.pdf.BorderSide.All));
cell.setVerticalAlignment(VerticalAlignmentType.Center);
cell.setAlignment(AlignmentType.Center);

}
}

doc.save("E:/aakash/TableSpan_Issue_DOM.pdf");
}

public static void SimplePDFAspose() throws Exception
{
final Pdf pdf = new Pdf();
final Section section = pdf.getSections().add();
final Paragraphs paragraphs = section.getParagraphs();
section.getPageInfo().setMargin(new MarginInfo(50.0f));
final Table table = new Table();
final Rows rows = table.getRows();
paragraphs.add(table);
final TextInfo textInfo = new TextInfo();
textInfo.setFontName("Arial");
final BorderInfo borderInfo = new BorderInfo(BorderSide.All, new aspose.pdf.Color("#000000"));
final MarginInfo marginInfo = new MarginInfo(3.0f);
final Color color = new Color("#CCCCCC");
final boolean a = withRowFormatting;
for (int j=0; j<ROW; j++)
{
System.out.println("Row number : " + (j+1));
final Row row = rows.add();
if (a) {
row.setDefaultCellBorder(borderInfo);
row.setDefaultCellTextInfo(textInfo);
row.setDefaultRowCellPadding(marginInfo);
row.setBackgroundColor(color);
row.setBorder(borderInfo);
}
for (int i=0; i<COL; i++)
{
final Cells cells = row.getCells();
Cell cell = cells.add("Row->" + (j + 1) + ":Column->" + (i + 1));
if (!a) {
cell.setBackgroundColor(color);
cell.setDefaultCellTextInfo(textInfo);
cell.setPadding(marginInfo);
cell.setBorder(borderInfo);
cell.setBackgroundColor(color);
final int paragraphCount = cell.getParagraphs().size();
for (int k=0; k<paragraphCount; k++)
cell.getParagraphs().get_Item(k).setMargin(marginInfo);
}
cell.isWordWrapped(true);
cell.setVerticalAlignment(VerticalAlignmentType.Center);
cell.setAlignment(AlignmentType.Center);
}
}
pdf.save("E:\\aakash\\Existing.pdf");
}
}

Regards

Aakash Bhattacharya

Hi Aakash,,

We are sorry for the inconvenience caused. While testing the scenario with the latest version of Aspose.Pdf for Java 4.5.0, We have managed to reproduce the reported issues and logged these in our bug tracking system as following for further investigation and resolution. We will notify you via this thread as soon as these are resolved.


PDFNEWJAVA-33962: OutofMemory exception (com.aspose.pdf)

PDFNEWJAVA-33963: Creation of empty PDF file with zero byte size (aspose.pdf)

Please feel free to contact us for any further assistance.

Best Regards,

The issues you have found earlier (filed as PDFNEWJAVA-33963) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

The issues you have found earlier (filed as PDFJAVA-33962) have been fixed in Aspose.PDF for Java 18.6.