28

我很难让 ImageMagickidentify将 PDF 识别为 CMYK。

本质上,假设我正在构建这个文件,test.texpdflatex

\documentclass[a4paper,12pt]{article}

%% https://tex.stackexchange.com/questions/13071
\pdfcompresslevel=0

%% http://compgroups.net/comp.text.tex/Making-a-cmyk-PDF
%% ln -s /usr/share/color/icc/sRGB.icm .
% \immediate\pdfobj stream attr{/N 4} file{sRGB.icm}
% \pdfcatalog{%
% /OutputIntents [ <<
% /Type /OutputIntent
% /S/GTS_PDFA1
% /DestOutputProfile \the\pdflastobj\space 0 R
% /OutputConditionIdentifier (sRGB IEC61966-2.1)
% /Info(sRGB IEC61966-2.1)
% >> ]
% }

%% http://latex-my.blogspot.com/2010/02/cmyk-output-for-commercial-printing.html
%% https://tex.stackexchange.com/questions/9961
\usepackage[cmyk]{xcolor}

\begin{document}
Some text here...
\end{document}

如果我然后尝试识别生成的test.pdf文件,无论我尝试了哪些选项(至少根据源代码中的链接),我都会将它作为 RGB - 然而,其中的颜色将保存为 CMYK;对于上述来源:

$ grep -ia 'cmyk\|rgb\| k' test.pdf 
0 0 0 1 k 0 0 0 1 K
0 0 0 1 k 0 0 0 1 K
0 0 0 1 k 0 0 0 1 K
0 0 0 1 k 0 0 0 1 K
FontDirectory/CMR12 known{/CMR12 findfont dup/UniqueID known{dup
/PTEX.Fullbanner (This is pdfTeX, Version 3.1415926-1.40.11-2.2 (TeX Live 2010) kpathsea version 6.0.0)

$ identify -verbose 'test.pdf[0]'
...
  Type: Palette
  Endianess: Undefined
  Colorspace: RGB
  Depth: 16/8-bit
  Channel depth:
    red: 8-bit
    green: 8-bit
    blue: 8-bit
  Channel statistics:
    Red:
...
    Green:
...
    Blue:
...
  Histogram:
         5: (12593,11565,11822) #31312D2D2E2E rgb(49,45,46)
         4: (16448,15420,15677) #40403C3C3D3D rgb(64,60,61)
         9: (20303,19275,19532) #4F4F4B4B4C4C rgb(79,75,76)
        25: (23901,23130,23387) #5D5D5A5A5B5B rgb(93,90,91)
...

如果我也取消注释该\immediate\pdfobj stream ... 部分,也会发生同样的情况;然而,如果文档中只有一种颜色(黑色),我看不出哪里会identify出现 RGB 值的直方图(尽管可以说,它们都接近灰色)?!

 

所以没关系,然后我最好尝试使用ghostscript将其转换test.pdf为新的pdf,它将被识别为CMYK identify- 但即使在那里也没有运气:

$ gs -dNOPAUSE -dBATCH -dSAFER -sDEVICE=pdfwrite  -sOutputFile=test-gs.pdf -dUseCIEColor -sProcessColorModel=DeviceRGB -dProcessColorModel=/DeviceCMYK -sColorConversionStrategy=/CMYK test.pdf 

GPL Ghostscript 9.01 (2011-02-07)
Copyright (C) 2010 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Processing pages 1 through 1.
Page 1


$ identify -verbose 'test-gs.pdf[0]'
...
  Type: Grayscale
  Base type: Grayscale
  Endianess: Undefined
  Colorspace: RGB
  Depth: 16/8-bit
...

因此,唯一identify被认为是变化的是Type: Grayscale(来自以前的Type: Palette);但否则它仍然会看到 RGB 颜色空间!

除此之外,请注意identify 能够正确报告 CMYK pdf - 请参阅CMYK 海报示例:将 pdf 页面大小拟合到(位图)图像大小?#17843 - TeX - LaTeX - Stack Exchangeconvert获取使用和生成此类 PDF 文件的命令行示例gs。其实我们可以执行:

convert test.pdf -depth 8 -colorspace cmyk -alpha Off test-c.pdf

...这导致 PDF 被identify编辑为 CMYK - 但是,PDF 也将被光栅化(默认为 72 dpi)。

编辑:我刚刚发现,如果我在 OpenOffice 中创建一个 .odp 演示文稿,并将其导出为 PDF;该 PDF 默认为 RGB,但是,以下命令(来自ghostscript 示例 | Production Monkeys):

# Color PDF to CMYK:
gs -dSAFER -dBATCH -dNOPAUSE -dNOCACHE -sDEVICE=pdfwrite \
-sColorConversionStrategy=CMYK -dProcessColorModel=/DeviceCMYK \
-sOutputFile=output.pdf input.pdf

...实际上会生成一个 CMYK pdf,由以下人员报告identify(尽管黑色将是丰富的,而不是简单的 - 在所有四个通道上);但是,此命令在幻灯片添加了图像时才有效(显然,它是触发颜色转换的那个?!)!有趣的是,我无法从pdflatexPDF 中获得相同的效果。

 

所以我想我的问题可以通过两种方式提出:

  • Linux 中是否有任何命令行转换方法,可以将 RGB pdf 转换为 CMYK pdf,同时保留矢量,这在中被识别identify(并因此构建正确的 CMYK 颜色直方图)
  • 是否有任何其他类似于 的命令行 Linux 工具identify,即使在原始test.pdffrom中也可以正确识别 CMYK 颜色的使用pdflatex并且可能基于任意选择的 PDF 页面构建颜色直方图,就像identify应该的那样)?

提前感谢您的任何答案,
干杯!

 

一些参考资料:

4

6 回答 6

30

sdaau,您用于尝试将 PDF 转换为 CMYK 的命令不正确。试试这个:

 gs \
   -o test-cmyk.pdf \
   -sDEVICE=pdfwrite \
   -sProcessColorModel=DeviceCMYK \
   -sColorConversionStrategy=CMYK \
   -sColorConversionStrategyForImages=CMYK \
    test.pdf 

更新

如果颜色转换无法按预期工作,并且您看到“无法将颜色空间转换为灰色,正在将策略恢复为 LeaveColorUnchanged”之类的消息,那么...

  1. 您的 Ghostscript 可能是9.x 版本系列的较新版本,并且
  2. 您的源 PDF 可能使用嵌入式ICC 颜色配置文件

在这种情况下,添加-dOverrideICC到命令行并查看它是否根据需要更改结果。


更新 2

为避免图像中出现 JPEG 伪影(以前没有),请添加:

-dEncodeColorImages=false

进入命令行。

(几乎所有 GS PDF->PDF处理都是如此,而不仅仅是这种情况。因为 GS 默认情况下会在被要求生成 PDF 输出时创建一个全新的文件,其中包含新构造的对象和新的文件结构——它不会只需重新使用以前的对象,因为像{pdftk那样更“愚蠢”的 PDF 处理器还有其他优点,但不要误解我的说法!} . GS 默认应用 JPEG 压缩——查看当前的Ps2pdf 文档并搜索“ColorImageFilter”了解更多细节...)pdftk

于 2011-12-19T21:02:07.493 回答
6

我有一个不相关的问题,但我目前也在为 CMYK PDF 苦苦挣扎。

我在这里写了这个小脚本(它叫做 pdf2pdfx):

#!/bin/bash

gs \
-dPDFX \
-dBATCH \
-dNOPAUSE \
-dNOOUTERSAVE \
-sDEVICE=pdfwrite \
-sColorConversionStrategy=CMYK \
-dProcessColorModel=/DeviceCMYK \
-dPDFSETTINGS=/prepress \
-sOutputFile="${1%%.pdf}_X-3.pdf" \
PDFX_def.ps \
"$1"

并且我的 PDFX_def.ps 包含以下内容(我删除了 ICC 配置文件并定义了 FOGRA39,这应该没问题):

%!
% $Id$
% This is a sample prefix file for creating a PDF/X-3 document.
% Feel free to modify entries marked with "Customize".

% This assumes an ICC profile to reside in the file (ISO Coated sb.icc),
% unless the user modifies the corresponding line below.

systemdict /ProcessColorModel known {
  systemdict /ProcessColorModel get dup /DeviceGray ne exch /DeviceCMYK ne and
} {
  true
} ifelse
{ (ERROR: ProcessColorModel must be /DeviceGray or DeviceCMYK.)=
  /ProcessColorModel cvx /rangecheck signalerror
} if

% Define entries to the document Info dictionary :

% /ICCProfile (/usr/share/color/icc/ISOcoated_v2_300_eci.icc) def  % Customize or remove.

[ /GTS_PDFXVersion (PDF/X-3:2002) % Must be so (the standard requires).
  /Title (Title)                  % Customize.
  /Trapped /False                 % Must be so (Ghostscript doesn't provide other).
  /DOCINFO pdfmark

% Define an ICC profile :

currentdict /ICCProfile known {
  [/_objdef {icc_PDFX} /type /stream /OBJ pdfmark
  [{icc_PDFX} <</N systemdict /ProcessColorModel get /DeviceGray eq {1} {4} ifelse >> /PUT pdfmark
  [{icc_PDFX} ICCProfile (r) file /PUT pdfmark
} if

% Define the output intent dictionary :

[/_objdef {OutputIntent_PDFX} /type /dict /OBJ pdfmark
[{OutputIntent_PDFX} <<
  /Type /OutputIntent              % Must be so (the standard requires).
  /S /GTS_PDFX                     % Must be so (the standard requires).
  /OutputCondition (Commercial and specialty printing) % Customize
  /Info (none)                     % Customize
  /OutputConditionIdentifier (FOGRA39)      % Customize
  /RegistryName (http://www.color.org)   % Must be so (the standard requires).
  currentdict /ICCProfile known {
    /DestOutputProfile {icc_PDFX}  % Must be so (see above).
  } if
>> /PUT pdfmark
[{Catalog} <</OutputIntents [ {OutputIntent_PDFX} ]>> /PUT pdfmark

识别然后正确报告 CMYK 颜色空间。前:

tbart@blackknight ~/orpheus/werbung/action $ identify -verbose action_schulungsvideo_v3_print.pdf
Image: action_schulungsvideo_v3_print.pdf
  Format: PDF (Portable Document Format)
  Class: DirectClass
  Geometry: 612x859+0+0
  Resolution: 72x72
  Print size: 8.5x11.9306
  Units: Undefined
  Type: TrueColor
  Endianess: Undefined
  Colorspace: RGB
  Depth: 16/8-bit
  Channel depth:
    red: 8-bit
    green: 8-bit
    blue: 8-bit
  Channel statistics:
    Red:
      min: 0 (0)
      max: 65535 (1)
      mean: 53873.6 (0.822058)
      standard deviation: 19276.7 (0.294144)
      kurtosis: 1.854
      skewness: -1.82565
    Green:
      min: 0 (0)
      max: 65535 (1)
      mean: 55385.6 (0.84513)
      standard deviation: 19274.6 (0.294112)
      kurtosis: 2.09868
      skewness: -1.91651
    Blue:
      min: 0 (0)
      max: 65535 (1)
      mean: 51020 (0.778516)
      standard deviation: 20077.7 (0.306367)
      kurtosis: 0.860627
      skewness: -1.52344
  Image statistics:
    Overall:
      min: 0 (0)
      max: 65535 (1)
      mean: 53426.4 (0.815235)
      standard deviation: 19546.7 (0.298263)
      kurtosis: 1.59453
      skewness: -1.75701
  Rendering intent: Undefined
  Interlace: None
  Background color: white
  Border color: rgb(223,223,223)
  Matte color: grey74
  Transparent color: black
  Compose: Over
  Page geometry: 612x859+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: Undefined
  Orientation: Undefined
  Properties:
    date:create: 2011-09-14T15:38:57+02:00
    date:modify: 2011-09-14T15:38:57+02:00
    pdf:HiResBoundingBox: 612.283x858.898+0+0
    pdf:Version: PDF-1.5 
    signature: 210bfc9cf90e3b9505385f8b2267da1665b5c2de28bb5223311afba01718bbeb
  Artifacts:
    verbose: true
  Tainted: False
  Filesize: 1.577MBB
  Number pixels: 526KB
  Pixels per second: 52.57MB
  User time: 0.020u
  Elapsed time: 0:01.009
  Version: ImageMagick 6.6.5-6 2011-04-08 Q16 http://www.imagemagick.org

后:

tbart@blackknight ~/orpheus/werbung/action $ pdf2pdfx action_schulungsvideo_v3_print.pdf
GPL Ghostscript 9.04 (2011-08-05)
Copyright (C) 2011 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Processing pages 1 through 1.
Page 1


tbart@blackknight ~/orpheus/werbung/action $ identify -verbose action_schulungsvideo_v3_print_X-3.pdf 
Image: action_schulungsvideo_v3_print_X-3.pdf
  Format: PDF (Portable Document Format)
  Class: DirectClass
  Geometry: 612x859+0+0
  Resolution: 72x72
  Print size: 8.5x11.9306
  Units: Undefined
  Type: ColorSeparation
  Base type: ColorSeparation
  Endianess: Undefined
  Colorspace: CMYK
  Depth: 16/8-bit
  Channel depth:
    cyan: 8-bit
    magenta: 8-bit
    yellow: 8-bit
    black: 8-bit
  Channel statistics:
    Cyan:
      min: 0 (0)
      max: 65535 (1)
      mean: 8331.78 (0.127135)
      standard deviation: 14902.2 (0.227392)
      kurtosis: 1.62171
      skewness: 1.7799
    Magenta:
      min: 0 (0)
      max: 62194 (0.94902)
      mean: 6739.34 (0.102836)
      standard deviation: 14517.5 (0.221523)
      kurtosis: 2.08183
      skewness: 1.93276
    Yellow:
      min: 0 (0)
      max: 65535 (1)
      mean: 13310.1 (0.203098)
      standard deviation: 17022.5 (0.259746)
      kurtosis: 0.991135
      skewness: 1.45216
    Black:
      min: 0 (0)
      max: 56540 (0.862745)
      mean: 7117.47 (0.108606)
      standard deviation: 16803.7 (0.256408)
      kurtosis: 3.02752
      skewness: 2.16554
  Image statistics:
    Overall:
      min: 0 (0)
      max: 65535 (1)
      mean: 8874.66 (0.135419)
      standard deviation: 15850.6 (0.241864)
      kurtosis: 2.17614
      skewness: 1.88139
  Total ink density: 292%
  Rendering intent: Undefined
  Interlace: None
  Background color: white
  Border color: cmyk(223,223,223,0)
  Matte color: grey74
  Transparent color: black
  Compose: Over
  Page geometry: 612x859+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: Undefined
  Orientation: Undefined
  Properties:
    date:create: 2011-09-14T15:39:30+02:00
    date:modify: 2011-09-14T15:39:30+02:00
    pdf:HiResBoundingBox: 612.28x858.9+0+0
    pdf:Version: PDF-1.3 
    signature: 0416db7487ea147b974ece5748bc4284e82bfc3fb7cd07a4de050421ba112076
  Artifacts:
    verbose: true
  Tainted: False
  Filesize: 2.103MBB
  Number pixels: 526KB
  Pixels per second: 5.25708PB
  User time: 0.000u
  Elapsed time: 0:01.000
  Version: ImageMagick 6.6.5-6 2011-04-08 Q16 http://www.imagemagick.org

这是 64 位 Gentoo 和 gs 9.04 也许有帮助?

源 PDF 源于inkscape pdf 导出,颜色仅限于 ECI ISO 涂层 v2 中涵盖的颜色。我将此作为一种解决方法,以解决缺少的 inkscape 的 CMYK 导出和缺少印前就绪的 PDF/X 输出...

于 2011-09-14T13:56:40.930 回答
4

好吧,这里有一些东西,至少......

最初,我需要这种方法来确保我的 PDF 文件采用 CMYK 格式,并且文本为“纯黑色”C:0、M:0、Y:0、K:100 - 因为我遇到了问题以前使用打印机时,他们会抱怨我的 Latex PDF 包含文本“丰富的黑色”(因此成本更高)。我通常会选择它,identify因为它似乎是唯一可以解析 PDF 和颜色的工具(而且它也相对容易记住)。

好吧,我通读了技术提示:使用 Ghostscript 转换和合并文件 | Linux杂志;建议使用 的tiffsep设备gs进行分离。这对我来说扮演着同样的角色identify;我可以这样做:

$ gs -sDEVICE=tiffsep -dNOPAUSE -dBATCH -dSAFER -r150x150 -sOutputFile=p%08d.tif test.pdf 

$ ls p*
p00000001.Black.tif  p00000001.Magenta.tif  p00000001.Yellow.tif  p00000001.Cyan.tif   p00000001.tif

$ eog p00000001.tif

...然后我可以使用左/右箭头“迭代”分离图像 - 如果它是“纯黑”或“浓黑”,立即显而易见。

因此,这表明,无论显示什么identifytest.pdffrompdflatex实际上都将“纯黑色”作为文本颜色,正如它应该的那样(其他分色为空白)-但是,执行以下操作:

# do a conversion of original PDF
$ gs -dPDFA -dBATCH -dNOPAUSE -dNOOUTERSAVE -dUseCIEColor -sProcessColorModel=DeviceCMYK -sDEVICE=pdfwrite -sOutputFile=out_pdfa.pdf test.pdf

# do a separation on the converted pdf
$ gs -sDEVICE=tiffsep -dNOPAUSE -dBATCH -dSAFER -r150x150 \
  -dFirstPage=1 -dLastPage=1 -sOutputFile=p%08d.tif out_pdfa.pdf

# view
$ eog p00000001.tif

... 将显示特定out_pdfa.pdf内容实际上具有“丰富的黑色” - 即文本墨水会覆盖所有四个分色!(identify也将这个显示为 RGB)。

所以,我希望这种gs/tiffsep技术比identify:)

 

注意:我使用的是带有 GhostScript 9.01 的 Ubuntu Natty - 但是,它有一个令人讨厌的错误tiffsep错误 691857 – tiffsep 在版本 9 中崩溃(缺少 lab.icc)。这已在 9.02 中修复 - 并且 9.02 已在 oneiric 中作为 ghostscript发布。为了在 Natty 下使用 9.02,我遵循了如何使用 apt-get 更新单个包?- Ubuntu 论坛

sudo nano /etc/apt/sources.list # add deb http://archive.ubuntu.com/ubuntu/ oneiric main restricted
sudo apt-get update
sudo apt-get install ghostscript # this upgrades only gs and dependencies 
sudo nano /etc/apt/sources.list  # remove/comment oneiric repo
sudo apt-get update && sudo apt-get upgrade # should be back to normal here

请注意,对于有缺陷的 9.01 版本,即使此命令也会失败:

$ GS_LIB=/usr/share/ghostscript/9.01/iccprofiles/ gs -sICCProfilesDir=/usr/share/ghostscript/9.01/iccprofiles/ -sDEVICE=tiffsep -dNOPAUSE -dBATCH -dSAFER -sOutputFile=p%08d.tif out_pdfa.pdf

...
sfopen: gs_parse_file_name failed.
sfopen: gs_parse_file_name failed.
... gsicc_open_search(): Could not find lab.icc ...

.. 在 9.02 中,无需sICCProfilesDir明确指定。

于 2011-06-05T10:00:05.193 回答
2

我也被这个逼疯了。我完全尝试了@tbart 的示例,但它仅适用于某些输入pdf(似乎已经包含图像,rgb 与否?),而不适用于其他。具体来说,让我们来看看这个超级简单的 ps 文件:

%!PS
/Times-Roman findfont 30 scalefont setfont
72 680 moveto
0.81 0.72 0 0 setcmykcolor
(This is text!) show
showpage

如果我调用这个 test1.ps,然后运行这个命令(在 windows 上,gs 9.14):

gswin64c -dEmbedAllFonts=true -dPDFX -dBATCH -dNOPAUSE -dNOOUTERSAVE -sDEVICE=pdfwrite -dProcessColorModel=/DeviceCMYK -sOutputICCProfile=CoatedGRACoL2006.icc   -sColorConversionStrategy=CMYK -sColorConversionStrategyForImages=CMYK -sOutputFile=test1.pdf PDFX_def.ps test1.ps

如果您使用的是 linux/cygwin,请将 gswin64c 替换为 gs。

我使用的 CMYK ICC 在 PDFX_def.ps 和上面的命令中。你可以从这里得到它,但它只是 moo 想要他们的卡的随机 ICC,它似乎并不特别: http ://www.adobe.com/support/downloads/thankyou.jsp?ftpID=4075&fileID=3790

此 test1.pdf 输出在 Illustrator 中加载为 CMYK pdf,但识别 -verbose 表示它是 sRGB。如果我做@sdaau 的 tiffsep 事情,它会写出分隔符并且它们具有正确的值。

所以,我不知道。

任何人都可以将此 ps 文件转换为识别识别的 CMYK pdf 吗?

克里斯


编辑:哇。我可能已经弄清楚并修复了它。看起来识别只是在 PDF 文件中寻找 /ColorSpace /DeviceCMYK,所以如果我破解 PDFX_def.ps 来输出它,识别将称之为 CMYK。因此,通过查看有效的 pdf 文件,我发现如果他们有此行标识有效,如果没有,则它们被错误地标记为 sRGB。

在 PDFX_def.ps 的末尾,添加 /ColorSpace /DeviceCMYK 行:

[/_objdef {OutputIntent_PDFX} /type /dict /OBJ pdfmark
[{OutputIntent_PDFX} <<
  /ColorSpace /DeviceCMYK          % convince ImageMagick's identify that it's CMYK
  /Type /OutputIntent              % Must be so (the standard requires).
  /S /GTS_PDFX                     % Must be so (the standard requires).
  /OutputCondition (Commercial and specialty printing) % Customize
  /Info (none)                     % Customize
  /OutputConditionIdentifier (CGATS TR 003)      % Customize
  /RegistryName (http://www.color.org)   % Must be so (the standard requires).
  currentdict /ICCProfile known {
    /DestOutputProfile {icc_PDFX}  % Must be so (see above).
  } if
>> /PUT pdfmark
[{Catalog} <</OutputIntents [ {OutputIntent_PDFX} ]>> /PUT pdfmark

繁荣。我希望这不会对兼容性或任何事情产生任何奇怪的影响。

于 2014-08-08T03:06:35.973 回答
1

当我在队列中有另一个打印作业时,再次使用 PDF/X-3 重新访问 CMYK 转换让我发现以下内容:

如果您只需要 CMYK,请避免使用 X-3。它不支持透明度(https://en.wikipedia.org/wiki/PDF/X),并且您将获得的青色图像既不令人满意,也实际上不符合任何标准。如果您有 alpha、不透明度、渐变,如果您的印刷店并非绝对需要,则不要转换为 PDF/X-3。

如果您确实需要 pdf/X,则需要光栅化并使用 X-3。在“众所周知的工具链”(imagemagick、inkscape、gimp 等)中,我所知道的 Linux / 自由软件产品上没有 X-4

然而,我仍在与定义丰富的黑色 f.ex战斗。60%C, 60%M, 40%Y, 100%K——这里的印刷厂相当典型的标准。每当我在inkscape中设置它时,它会在导出后立即消失(到RGB;开罗限制)

尽管如此,这似乎让我接近他们的期望:

#!/bin/bash

# possibly ps2ps2 for keeping fonts?
pdf2ps -sOutputFile=- "$1" | gs \
-dPDFX \
-dBATCH \
-dNOPAUSE \
-dNOOUTERSAVE \
-dPDFSETTINGS=/prepress \
-dCompatibilityLevel=1.4 \
-sDEVICE=pdfwrite \
-sColorConversionStrategy=CMYK \
-sProcessColorModel=DeviceCMYK \
-dHaveTransparency=false \
-sOutputFile="${1%%.pdf}_X-3.pdf" \
PDFX_def.ps \
-

对于真正的 CMYK 创建到 CMYK-PDF 输出工作流程的任何见解仍然非常受欢迎。Scribus 不是真正的解决方案,因为它在正确导入inkscape SVG 时存在很多问题。除此之外,scribus 在创建 CMYK-PDF 方面做得还不错。

于 2015-09-24T21:40:48.290 回答
1

我发现命令行 forghostscript非常令人困惑,谷歌搜索给出了很多类似的,有时是相互矛盾的建议,其中大部分对我不起作用。

就我而言,我从纯黑色或白色 SVG(所有矢量 + 文本)开始。使用CairoSVG将其转换为 PDF会生成RGB PDF。

ghostscript我发现执行转换为 CMYK(或仅“单板”黑色)的最小(9.50 版)命令是:

gs -q -sDEVICE=pdfwrite -sColorConversionStrategy=CMYK -o <output.pdf> <intput.pdf>

笔记:

  • -sColorConversionStrategy=Gray将制作一个“单板”,只有黑色的文件(这实际上是我想要的)。
  • -o-sOutputFile设置输出文件与开关不一样。
  • <input_file.pdf>不能是与<output_file.pdf>;相同的文件 如果你这样做,你会得到一个空白的 PDF。
  • 就我而言,我不想保留 CairoSVG 生成的中间 RGB PDF,所以我这样做了cairosvg <input_file.svg> -f pdf | gs -q -sDEVICE=pdfwrite -sColorConversionStrategy=Gray -o <output_file.pdf> --ghostcript 命令末尾的 告诉它从标准输出中获取输入。

To verify that I ended up with the PDF file I desired, I used Adobe Acrobat's Preflight check, as suggested here, for conversion to PDF/X format, which does not support RGB colors.

于 2021-02-15T17:31:00.130 回答