Components for Developers
© 2000-2012, Two Pilots

PDF Library Download Features Manual Tutorials FAQ Pricing HTML2PDF-X Pilot History In the Lab

PDF Creator Pilot documentation

Download CHM version of this manual.
Transparency
Collapse All

This method sets the new opacity level for fill color.

Syntax

HRESULT SetOpacityFill (
FLOAT opacity
)
Parameters
opacity
New opacity level

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

Example

Using Opacity

Delphi
[copy to clipboard]
{ PDF object is supposed to be created }
PDF.SetColorSpaceType(cstDefaultRGB);
PDF.SetLineWidth(10);

{ 1st square }
PDF.SetColorStroke(0, 0, 0, 0);
PDF.SetColorFill(1, 0, 0, 0);
PDF.DrawRectangle(50, 50, 100, 100, 0);
PDF.FillAndStroke;

{ 2nd square }
PDF.SetColor(0, 0, 1, 0);
PDF.SetOpacityStroke(0.2);
PDF.SetOpacityFill(0.8);
{ or just set the same opacity level for
  both colors, call:
   PDF.SetOpacity(0.5); }
PDF.DrawRectangle(100, 100, 100, 100, 0);
PDF.FillAndStroke;

PDF.SetColorStroke(0, 1, 0, 0);
PDF.SetColorFill(0.2, 0.2, 1, 0);
PDF.DrawRectangle(100, 100, 100, 100, 0);
PDF.FillAndStroke;

PDF.SaveToFile('test.pdf', true);
C/C++
[copy to clipboard]
// PDF object is supposed to be created
PDF->SetColorSpaceType(cstDefaultRGB);
PDF->SetLineWidth(10);

//1st square
PDF.SetColorStroke(0, 0, 0, 0);
PDF.SetColorFill(1, 0, 0, 0);
PDF.DrawRectangle(50, 50, 100, 100, 0);
PDF.FillAndStroke();

//2nd square
PDF->SetColor(0, 0, 1, 0);
PDF->SetOpacityStroke(0.2f);
PDF->SetOpacityFill(0.8f);
// or just set the same opacity level for
// both colors, call:
//  PDF->SetOpacity(0.5f);
PDF->DrawRectangle(100, 100, 100, 100, 0);
PDF->FillAndStroke();

PDF->SetColorStroke(0, 1, 0, 0);
PDF->SetColorFill(0.2f, 0.2f, 1, 0);
PDF->DrawRectangle(100, 100, 100, 100, 0);
PDF->FillAndStroke();

PDF->SaveToFile("test.pdf", true);
C#
[copy to clipboard]
// PDF object is supposed to be created
PDF.SetColorSpaceType(ColorSpaceType.cstDefaultRGB);
PDF.SetLineWidth(10);

//1st square
PDF.SetColorStroke(0, 0, 0, 0);
PDF.SetColorFill(1, 0, 0, 0);
PDF.DrawRectangle(50, 50, 100, 100, 0);
PDF.FillAndStroke();

//2nd square
PDF.SetColor(0, 0, 1, 0);
PDF.SetOpacityStroke(0.2);
PDF.SetOpacityFill(0.8);
// or just set the same opacity level for
// both colors, call:
//  PDF.SetOpacity(0.5);
PDF.DrawRectangle(100, 100, 100, 100, 0);
PDF.FillAndStroke();

PDF.SetColorStroke(0, 1, 0, 0);
PDF.SetColorFill(0.2, 0.2, 1, 0);
PDF.DrawRectangle(100, 100, 100, 100, 0);
PDF.FillAndStroke();

PDF.SaveToFile("test.pdf", true);
Visual Basic
[copy to clipboard]
' PDF object is supposed to be created
PDF.SetColorSpaceType 1 'ColorSpaceType.cstDefaultRGB
PDF.SetLineWidth 10

'1st square
PDF.SetColorStroke 0, 0, 0, 0
PDF.SetColorFill 1, 0, 0, 0
PDF.DrawRectangle 50, 50, 100, 100, 0
PDF.FillAndStroke

'2nd square
PDF.SetColor 0, 0, 1, 0
PDF.SetOpacityStroke 0.2
PDF.SetOpacityFill 0.8
'' or just set the same opacity level for
'' both colors, call:
''  PDF.SetOpacity 0.5
PDF.DrawRectangle 100, 100, 100, 100, 0
PDF.FillAndStroke

PDF.SetColorStroke 0, 1, 0, 0
PDF.SetColorFill 0.2, 0.2, 1, 0
PDF.DrawRectangle 100, 100, 100, 100, 0
PDF.FillAndStroke

PDF.SaveToFile "test.pdf", true

See Also

PDF Library Download Features Manual Tutorials FAQ Pricing HTML2PDF-X Pilot History In the Lab

 

 

PDF Library | Virtual Printer | Converters to PDF

Support | Blog | Forum | Contacts

© 2000-2012, Two Pilots