embed pkcs7 in pdf with php

I am trying to implement digital signature in PDF with PHP.

Implementation steps are:

  • Ask user to upload PDF that needs to be signed
  • Validate user with their Unique identifier
  • API process data to generate DSC and responds with document signature digested value as Pkcs7 in xml format (Third party)
  • Embed pkcs7 in PDF (need help in this)

I have checked TCPDF library but it does not explain on how to attach Pkcs7 in PDF.

I am trying to find something like Java bouncycastle library for PHP.