How to convert a PDF to grayscale from command line avoiding to be rasterized?

后端 未结 7 999
暖寄归人
暖寄归人 2020-12-14 08:51

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

Ghostscript (v 9.10) with pdfwrite Device fails with a \"Unabl

7条回答
  •  臣服心动
    2020-12-14 09:16

    If you crack into the file, you'll find that most of the colors are determined through an RGB ICC based color space (look for 8 0 R to find all the references to this colorspace). Perhaps gs is complaining about that?

    Who knows.

    The take away is that converting a page from one colorspace to another without affecting the content is non-trivial in that you need to be able to render the page and trap all changes to the current color/colorspace and substitute an equivalent in the target space as well as convert all image XObjects in the wrong colorspace, which will require decoding the image data and re-encoding it in the target space, as well as all form XObjects, which will be a task similar to trying to convert the parent page since form XObjects (I think your doc has 4) also contain resources and a content stream of page marking operators (which may include more XObjects).

    It's certainly doable, but the process is nearly the same as rendering but with some fairly special-purpose code.

提交回复
热议问题