本文整理了Java中org.apache.pdfbox.pdmodel.PDDocument.saveIncremental()
方法的一些代码示例,展示了PDDocument.saveIncremental()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。PDDocument.saveIncremental()
方法的具体详情如下:
包路径:org.apache.pdfbox.pdmodel.PDDocument
类名称:PDDocument
方法名:saveIncremental
[英]Save the PDF as an incremental update. This is only possible if the PDF was loaded from a file or a stream, not if the document was created in PDFBox itself.
[中]将PDF另存为增量更新。这只有在PDF是从文件或流加载的情况下才可能实现,而不是在PDFBox中创建的文档。
代码示例来源:origin: apache/pdfbox
/**
* Prepares the TimeStamp-Signature and starts the saving-process.
*
* @param document given Pdf
* @param output Where the file will be written
* @throws IOException
*/
public void signDetached(PDDocument document, OutputStream output) throws IOException
{
int accessPermissions = SigUtils.getMDPPermission(document);
if (accessPermissions == 1)
{
throw new IllegalStateException(
"No changes to the document are permitted due to DocMDP transform parameters dictionary");
}
// create signature dictionary
PDSignature signature = new PDSignature();
signature.setType(COSName.DOC_TIME_STAMP);
signature.setFilter(PDSignature.FILTER_ADOBE_PPKLITE);
signature.setSubFilter(COSName.getPDFName("ETSI.RFC3161"));
// No certification allowed because /Reference not allowed in signature directory
// see ETSI EN 319 142-1 Part 1 and ETSI TS 102 778-4
// http://www.etsi.org/deliver/etsi_en%5C319100_319199%5C31914201%5C01.01.00_30%5Cen_31914201v010100v.pdf
// http://www.etsi.org/deliver/etsi_ts/102700_102799/10277804/01.01.01_60/ts_10277804v010101p.pdf
// register signature dictionary and sign interface
document.addSignature(signature, this);
// write incremental (only for signing purpose)
document.saveIncremental(output);
}
代码示例来源:origin: apache/pdfbox
document.saveIncremental(output);
代码示例来源:origin: apache/pdfbox
doc.saveIncremental(fos);
代码示例来源:origin: apache/pdfbox
document.saveIncremental(output);
代码示例来源:origin: apache/pdfbox
doc.saveIncremental(fos);
代码示例来源:origin: arhs/sd-dss
@Override
public void saveIncremental() throws IOException {
try {
document.saveIncremental(tempInput, tempOutput);
tempOutput.close();
tempInput.close();
tempInput = new FileInputStream(tempDocumentOut);
DSSUtils.copy(tempInput, output);
tempInput.close();
} catch (COSVisitorException e) {
throw new IOException(e);
}
}
代码示例来源:origin: org.apache.pdfbox/pdfbox-examples
document.saveIncremental(output);
代码示例来源:origin: stackoverflow.com
PDDocument document = PDDocument.load(inputStream);
...
document.addSignature(new PDSignature(this.dts.getDocumentTimeStamp()), this);
document.saveIncremental(new FileOutputStream("C:/result.pdf"));
document.close();
代码示例来源:origin: org.apache.pdfbox/pdfbox-examples
doc.saveIncremental(fos);
代码示例来源:origin: stackoverflow.com
PDDocument pdf = PDDocument.load(inputFile);
MessageDigest digest = MessageDigest.getInstance("SHA-256");
TSAClient tsaClient = new TSAClient(new URL("your time stamp authority"), null, null, digest);
pdf.addSignature(signature, new TimestampSignatureImpl(tsaClient));
pdf.saveIncremental(new FileOutputStream(outputFile));
pdf.close();
代码示例来源:origin: org.apache.pdfbox/pdfbox-examples
doc.saveIncremental(fos);
代码示例来源:origin: arhs/sd-dss
public static void saveDocumentIncrementally(SignatureParameters parameters, File signedFile, FileOutputStream fileOutputStream, PDDocument pdDocument) throws DSSException {
FileInputStream signedFileInputStream = null;
try {
signedFileInputStream = new FileInputStream(signedFile);
// the document needs to have an ID, if not a ID based on the current system time is used, and then the digest of the signed data is different
if (pdDocument.getDocumentId() == null) {
final byte[] documentIdBytes = DSSUtils.digest(DigestAlgorithm.MD5, parameters.bLevel().getSigningDate().toString().getBytes());
pdDocument.setDocumentId(DSSUtils.toLong(documentIdBytes));
pdDocument.setDocumentId(0L);
}
pdDocument.saveIncremental(signedFileInputStream, fileOutputStream);
} catch (IOException e) {
throw new DSSException(e);
} catch (COSVisitorException e) {
throw new DSSException(e);
} finally {
DSSUtils.closeQuietly(signedFileInputStream);
}
}
代码示例来源:origin: org.apache.pdfbox/pdfbox-examples
/**
* Prepares the TimeStamp-Signature and starts the saving-process.
*
* @param document given Pdf
* @param output Where the file will be written
* @throws IOException
*/
public void signDetached(PDDocument document, OutputStream output) throws IOException
{
int accessPermissions = SigUtils.getMDPPermission(document);
if (accessPermissions == 1)
{
throw new IllegalStateException(
"No changes to the document are permitted due to DocMDP transform parameters dictionary");
}
// create signature dictionary
PDSignature signature = new PDSignature();
signature.setType(COSName.DOC_TIME_STAMP);
signature.setFilter(PDSignature.FILTER_ADOBE_PPKLITE);
signature.setSubFilter(COSName.getPDFName("ETSI.RFC3161"));
// No certification allowed because /Reference not allowed in signature directory
// see ETSI EN 319 142-1 Part 1 and ETSI TS 102 778-4
// http://www.etsi.org/deliver/etsi_en%5C319100_319199%5C31914201%5C01.01.00_30%5Cen_31914201v010100v.pdf
// http://www.etsi.org/deliver/etsi_ts/102700_102799/10277804/01.01.01_60/ts_10277804v010101p.pdf
// register signature dictionary and sign interface
document.addSignature(signature, this);
// write incremental (only for signing purpose)
document.saveIncremental(output);
}
代码示例来源:origin: org.verapdf/pdfbox-metadata-fixer
/**
* {@inheritDoc} Implemented by Apache PDFBox library.
*/
@Override
public MetadataFixerResult saveDocumentIncremental(final MetadataFixerResultImpl.RepairStatus status,
OutputStream output) {
MetadataFixerResultImpl.Builder builder = new MetadataFixerResultImpl.Builder();
try {
PDMetadata meta = this.document.getDocumentCatalog().getMetadata();
boolean isMetaPresent = meta != null && this.isNeedToBeUpdated();
boolean isMetaAdd = meta == null && this.metadata != null;
if (isMetaPresent || isMetaAdd) {
this.metadata.updateMetadataStream();
if (isMetaAdd) {
this.document.getDocumentCatalog().getCOSObject().setNeedToBeUpdated(true);
}
this.document.saveIncremental(output);
output.close();
builder.status(getStatus(status));
} else {
builder.status(status);
}
} catch (Exception e) {
LOGGER.info(e);
builder.status(FIX_ERROR).addFix("Problems with document save. " + e.getMessage());
}
return builder.build();
}
代码示例来源:origin: org.apache.pdfbox/pdfbox-examples
document.saveIncremental(output);
内容来源于网络,如有侵权,请联系作者删除!