TransformColors
IPDFDocument4 :: General document management :: Common

See Also Example
Collapse All

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

Syntax

HRESULT TransformColors (
BSTR colorspaceFile
)
Parameters
colorspaceFile
Path to the file containing a color space

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 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.TransformColors('USWebUncoated.icc');
PDF.AddColorTransformationRule(0, 0, 0, 0, 0, 0, 0, 1);
PDF.AddColorTransformationRule(1, 1, 1, 0, 0, 0, 1, 0);

PDF.SetTextRenderingMode(trFillAndStroke);
PDF.SetColorFill(0, 0, 0, 0);
PDF.SetColorStroke(0, 0, 0, 0);
PDF.ShowText('Hello, PDF');
PDF.SetColorFill(1, 1, 1, 0);
PDF.SetColorStroke(1, 1, 1, 0);
PDF.ShowText(' Hello, PDF');
PDF.SaveToFile('test.pdf', true);
C/C++
[copy to clipboard]
// PDF object is supposed to be created

// 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->TransformColors("USWebUncoated.icc");
PDF->AddColorTransformationRule(0, 0, 0, 0, 0, 0, 0, 1);
PDF->AddColorTransformationRule(1, 1, 1, 0, 0, 0, 1, 0);

PDF->SetTextRenderingMode(trFillAndStroke);
PDF->SetColorFill(0, 0, 0, 0);
PDF->SetColorStroke(0, 0, 0, 0);
PDF->ShowText("Hello, PDF");
PDF->SetColorFill(1, 1, 1, 0);
PDF->SetColorStroke(1, 1, 1, 0);
PDF->ShowText(" Hello, PDF");
PDF->SaveToFile("test.pdf", TRUE);
C#
[copy to clipboard]
// PDF object is supposed to be created

// 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.TransformColors("USWebUncoated.icc");
PDF.AddColorTransformationRule(0, 0, 0, 0, 0, 0, 0, 1);
PDF.AddColorTransformationRule(1, 1, 1, 0, 0, 0, 1, 0);

PDF.SetTextRenderingMode(TextRenderingMode.trFillAndStroke);
PDF.SetColorFill(0, 0, 0, 0);
PDF.SetColorStroke(0, 0, 0, 0);
PDF.ShowText("Hello, PDF");
PDF.SetColorFill(1, 1, 1, 0);
PDF.SetColorStroke(1, 1, 1, 0);
PDF.ShowText(" Hello, PDF");
PDF.SaveToFile("test.pdf", true);
Visual Basic
[copy to clipboard]
' PDF object is supposed to be created

' 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.TransformColors "USWebUncoated.icc"
PDF.AddColorTransformationRule 0, 0, 0, 0, 0, 0, 0, 1
PDF.AddColorTransformationRule 1, 1, 1, 0, 0, 0, 1, 0

PDF.SetTextRenderingMode 2 'trFillAndStroke
PDF.SetColorFill 0, 0, 0, 0
PDF.SetColorStroke 0, 0, 0, 0
PDF.ShowText "Hello, PDF"
PDF.SetColorFill 1, 1, 1, 0
PDF.SetColorStroke 1, 1, 1, 0
PDF.ShowText " Hello, PDF"
PDF.SaveToFile "test.pdf", true

See Also

Reference