عمليات الإدخال والإخراج

عمليات الإدخال والإخراج

أنماط الإدخال والإخراج

Aspose.PDF FOSS for Java consistently accepts both file paths and Java streams as المدخلات والخروج في جميع واجهات برمجة التطبيق الرئيسية، بما في ذلك: Document, PdfFileEditor,وكل شيء فصول الواجهة.

وثيقة إدخال/إخراج

المجلس الوزاري Document القسم يقبل خط مسار ملف أو صفحة المعلومات. InputStream في بناءه. المجلس الوزاري 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 Stream

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 للتجهيز في التدفق:

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);

إدخال/إخراج الجبهة

جميع فئات الواجهة (مثل:. PdfAnnotationEditor, PdfContentEditor, PdfFileSecurity) اتبع نفس نمط الربط - التشغيل- الحفاظ على وقبول مسارات الملفات، والتيار، أو a Document المادة عبرهم bindPdf() طريقة.

انظر أيضا

 العربية