I have a 60 pages word document. When i get the total pages of this document, it show me 57 pageCount. When i convert it into image. It come out with 57 images only. What I found out is that some pages contents has been "squeeze" into one page. For example: content in page 4 is just few line text, when convert it into image, the content will "squeeze" to page 3. So how am i suppose to do so that I can get the exactly same amount of pages as the original file when get the page count and images.
This is my code:
//to get total pages
using (Spire.Doc.Document document = new Spire.Doc.Document())
{
document.LoadFromFile(source, Spire.Doc.FileFormat.Auto);
pageNumber = document.PageCount;
}
//convert to images
using (Spire.Doc.Document document = new Spire.Doc.Document())
{
document.LoadFromFileInReadMode(file, Spire.Doc.FileFormat.Docx);
Image[] images = document.SaveToImages(fromPage, toPage, Spire.Doc.Documents.ImageType.Bitmap);
int i = 1;
foreach (Image img in images)
{
var target = path + Path.DirectorySeparatorChar + "Page_" + i.ToString();
var pngTarget = Path.ChangeExtension(target, "png");
img.Save(pngTarget, System.Drawing.Imaging.ImageFormat.Png);
imageList.Add(pngTarget);
i++;
}
}