First of all, I apologise for my bad English. The css does not work when reading string from html file and converting it to pdf. There is no problem in your online file conversion when converting from html to pdf.
Here are my codes. My sample html file and the resulting pdf file. xxx.zip (38.4 KB)
var html1 = File.ReadAllText(@“xxx.html”);
var stream = new MemoryStream(Encoding.UTF8.GetBytes(html1));
byte[] result = Array.Empty();
var loadOptions = new GroupDocs.Conversion.Options.Load.WebLoadOptions
{
Format = WebFileType.Html,
};
using (var converter = new GroupDocs.Conversion.Converter((() => stream, () => loadOptions))
{
licence license = new License();
license.SetLicense(@“GroupDocs.Total.NET.lic”);
PdfConvertOptions options = new PdfConvertOptions();
converter.Convert(() => new MemoryStream(), (page, fileType, convertedStream) =>
{
var memoryStream = new MemoryStream();
convertedStream.CopyTo(memoryStream);
result = memoryStream.ToArray();
}, options);
}