Render to PDF
Leave feedback
When rendering to PDF, GroupDocs.Viewer renders all pages of the source document as a single PDF document.
To render files to PDF, follow these steps:
- Create an instance of the Viewer class. Specify the source document path as a constructor parameter.
- Instantiate the PdfViewOptions object. Specify a path to save the rendered file.
- Call the View.view() method of the Viewer object. Specify the PdfViewOptions object as the parameter.
The following code snippet shows how to render a .docx document to PDF:
with gv.Viewer("sample.docx") as viewer:
pdf_options = gvo.PdfViewOptions("output-to-pdf.pdf")
viewer.view(pdf_options)
print(f"\nSource document rendered successfully.")
For details, please refer to the following pages:
- Reorder pages
- Protect PDF document
- Specify the JPEG image quality
- Set image size limits
- Optimize the output PDF file
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.