DynaPDF Manual - Page 154

Previous Page 153   Index   Next Page 155

Function Reference
Page 154 of 818
patterns are applied like a mask in the user defined color. The color must be defined in the current
color space.
To disable a pattern just change the current fill or stroke color with SetFillColor(), SetStrokeColor()
or SetColors().
Return values:
If the function succeeds the return value is 1. If the function fails the return value is 0.
Example (Delphi):
{$R *.dfm}
uses dynapdf; // include the unit dynapdf.pas
// First we define our callback function that is called if an
// error occurred. Note: The calling convention is stdcall!
function ErrProc(const Data: Pointer; ErrCode: Integer; const ErrMessage:
PAnsiChar; ErrType: Integer): Integer; stdcall;
var s: String;
s := Format('%s'#13'Abort processing?', [ErrMessage]);
if MessageDlg(s, mtError, [mbYes, mbNo], 0) = mrYes then
Result := -1 // break processing
Result := 0; // try to continue
procedure TForm1.Button1Click(Sender: TObject);
var pdf: TPDF; pat: Integer; cw, h: Single;
pdf := nil;
pdf := TPDF.Create;
// Set the error callback first. No need to check return values.
pdf.SetOnErrorProc(nil, @ErrProc);
pdf.SetDocInfoA(diAuthor, 'Jens Boschulte');
pdf.SetDocInfoA(diCreator, 'Delphi sample project');
pdf.SetDocInfoA(diSubject, 'How to use patterns');
pdf.SetDocInfoA(diTitle, 'Vector graphics');
pdf.SetViewerPreferences(vpDisplayDocTitle, avNone);
// create a colored tiling pattern
pat := pdf.BeginPattern(ptColored, ttFastConstSpacing, 20, 20);
pdf.SetFontA('ZapfDingbats', fsNone, 12, false, cp1252);
h := pdf.GetAscent;
cw := pdf. GetTextWidthA(#171);
pdf.WriteTextA(0, 0, #171);

Previous topic: ApplyAppEvent, ApplyPattern

Next topic: ApplyShading

Start Chat