pdftools_toolbox.pdf.content.color_space

Classes

ColorSpace(handle)

class pdftools_toolbox.pdf.content.color_space.ColorSpace(handle)[source]

Bases: _NativeObject, ABC

static create_process_color_space(target_document: Document, type: ProcessColorSpaceType) ColorSpace[source]

Get the canonical grayscale, RGB, or CMYK color space.

Depending on the PDF/A compliance and the output intent, this is either a device color space (pdftools_toolbox.pdf.content.device_gray_color_space.DeviceGrayColorSpace , pdftools_toolbox.pdf.content.device_rgb_color_space.DeviceRgbColorSpace , pdftools_toolbox.pdf.content.device_cmyk_color_space.DeviceCmykColorSpace ), a calibrated color space (pdftools_toolbox.pdf.content.calibrated_gray_color_space.CalibratedGrayColorSpace , pdftools_toolbox.pdf.content.calibrated_rgb_color_space.CalibratedRgbColorSpace ), or an ICC-based color space (4-channel pdftools_toolbox.pdf.content.icc_based_color_space.IccBasedColorSpace ). The returned color space object is not yet used on any page, but it is associated with the given target document.

Parameters:
Returns:

newly created color space object

Return type:

pdftools_toolbox.pdf.content.color_space.ColorSpace

Raises:
  • OSError – Unable to read a required ICC profile or writing to the document

  • ValueError – if the targetDocument argument has already been closed

  • ValueError – if the targetDocument argument is read-only

static copy(target_document: Document, color_space: ColorSpace) ColorSpace[source]

Copy a color space

Copy a color space object from an input document to the given targetDocument. The returned object is associated with the given target document but not yet part of it.

Parameters:
Returns:

the copied color space, associated with the current document.

Return type:

pdftools_toolbox.pdf.content.color_space.ColorSpace

Raises:
  • OSError – Error reading from the source document or writing to the target document

  • pdftools_toolbox.corrupt_error.CorruptError – The source document is corrupt

  • pdftools_toolbox.conformance_error.ConformanceError – The conformance level of the source document is not compatible with the conformance level of the target document.

  • ValueError – if the targetDocument argument has already been closed

  • ValueError – if the targetDocument argument is read-only

  • ValueError – if the colorSpace object is not associated with an input document

  • ValueError – if the colorSpace object has already been closed

property component_count: int

the number of components in the color space.

Returns:

int

Raises:

StateError – if the color space has already been closed