Components for Developers
© 2000-2008, Two Pilots

PDF Library Download Features Manual Tutorials FAQ Pricing HTML2PDF Add-on History In the Lab

PDF Creator Pilot documentation

Download CHM version of this manual.
Patterns
AddUnColoredPattern

See Also Example
Collapse All

This method creates an uncolored pattern in a PDF document and returns its number. The uncolored pattern has no inherent color; the color must be specified separately whenever the pattern is used.

Syntax

LONG AddUnColoredPattern (
PatternTilingType tilingType,
ColorSpaceType type
)
Parameters
tilingType
Pattern tiling type that controls adjustments to the spacing of tiles relative to the device's pixel grid

type
Default colorspace type of the pattern

Return value
Number of the pattern

Remarks

The return value is an identifier in the document's patterns collection and can be used in the SetPattern and SwitchToPattern methods.

Example

Filling Shapes with a Pattern

Delphi
[copy to clipboard]
{ PDF object is supposed to be created }
pattern := PDF.AddUnColoredPattern(pttConstantSpacing, cstDefaultRGB);
PDF.SwitchToPattern(pattern);
PDF.PageHeight := 5;
PDF.PageWidth := 5;
PDF.SetColorSpaceType(cstDefaultRGB);
PDF.SetColor(1, 0, 0, 0); { this call will be ignored, as we compose uncolored pattern }
PDF.DrawCircle(2, 2, 2);
PDF.FillAndStroke;
PDF.SwitchToCurrentPage;

PDF.SetPattern(pattern);
{ now all paths will be filled with created pattern }

PDF.SetColor(0, 1, 0, 0);
helvetica := PDF.AddBuiltInFont(bfHelveticaBoldOblique, false, false);
PDF.UseFont(helvetica, 28);
PDF.ShowTextAt(50, 50, 'Uncolored Pattern colored green');
PDF.SetColor(0, 0, 1, 0);
PDF.ShowTextAt(50, 100, 'Same Pattern colored blue');
{ back to simple filling }
PDF.SetColorSpaceType(cstDefaultRGB);
PDF.SetColor(0, 0, 0, 0);
PDF.ShowTextAt(50, 150, 'Usual text');
PDF.SaveToFile('test.pdf', true);
C/C++
[copy to clipboard]
// PDF object is supposed to be created
long pattern = PDF->AddUnColoredPattern(pttConstantSpacing, cstDefaultRGB);
PDF->SwitchToPattern(pattern);
PDF->PageHeight = 5;
PDF->PageWidth = 5;
PDF->SetColorSpaceType(cstDefaultRGB);
PDF->SetColor(1, 0, 0, 0); //this call will be ignored, as we compose uncolored pattern
PDF->DrawCircle(2, 2, 2);
PDF->FillAndStroke();
PDF->SwitchToCurrentPage();

PDF->SetPattern(pattern);
// now all paths will be filled with created pattern

PDF->SetColor(0, 1, 0, 0);
long helvetica = PDF->AddBuiltInFont(bfHelveticaBoldOblique, false, false);
PDF->UseFont(helvetica, 28);
PDF->ShowTextAt(50, 50, "Uncolored Pattern colored green");
PDF->SetColor(0, 0, 1, 0);
PDF->ShowTextAt(50, 100, "Same Pattern colored blue");
// back to simple filling
PDF->SetColorSpaceType(cstDefaultRGB);
PDF->SetColor(0, 0, 0, 0);
PDF->ShowTextAt(50, 150, "Usual text");
PDF->SaveToFile("test.pdf", true);
C#
[copy to clipboard]
// PDF object is supposed to be created
long pattern = PDF.AddUnColoredPattern(PatternTilingType.pttConstantSpacing, ColorSpaceType.cstDefaultRGB);
PDF.SwitchToPattern(pattern);
PDF.PageHeight = 5;
PDF.PageWidth = 5;
PDF.SetColorSpaceType(ColorSpaceType.cstDefaultRGB);
PDF.SetColor(1, 0, 0, 0); //this call will be ignored, as we compose uncolored pattern
PDF.DrawCircle(2, 2, 2);
PDF.FillAndStroke();
PDF.SwitchToCurrentPage();

PDF.SetPattern(pattern);
// now all paths will be filled with created pattern

PDF.SetColor(0, 1, 0, 0);
long helvetica = PDF.AddBuiltInFont(BuiltInFont.bfHelveticaBoldOblique, false, false);
PDF.UseFont(helvetica, 28);
PDF.ShowTextAt(50, 50, "Uncolored Pattern colored green");
PDF.SetColor(0, 0, 1, 0);
PDF.ShowTextAt(50, 100, "Same Pattern colored blue");
// back to simple filling
PDF.SetColorSpaceType(ColorSpaceType.cstDefaultRGB);
PDF.SetColor(0, 0, 0, 0);
PDF.ShowTextAt(50, 150, "Usual text");
PDF.SaveToFile("test.pdf", true);
Visual Basic
[copy to clipboard]
' PDF object is supposed to be created
pattern = PDF.AddUnColoredPattern(1, 1)' pttConstantSpacing, cstDefaultRGB
PDF.SwitchToPattern pattern
PDF.PageHeight = 5
PDF.PageWidth = 5
PDF.SetColorSpaceType 1 'cstDefaultRGB
PDF.SetColor 1, 0, 0, 0 ' this call will be ignored, as we compose uncolored pattern
PDF.DrawCircle 2, 2, 2
PDF.FillAndStroke
PDF.SwitchToCurrentPage

PDF.SetPattern pattern
' now all paths will be filled with created pattern

PDF.SetColor 0, 1, 0, 0
helvetica = PDF.AddBuiltInFont(9, false, false) 'bfHelveticaBoldOblique
PDF.UseFont helvetica, 28
PDF.ShowTextAt 50, 50, "Uncolored Pattern colored green"
PDF.SetColor 0, 0, 1, 0
PDF.ShowTextAt 50, 100, "Same Pattern colored blue"
' back to simple filling
PDF.SetColorSpaceType 1 'cstDefaultRGB
PDF.SetColor 0, 0, 0, 0
PDF.ShowTextAt 50, 150, "Usual text"
PDF.SaveToFile "test.pdf", true

See Also

PDF Library Download Features Manual Tutorials FAQ Pricing HTML2PDF Add-on History In the Lab

 

 

PDF Library | Virtual Printer | Converters to PDF

Support | Blog | Forum | Contacts

© 2000-2008, Two Pilots