Free Support Forum - aspose.com

Creating bulk pdf files in multiple threads

I have a task where I need to generate approx 30,000 pdf files.

I have a function in my page that I call over and over which will generate a single file.

I'm trying to improve the speed of generating these files by spinning up multiple threads like this:

var t = new Thread(() => LoadReportBulkRun(startID, endID));

t.Start();

var t2 = new Thread(() => LoadReportBulkRun(startID, endID));

t2.Start();

I've tried running it with 1 thread and it takes about 10 hours. It only slightly improves if I run approx 5-10 threads.

Is there a better way of simulatneously generating these PDFs?

Hi,


Thanks for using our products.

Aspose.Pf for .NET can be used in multi-threaded environment but ensure that a particular document can only be accessed by a single thread. I am afraid currently we do not support the feature to allow multiple threads to access single document. Furthermore, the document generation time depends upon the contents being placed inside the document but 10 hours time to generate a single file is quite much. Is it possible that you can share some sample project which can help us in replicating this issue at our end.

Once we have investigated the issue, we would be in a position to suggest some performance improvement options. We are really sorry for this inconvenience.
codewarior:
Hi,

Thanks for using our products.

Aspose.Pf for .NET can be used in multi-threaded environment but ensure that a particular document can only be accessed by a single thread. I am afraid currently we do not support the feature to allow multiple threads to access single document. Furthermore, the document generation time depends upon the contents being placed inside the document but 10 hours time to generate a single file is quite much. Is it possible that you can share some sample project which can help us in replicating this issue at our end.

Once we have investigated the issue, we would be in a position to suggest some performance improvement options. We are really sorry for this inconvenience.

It's not actually taking 10hrs to produce 1 but actually 30,000 pdfs from scratch. Sorry, if there was any confusion. Does this sound about right? The document has is generally 1 page and has a table on it with about 15 columns and 10 rows.

I ensure that we are not working on the generating the same file twice because I run my threads in different ranges. ie Thread 1 creates documents 1-1000, Thread 2 creates documents 1001 through 2000 etc.

I'm just looking for advice on performance expectations and bulk generation of files from scratch.

Thanks.

mcausi:
It's not actually taking 10hrs to produce 1 but actually 30,000 pdfs from scratch. Sorry, if there was any confusion. Does this sound about right? The document has is generally 1 page and has a table on it with about 15 columns and 10 rows.
Hi,

Thanks for sharing the details. Earlier I have been surprised to hear that a single document generation process took 10 hours. However I cannot share any accurate/certain time-frame for the generation of 30,000 documents but it all depends upon the contents and size of resultant files being generated.

mcausi:
I ensure that we are not working on the generating the same file twice because I run my threads in different ranges. ie Thread 1 creates documents 1-1000, Thread 2 creates documents 1001 through 2000 etc.

I'm just looking for advice on performance expectations and bulk generation of files from scratch.

If you are generating a document based on particular template, can you please share some code snippet which can help us in creating this document at our end so that we can further investigate on how to improve the document generation time.


In order to get a bit better performance, you may consider using the code snippet shared over Writing PDF directly


We are sorry for your inconvenience.