I/O ऑपरेशन

I/O पैटर्न

Aspose.PDF FOSS for Java consistently accepts both file paths and Java streams as सभी प्रमुख एपीआई में आयात और उत्पादन, जिसमें शामिल हैं Document, PdfFileEditor,और सबके फ़ैक्साड क्लास.

दस्तावेज I/O

के लिए 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 स्ट्रीम समर्थन

PdfFileEditor ऑपरेशन दोनों फ़ाइल मार्ग तारों और जावा को स्वीकार करते हैं 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);

फ़ैक्साड I/O

सभी वर्गों (जैसे कि. PdfAnnotationEditor, PdfContentEditor, PdfFileSecurity) एक ही बंड-ऑपरेट-सहेजें पैटर्न का पालन करें और फ़ाइल मार्गों, स्ट्रीम या एक को स्वीकार करें Document उनके माध्यम से वस्तुओं के लिए bindPdf() तरीके से।.

See Also

 हिन्दी