Free Support Forum -

Issue while generating PDF reports with Large Data Volume

Hi Team,
We are facing PDF generation issues as below:
. Our API is able to generate PDF file, if the Data load is less than 50,000 records
. But when API is with 50,000+ records, API stop working
. When we do similar file generation with Aspose Excel, file generates properly for those many records.

Please reply:
. if Aspose engine can generate PDF files with bulk/heavy data?
. How much count Aspose are sure of with data volume?


There is no such limitations in the API in terms of data size or volume. However, if you are facing some issue, please share a sample console application with dummy data which is able to reproduce the similar issue you are facing. We will test the scenario in our environment and address it accordingly.

Hi @asad.ali

After some analysis, we found that below method is creating issues with high volume of records in pdf files.

Purpose of method is, read each row from collection (grid) and perform right alignment for numbers and left alignment for remaining data types and insert into pdf(table).

Can you please check if this is correct way or we can have some better solution ??

Code Snippet:

Table tab = new Table();
TextState tr = new TextState();
TextState tl = new TextState();

// Variables Info
// grid : holds 50000 rows.
// colValueType : hold info about columns if that is number or string type data.

/data insertion part/
for (ArrayList onerow : grid)
i = 0;
orderkeys =1;
Row rowt = tab.getRows().add();
for (Object obj : onerow)
if (i > MAX_PDF_COLS)
i = 0;
// Data Insert with Alignment
rowt.getCells().add(obj.toString(), tr);
rowt.getCells().add(obj.toString(), tl);

Thanks in advance.


The code snippets seems fine. Would you please explain a bit more about what type of issue it is creating at your side? Please make sure to try latest version of the API i.e. 20.12 and if issue still persists, please share a sample console application which is able to reproduce the issue in our environment so that we can test the scenario and address it accordingly.


I have attached some sample code, which gives java memory details while generating table for PDF. In some time interval, Server goes out of memory and Thread Starvation occurs.

"grid" : variable having 40K rows. Each row will have 12 Columns.

Note : Code is printing stats for every 1000 rows.

PerformanceIssue_AsposePDF.jpg (177.0 KB)


We tested the scenario in our environment while using Aspose.PDF for Java 20.12 and the following code snippet:

Document doc = new Document();
Page page = doc.getPages().add();
Table table = new Table();
table.setColumnWidths("8 8 8 8 8 8 8 8 8 8 8 8");

for(int i = 1; i <= 40000; i++)
 Row row = table.getRows().add();
 if(i%1000 == 0)
  System.out.println("Generated " + i + " Rows.......!!!");
  Runtime runtime = Runtime.getRuntime();
  long memory = runtime.totalMemory() - runtime.freeMemory();
  System.out.println("Total Memory : " + runtime.totalMemory()/1024 + " MBs.");
  System.out.println("Used Memory : " + memory/1024 + " MBs.");
 for(int j = 1; j <= 12; j++)
  row.getCells().add("r" + i + "c" + j);
} + "Table.pdf");

The program took more than 3 minutes to process 35k rows and afterward it got frozen. We waited for more than 10 minutes and had to terminate the program forcefully. Therefore, we have logged a performance related issue as PDFJAVA-40064 in our issue tracking system. We will further look into its details and keep you posted with the status of its correction. Please be patient and spare us some time.

We apologize for the inconvenience.

PS: In the meantime, could you please try to increase Java Heap Size at your side and see if it resolves the issue.


Tried with increased Heap Size but it just runs for few more records and then Freezes.

How much approximate time it would take to resolve above issue ??


The ticket has recently been logged in our issue tracking system and is pending for analysis. It will be resolved on a first come first serve basis. Also, the performance-related issues are complex in nature and require a significant amount of time to get fixed. We will surely inform you as soon as we make some definite progress towards resolution of the issue. Please be patient and spare us some time.

We apologize for the inconvenience.