Saving_PDFissue.docx (22.4 KB)
Help Request: System Hangs and Closes When Saving Large PDF Files with Aspose.PDF
Description:
We are using Aspose.PDF to delete pages from PDF files with sizes varying between 295 MB and 995 MB. However, we are encountering significant performance issues when saving the processed PDF files to disk or memory stream. The system hangs and eventually closes after waiting for 6 to 24 hours, and no error message is shown. We are using the APOSE version 25.1.1.
Steps Performed:
- Load PDF Document: Using Aspose.PDF to load the original PDF document.
- Delete Pages: Deleting specific pages from the document.
- Save PDF Document: Attempting to save the modified PDF document to disk or memory stream.
- Compress and Save: Compressing the modified PDF and saving it to a database.
Observations:
- The system hangs and eventually closes after waiting for 6 to 24 hours with no error message.
- The issue occurs consistently across different file sizes within the 295 MB to 995 MB range.
Request:
Could you please provide guidance on how to optimize the saving process for large PDF files using Aspose.PDF? Any recommendations or best practices for improving the performance of saving large PDF documents would be greatly appreciated. Additionally, any insights into why the system hangs and how to prevent it would be extremely helpful.
CODE We using:
using (FileStream fileStream = new FileStream(newPDFFilePath, FileMode.Create, FileAccess.Write, FileShare.None))
{
originalPdf.Save(fileStream);
byte[] newPDFBytes = File.ReadAllBytes(newPDFFilePath);
//Save to DB
SaveExternalReprintFiles(reprintFileId, newExcelFileName, newPDFFileName, Compress(newPDFFileName, newPDFBytes), Compress(newExcelFilePath));
}
@BharaneswarMurugesan
The issue can be file specific which is why we need a sample document from your side so that we can try to observe the similar issue in our environment and address it accordingly. Also, the code snippet you shared does not seem complete. Please share the code snippet which is responsible for deleting pages and compressing the PDF document so that we can use it accordingly to replicate the issue. You can upload your document to Google Drive or Dropbox and share the link with us.
HI @asad.ali, Please find the reference PDF doc link in the google drive,
@BharaneswarMurugesan
We tried with below code snippet and noticed that the program got stuck on Delete() call. Can you please confirm if you are using the same approach?
string inputFile = dataDir + "4501715532_1_100000038900_1_100000039121_AUX_PRINT_000168004.pdf";
Document document = new Document(inputFile);
document.Pages.Delete(2);
string outputFile = dataDir + "output.pdf";
document.Save(outputFile);
Yes, we are also using a similar approach, but we are only facing issue in Save(outputFile) for the large PDF files and getting slowness. Could you share the exact solution or any specific change for this issue?
Note: We have tried many approaches for this saving the larger files PDF, but we didn’t get the appropriate solutions. Find the below approaches,
foreach (var page in pagesToDelete.OrderByDescending(p => p))
{
pdfDocument.Pages.Delete(page);
}
Saving Issue for the large PDF Files:
Approach:1 Using the Direct Save Document
pdfDocument.Save(outputFile);
Approach :2 Using the Filestream (Direct File Saving)
using (FileStream fileStream = new FileStream(newPDFFilePath, FileMode.Create, FileAccess.Write, FileShare.None))
{
pdfDocument.Save(fileStream);
}
Approach: 3 Using the MemoryStream(Saving in Memory)
Using (Memorystream memorystream = new Memorystream())
{
pdfDocument.save(memorystream );
}
@BharaneswarMurugesan
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): PDFNET-59339
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
Any updates on this issue
@BharaneswarMurugesan
The ticket has recently been logged in our issue tracking system and it will be prioritized on a first come first serve basis. As soon as we make some progress towards ticket resolution, we will inform you here. Please be patient and spare us some time.
We are sorry for the inconvenience.
Hello,
I am from Bharaneswar’s team. We are working together on this issue. It’s been 13 days since your last reply. Request you to please update the latest.
Thank you.
@jph4359
As shared earlier, the ticket has recently been logged and as per free support model policies, it will be investigated/resolved on a first come first serve basis. At the moment, there are other issues in the queue that were logged previously than yours and we have been working on them. As soon as we have some certain updates about resolution of the ticket or have some information about fix ETA, we will let you know via this forum thread. Please be patient and spare us some time.
We are sorry for the inconvenience.
Its been close to 2 months, can we have an update please ?
@jph4359
We are afraid that we do not have any updates about ticket resolution at the moment. The ticket is not yet fully investigated due to other issues in the queue. Once we have some updates in this regard, we will certainly inform you. Please spare us some time.
We are sorry for the inconvenience.