Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/335.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在C#中获取wkhtmltopdf日志信息?_C#_Pdf Generation_Wkhtmltopdf - Fatal编程技术网

如何在C#中获取wkhtmltopdf日志信息?

如何在C#中获取wkhtmltopdf日志信息?,c#,pdf-generation,wkhtmltopdf,C#,Pdf Generation,Wkhtmltopdf,我正在使用它将一些html转换为pdf。我想我遇到了一些javascrpot错误,我想从wkhtmltopdf访问一些调试\日志记录。有人知道如何获取日志信息吗 var wkhtmlDir = Settings.HtmlToPdfFolderPath; var wkhtml = Settings.HtmlToPdfExePath; var p = new Process(); p.StartInfo.CreateNoWindow

我正在使用它将一些html转换为pdf。我想我遇到了一些javascrpot错误,我想从wkhtmltopdf访问一些调试\日志记录。有人知道如何获取日志信息吗

        var wkhtmlDir = Settings.HtmlToPdfFolderPath;
        var wkhtml = Settings.HtmlToPdfExePath;
        var p = new Process();

        p.StartInfo.CreateNoWindow = true;
        p.StartInfo.RedirectStandardOutput = true;
        p.StartInfo.RedirectStandardError = true;
        p.StartInfo.RedirectStandardInput = true;
        p.StartInfo.UseShellExecute = false;
        p.StartInfo.FileName = wkhtml;
        p.StartInfo.WorkingDirectory = wkhtmlDir;

        string switches = "";
        switches += "--print-media-type --redirect-delay 800 ";
        //switches += "--margin-top 10mm --margin-bottom 10mm --margin-right 10mm --margin-left 10mm ";
        switches += "--page-size Letter ";
        p.StartInfo.Arguments = switches + " " + url 
        p.Start();

        //read output
        byte[] buffer = new byte[32768];
        byte[] file;
        using (var ms = new MemoryStream())
        {
            while (true)
            {
                int read = p.StandardOutput.BaseStream.Read(buffer, 0, buffer.Length);

                if (read <= 0)
                {
                    break;
                }
                ms.Write(buffer, 0, read);
            }
            file = ms.ToArray();
        }

        // wait or exit
        p.WaitForExit(60000);

        // read the exit code, close process
        int returnCode = p.ExitCode;
        p.Close();

        //return returnCode == 0 ? file : null;

        return file;
var wkhtmlDir=Settings.HtmlToPdfFolderPath;
var wkhtml=Settings.HtmlToPdfExePath;
var p=新流程();
p、 StartInfo.CreateNoWindow=true;
p、 StartInfo.RedirectStandardOutput=true;
p、 StartInfo.RedirectStandardError=true;
p、 StartInfo.RedirectStandardInput=true;
p、 StartInfo.UseShellExecute=false;
p、 StartInfo.FileName=wkhtml;
p、 StartInfo.WorkingDirectory=wkhtmlDir;
字符串开关=”;
开关+=“--打印介质类型--重定向延迟800”;
//开关+=“--上页边距10mm--下页边距10mm--右页边距10mm--左页边距10mm”;
开关+=“--页面大小字母”;
p、 StartInfo.Arguments=switches+“”+url
p、 Start();
//读取输出
字节[]缓冲区=新字节[32768];
字节[]文件;
使用(var ms=new MemoryStream())
{
while(true)
{
int read=p.StandardOutput.BaseStream.read(缓冲区,0,缓冲区,长度);

如果(读取可以读取标准误差和标准输出:

String output=String.Format(“STD:{0}\nErr:{1}”,p.StandardOutput.ReadToEnd(),
p、 StandardError.ReadToEnd());

这就是你要找的吗