Support Center

Saving document to image file

When saving a DocumentModel to an image file, we use an ImageSaveOptions to specify various options for the resulting image.

When using a default options, the resulting image file will contain the first document's page content; this is because the default value of the ImageSaveOptions.PageNumber property is 0.
We can use this property in order to save each page as a separate image; the following is a demonstration sample that uses this "Sample.docx" as an input file:

C# code

DocumentModel document = DocumentModel.Load("Sample.docx");
ImageSaveOptions options = new ImageSaveOptions(ImageSaveFormat.Png);
int pageCount = document.GetPaginator().Pages.Count;
for (int i = 0; i < pageCount; i++)
    options.PageNumber = i;
    document.Save(string.Format("SamplePage{0}.png", i), options);

VB.NET code

Dim document As DocumentModel = DocumentModel.Load("Sample.docx")
Dim options As New ImageSaveOptions(ImageSaveFormat.Png)
Dim pageCount As Integer = document.GetPaginator().Pages.Count
For i As Integer = 0 To pageCount - 1
    options.PageNumber = i
    document.Save(String.Format("SamplePage{0}.png", i), options)

The following are the resulting "SamplePageX.png" files:

SamplePage0.png SamplePage1.png SamplePage2.png

Also if we want to create a single image that will contain all the document's pages, we can save each document's page into a Tiff frame, thus creating a single TIFF image file:

C# code

DocumentModel document = DocumentModel.Load("Sample.docx");
ImageSaveOptions options = new ImageSaveOptions(ImageSaveFormat.Tiff);
options.PageCount = int.MaxValue;
document.Save("Sample.tiff", options);

VB.NET code

Dim document As DocumentModel = DocumentModel.Load("Sample.docx")
Dim options As New ImageSaveOptions(ImageSaveFormat.Tiff)
options.PageCount = Integer.MaxValue
document.Save("Sample.tiff", options)

The following are the resulting "Sample.tiff" file's frames:

Sample.tiff Frame 1 Sample.tiff Frame 2 Sample.tiff Frame 3

2 of 2 people found this page helpful
Subscribe to this article to get an email notification when it is updated.


  • How do I set the resolution (e.g. to 300dpi)?
  • Hi,

    Currently GemBox.Document does not provide an API for setting the resolution, but note that internally it uses a 300 DPI.
    Nevertheless if interested please feel free to create a new GemBox.Document Feature Request on our feedback page, but at this moment I cannot tell you exactly when it will be implemented.


    Gemmeus d.o.o.
  • Hi, We are also hoping to be able to produce a higher resolution TIFF image using the Document Save options - are you able to provide an update on when this feature may be implemented?