Difference in image output for html files between Aspose versions

We use Aspose.Words to convert html files to images. We recently moved from version 17.3 to 18.10 and noticed the images are different between the two releases. I can provide a lot more detail but here is a code snippet that resembles the code we use:

var directory = args[0];
var sourceFileName = args[1];

			using (var fileStream = Assembly.GetExecutingAssembly()
				.GetManifestResourceStream($"AsposeWordsTiffTest.TestFiles.{sourceFileName}"))
			{
				var asposeDocument = new Document(fileStream);

				for (var i = 0; i < asposeDocument.PageCount; i++)
				{
					var saveOptions = new ImageSaveOptions(SaveFormat.Tiff)
					{
						PageIndex = i,
						PageCount = 1,
						Resolution = 200,
						TiffCompression = TiffCompression.Ccitt4,
					};

					var file = Path.Combine(directory, $"{sourceFileName}_{i}.tif");
					asposeDocument.Save(file, saveOptions);
				}
			}

I can send a VS solution and example html files that generate images that differ between the version if necessary. Thanks in advance.

@thayesxx

Thanks for your inquiry. Please ZIP and attach the following resources here for testing.

  • Input file(s).
  • output file(s) showing undesired behavior.
  • working source code to reproduce this issue.

We will then investigate the issue on our end and provide you more information.

P.S. If your file size is big then you may upload the ZIP file to Dropbox or any other file hosting service and share the download link here for testing.

Summary

I have attached zip AsposeWordsTiffTest.zip. If you open zip and navigate to AsposeWordsTiffTest.zip\AsposeWordsTiffTest you will see a AsposeReadme.docx. The dlls and license files used for testing are located in AsposeWordsTiffTest\packages. Let me know if you have questions

@thayesxx

Unfortunately, we have not found the attachment with your post. Please attach it again.
Thanks for your cooperation.

They are in the zip see AsposeWordsTiffTest.zip\AsposeWordsTiffTest\AsposeWordsTiffTest\TestFiles

there are two files: HTML embedded.html and TooLongEmbedded.html

@thayesxx

I am afraid, we do not see any attachments in this thread. If your file size is big then you may upload the ZIP file to Dropbox or any other file hosting service and share the download link here for testing.

Also, please try the latest version of Aspose.Words for .NET i.e. 18.12 and let us know how it goes on your side.

Apparently your upload function does not work for larger zips. I uploaded a zip and a full vs studio solution and I guess you did not get it.

I also attached the program.cs in a zip and another one with the html files.

Please confirm receipt of the zips and then I will upload more.

Program.zip (684 Bytes)
html files.zip (9.3 KB)

@thayesxx

Thanks for sharing required files. We have received Zips of program.cs and HTML files. Please also share output file(s) showing undesired behavior. Thanks for your cooperation.

Attached is the output zip.output.zip (90.9 KB)

@thayesxx

Thanks for your inquiry. We have tested the scenarios and have managed to reproduce the same issues at our side. For the sake of correction, we have logged these problems in our issue tracking system as

WORDSNET-17907 : Table is rendered improperly during HTML to TIFF conversion
WORDSNET-17908 : Table width is incorrect in rendered TIFF

You will be notified via this forum thread once these issues are resolved.

We apologize for your inconvenience.

Great. What is the eta on these tickets?

@thayesxx

I am afraid, there is no ETA (time frame) available at the moment. We will inform you via this thread as soon as any estimates or further updates are available. We apologize for your inconvenience.

Given that there is no ETA on these issues. Is there a recommended way to run two different versions of aspose (in this case use an older version of Aspose.Words) at the same time?

Tim

@thayesxx

Thanks for your inquiry.

Please note that Aspose.Words mimics the behavior of MS Word. If you open the HTML in MS Word, the table is rendered outside the page. Please check the attached screenshot.

To get the desired output, please use the Table.PreferredWidth property as shown below. Hope this helps you. This is not a bug in Aspose.Words. So, we have closed it.

var doc = new Document(MyDir + "TooLongEmbedded.html");

foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
{
    table.PreferredWidth = PreferredWidth.FromPercent(100);
}

ImageSaveOptions options = new ImageSaveOptions(SaveFormat.Tiff);
options.PageSavingCallback = new HandlePageSavingCallback();
options.PageCount = doc.PageCount;
options.PageIndex = 0;
options.Resolution = 900;
options.TiffCompression = TiffCompression.Ccitt4;

doc.Save(MyDir + "Out.tiff", options);

private class HandlePageSavingCallback : IPageSavingCallback
{
    public void PageSaving(PageSavingArgs args)
    {
        args.PageFileName = string.Format(MyDir + @"Page_{0}.tiff", args.PageIndex);
    }
}

Regarding WORDSNET-17907, we will share our findings with you shortly.

@thayesxx

It is to inform you that the issue which you are facing is actually not a bug in Aspose.Words. So, we have closed this issue (WORDSNET-17907) as ‘Not a Bug’.

You can use following code example to get the desired output. Hope this helps you.

var doc = new Document(MyDir + "HTML_embedded.html");
doc.FirstSection.PageSetup.Orientation = Orientation.Landscape;
foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
{
    table.PreferredWidth = PreferredWidth.FromPercent(100);
    table.LeftPadding = 5;
    foreach (Cell cell in table.GetChildNodes(NodeType.Cell, true))
    {
        cell.CellFormat.FitText = true;
    }
}
doc.UpdatePageLayout();
ImageSaveOptions options = new ImageSaveOptions(SaveFormat.Tiff);
options.PageSavingCallback = new HandlePageSavingCallback();
options.PageCount = doc.PageCount;
options.PageIndex = 0;
options.Resolution = 900;
options.TiffCompression = TiffCompression.Ccitt4;

doc.Save(MyDir + "Out.tiff", options);

Thanks for you feedback on code changes. Can you explain why between versions 17.3 to 18.10 of Aspose.Words I get different image results with my original code?

Tim

@thayesxx

Thanks for your inquiry. The latest version of Aspose.Words for .NET 19.1 generates the correct output. Could you please share your expected output documents here for our reference? We will then provide you more information about your query.

Earlier in this post I provided html files (html files.zip)that you can use as input and compare output images between 17.3 and19.x along with test code.

Tim

@thayesxx

Thanks for your inquiry. As shared earlier, Aspose.Words mimics the behavior of MS Word.

Please share the screenshot of problematic sections of output document along with your desired output. We will investigate the issue and provide you more information about your query.

Here is a side by side comparison using BeyondCompare of the tiffs.

image.png (91.2 KB)

I uploaded a zip with output from 17.x and 18.x.

Aspose17-18Output.zip (90.9 KB)

Let me know if you need anything else.