You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Gianluca Sartori <g....@gmail.com> on 2022/07/11 13:13:20 UTC

Save Separation image

Dear all,

I need to extract, for each color separation, the rasterized image that
represents it. I need to preview each color of the PDF. This is the code I
came up with, do you know how can I get a BufferedImage?

Or a better way to approach the problem would be really helpful!

Groovy (but you can suggest with Java, no problem with that)

for (page in input.pages) {
    for (name in page.resources.colorSpaceNames) {
        PDColor color = page.resources.getColorSpace(name).initialColor
        PDColorSpace cs = color.getColorSpace()

        if (cs in PDSeparation) {
            WritableRaster raster = ???
            BufferedImage img = cs.toRGBImage(raster)
            results.add(cs.colorantName)
        }
    }
}


Gianluca Sartori
--
Cell. +39 388 1026822

Re: Save Separation image

Posted by Tilman Hausherr <TH...@t-online.de>.
We don't keep intermediate images except for patterns and transparency 
groups. And these intermediate images are usually RGB so they are not 
really 100% correct.

Or do you want an image of the color chart, like in PDFDebugger?

Tilman

Am 11.07.2022 um 15:13 schrieb Gianluca Sartori:
> Dear all,
>
> I need to extract, for each color separation, the rasterized image that
> represents it. I need to preview each color of the PDF. This is the code I
> came up with, do you know how can I get a BufferedImage?
>
> Or a better way to approach the problem would be really helpful!
>
> Groovy (but you can suggest with Java, no problem with that)
>
> for (page in input.pages) {
>      for (name in page.resources.colorSpaceNames) {
>          PDColor color = page.resources.getColorSpace(name).initialColor
>          PDColorSpace cs = color.getColorSpace()
>
>          if (cs in PDSeparation) {
>              WritableRaster raster = ???
>              BufferedImage img = cs.toRGBImage(raster)
>              results.add(cs.colorantName)
>          }
>      }
> }
>
>
> Gianluca Sartori
> --
> Cell. +39 388 1026822
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org