如何从命令行将PDF转换为灰度图以避免被光栅化? [英] How to convert a PDF to grayscale from command line avoiding to be rasterized?

查看:114
本文介绍了如何从命令行将PDF转换为灰度图以避免被光栅化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将此PDF转换为灰度: https://dl.dropboxusercontent.com/u/10351891/page-27.pdf

I'm trying to convert to grayscale this PDF: https://dl.dropboxusercontent.com/u/10351891/page-27.pdf

带有pdfwrite的Ghostscript(v 9.10)设备失败,并显示无法将颜色空间转换为灰度,将策略转换为LeaveColorUnchanged".消息.

Ghostscript (v 9.10) with pdfwrite Device fails with a "Unable to convert color space to Gray, reverting strategy to LeaveColorUnchanged." message.

我可以通过一个中间ps文件(使用gs,pdftops(v 0.24.3)或pdf2ps)对其进行转换,但是这种转换将整个PDF栅格化. 我尝试了很多其他事情:使用qpdf(v 5.0.1)或pdftk(v 1.44)规范化PDF,将其转换为svg文件,然后通过Inkscape(v 0.48.4)转换回PDF.工作.

I'm able to convert it through an intermediary ps file (using gs, pdftops (v 0.24.3) or pdf2ps) but this convertion rasterize the whole PDF. I tryed a lot of other things: normalize the PDF using qpdf (v 5.0.1) or pdftk (v 1.44), transform it to a svg file and back to a PDF via Inkscape (v 0.48.4)... nothing seems to work.

我发现的唯一解决方案(不适用于生产环境)是在Mac上使用预览"并手动或通过Automator脚本应用Quartz Gray Tone滤镜.

The only one solution I found (which is not suitable for me in production environment) is to use Preview on my Mac and apply a Quartz Gray Tone filter manually or with an Automator script.

有人找到另一种可行的方法吗? 还是可以规范化PDF或解决问题以防止Ghostscript消息无法转换色彩空间..."或以其他方式强制色彩空间?

Anyone find another working way to do it? Or is it possible to normalize the PDF or fix the issue to prevent the Ghostscript message "Unable to convert color space..." or to force the color space in another way?

谢谢!

推荐答案

gs \
   -sDEVICE=pdfwrite \
   -sProcessColorModel=DeviceGray \
   -sColorConversionStrategy=Gray \
   -dOverrideICC \
   -o out.pdf \
   -f page-27.pdf

此命令将文件转换为灰度(GS 9.10).

This command converts your file to grayscale (GS 9.10).

这篇关于如何从命令行将PDF转换为灰度图以避免被光栅化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆