Skip to main content

SaveMode Enum

Lists save modes for documents that contain signatures.

Declaration

public enum SaveMode extends Enum<SaveMode> implements IIntEnum

Members

Name Description
AUTO

If the document is loaded from a stream or channel and contains signatures or pending signatures, the API saves changes as an incremental update. Otherwise, the API rewrites the document.

REWRITE

The API rewrites the entire document with all changes and then applies pending signatures.

fromValue(int value)

Returns the SaveMode enumeration constant with the specified integer value.

getName()

Returns the name of the SaveMode enumeration constant.

getValue()

Returns the integer value of the SaveMode enumeration constant.

toString()

Returns the string representation of the SaveMode enumeration constant.

valueOf(String name)

Returns the SaveMode enumeration constant with the specified name.

values()

Returns an array of all SaveMode enumeration constants.

Remarks

Call the SaveOptions.getSaveMode() method to get the save mode. Call the SaveOptions.setSaveMode(value) method to specify how the API saves a document that contains signatures.

Refer to the following help topic for additional information: Sign PDF Documents — PDF Document API for Java.

Example

Sign a PDF Document and Rewrite the Entire Document

The following code snippet signs an existing signature field and rewrites the entire document:

import java.io.*;
import java.nio.file.*;
import com.devexpress.docs.pdf.*;

public class Main {
    public static void main(String[] args) throws Exception {
        try (InputStream inputStream = Files.newInputStream(Path.of("Document.pdf"));
             PdfDocument pdfDocument = new PdfDocument(inputStream);
             InputStream certificateStream = Files.newInputStream(Path.of("certificate.pfx"))) {
            if (pdfDocument.getFields().findByName("Signature1") instanceof SignatureField signatureField
                    && !signatureField.getIsSigned()) {
                SignatureOptions options = new SignatureOptions();
                options.setCertificate(certificateStream, "CERTIFICATE_PASSWORD");
                options.setReason("Approved");
                pdfDocument.addSignature(signatureField, options);

                SaveOptions saveOptions = new SaveOptions();
                saveOptions.setSaveMode(SaveMode.REWRITE);

                Files.createDirectories(Path.of("output"));
                try (OutputStream outputStream = Files.newOutputStream(Path.of("output", "Document.pdf"))) {
                    pdfDocument.save(outputStream, saveOptions);
                }
            }
        }
    }
}

Implements

com.devexpress.java.enums.IIntEnum

Inherited Members

java.lang.Enum.<T>valueOf(java.lang.Class<T>,java.lang.String)
java.lang.Enum.clone()
java.lang.Enum.compareTo(E)
java.lang.Enum.describeConstable()
java.lang.Enum.equals(java.lang.Object)
java.lang.Enum.finalize()
java.lang.Enum.getDeclaringClass()
java.lang.Enum.hashCode()
java.lang.Enum.name()
java.lang.Enum.ordinal()
java.lang.Enum.toString()
java.lang.Object.getClass()
java.lang.Object.notify()
java.lang.Object.notifyAll()
java.lang.Object.wait()
java.lang.Object.wait(long)
java.lang.Object.wait(long,int)

Inheritance

Object
java.lang.Enum
SaveMode