How to reduce file size increased by digital signature?

Hello, I am evaluating AsposePDF for our coming project. I have a PDF template that has 4 digital signature fields. Each time I use AsposePDF to add a new signature, the file size increases dramatically.

I am using an evaluation license. Could that be the reason for this? Will it get better with a real license? If not is there any ways I can reduce file size caused by digital signature?

Here are the files and details of the comparison:
digital-siganture-file-size.zip (6.4 MB)

In summary, after 4 digital signatures, the final PDF size produced by Acrobat is 235 KB, the PDF size produced by Aspose PDF is 2.3 MB. That’s 10 times the difference.

@hao.deng

You can optimize the PDF file size after signing it digitally. For example, please check the below code snippet that we used with 23.7 version of the API and file size was reduced to ~800KB:

var oo = new Aspose.Pdf.Optimization.OptimizationOptions();
oo.ImageCompressionOptions.MaxResolution = 300;
oo.ImageCompressionOptions.ResizeImages = true;
oo.ImageCompressionOptions.CompressImages = true;
oo.ImageCompressionOptions.Encoding = Optimization.ImageEncoding.Jpeg;
oo.ImageCompressionOptions.Version = Aspose.Pdf.Optimization.ImageCompressionVersion.Standard;
oo.AllowReusePageContent = true;
oo.RemoveUnusedObjects = true;
oo.RemoveUnusedStreams = true;
oo.LinkDuplcateStreams = true;
oo.SubsetFonts = true;
oo.AllowReusePageContent = true;
using (Document document = new Document(dataDir + "aspose4.pdf"))
{
 document.OptimizeResources(oo);
 document.Save(dataDir + "optimized" + DateTime.Now.Millisecond + ".pdf");
}

optimized875.pdf (816.0 KB)

somewhat better. thank you!

Dear asad.ali,

This is to follow up from a solution you posted on July 2023. The PDF size was growing considerately after each signature. You posted a solution to reduce the size by using
Aspose.Pdf.Optimization.OptimizationOptions class.
While the file size did reduce, it come with another problem: the PDF become “corrupt”. Opening “optimized875.pdf” in the above post with Acrobat, and click on the signature field, Acrobat would report “Siganture Contas incorrect, unrecognized, corrtupted or suspiscious data. Support information: SigDict/Contents illegal data

Would you have a fix for this? I’d rather have a weaker optimization than having a corrupt PDF document.

@hao.deng

Can you please confirm if we can use earlier shared files for this problem as well? For your information, both input and output (optimized) files are showing invalid signatures in our environment. That is happening may be because we have not added the signatures to the trusted source collection of Adobe Reader.

If you can please share some screenshots for our reference of valid and invalid signatures after optimization, we will continue with the investigation and addressing this issue accordingly.

Here are the 2 PDF I digitally signed with Aspose PDF:
#1 signed.pdf - signed PDF without applying optimization code
#2 signed-optimized.pdf - signed PDF with optimization code applied after digital signature is placed.

Notice in #2, opening the file in Acrobat, and opening the digital signature field prompts this error:
Error during signature verification
Siganture contains incorrect unrecognized corrupted or suspiscious data. Suppor information: SigDict/Contents Illegal data.
signed.pdf (743.2 KB)

signed-optimized.pdf (699.6 KB)

@hao.deng

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-56033

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.