A “Hello, World!” example is often the first step when exploring GroupDocs.Viewer for Python via .NET. It serves as a simple test to confirm that your development environment is correctly set up and that the library is functioning as expected.
Overview
GroupDocs.Viewer for Python via .NET renders documents to HTML, PDF, PNG, and JPEG without Microsoft Office or any other software. A wide range of supported formats makes it versatile for different use cases.
How to render a document
The following steps render a Word document to a PDF file:
Import Viewer and the view options of the output you need, here PdfViewOptions.
Instantiate a Viewer with the path to the sample document.
Create the view options with the output file name.
Call view() with the options.
Complete example
The example below renders the five pages of the sample annual report into one PDF file:
fromgroupdocs.viewerimportViewerfromgroupdocs.viewer.optionsimportPdfViewOptionsdefhello_world():# Load the documentwithViewer("sample.docx")asviewer:# Render every page into one PDF fileviewer.view(PdfViewOptions("output.pdf"))print("Document rendered successfully. Output saved to output.pdf.")if__name__=="__main__":hello_world()
sample.docx is the sample file used in this example. Click here to download it.
To render to HTML pages or page images instead, replace PdfViewOptions with HtmlViewOptions.for_embedded_resources("page_{0}.html") or PngViewOptions("page_{0}.png"); {0} is replaced with the page number. The Quick Start Guide shows all three.
Without a license, the PDF has two pages, each with an evaluation notice. See Licensing and Evaluation.
Additional resources
This demo references the GroupDocs.Viewer for Python via .NET code samples.
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
Ask AI
Ask anything about this page — the answer is based on its content.
Searching the docs and writing an answer…
Something went wrong while getting an answer. Please try again in a moment.