We are trying to convert a HTML file to an PDF following the instructions found on this link :
However we noticed that CSS is not done correctly.
This is the code we use to generate the PDF file :
Dim p As New Pdf
p.HtmlInfo.ImgUrl = HttpContext.Current.Server.MapPath(“…/images/”)
p.HtmlInfo.ExternalResourcesBasePath = HttpContext.Current.Server.MapPath(“…/styles/”)
Dim sect As Section = p.Sections.Add
Dim r As StreamReader = File.OpenText(HttpContext.Current.Server.MapPath(“…/templates/templatetest.html”))
Dim text As Text = New Text(sect, r.ReadToEnd())
text.IsHtmlTagSupported = True
text.IsFitToPage = True
sect.Paragraphs.Add(text)
p.Save(HttpContext.Current.Server.MapPath(“…/”) & “/test” & Date.Now.Hour & Date.Now.Minute & Date.Now.Second & “.pdf”)
Just a quick straightforward test as you could see.
Images are correctly displayed, However the CSS is almost completely ignored.
The isFitToPage method looks to be ignored too.
I’ve included the templatetest.html, styles.css and images and the generated PDF file in a ZIP file so you could reproduce the problem.
Could you have a look into these problems ?