how to pass html as a string using wkhtmltopdf?

后端 未结 3 2011
轻奢々
轻奢々 2020-12-04 10:29

how to pass html as a string instead of url in wkhtmltopdf using asp.net, c#?

3条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-04 11:10

    I know this is an older post, but I want future developers to have this option. I had the same need, and the idea of having to start a background process just to get a PDF inside of a web app is terrible.

    Here's another option: https://github.com/TimothyKhouri/WkHtmlToXDotNet

    It's a .NET native wrapper around wkhtmltopdf.

    Sample code here:

    var pdfData = HtmlToXConverter.ConvertToPdf("

    COOOL!

    ");

    Note, it's not thread-safe as of right now - I'm working on that. So just use a monitor or something or a lock.

提交回复
热议问题