I tried to convert html to pdf by using DinkToPDF .
Unfortunately the pdf result is different than source HTML.
Here are my DinkToPdf settings:
var globalSettings = new GlobalSettings
{
ColorMode = ColorMode.Color,
Orientation = Orientation.Portrait,
PaperSize = PaperKind.A4,
DocumentTitle = title,
Out = string.Empty,
};
var objectSettings = new ObjectSettings
{
PagesCount = true,
HtmlContent = htmlBody,
WebSettings = { DefaultEncoding = "utf-8" }
};
Sample Source HTML
Sample PDF result
Is it a bug? Or is there something wrong with my code?
DinkToPdf is based on wkhtmltopdf and doesn't support a lot of modern CSS.
See this StackOverflow post on DinkToPdf.
Its not a Bug. As explained by @zvons, it wont support Modern CSS like Flexbox. Further there are many Global settings which alter font depth, spacing etc. between characters.
Eg: DPI is important setting for PDF. This cant be done from CSS. Alter Global settings to achieve the result.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.