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

Free Support Forum - aspose.com

CSS is not applied after HTML to Image conversion using C#

Hi Aspose Team,

The requirement of my project is to convert the a html file to image files which look like the input html, including column display, font type, font style, etc

Can someone explain me how to achieve this with an example.

I have tried in several different ways but with no success.

It would be a great help for me if someone can explain with an example.

The sample code I am using is:

Aspose.Words.License license = new Aspose.Words.License();
license.SetLicense(@"C:\Jetstream\500\Resources\Aspose.Words.lic");

//load the html file into Aspose.Words
Aspose.Words.LoadOptions lo = new Aspose.Words.LoadOptions();
lo.LoadFormat = Aspose.Words.LoadFormat.Html;

Aspose.Words.Document doc2 = new Aspose.Words.Document(@" D:\test2.htm", lo);

//Convert the document to images
for (int pageCounter = 0, stop = doc2.PageCount; pageCounter < stop; pageCounter++)
{
Aspose.Words.Saving.ImageSaveOptions options2 = new Aspose.Words.Saving.ImageSaveOptions(SaveFormat.Png);
options2.PageIndex = pageCounter;
options2.PrettyFormat = true;
// images are of the format \<0-padded-page-index>.png, e.g. (somepath\myfile02.png)
doc2.Save(string.Format("{0}{1}{2}{3:d2}.png", "D:\\Aspose\\RDP\\NEWFiles\\Images\\", "", "MyImagetest", pageCounter + 1), options2);
}

Please let me know if you need more information.

Thanks,
Siddi.

Hi Siddi,

Please visit following forum link for your kind reference. Please use the latest version of Aspose.Words for .NET 11.0.0.