Reputation: 3087
I have a serious problem with Pechkin
(WkHtmlToPdf).
After converting an html string to pdf for n-times, it won't work anymore.
Does anybody know how can I fix the problem?
Here is my code:
public static byte[] HtmlToPdf(string html)
{
// Create global configuration object
var gc = new GlobalConfig();
// A new instance of Margins with x-inch margins.
gc.SetMargins(new Margins(20, 20, 20, 20))
.SetPaperSize(PaperKind.A4);
var pechkin = new SimplePechkin(gc);
var configuration = new ObjectConfig();
// Generate the PDF with the given configuration
var pdfContent = pechkin.Convert(configuration, html);
pechkin.Dispose();
return pdfContent;
}
In the caller method:
var html = "Hi there!";
var pdf = PdfHelper.HtmlToPdf(html);
PdfHelper.DownloadAsPdfFile("MyFileName", pdf);
Actually after n-times print, the program is stopped in Convert
line:
var pdfContent = pechkin.Convert(configuration, html);
Any help would be much appreciated.
Upvotes: 0
Views: 1002