Generating Images from

Hi,

We are using Aspose.Words for .NET to generate thumbnails for word documents. For some of our document we are seeing different results than we would expect. I have attached the word doc and an example picture of what the thumbnail looks like. I have tried this using both v11.7 and v11.9 and the result is the same in both.

I know it’s something specific to this document. When viewing the word doc in the web layout, it shows as one continuous document, but when viewing it in the print layout, the bottom half of the page is empty. It looks like the bottom half of the page being empty is causing the thumbnail to only contain the top part of the page.

Thanks for any help you can offer,

Josh

Hi Josh,

Thanks for your inquiry. Well, please note that Html based formats are not paginated that is why when you view the Word document in the web layout, it shows as one continuous document. May be in this case, you can alter the PageHeight to a much higher value to be able to decide on what content of Word document you would like to be rendered as Png thumbnail:

Document doc = new Document(@"C:\Temp\May_LWWW_Email.doc");
PageSetup ps = doc.FirstSection.PageSetup;
// Set the height to be 22 inches tall
ps.PageHeight = 22 * 72;
doc.Save(@"C:\Temp\out.png");

Best regards,

Was there any point in the past where documents like this showed as a complete thumbnail as taken from the web layout? I thought this had worked sometime in the past year or so. We have been using the below code since March 2012 and we currently have documents that were saved previously in this format that do have a full thumbnail. I’ll try and figure out which version we were using and let you know.

The resolution is passed in as 120 and the startpage is 1.

public Image CreateThumbnail(byte[] file, int resolution, int startPage, int numberOfPages)
{
    Document doc = new Document(new MemoryStream(file));

    ImageSaveOptions options = new ImageSaveOptions(SaveFormat.Png);
    options.PageCount = numberOfPages;
    options.PageIndex = startPage - 1;
    options.Resolution = resolution;

    Image result = null;
    using (MemoryStream ms = new MemoryStream())
    {
        doc.Save(ms, options);

        result = Image.FromStream(ms);
    }

    return result;
}

Would switching this to use the FirstSection.PageHeight affect thumbnails generated for normal word documents?

P.S. Sorry for forgetting to finish my thought in the subject of the post. I was doing too many things at once yesterday.

Hi Josh,

Thanks for your inquiry. Could you please provide a little more information about the Aspose.Words’ version number for which there were no problems on your side previously? I will further look into the details of this problem and will keep informed of my findings.

Best regards,

I was wrong about it working in the past. I saw a few that looked correct in our production environment and thought they were generated thumbnails, but it looks like they were manually uploaded thumbnails from a screenshot or something.

Thanks for the help. I think we’ll just go with manually updating the thumbnails for these html versions of our documents for now. We don’t have very many anyway.

Hi Josh,

Thank you for your understanding. If we can help you with anything else, please feel free to ask. We are always glad to help you.

Best regards,