获取斑点颜色名称

huangapple go评论49阅读模式
英文:

Get SpotColor Names

问题

有可能获取 PDF 中使用的专色名称吗?
我正在使用 C#。也许可以通过 Ghostscript 找到一种解决方法?

颜色分离

获取斑点颜色名称

我搜索了 Ghostscript 文档,但没有找到相关信息。
还尝试过使用 itextsharp。

英文:

Is there a possibility to get the names of the spotcolors used in a pdf?
I'm using c#. Maybe there is a workaround with ghostscript?

color seperation

获取斑点颜色名称

I searched the ghostscript doc but didn't find the thing.
Also tried with itextsharp.

答案1

得分: 0

可以使用Ghostscript从PDF中提取使用的专色名称。以下是如何在C#和Ghostscript中执行此操作的示例:

using System;
using System.Diagnostics;
using System.IO;

namespace GetSpotColorsFromPDF
{
    class Program
    {
        static void Main(string[] args)
        {
            var filePath = @"path\to\pdf";
            var outputFile = @"path\to\output.txt";

            var gsProcess = new Process
            {
                StartInfo = new ProcessStartInfo
                {
                    FileName = @"path\to\gswin64c.exe",
                    Arguments = $"-dNODISPLAY -dDumpSpotColors -sOutputFile={outputFile} {filePath}",
                    RedirectStandardOutput = true,
                    UseShellExecute = false,
                    CreateNoWindow = true,
                }
            };

            gsProcess.Start();
            gsProcess.WaitForExit();

            var output = File.ReadAllText(outputFile);
            Console.WriteLine(output);
        }
    }
}

请注意,您需要在计算机上安装Ghostscript并在代码中指定gswin64c.exe可执行文件的路径。-dNODISPLAY和*-dDumpSpotColors参数用于从PDF中提取专色信息,-sOutputFile*参数用于指定提取信息的输出文件。提取的信息将保存到指定的输出文件中,然后读入一个字符串并打印到控制台。

英文:

Yes, you can extract the spot color names used in a PDF using Ghostscript. Here is an example of how to do it with C# and Ghostscript:

using System;
using System.Diagnostics;
using System.IO;

namespace GetSpotColorsFromPDF
{
    class Program
    {
        static void Main(string[] args)
        {
            var filePath = @"path\to\pdf";
            var outputFile = @"path\to\output.txt";

            var gsProcess = new Process
            {
                StartInfo = new ProcessStartInfo
                {
                    FileName = @"path\to\gswin64c.exe",
                    Arguments = $"-dNODISPLAY -dDumpSpotColors -sOutputFile={outputFile} {filePath}",
                    RedirectStandardOutput = true,
                    UseShellExecute = false,
                    CreateNoWindow = true,
                }
            };

            gsProcess.Start();
            gsProcess.WaitForExit();

            var output = File.ReadAllText(outputFile);
            Console.WriteLine(output);
        }
    }
}

Note that you need to have Ghostscript installed on your machine and specify the path to the gswin64c.exe executable in the code. The -dNODISPLAY and -dDumpSpotColors arguments are used to extract the spot color information from the PDF and the -sOutputFile argument is used to specify the output file for the extracted information. The extracted information will be saved to the specified output file and then read into a string and printed to the console.

答案2

得分: 0

The output of -dPDFINFO will be determined by the file contents so start with a valid empty file and using OP windows version 1000\gswin64c

gswin64c -dPDFINFO blank.pdf -o should look like this (note this is console copy

GPL Ghostscript 10.0.0 (2022-09-21)
Copyright (C) 2022 Artifex Software, Inc.  All rights reserved.
This software is supplied under the GNU AGPLv3 and comes with NO WARRANTY:
see the file COPYING for details.

        File has 1 page.

Producer: GPL Ghostscript 10.00.0
CreationDate: D:20230115003354Z00'00'
ModDate: D:20230115003354Z00'00'

Processing pages 1 through 1.
Page 1 MediaBox: [0 0 595 842]


C:\Apps\PDF\GS\gs1000w64\bin>

to suppress the copy write use -q

to save in a file use level2 redirection

gswin64c -q -dBATCH -dPDFINFO blank.pdf 2>out.txt

To filter output of text file use pipe filters

Does it have spot colours

What are they

As long as no open standard for spot colours exists, TCPDF users will have to buy a colour book by one of the colour manufacturers and insert the values and names of spot colours directly

So here the names are on an RGB scale

- Dark Green   is 0,71,57
- Light Yellow is 255,246,142
- Black        is 39,36,37
- Red          is 166,40,52
- Green        is 0,132,75
- Blue         is 0,97,157
- Yellow       is 255,202,9

But black is not full black is there a better way? yes, of course

type example_037.pdf|find /i "/separation" Now we can see the CMYK spots

In this simplified case, the CMYK values after each name are shown as, for example, Full Black = [0.000000 0.000000 0.000000 1.000000].
Note often the separation may be encoded inside the PDF data, thus you need to decompress the data first to do the search. There are several tools to do the decompression, so common cross-platform ones are qpdf (FOSS) mutool (partner to GhostScript) and PDFtk amongst others.

英文:

The output of -dPDFINFO will be determined by the file contents so start with a valid empty file and using OP windows version 1000\gswin64c

gswin64c -dPDFINFO blank.pdf -o should look like this (note this is console copy

GPL Ghostscript 10.0.0 (2022-09-21)
Copyright (C) 2022 Artifex Software, Inc.  All rights reserved.
This software is supplied under the GNU AGPLv3 and comes with NO WARRANTY:
see the file COPYING for details.

        File has 1 page.

Producer: GPL Ghostscript 10.00.0
CreationDate: D:20230115003354Z00'00'
ModDate: D:20230115003354Z00'00'

Processing pages 1 through 1.
Page 1 MediaBox: [0 0 595 842]


C:\Apps\PDF\GS\gs1000w64\bin>

to suppress the copy write use -q
获取斑点颜色名称

to save in a file use level2 redirection

gswin64c -q -dBATCH -dPDFINFO blank.pdf 2>out.txt
获取斑点颜色名称

To filter output of text file use pipe filters
获取斑点颜色名称

Does it have spot colours
获取斑点颜色名称

What are they
获取斑点颜色名称

>As long as no open standard for spot colours exists, TCPDF users will have to buy a colour book by one of the colour manufacturers and insert the values and names of spot colours directly

So here the names are on a RGB scale

- Dark Green   is 0,71,57
- Light Yellow is 255,246,142
- Black        is 39,36,37
- Red          is 166,40,52
- Green        is 0,132,75
- Blue         is 0,97,157
- Yellow       is 255,202,9

But black is not full black is there a better way? yes of course

type example_037.pdf|find /i "/separation" Now we can see the CMYK spots
获取斑点颜色名称

In this simplified case the CMYK values after each name are shown as for example Full Black = [0.000000 0.000000 0.000000 1.000000].
Note often the separation may be encoded inside the PDF data thus you need to decompress the data first to do the search. There are several tools to do the decompression, so common cross platform ones are qpdf (FOSS) mutool (partner to GhostScript) and PDFtk amongst others.

答案3

得分: 0

cpdf -list-spot-colors in.pdf将它们列出,每个占一行,输出到标准输出。

英文:

cpdf -list-spot-colors in.pdf will list them, one per line, to standard output.

huangapple
  • 本文由 发表于 2023年2月6日 13:36:04
  • 转载请务必保留本文链接:https://go.coder-hub.com/75357665.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定