I'm trying to convert a dynamic HTML page to a PDF file using wkhtmltopdf with Codaxy C# Wrapper.
It works fine on the local machine, but when I try to publish it / upload it to the IIS server,

It gives me: Exit with code 1 due to network error: ContentNotFoundError.

Please help me :D

有帮助吗?

解决方案

This is the solution used by the user who created this question.

Hi I have already resolved the issue by changing the code wrapper.
I used http://github.com/tuespetre/TuesPechkin instead of codaxy.

其他提示

Hi I have already resolved the issue by changing the code wrapper. I used https://github.com/tuespetre/TuesPechkin instead of codaxy. ^_^

Could the error be that the url you gave wasn't accessible by your server ?

For other people, we can write a little method in PdfConvert.cs in Codaxy.WkHtmlToPdf to give html generated, for exemple, in our controller :

public static void ConvertHtmlToPdf(string htmlHeader, string htmlContent, string htmlFooter, PdfOutput output)
{
    String inputHeaderFilePath;
    String inputContentFilePath;
    String inputFooterFilePath;

    inputHeaderFilePath = Path.Combine(Environment.TempFolderPath, String.Format("{0}.html", Guid.NewGuid()));
    inputContentFilePath = Path.Combine(Environment.TempFolderPath, String.Format("{0}.html", Guid.NewGuid()));
    inputFooterFilePath = Path.Combine(Environment.TempFolderPath, String.Format("{0}.html", Guid.NewGuid()));

    // Feed Temp files
    File.WriteAllText(inputHeaderFilePath, htmlHeader);
    File.WriteAllText(inputContentFilePath, htmlContent);
    File.WriteAllText(inputFooterFilePath, htmlFooter);

    PdfDocument document = new PdfDocument() { HeaderUrl = inputHeaderFilePath, Url = inputContentFilePath, FooterUrl = inputFooterFilePath };
    ConvertHtmlToPdf(document, output);

    //Remove Temp files
    File.Delete(inputHeaderFilePath);
    File.Delete(inputContentFilePath);
    File.Delete(inputFooterFilePath);
}

What do you think about it ?

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top