Câu hỏi thường gặp — Aspose.PDF FOSS for Java

Câu hỏi thường gặp — Aspose.PDF FOSS for Java

Câu hỏi thường gặp

Phiên bản Java nào được yêu cầu?

Aspose.PDF FOSS cho Java yêu cầu Java 11 trở lên. Các bản phát hành JDK LTS (11, 17, 21) được khuyến nghị cho môi trường sản xuất.

Thư viện có miễn phí để sử dụng không?

Có. Aspose.PDF FOSS cho Java được cấp phép MIT. Không cần thỏa thuận thương mại, khóa API, hay kích hoạt.

Làm thế nào để thêm thư viện vào dự án Maven?

Thêm các mục sau vào pom.xml của bạn:

<dependency>
  <groupId>org.aspose</groupId>
  <artifactId>aspose-pdf-foss</artifactId>
  <version>26.8.0</version>
</dependency>

Làm thế nào để tạo một tài liệu PDF mới?

Sử dụng lớp Document mà không có đối số:

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

Làm thế nào để lấy số trang của tài liệu hiện có?

Mở tài liệu và gọi size() trên bộ sưu tập các trang:

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

Làm thế nào để nối hai tệp PDF lại với nhau?

Sử dụng PdfFileEditor.concatenate():

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

Làm thế nào để mã hóa một tệp PDF?

Sử dụng PdfFileSecurity từ gói facades với DocumentPrivilege và KeySize:

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

Làm thế nào để áp dụng mã hóa AES cho dữ liệu?

Sử dụng các phương thức tĩnh AESCipher cho việc mã hóa và giải mã AES ở mức byte thô:

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

Mã nguồn ở đâu?

Mã nguồn và hệ thống theo dõi lỗi có sẵn tại https://github.com/aspose-pdf-foss/Aspose.PDF-FOSS-for-Java.

Xem thêm

 Tiếng Việt