Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save conholdate-gists/fac76ac0298ae74b40a0be81e7370bed to your computer and use it in GitHub Desktop.
Save conholdate-gists/fac76ac0298ae74b40a0be81e7370bed to your computer and use it in GitHub Desktop.
Convert Word Document DOC DOCX to JPG PNG Image in C# .NET
// Load the input Word document
Aspose.Words.Document doc = new Aspose.Words.Document("Words.docx");
// Initialize an object of ImageSaveOptions class
Aspose.Words.Saving.ImageSaveOptions options = new Aspose.Words.Saving.ImageSaveOptions(Aspose.Words.SaveFormat.Jpeg);
// Set the "PageSet" to "0" to convert only the first page of a document.
options.PageSet = new Aspose.Words.Saving.PageSet(0);
// Set the image's brightness and contrast.
options.ImageBrightness = 0.3f;
options.ImageContrast = 0.7f;
// Set the horizontal resolution.
options.HorizontalResolution = 72f;
// Save output JPG image
doc.Save("Word-to-JPG.jpg", options);
// Load the input Word document
Aspose.Words.Document doc = new Aspose.Words.Document("Words.docx");
// Initialize an object of ImageSaveOptions class
Aspose.Words.Saving.ImageSaveOptions options = new Aspose.Words.Saving.ImageSaveOptions(Aspose.Words.SaveFormat.Png);
// Set the horizontal resolution.
options.HorizontalResolution = 72f;
// Save output PNG image
doc.Save("Word-to-PNG.png", options);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment