我试图通过在批处理文件中使用wkhtmltopdf(ver0.12.6)将多个html文件组合成一个pdf文件,另外还有一些选项需要处理。
因为在运行批处理文件之前,我需要的html文件的数量可能会发生变化,所以我将所有这些文件都移动到一个文件夹中。因此,我的目标是加载文件夹中的所有html文件,添加一些我需要的选项,并调用wkhtmltopdf来生成pdf文件。
以下是我所做的:
@echo off
setlocal
set TARGET=Result
:: go to the folder with lots of html files and one css file
cd .\myfolder
:: convert to a pdf file
wkhtmltopdf ^
--enable-local-file-access ^
--user-style-sheet %TARGET%_Report.css ^
(FOR %%A IN ("*.html") DO %%A) ^
%TARGET%_Report.pdf
cd..
pause
遗憾的是,它不能工作。我认为问题是我不能用这种方式使用FOR循环,但我不知道如何修复它。
这是错误信息。请给我一些建议,谢谢!
Loading pages (1/6)
Error: Failed to load http:/, with network status code 3 and http status code 0 - Host not found
Error: Failed loading page http: (sometimes it will work just to ignore this error with --load-error-handling ignore)
Error: Failed to load http:/, with network status code 3 and http status code 0 - Host not found
Error: Failed loading page http: (sometimes it will work just to ignore this error with --load-error-handling ignore)
Error: Failed to load http:/, with network status code 3 and http status code 0 - Host not found
Error: Failed loading page http: (sometimes it will work just to ignore this error with --load-error-handling ignore)
Error: Failed to load http:/, with network status code 3 and http status code 0 - Host not found
Error: Failed loading page http: (sometimes it will work just to ignore this error with --load-error-handling ignore)
Error: Failed to load http://in/, with network status code 3 and http status code 0 - Host in not found
Error: Failed loading page http://in (sometimes it will work just to ignore this error with --load-error-handling ignore)
Error: Failed to load http://do/, with network status code 3 and http status code 0 - Host do not found
Error: Failed loading page http://do (sometimes it will work just to ignore this error with --load-error-handling ignore)
Exit with code 1 due to network error: HostNotFoundError
发布于 2022-10-06 06:46:22
请试试我的代码
回声开启
对于/f "delims=“%a in ('dir /b /s "D:\source folder*.html‘),请执行"directorywkhtmltopdf\bin\wkhtmltopdf.exe”-s A4 %a "D:\OUTPUT DIRECTORY\pdf%%~na.pdf“
暂停回波
我试过这段代码,它可以工作。
但是,在result.pdf上的结果,您必须转到您的pdf文档的最后一页,以查看结果。
我仍然对结果感到困惑:我也许有更多的帮助
https://stackoverflow.com/questions/73135520
复制相似问题