I am using Aspose.Words for .NET to generate thumbnails for Microsoft Office docs. I am having trouble generating thumbnails for the word doc attached to this post. I am seeing the doc.Save(ms, options) call taking >10 minutes. Is there anything wrong with the below code? If so, do you have suggestions on ways to fix this issue?
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); //<— TIMES OUT HERE
result = Image.FromStream(ms);
}
return result;
}
Thanks for your inquiry. I have managed to reproduce the same issue at my side. I have logged this issue as WORDSNET-7242 in our issue tracking system. I have linked this forum thread to the same issue and you will be notified via this forum thread once this issue is resolved.
Is there anything specific about that document that we should avoid using? It would be nice to be able to have a thumbnail for that document until this bug is fixed.
Thanks for your inquiry. Currently, this issue is pending for analysis and is in the queue. Once this issue is analyzed, we will then be able to provide you detail of this issue.
I have a similar experience, but I would add something interesting. I am using Aspose.Words in a web context to render a single-page invoice to a PDF by doing a mail merge from a Word document as a template. I notice a more than 10 second delay specifically in the .Save() method. But then, if I click the button to render it again, the response is nearly instant. I can keep triggering it and getting these fast responses. But if I leave it again for a few minutes to do other work and come back for another print, the delay appears, again. I have two different Word templates I’m working with that display this same behavior.
At first I hypothesized that Aspose.Words might take a long time to process the license file and then cache that information for subsequent calls, but the slowdown occurs well after those lines of code. It’s also after loading the Word document and performing the mail merge. It’s definitely during the save that the bulk of the delay occurs. Might there be a curious permission issue that Aspose.Words is dealing with or some other inquiry to the operating system’s file system before it actually saves that causes the problem? Food for thought.
We are using a evaluation license for testing, but we are seeing the same thing as JimCarnicelli. We are working with some large documents with hundreds of bookmarks and it takes between 3 - 4 minutes for the document to save the first time on the server. Curiously, the delay is only a few seconds on a desktop system in the Visual Studio development environment.
We want to purchase Aspose Words in the next week or so, but I would love to see this issue resolved first.
Thanks for your inquiry. Could you please attach your input Word document here for testing? Please also share, which .NET framework version and Aspose.Words version you are using? I will investigate the issue on my side and provide you more information.
JimCarnicelli:
I have a similar experience, but I would add something interesting. I am using Aspose.Words in a web context to render a single-page invoice to a PDF by doing a mail merge from a Word document as a template.
Are you rendering the output PDF file in web browser?
Hi there,
We are using Aspose Words 11.5.0.0 and .Net framework 4.0. Our web application opens, updates and saves the Word doc on the server and then makes it available for download.
I have attached a sample document that has the issue.
Please let me know if you need any other information.
Thanks for sharing the document. I have tested the scenario and have not found the timing issue with Document.Save method while using latest version of Aspose.Words for .NET. As you shared that the Document.Save method take 3-4 minutes, the latest version is taking less than a second at my side with following code snippet. Please upgrade to the latest version of Aspose.Words i.e. v11.10.0 and let us know how it goes on your side. I hope, this will help.
I have another document that looks like it has the same issue. My code is still the same as my first post and it times out in the same place. I updated to the latest version of Aspose.Words and it still times out. I attached the document to this post.
Thanks for sharing the details. I have managed to reproduced the same issue at my side while using latest version of Aspose.Words for .NET. Unfortunately, this issue WORDSNET-7242 is not resolved yet. You will be notified via this forum thread once this issue is resolved.
Hi there,
We upgraded to v11.10.0 and are still seeing the VERY slow response (3 - 7 minutes) on the document save. This happens only on the server, but we have tested it on 2 different Win2008/64 servers and the result is the same. We are saving the document as a “.doc” file. We are not doing a “doc.updateFields()”, but otherwise our code is pretty much the same as what we posted.
Can you help ?
Thanks
*tahir.manzoor:
Hi Chris,
Thanks for sharing the document. I have tested the scenario and have not found the timing issue with Document.Save method while using latest version of Aspose.Words for .NET. As you shared that the Document.Save method take 3-4 minutes, the latest version is taking less than a second at my side with following code snippet. Please upgrade to the latest version of Aspose.Words i.e. v11.10.0 and let us know how it goes on your side. I hope, this will help.
Thanks for your inquiry. Unfortunately, your issue is not resolved yet. The problem do not exits with "SA-State-Form-BM.doc" file. However, the problem exits with other shared documents. We will update you via this forum thread once this issue is resolved.
Is there any update on this issue? I have upgraded to v11.11 and have found another document that has the same problem. I have attached it to this reply.
Thanks for your patience and sharing the another document.
I am afraid your issue has now been postponed till a later date due to some other important issues and new features. We will inform you as soon as there are any further developments.
Thanks for your inquiry. I have requested the development team to share the ETA of this issue. As soon as any information is shared by them, I will be more than happy to share that with you. We appreciate your patience.
jkschanke:
Also, if I may ask, what is more important than the functionality of your existing products?
We are considering to buy Aspose.Words (.Net),
however we are facing the slow performance when rendering the page as .png or pdf or even when retrieving the page count
the test.docx used is two simple pages and ran on C# .Net 4.5 Windows 8 Core i3 - 4GB RAM Solid state hard drive and it is taking around 2.5-3 seconds for this small docx.
- Time is measured only for the saving not for loading the docx
Any Help Please…
please find the code used
License L = new License();
Stream LicS = File.OpenRead( @"C:\Trials\Aspose.Words.lic");
L.SetLicense(LicS);
Stream stream = File.OpenRead(Loc + @"test.docx");
Document doc = new Document(stream);
stream.Close();
Console.WriteLine("Start Monitoring"); Console.ReadLine();
// Start Measuring Time
DateTime d1 = DateTime.Now;
var opt = new ImageSaveOptions(SaveFormat.Png);
opt.JpegQuality = 100;
opt.Resolution = 96;
opt.PageCount = 1;
opt.PageIndex = 1;
doc.Save(Loc + "test.png");
Console.WriteLine((DateTime.Now - d1).TotalMilliseconds);
Console.ReadLine();
Thanks for your inquiry. Perhaps, you are using an older version of Aspose.Words; as with Aspose.Words v13.9.0, I am unable to reproduce this problem on my side. The conversion of Docx to Pdf/Png takes less than a second at my side.
I would suggest you please upgrade to the latest version of Aspose.Words i.e. v13.9.0 and let us know how it goes on your side. I hope, this will help.