TransformColors
IPDFDocument3 :: General document methods

See Also Example
Collapse All

This method sets the specified ICC profile which all colors will be transformed to.

Syntax

HRESULT TransformColors (
BSTR colorspaceFile
)
Parameters
colorspaceFile
Path to the file with the colorspace

Return value
If successful, this method returns S_OK. If it fails, this method should return one of the error values.

Remarks

Only CMYK out profiles are supported.

Example

Transforming Colors

Delphi
[copy to clipboard]
{ PDF object is supposed to be created }
PDF.AutoLaunch := true;
PDF.FileName := 'test.pdf';

PDF.BeginDoc;

{ PDF will use icc file to transform colors.                       }
{ But we override 2 colors to our custom values:                   }
{  CMYK color (0, 0, 0, 0) -> CMYK color (0, 0, 0, 1)              }
{  CMYK while color (1, 1, 1, 0) -> CMYK yellow color (0, 0, 1, 0) }
PDF.TransformColorsToCMYK('USWebUncoated.icc');
PDF.AddColorTransformationRule(0, 0, 0, 0, 0, 0, 0, 1);
PDF.AddColorTransformationRule(1, 1, 1, 0, 0, 0, 1, 0);

PDF.PDFPAGE_SetTextRenderingMode(TxTextRenderingMode.trmFillAndStroke);
PDF.PDFPAGE_SetColorFill(0, 0, 0, 0);
PDF.PDFPAGE_SetColorStroke(0, 0, 0, 0);
PDF.PDFPAGE_TextShow('Hello, PDF');
PDF.PDFPAGE_SetColorFill(1, 1, 1, 0);
PDF.PDFPAGE_SetColorStroke(1, 1, 1, 0);
PDF.PDFPAGE_TextShow(' Hello, PDF');

PDF.EndDoc;
C/C++
[copy to clipboard]
// PDF object is supposed to be created
PDF->AutoLaunch = TRUE;
PDF->FileName = "test.pdf";

PDF->BeginDoc();

// PDF will use icc file to transform colors.
// But we override 2 colors to our custom values:
//  CMYK color (0, 0, 0, 0) -> CMYK color (0, 0, 0, 1)
//  CMYK while color (1, 1, 1, 0) -> CMYK yellow color (0, 0, 1, 0)
PDF->TransformColorsToCMYK("USWebUncoated.icc");
PDF->AddColorTransformationRule(0, 0, 0, 0, 0, 0, 0, 1);
PDF->AddColorTransformationRule(1, 1, 1, 0, 0, 0, 1, 0);

PDF->PDFPAGE_SetTextRenderingMode(trmFillAndStroke);
PDF->PDFPAGE_SetColorFill(0, 0, 0, 0);
PDF->PDFPAGE_SetColorStroke(0, 0, 0, 0);
PDF->PDFPAGE_TextShow("Hello, PDF");
PDF->PDFPAGE_SetColorFill(1, 1, 1, 0);
PDF->PDFPAGE_SetColorStroke(1, 1, 1, 0);
PDF->PDFPAGE_TextShow(" Hello, PDF");

PDF->EndDoc();
C#
[copy to clipboard]
// PDF object is supposed to be created
PDF.AutoLaunch = true;
PDF.FileName = "test.pdf";

PDF.BeginDoc();

// PDF will use icc file to transform colors.
// But we override 2 colors to our custom values:
//  CMYK color (0, 0, 0, 0) -> CMYK color (0, 0, 0, 1)
//  CMYK while color (1, 1, 1, 0) -> CMYK yellow color (0, 0, 1, 0)
PDF.TransformColorsToCMYK("USWebUncoated.icc");
PDF.AddColorTransformationRule(0, 0, 0, 0, 0, 0, 0, 1);
PDF.AddColorTransformationRule(1, 1, 1, 0, 0, 0, 1, 0);

PDF.PDFPAGE_SetTextRenderingMode(TxTextRenderingMode.trmFillAndStroke);
PDF.PDFPAGE_SetColorFill(0, 0, 0, 0);
PDF.PDFPAGE_SetColorStroke(0, 0, 0, 0);
PDF.PDFPAGE_TextShow("Hello, PDF");
PDF.PDFPAGE_SetColorFill(1, 1, 1, 0);
PDF.PDFPAGE_SetColorStroke(1, 1, 1, 0);
PDF.PDFPAGE_TextShow(" Hello, PDF");

PDF.EndDoc();
Visual Basic
[copy to clipboard]
' PDF object is supposed to be created
PDF.AutoLaunch = true
PDF.FileName = "test.pdf"

PDF.BeginDoc

' PDF will use icc file to transform colors.
' But we override 2 colors to our custom values:
'  CMYK color (0, 0, 0, 0) -> CMYK color (0, 0, 0, 1)
'  CMYK while color (1, 1, 1, 0) -> CMYK yellow color (0, 0, 1, 0)
PDF.TransformColorsToCMYK "USWebUncoated.icc"
PDF.AddColorTransformationRule 0, 0, 0, 0, 0, 0, 0, 1
PDF.AddColorTransformationRule 1, 1, 1, 0, 0, 0, 1, 0

PDF.PDFPAGE_SetTextRenderingMode 2 trmFillAndStroke
PDF.PDFPAGE_SetColorFill 0, 0, 0, 0
PDF.PDFPAGE_SetColorStroke 0, 0, 0, 0
PDF.PDFPAGE_TextShow "Hello, PDF"
PDF.PDFPAGE_SetColorFill 1, 1, 1, 0
PDF.PDFPAGE_SetColorStroke 1, 1, 1, 0
PDF.PDFPAGE_TextShow " Hello, PDF"

PDF.EndDoc

See Also

Reference