On this page
Guides
Save a Document
ComPDFKit supports incremental saving and full saving.
When the document is saved to the original path, the PDF document will be saved incrementally, meaning all changes will be appended to the file. This can significantly speed up the saving process for large files. However, it results in an increase in document size with each save.
When the document is saved to a new path, the PDF document will undergo non-incremental saving. This entails overwriting the entire document instead of appending changes at the end.
This example shows how to save a document by incremental saving and full saving :
java
// First, check if the document has been modified. If there are any changes, please save them.
if (document.hasChanges()) {
boolean res;
// Incrementally save the document object to the current path.
res = document.save();
// Save the document object to the specified path in a non-incremental manner; `isRemoveSecurity` indicates whether to remove the document's password.
//res = document.saveAs(uri, isRemoveSecurity);
}
// Close the document and release resources.
document.close();
kotlin
// First, check if the document has been modified. If there are any changes, please save them.
if (document.hasChanges()) {
// Incrementally save the document object to the current path.
val res = document.save()
// Save the document object to the specified path in a non-incremental manner; `isRemoveSecurity` indicates whether to remove the document's password.
// res = document.saveAs(uri, isRemoveSecurity)
}
// Close the document and release resources.
document.close()