Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NReco.PdfGenerator The pipe has been ended error on the server

I'm using NReco.PdfGenerator for my PDF documents(that component is based on WkHtmlToPdf tool), my code allow me to create a pdf calling a function with the parameters controller, action, model:

public static byte[] GeneratePdfDocument(System.Web.Mvc.Controller controller, string viewName, object model)
{
     string result;
     controller.ViewData.Model = model;
     using (StringWriter sw = new StringWriter())
     {
         ViewEngineResult viewResult = ViewEngines.Engines.FindPartialView(controller.ControllerContext, viewName);
         ViewContext viewContext = new ViewContext(controller.ControllerContext, viewResult.View, controller.ViewData, controller.TempData, sw);
         viewResult.View.Render(viewContext, sw);

         result = sw.ToString();
     }

     return (new NReco.PdfGenerator.HtmlToPdfConverter()).GeneratePdf(result);
}

With this code I can create a PDF easily from my views and it's working great on my development environment but on a server I'm getting this error:

The pipe has been ended.

Description: An unhandled exception occurred during the execution of the    current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.IO.IOException: The pipe has been ended.


[IOException: The pipe has been ended.]
System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +11185413
System.IO.FileStream.WriteCore(Byte[] buffer, Int32 offset, Int32 count) +10770013
System.IO.FileStream.Write(Byte[] array, Int32 offset, Int32 count) +139
NReco.PdfGenerator.HtmlToPdfConverter.GeneratePdfInternal(String htmlFilePath, Byte[] inputBytes, String coverHtml, String outputPdfFilePath, Stream outputStream) +2166

[Exception: Cannot generate PDF: The pipe has been ended.]
NReco.PdfGenerator.HtmlToPdfConverter.GeneratePdfInternal(String htmlFilePath, Byte[] inputBytes, String coverHtml, String outputPdfFilePath, Stream outputStream) +2734
NReco.PdfGenerator.HtmlToPdfConverter.GeneratePdf(String htmlContent, String coverHtml, Stream output) +51
NReco.PdfGenerator.HtmlToPdfConverter.GeneratePdf(String htmlContent, String coverHtml) +42

I think that is maybe a problem with permissions or some configuration on my IIS, any idea?

like image 283
TlonXP Avatar asked May 04 '15 18:05

TlonXP


1 Answers

You are probably missing Visual C++ Redistributable Packages for VS2013 (x86). Even if your server is running 64bit Windows, you need to install the x86 C++ Packages.

like image 56
Ici Avatar answered Nov 09 '22 13:11

Ici