Performance on PDF Protection

Hi !

I just would like to know if there is some way to enhance the performance of the NET 5.0 libraries (PDF-Base and Compression-Base.dll) during the PDF protection with passwords.

I noticed that PDF Signature (with a lot of effects) can be 20x faster than just protecting the same PDF file. Thinking on this, I was wondering if Winforms PDF Libraries has the same performance behaviour (I will test it later) but one thing warned me: the NET 5 libraries does not have the option of save "per string" but only "per stream". See below:

Winforms:
LoadedDocument.Save("Output.pdf")

NET 5
LoadedDocument.Save(New Filestream("Output.pdf", File.Create, FileMode.Write)

So, I'm not sure if it would be a reason, but I have seen a lot of "stream" codes without the best performance settings, as a buffer set to 4096 bytes and more, which can cause a unecessary delay of disk operations.

Another question: instead I have to utilize the SAVE method of "LoadedDocument", could I move its contents to an array and save it according my preferences (eg.  using BinaryWriter or something else)?

Thanks a lot for any help on this.






4 Replies

SL Sowmiya Loganathan Syncfusion Team January 27, 2021 12:32 PM UTC

Hi DavidBS,    
   
Thank you for contacting Syncfusion support.    
   
I just would like to know if there is some way to enhance the performance of the NET 5.0 libraries (PDF-Base and Compression-Base.dll) during the PDF protection with passwords.   
   
I noticed that PDF Signature (with a lot of effects) can be 20x faster than just protecting the same PDF file. Thinking on this, I was wondering if Winforms PDF Libraries has the same performance behavior (I will test it later)   
   
We have tried the PDF signature and PDF security in the ASP.NET Core platform. But we regret to let you know that we were unable to face this issue. Could you please provide us the below details, it will helpful for us to provide the precise solution on this?    
   
  • Performance issue details (time taken for both features)
  • Code snippet
but one thing warned me: the NET 5 libraries do not have the option of saving "per string" but only "per stream". See below:   
   
Winforms:   
LoadedDocument.Save("Output.pdf")   
   
NET 5   
LoadedDocument.Save(New Filestream("Output.pdf", File.Create, FileMode.Write)   


   
So, I'm not sure if it would be a reason, but I have seen a lot of "stream" codes without the best performance settings, as a buffer set to 4096 bytes and more, which can cause an unnecessary delay of disk operations.   
   
As per the PDF specification in the ASP.NET Core platform, a PDF document can be saved only in the stream.    
   
Note: The WinForms and WPF control support in .NET Core 5.0 have been provided. To run this application, please install thesystem.Drawing.Common NuGet package as a dependent package.   
Another question: instead I have to utilize the SAVE method of "LoadedDocument", could I move its contents to an array and save it according to my preferences (eg.  using BinaryWriter or something else)?   
You can save the PDF document using Stream in the ASP.NET Core platform and move that content into an array and save it according to your preference.    
  
Regards, 
Sowmiya Loganathan 



DA DavidBS January 27, 2021 05:09 PM UTC

Hi Sowmiya,

I'll try to provide the comparison code to you in few hours.
See you soon.

Thanks!


DA DavidBS January 27, 2021 11:01 PM UTC

Hi Sowmiya!

Interesting that my tests showed different results I was expecting to see!
I NET5 we have, truly, best performance than using NET 4.8 (as shown in attached ZIP), from aprox. 10%-20%.

But anyway, if considering the encryption performance, mainly using PDF 2.0 settings (AES and 256-bitRev6 keys), we still have a brutal difference (10x in average) of performance between "protection" and "signing". I guess this occurence may be related to the AES routine utilized there (from MS/NET or third-party).

But it is NOT a Syncfusion problem or fault. 
I just understand that this routine can be enhanced in the future.

Thanks for your time Sowmiya.
Warm hugs!







Attachment: results_6ed61828.zip


SL Sowmiya Loganathan Syncfusion Team January 28, 2021 12:44 PM UTC

Hi DavidBS,   
 
Thank you for the details.   
 
We have tried to reproduce the reported issue “Compared to PDF signing, PDF protection takes long time in .NET 5.0” using Syncfusion.Pdf.Net.Core NuGet package. But we regret to let you know that we were unable to reproduce it. Please refer the below sample which we have tried from below,   
 
 
Could you please provide us the below details, it will helpful for us to provide precise solution on this.   
  • Modified sample / code snippet used in your end
  • Product version
  • If you are trying to sign/protect an existing PDF document, please share the input PDF documents
 
Regards,  
Sowmiya Loganathan 


Loader.
Up arrow icon