PdfBox - PDColorSpaceFactory.createColorSpace(document, iccColorSpace) throws nullpointerexception

前端 未结 1 541
耶瑟儿~
耶瑟儿~ 2021-01-24 16:57

I\'m trying to create a PDF which has a single image on a single page. The tricky part is to use a custom (defined in a separate file) CMYK color space.

I\'ve tried to c

相关标签:
1条回答
  • 2021-01-24 17:07

    Ok, this seems to be a bug with the first constructor. You could use the second constructor, which uses a COSArray:

    The PDF spec explains what to do:

    "An ICCBased colour space shall be an array: [/ICCBased stream]"

    So you need to create a COSArray, with COSName.ICCBASED as first element, and a COSStream with your ICC data in the second. Create a COSStream and write to it with createFilteredStream(). That COSArray you can use for the second constructor.

    Alternatively, just use PDDeviceCMYK.INSTANCE as the colorspace :-)

    Update: I have opened issue PDFBOX-2812 and it has been fixed. You can get a snapshot in a few hours here.

    0 讨论(0)
提交回复
热议问题