我做过类似的事情。这是对的吗?
我有:
PDDocumentCatalog catalog = template.getDocumentCatalog();
COSDictionary catalogDictionary = catalog.getCOSDictionary();
COSDictionary dssDictionary = new COSDictionary();
COSArray certDSS = getCertificateCosArray(certChainList);
dssDictionary.setItem(COSName.getPDFName("Cert"), certDSS);
catalogDictionary.setItem(COSName.getPDFName("DSS"), dssDictionary);
and code to fill:
public static COSArray getCertificateCosArray( List<X509Certificate> certChainList) {
COSArray certDSS = new COSArray();
for (X509Certificate x509Certificate : certChainList) {
PDStream certificateStream = new PDStream(new COSStream(new RandomAccessBuffer()));
appendRawCommands(certificateStream.createOutputStream(), x509Certificate.getEncoded());
PDObjectStream pd = new PDObjectStream(certificateStream.getStream());
certDSS.add(pd);
}
return certDSS;
}
我想它已经完成了。这是正确的方法吗?你怎么看?