Html to PDF manage font size, font family. etc

Hi.
I have a html string for PDF content. It looks different from browser. To manage pdf content, font family, font weight, size. What’s the better place to control this. Is it better in html like inline style/import css. Or using AspPose.Document.HtmlLoadOptions.

Thank you

@pxie0705

Would you kindly share sample HTML in .zip format along with your expected output PDF for our reference? We will test the scenario in our environment and address it accordingly.

Thank you.
Here are my html string which includes inline style for header and footer.
.Downloads.zip (69.0 KB)
and here is my code snippet
image.png (65.5 KB)
it seems there are many places to control style/font… What’s the best practice to control style.
in my case

  • inline style in html string
  • HtmlFragment.TextState
  • HtmlFragment.PageInfo.DefaultTextState
  • Document.LoadOption
    Does it take any order?

@pxie0705

We are checking it and will get back to you shortly.

@pxie0705

In order to get expected results, you use inline styling as well as specify an external CSS file. However, in case you are using an external CSS file in the <head> tag, you will need to specify the path to CSS file in HtmlLoadOptions like below:

HtmlLoadOptions options = new HtmlLoadOptions("Path to CSS file and other resources like images");

Please also note that you can specify HtmlLoadOptions() for HtmlFragment as well.