HtmlArea ignores style and css attributes

HtmlArea ignores style and css attributes

Forum member · Mar 8, 2021
I'm attempting to use an HtmlArea with some html text. The html tags are rendered, but my style attributes are ignored. Is this by design? I've attempted to use font-size, border, color, margin, etc. all to no avail. I've also attempted to use a <style> tag and the class attribute. Same result. Here's some sample code: var html = "<style='font-size:50px'>Header Goes Here'>"; var htmlArea = new HtmlArea(html, 0, 0, 500, 500); page.Elements.Add(htmlArea); document.Draw("Output.pdf"); Any suggestions on how to get it to recognize style?

Re: HtmlArea ignores style and css attributes

Support · Mar 9, 2021
Hello, It looks like there is a syntax issue in your example. You can set an inline style or use the style tag to specify properties for specific tags. Here is a sample: Document document = new Document(); Page page = new Page(); document.Pages.Add(page); //Using inline style tag //var html = "<p style=\"color:red; font-size:50px \">This is a paragraph.</p>"; //Using a style tag var html="<html>"+ "<head>"+ "<style>"+ "h1 {color:red;}"+ "p {color:blue;}"+ "</style>"+ "</head>"+ "<body>"+ "<h1>A heading</h1>"+ "<p>A paragraph.</p>"+ "</body>"+ "</html>"; var htmlArea = new HtmlArea(html, 0, 0, 500, 500); page.Elements.Add(htmlArea); String output = "C:/Temp/MyDocument.pdf"; document.Draw(output); Thanks, ceTe Software Support Team