Farrel Wiraputra
Farrel Wiraputra

Reputation: 1

DinkToPDF pdf result is different from the HTML

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 source html

Sample PDF result

dinktopdf result

Is it a bug? Or is there something wrong with my code?

Upvotes: 0

Views: 4061

Answers (2)

Gokul Thiagarajan
Gokul Thiagarajan

Reputation: 830

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.

Upvotes: 0

zvons
zvons

Reputation: 11

DinkToPdf is based on wkhtmltopdf and doesn't support a lot of modern CSS.

See this StackOverflow post on DinkToPdf.

Upvotes: 1

Related Questions