Linux piping ( convert -> pdf2ps -> lp)

丶灬走出姿态 提交于 2020-01-01 11:43:46

问题


Ok, so I can print a PDF doing:

pdf2ps file.pdf - | lp -s

But now I want to use convert to merge several PDF files, I can do this with:

convert file1.pdf file2.pdf merged.pdf

which merges file1.pdf and file2.pdf into merged.pdf, target can be replaced with '-'.

Question

How could I pipe convert into pdf2ps and then into lp though?


回答1:


convert file1.pdf file2.pdf - | pdf2ps - - | lp -s should do the job.

You send the output of the convert command to psf2ps, which in turn feeds its output to lp.




回答2:


You can use /dev/stdout like a file:

convert file1.pdf file2.pdf /dev/stdout | ...

I use gs for merging pdfs like:

gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=/dev/stdout -f ...



回答3:


Since hidden behind your pdf2ps command there is a Ghostscript command running (which accomplishes the PDF -> PS conversion), you could also run Ghostscript directly to generate the PostScript:

gs -o output.ps      \
   -sDEVICE=ps2write \
    file1.pdf        \
    file2.pdf        \
    file3.pdf ...

Note, that older GS releases didn't include the ps2write device (which generates PostScript Level 2), but only pswrite (which generates the much larger PostScript Level 1). So change the above parameter accordingly if need be.

Older Ghostscript versions may also need to replace the modern abbreviation of -o - with the more verbose -dNOPAUSE -dBATCH -sOutputFile=/dev/stdout. Only newer GS releases (all after April 2006) know about the -o parameter.

Now, to directly pipe the PostScript output to the lp command, you would have to do this:

gs -o -              \
   -sDEVICE=ps2write \
    file1.pdf        \
    file2.pdf        \
    file3.pdf ...    \
| lp -s <other-lp-options>

This may be considerably faster than running pdftk first (but this also depends on your input files).




回答4:


convert file1.pdf file2.pdf merged.pdf
pdf2ps merged.pdf - | lp -s


来源:https://stackoverflow.com/questions/2507596/linux-piping-convert-pdf2ps-lp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!