You can load a document from a stream without saving it as a file on a disk. You can use this feature to load a document from different sources like a URL, FTP, and so on.
To load a document from a stream, follow these steps:
Implement a method to get the document stream.
Call the Viewer class constructor. Specify the method implemented in the previous step.
The following code snippet shows how to load a document from a stream:
fromgroupdocs.viewerimportViewerfromgroupdocs.viewer.optionsimportHtmlViewOptionsdefload_document_from_stream():# Open document streamstream=open("sample.docx","rb")# Render a document from the stream.withViewer(stream)asviewer:options=HtmlViewOptions.for_embedded_resources("page_{0}.html")viewer.view(options)if__name__=="__main__":load_document_from_stream()
sample.docx is the sample file used in this example. Click here to download it.
See also Load document from URL for a concrete example of downloading a document into a BytesIO stream and rendering it without ever writing it to disk.
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.
On this page
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.