We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

doc.PageCount changed when doc.save

Hi Aspose,
When I loaded and processed hang.html using Aspose words to create jpg image, “doc.PageCount” changed when i call doc.save. As a result, a lot of duplicate image is created.
I attached sample.zip and this worked fine with firefox. I used
Aspose Word (16.8.0).
NOTE: It’s INFECTED html
My code is:

HtmlLoadOptions loadOption = new HtmlLoadOptions();
loadOption.WebRequestTimeout = 60000;
//Clean outputFile
Document doc = new Document(inputFile, loadOption);
Aspose.Words.Saving.ImageSaveOptions options;
options = new Aspose.Words.Saving.ImageSaveOptions(Aspose.Words.SaveFormat.Jpeg);
options.PageCount = 1;
for (int i = 0; i < doc.PageCount; i++) // doc.PageCount CHANGED THERE
{
options.PageIndex = i;
string pageName = “Page” + “_” + (i + 1) + “.jpg”;
doc.Save(pageName, options);
}

Please help.

Hi there,

Thanks for your inquiry. Unfortunately, we cannot download the infected document. Microsoft Security Essential stops the shared .zip file from downloading. Could you please attach virus free document for testing? We will investigate the issue on our side and provide you more information.

Sorry but i need to process that INFECTED HTML, can you setup virtual machine to test it?

Hi there,


Thanks for your inquiry. In your case, we suggest you please use following code example to convert each document’s page to Jpeg file format.

We noticed that Aspose.Words hangs while importing the shared html into its DOM. We have logged this issue as WORDSNET-14221.

We saved the shared html to disk and tested the shared scenario and have noticed that the images are duplicated in output Jpeg. We have logged this problem in our issue tracking system as and WORDSNET-14222. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.



Document doc = new Document(MyDir + @“in.docx”);

ImageSaveOptions opts = new ImageSaveOptions(SaveFormat.Jpeg);<o:p></o:p>

opts.PageIndex = 0;<o:p></o:p>

opts.PageCount = doc.PageCount;<o:p></o:p>

opts.PageSavingCallback = new HandlePageSavingCallback();<o:p></o:p>

doc.Save(MyDir + @“16.8.0.Jpeg”, opts);<o:p></o:p>


private class HandlePageSavingCallback : IPageSavingCallback<o:p></o:p>

{<o:p></o:p>

public void PageSaving(PageSavingArgs args)<o:p></o:p>

{<o:p></o:p>

args.PageFileName = string.Format(MyDir + @“Page_{0}.Jpeg”, args.PageIndex);

}<o:p></o:p>

}

Hi there,

Thanks for your patience. It is to inform you that our product team has completed the work on issue (WORDSNET-14221) and has come to a conclusion that this issue is not a bug in Aspose.Words. So, we have closed this issue as 'Not a Bug'. The original file contains many external resources and Aspose.Words takes time while tries to download them.

Regarding WORDSNET-14222, we will inform you via this forum thread once there is any update available on this issue.

The issues you have found earlier (filed as WORDSNET-14221) have been fixed in this Aspose.Words for .NET 16.11.0 update and this Aspose.Words for Java 16.11.0 update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.

The issues you have found earlier (filed as WORDSNET-14222) have been fixed in this Aspose.Words for .NET 17.1.0 update and this Aspose.Words for Java 17.1.0 update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.