This method creates a colored pattern in a PDF document and returns its number. A colored pattern is a pattern whose color is self-contained.
LONG AddColoredPattern ( PatternTilingType tilingType ) |
The return value is an identifier in the document's patterns collection and can be used in the SetPattern and SwitchToPattern methods.
{ PDF object is supposed to be created } pattern := PDF.AddColoredPattern(pttConstantSpacing); { compose a pattern } PDF.SwitchToPattern(pattern); PDF.PageHeight := 10; PDF.PageWidth := 10; PDF.SetColorSpaceType(cstDefaultRGB); PDF.SetColorFill(1, 0, 0, 0); { we may use color, as we compose colored pattern } PDF.DrawRectangle(0, 0, 5, 5, 0); PDF.Fill; PDF.SetColorFill(0, 1, 0, 0); PDF.DrawRectangle(5, 0, 5, 5, 0); PDF.Fill; PDF.SetColorFill(0, 0, 1, 0); PDF.DrawRectangle(0, 5, 5, 5, 0); PDF.Fill; PDF.SetColorFill(1, 0.5f, 0, 0); PDF.DrawRectangle(5, 5, 5, 5, 0); PDF.Fill; PDF.SwitchToCurrentPage; PDF.SetPattern(pattern); { now all paths will be filled with created pattern } helvetica := PDF.AddBuiltInFont(bfHelveticaBoldOblique, false, false); PDF.UseFont(helvetica, 58); PDF.ShowTextAt(50, 50, 'Pattern-filled text'); PDF.DrawCircle(200, 200, 80); PDF.FillAndStroke; PDF.SaveToFile('test.pdf', true);
// PDF object is supposed to be created long pattern = PDF->AddColoredPattern(pttConstantSpacing); // compose a pattern PDF->SwitchToPattern(pattern); PDF->PageHeight = 10; PDF->PageWidth = 10; PDF->SetColorSpaceType(cstDefaultRGB); PDF->SetColorFill(1, 0, 0, 0); //we may use color, as we compose colored pattern PDF->DrawRectangle(0, 0, 5, 5, 0); PDF->Fill(); PDF->SetColorFill(0, 1, 0, 0); PDF->DrawRectangle(5, 0, 5, 5, 0); PDF->Fill(); PDF->SetColorFill(0, 0, 1, 0); PDF->DrawRectangle(0, 5, 5, 5, 0); PDF->Fill(); PDF->SetColorFill(1, 0.5f, 0, 0); PDF->DrawRectangle(5, 5, 5, 5, 0); PDF->Fill(); PDF->SwitchToCurrentPage(); PDF->SetPattern(pattern); // now all paths will be filled with created pattern long helvetica = PDF->AddBuiltInFont(bfHelveticaBoldOblique, false, false); PDF->UseFont(helvetica, 58); PDF->ShowTextAt(50, 50, "Pattern-filled text"); PDF->DrawCircle(200, 200, 80); PDF->FillAndStroke(); PDF->SaveToFile("test.pdf", true);
// PDF object is supposed to be created long pattern = PDF.AddColoredPattern(PatternTilingType.pttConstantSpacing); // compose a pattern PDF.SwitchToPattern(pattern); PDF.PageHeight = 10; PDF.PageWidth = 10; PDF.SetColorSpaceType(ColorSpaceType.cstDefaultRGB); PDF.SetColorFill(1, 0, 0, 0); //we may use color, as we compose colored pattern PDF.DrawRectangle(0, 0, 5, 5, 0); PDF.Fill(); PDF.SetColorFill(0, 1, 0, 0); PDF.DrawRectangle(5, 0, 5, 5, 0); PDF.Fill(); PDF.SetColorFill(0, 0, 1, 0); PDF.DrawRectangle(0, 5, 5, 5, 0); PDF.Fill(); PDF.SetColorFill(1, 0.5f, 0, 0); PDF.DrawRectangle(5, 5, 5, 5, 0); PDF.Fill(); PDF.SwitchToCurrentPage(); PDF.SetPattern(pattern); // now all paths will be filled with created pattern long helvetica = PDF.AddBuiltInFont(BuiltInFont.bfHelveticaBoldOblique, false, false); PDF.UseFont(helvetica, 58); PDF.ShowTextAt(50, 50, "Pattern-filled text"); PDF.DrawCircle(200, 200, 80); PDF.FillAndStroke(); PDF.SaveToFile("test.pdf", true);
' PDF object is supposed to be created pattern = PDF.AddColoredPattern(1) 'pttConstantSpacing ' compose a pattern PDF.SwitchToPattern pattern PDF.PageHeight = 10 PDF.PageWidth = 10 PDF.SetColorSpaceType 1 'cstDefaultRGB PDF.SetColorFill 1, 0, 0, 0 ' will may use color, as we compose colored pattern PDF.DrawRectangle 0, 0, 5, 5, 0 PDF.Fill PDF.SetColorFill 0, 1, 0, 0 PDF.DrawRectangle 5, 0, 5, 5, 0 PDF.Fill PDF.SetColorFill 0, 0, 1, 0 PDF.DrawRectangle 0, 5, 5, 5, 0 PDF.Fill PDF.SetColorFill 1, .5, 0, 0 PDF.DrawRectangle 5, 5, 5, 5, 0 PDF.Fill PDF.SwitchToCurrentPage PDF.SetPattern pattern ' now all paths will be filled with created pattern helvetica = PDF.AddBuiltInFont(9, false, false) 'bfHelveticaBoldOblique PDF.UseFont helvetica, 58 PDF.ShowTextAt 50, 50, "Pattern-filled text" PDF.DrawCircle 200, 200, 80 PDF.FillAndStroke PDF.SaveToFile "test.pdf", true