• פעולות I/O

I/O דפוסים

Aspose.PDF FOSS for Java consistently accepts both file paths and Java streams as תוצאות ושימוש בכל ה-APIs העיקריים, כולל: Document, PdfFileEditor,וכל זה שיעורי פקסאד.

מסמך I/O

The Document הקורס מקבל קובץ מסלול או InputStream על הבניין שלו. The save() שיטת קבלת קובץ מסלול שורת או OutputStream.

// File path input
try (Document doc = new Document("input.pdf")) {
    doc.save("output.pdf");
}

// Stream input/output
try (Document doc = new Document(inputStream)) {
    doc.save(outputStream);
}

שני המפיקים להעלות את כל המסמך בזיכרון.למסמכים גדולים, להבטיח יש מספיק מקום או לשקול להשתמש בו. PdfFileEditor.setUseDiskBuffer(true).

PDFFileEditor תמיכה זרם

PdfFileEditor פעולות מקבלות שני קבצים של מסלולי קובץ ו- Java InputStream/OutputStream אובייקטים :

PdfFileEditor editor = new PdfFileEditor();
// All operations support both file paths and streams
editor.concatenate(new InputStream[]{s1, s2}, outputStream);
editor.extract(inputStream, 1, 3, outputStream);

בזיכרון צינורות

עבור צינורות זיכרון שמונעים קבצים זמניים, להשתמש ByteArrayOutputStream ל תסרוקת מסמך, ולאחר מכן קופצים עם ByteArrayInputStream עבור עיבוד Downstream:

ByteArrayOutputStream buffer = new ByteArrayOutputStream();
try (Document doc = new Document()) {
    doc.getPages().add();
    doc.save(buffer);
}
byte[] pdfBytes = buffer.toByteArray();
// Pass pdfBytes downstream — no temp file needed
ByteArrayInputStream next = new ByteArrayInputStream(pdfBytes);

פסיכומטרי I/O

כל המעמדות (לדוגמה,. PdfAnnotationEditor, PdfContentEditor, PdfFileSecurity) עקוב אחר אותו דפוס חיבור-פעולה-שמירה וקבל את מסלולי הקבצים, זרימים או Document האובייקט באמצעות bindPdf() שיטת.

ראה גם

 עברית