Last active
April 26, 2019 15:58
-
-
Save GroupDocsGists/c659d025f32d195ad2ccf9263c531768 to your computer and use it in GitHub Desktop.
Getting Image Previews using GroupDocs.Metadata
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/groupdocs-metadata/GroupDocs.Metadata-for-.NET | |
using (PreviewHandler handler = PreviewFactory.Load("sample.docx")) | |
{ | |
// loop through the document pages | |
for (int i = 0; i < handler.Pages.Length; i++) | |
{ | |
// get preview images | |
PreviewImageData[] pagePreviews = handler.GetPageImage(i); | |
for (int j = 0; j < pagePreviews.Length; j++) | |
{ | |
// save images | |
File.WriteAllBytes(string.Format(@"D:\Documents\Previews\{0}-{1}.png",i, j), pagePreviews[j].Contents); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/groupdocs-metadata/GroupDocs.Metadata-for-Java | |
try (PreviewHandler handler = PreviewFactory.load("sample.docx")) | |
{ | |
// loop through the document pages | |
for (int i = 0; i < handler.getPages().length; i++) | |
{ | |
// get preview images | |
PreviewImageData[] pagePreviews = handler.getPageImage(i); | |
for (int j = 0; j < pagePreviews.length; j++) | |
{ | |
// save images | |
try (FileOutputStream stream = new FileOutputStream("D:\\Documents\\Preview\\" + i + "-" + j + ".png")) | |
{ | |
pagePreviews[j].writeTo(stream); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment