Rendering to PNG or JPEG
Contents
[
Hide
]Image Viewer provides PngViewOptions and JpgViewOptions classes to set specific options for rendering the document into desired image format.
Here are the steps for rendering documents into image with GroupDocs.Viewer API:
- Create new instance of Viewer class and pass source document path as a constructor parameter.
- Instantiate the PngViewOptions or JpgViewOptions object according to your requirements and specify saving path format for rendered document pages.
- Call View method of Viewer class instance and pass PngViewOptions or JpgViewOptions to it.
Rendering to PNG
This example shows how to render each document page into PNG image.
using (Viewer viewer = new Viewer("sample.docx"))
{
PngViewOptions viewOptions = new PngViewOptions();
viewer.View(viewOptions);
}
Rendering to JPEG
This example shows how to render each document page into JPG image.
using (Viewer viewer = new Viewer("sample.docx"))
{
JpgViewOptions viewOptions= new JpgViewOptions();
viewer.View(viewOptions);
}