【发布时间】:2019-12-09 21:50:12
【问题描述】:
我正在 Windows 机器上从 powershell 脚本运行 wkhtmltopdf。 我使用的命令是
& "C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf.exe" "C:\Desktop\Test.htm" "C:\Desktop\Report.pdf"
正在创建 pdf 文件,但它也抛出错误
wkhtmltopdf.exe : Loading pages (1/6)
At line:1 char:2
+ & <<<< "C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf.exe" "C:\Test.htm" "D:\Report.pdf"
+ CategoryInfo : NotSpecified: (Loading pages (1/6):String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
[> ] 0%[======> ] 10%[==============================> ]
50%[============================================================] 100%Counting pages (2/6)
[============================================================] Object 1 of 1Resolving links (4/6)
[============================================================] Object 1 of 1Loading headers and footers (5/6)
Printing pages (6/6)
[> ] Preparing[============================================================] Page 1 of 1Done
由于脚本返回错误,我无法继续进行。 请为此提供帮助。
【问题讨论】:
-
看来
wkhtmltopdf.exe正在将输出发送到错误流。你能做这样的事情吗$result = & "C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf.exe" "C:\Desktop\Test.htm" "C:\Desktop\Report.pdf"。这不是一个错误。 Just 是通过错误流来的,因此 PowerShell 将其视为一个。如果您可以捕获输出,那么您将不会看到这些消息。 -
嗨@matt,非常感谢您的及时回复。但是在进行建议的更改后,我也面临同样的错误。请帮我解决,