我尝试使用gulp-html-pdf和gulp-html2pdf将html转换为pdf,它们都导致错误:
[10:12:36] Starting 'convert-pdf'...
events.js:141
throw er; // Unhandled 'error' event
^
Error: write EPIPE
at exports._errnoException (util.js:907:11)
at Socket._writeGeneric (net.js:702:26)
at Socket._write (net.js:721:8)
at doWrite (_stream_writable.js:301:12)
at writeOrBuffer (_stream_writable.js:287:5)
at Socket.Writable.write (_stream_writable.js:215:11)
at Socket.write (net.js:648:40)
at PDF.PdfExec [as exec] (D:\gulp\node_modules\html-pdf\lib\pdf.js:141:15)
at PDF.PdfToBuffer [as toBuffer] (D:\gulp\node_modules\html-pdf\lib\pdf.js:44:8)
at DestroyableTransform._transform (D:\gulp\node_modules\gulp-html-pdf\index.js:19:8)
at DestroyableTransform.Transform._read (D:\gulp\node_modules\through2\node_modules\readable-stream\lib\_stream_transform.js:159:10)
at DestroyableTransform.Transform._write (D:\gulp\node_modules\through2\node_modules\readable-stream\lib\_stream_transform.js:147:83)
at doWrite (D:\gulp\node_modules\through2\node_modules\readable-stream\lib\_stream_writable.js:347:64)
at writeOrBuffer (D:\gulp\node_modules\through2\node_modules\readable-stream\lib\_stream_writable.js:336:5)
at DestroyableTransform.Writable.write (D:\gulp\node_modules\through2\node_modules\readable-stream\lib\_stream_writable.js:274:11)
at write (D:\gulp\node_modules\vinyl-fs\node_modules\readable-stream\lib\_stream_readable.js:623:24)
直接使用html-pdf
可以正常工作。
这是我的大口饭代码:
var gulp = require('gulp'),
pdf = require('gulp-html-pdf');
gulp.task('convert-pdf', function()
{
return gulp.src(["./sources/install.html"])
.pipe(pdf())
.pipe(gulp.dest("./build/"));
});
我在Mac上使用gulp-html-pdf
时没有问题。我还尝试根据对相同问题的几次答复中的建议设置phantomPath
,但没有任何运气。我还能尝试什么?