Render to PDF

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:

  1. Create an instance of the Viewer class. Specify the source document path as a constructor parameter.
  2. Instantiate the PdfViewOptions object. Specify a path to save the rendered file.
  3. Call the 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:

using GroupDocs.Viewer.Options;
using GroupDocs.Viewer;
// ...

using (Viewer viewer = new Viewer("sample.docx"))
{
	// Create a PDF file.
	PdfViewOptions viewOptions = new PdfViewOptions();
	viewer.View(viewOptions);
}
Imports GroupDocs.Viewer.Options
Imports GroupDocs.Viewer
' ...

Module Program
    Sub Main(args As String())
        Using viewer As Viewer = New Viewer("sample.docx")
            ' Create a PDF file.
            Dim viewOptions As PdfViewOptions = New PdfViewOptions()
            viewer.View(viewOptions)
        End Using
    End Sub
End Module

For details, please refer to the following pages: