We have an application which converts each page of word file into images. Our goal is to generate three different size of images for each page. Below is the code which accomplished the above requirement.
//initializing Aspose License for word application.
License license = new AsposeWord.License();
//initialize Aspose object for word application
Document doc = new AsposeWord.Document(sourcePath);
//fetch filename without extension
//define the image extension that needs to be considered as base for resizing.
//finding the number of pages in word template.
int numberOfPages = doc.PageCount;
//initializing Aspose word document builder object for finding orientation.
DocumentBuilder docBuilder = new AsposeWord.DocumentBuilder(doc);
orientation = docBuilder.PageSetup.Orientation.ToString();
//defining the options of image format
ImageSaveOptions options = new Aspose.Words.Saving.ImageSaveOptions(AsposeWord.SaveFormat.Bmp);
int imgCounter = 0;
//if temp folder directory doesn't exist create one.
tempFolderPath = CreateTargetDirectories(tempFolderPath);
//looping through first page of word document to create thumbnail.
//this can be modified to loop through all pages if thumbnail generation require for further pages.
for (int i = 0; i < 1; i++)
options.PageIndex = i;
options.PageCount = 1;
//saving first page of word document as a temporary bmp file in temporary folder
@"\" + fileName + "_Bmp" + ++imgCounter + imageFileExtension, options);
However the above code piece results into bad image output which has either text truncated or document images misplaced on the Output Image. See attached documents.
Please provide a fix for this.