Process of Deleting Text Stamps from Large PDF File using C# is too long

Hi,

We have large size PDF with TextStamp on each page of the file. Need to remove stamps using method DeleteStampById(int stampId), then save the PDF to local disk or into MemoryStream. We use Aspose.PDF 20.12.

The part of code we use:

Document doc = new Document($“C:/test/DeleteStampExample.pdf”);
using (PdfContentEditor contentEditor = new PdfContentEditor(doc))
{
contentEditor.DeleteStampById(2837); // stampID
doc.Save($“C:/test/DeleteStampExample_output.pdf”);
}

It takes too long if the PDF contains stamps - more than 30 minutes (I didn’t wait any longer) and saving is not ended. But if there are no stamps in file - it works more faster.

Please, take example files from sharing service:
https://dropmefiles.com/7MYRo
The first file (DeleteStampExample.pdf) with stamps and the second one (DeleteStampExample2.pdf) without stamps.

Is there any solution to speed up this?
Thanks for your help.

@apkarpunin

We tried to open the link and download the file but it was inaccessible. Can you please share a valid and working link to download the file?

@asad.ali

Please try download the files from Google Drive:
https://drive.google.com/drive/folders/1w2q3NqFyDrS1wJe1dq-qRxrXKBbl_PEv

@apkarpunin

We tested the scenario using Aspose.PDF for .NET 21.11 and noticed that the API was able to process the file “DeleteStampExample.pdf” in less than a minutes whereas the other file was taking much time in order to be saved. Please note that API did not take this time at DeleteStampById() method. Instead saving of the output file was taking this time.

Could you please try to test the scenario at your end with 21.11 version and share your findings with us? We will log an investigation ticket in our issue tracking system and share the ID with you.

@asad.ali

Unfortunately we have the licence allowing free upgrades until 28 Sep 2021 that’s why I’m not able to test Aspose.PDF 21.11.

However I tested the scenario using 21.09 version and checked process time of each code line. You’re right - DeleteStampById() method takes less than a minute. Process of saving into MemoryStream for the file “DeleteStampExample.pdf” takes too long, and for the file “DeleteStampExample2.pdf” it takes 10 seconds.

Then I tested only saving into MemoryStream:

Document doc = new Document($“C:/test/DeleteStampExample.pdf”);
using (MemoryStream tmpStream = new MemoryStream())
{
doc.Save(tmpStream);
}

The result was the same. For the file “DeleteStampExample.pdf” the process has not ended in a long time, for the file “DeleteStampExample2.pdf” it was taken 10 seconds.

@apkarpunin

Thanks for your feedback.

We have logged an issue as PDFNET-51048 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 are sorry for the inconvenience.