Load And Save To Stream in Python

Aspose.Words - Load And Save To Stream

Python Code

Document =jpype.JClass("com.aspose.words.Document")
FileInputStream = jpype.JClass("java.io.FileInputStream")
FileOutputStream = jpype.JClass("java.io.FileOutputStream")
ByteArrayOutputStream = jpype.JClass("java.io.ByteArrayOutputStream")
SaveFormat = jpype.JClass("com.aspose.words.SaveFormat")
\# Open the stream. Read only access is enough for Aspose.Words to load a document.
stream = FileInputStream(srcDocFile)
\# Load the entire document into memory.
doc = Document(stream)
\# You can close the stream now, it is no longer needed because the document is in memory.
\# ... do something with the document
\# Convert the document to a different format and save to stream.
dstStream = ByteArrayOutputStream()
doc.save(dstStream, SaveFormat.RTF)
output = FileOutputStream(outputRtfFile)

Download Running Code

Download Load And Save To Stream (Aspose.Words) from any of the below mentioned social coding sites: