FAQ — Aspose.PDF FOSS for Java

What Java version is required?

Aspose.PDF FOSS for Java requires Java 11 or later. JDK LTS releases (11, 17, 21) are recommended for production use.

Is the library free to use?

Yes. Aspose.PDF FOSS for Java is MIT-licensed. No commercial agreement, API key, or activation is required.

How do I add the library to a Maven project?

Add the following to your pom.xml:

<dependency>
  <groupId>org.aspose</groupId>
  <artifactId>aspose-pdf</artifactId>
  <version>0.1.0-alpha</version>
</dependency>

How do I create a new PDF document?

Use the Document class with no arguments:

try (Document doc = new Document()) {
    doc.getPages().add();
    doc.save("output.pdf");
}

How do I get the page count of an existing document?

Open the document and call size() on the pages collection:

try (Document doc = new Document("input.pdf")) {
    int count = doc.getPages().size();
}

How do I concatenate two PDF files?

Use PdfFileEditor.concatenate():

PdfFileEditor editor = new PdfFileEditor();
editor.concatenate("first.pdf", "second.pdf", "merged.pdf");

How do I encrypt a PDF?

Use PdfFileSecurity from the facades package with DocumentPrivilege and KeySize:

try (PdfFileSecurity security = new PdfFileSecurity("input.pdf", "secured.pdf")) {
    DocumentPrivilege priv = DocumentPrivilege.getForbidAll();
    priv.setAllowPrint(true);
    security.encryptFile("user", "owner", priv, KeySize.x256);
}

How do I apply AES encryption to data?

Use AESCipher static methods for raw byte-level AES encryption and decryption:

byte[] ciphertext = AESCipher.encrypt(key, plaintext);
byte[] decrypted  = AESCipher.decrypt(key, ciphertext);

Where is the source code?

The source code and issue tracker are available at https://github.com/aspose-pdf-foss/Aspose.PDF-FOSS-for-Java.

See Also