0

I'm using pechkin.synchronized to convert from HTML to PDF. On the first http request it works fine, but after that it gets stuck on the convert method and doesn't doesn't do anything after that.

Here's my controller action method:

public ActionResult ToPdf(int id)
{
    var order = _orderBll.GetById(id);
    var viewHtml = order.Body;
    byte[] pdfBuf = new SimplePechkin(new GlobalConfig()).Convert(viewHtml);

    return File(pdfBuf, "application/pdf");
}
Nic
  • 12,220
  • 20
  • 77
  • 105
luka
  • 103
  • 1
  • 5
  • 3
    See **"Why my Web App hangs on the "easy to use" code example below?"** on [Pechkin's GitHub page](https://github.com/gmanny/Pechkin). – cbr Mar 04 '15 at 07:44

2 Answers2

1

Try using SynchronizedPechkin.

See:

Unfortunately, Pechkin is a dead project and has many unresolved issues. You can avoid these by using Tuespechkin's ThreadSafeConverter, Pechkin's development is continuing there.

Example:

IConverter converter =
    new ThreadSafeConverter(
        new PdfToolset(
            new Win32EmbeddedDeployment(
                new TempFolderDeployment())));

// Keep the converter somewhere static, or as a singleton instance!
// Do NOT run the above code more than once in the application lifecycle!

byte[] result = converter.convert(document);
Nic
  • 12,220
  • 20
  • 77
  • 105
0

I had the same problem with my application too. So i download Synchronized Pechkin from Nuget manager. Your code will look like:

using Pechkin;
using Pechkin.Synchronized;
public ActionResult ToPdf(int id)
{
var order = _orderBll.GetById(id);
var viewHtml = order.Body;
byte[] pdfBuf = new SynchronizedPechkin(new GlobalConfig()).Convert(viewHtml);
return File(pdfBuf, "application/pdf");
}
Aitezaz Bilal
  • 13
  • 2
  • 5