The following code snippet shows how to load a document from a URL:
importrequestsimportiodefdownload_file(url):response=requests.get(url,stream=True,headers={"User-Agent":"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:25.0) Gecko/20100101 Firefox/25.0"},timeout=10)# Check if the request was successful (status code 200)response.raise_for_status()# Create a BytesIO stream from the contentstream=io.BytesIO(response.content)returnstreamurl="https://github.com/groupdocs-viewer/GroupDocs.Viewer-for-.NET/blob/master/Examples/GroupDocs.Viewer.Examples.CSharp/Resources/SampleFiles/sample.docx?raw=true";stream=download_file(url)withgv.Viewer(stream)asviewer:options=gvo.HtmlViewOptions.for_embedded_resources("page_{0}.html")viewer.view(options)
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.