Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Thu Mar 21, 2024 9:21 am

Hello,
We are using spirePDF in a spring boot application in version : 3.2.2
The latest SpirePDF version we use is version: 10.1.5
One of the service we use allows us to digitally sign our pdfs :

Code: Select all
@Override
public PdfDto signPdf(PdfDto pdfDto, LogDto logDto) throws IOException, PdfException {
   log.info("PdfServiceImpl signPdf() called");
   List<DataDto> dataDtos = new ArrayList<>();
   pdfDto.getData().forEach(dataDto -> {
      LogDto logDtoUpdate = logDto;
      ByteArrayOutputStream signedPdf = new ByteArrayOutputStream();
      InputStream certificateStream = Utils.base64DecodeFromString(dataDto.getCertificate());
      PdfDocument doc = null;
      try {
         doc = loadPdf(dataDto.getPdf(), logDtoUpdate);
         PdfCertificate cert = new PdfCertificate(IOUtils.toByteArray(certificateStream), dataDto.getPassword());
         if ((dataDto.getSignatureName() == null) || dataDto.getSignatureName().isEmpty()) {
            dataDto.setSignatureName("Signature");
         }
         PdfSignature pdfSign = new PdfSignature(doc,
               doc.getPages().get(doc.getPages().getCount() - 1),
               cert,
               dataDto.getSignatureName());
         pdfSign.setDocumentPermissions(PdfCertificationFlags.Forbid_Changes);
         pdfSign.setDocumentPermissions(PdfCertificationFlags.Allow_Form_Fill);
         pdfSign.setLocationInfo(dataDto.getLocation());
         pdfSign.setReason(dataDto.getReason());
         doc.saveToStream(signedPdf);
         String pdf64Signed = new Base64().encodeAsString(signedPdf.toByteArray());
         dataDtos.add(DataDto.builder().pdf(pdf64Signed).build());
      } catch (PdfException | IOException e) {
         throw new PdfException(e.getMessage(), logDtoUpdate);
      }
   });
   return PdfDto.builder()
      .data(dataDtos)
      .build();
}


Our issue is the following:
- depending on the original PDF size, signature can take a long time or not occur... We tried it with pdf with different sizes: 5Mo, 10Mo, 20Mo... after this, it becomes very long.

Is there any limitation on pdf size ? and to handle very big files what would be the solution ? Do we need more memory resources ?

dreamweaver
 
Posts: 4
Joined: Tue Feb 22, 2022 5:04 pm

Thu Mar 21, 2024 10:13 am

Hello,

Thanks for your inquriy.
Please be informed that signing a PDF document will read all the contents of the PDF document, so larger documents theoretically take more time. Sorry, we currently do not have a more efficient way to handle large documents, hope you can understand.

Sincerely,
William
E-iceblue support team
User avatar

William.Zhang
 
Posts: 454
Joined: Mon Dec 27, 2021 2:23 am

Return to Spire.PDF