Xojo Conferences
XDCMay2019MiamiUSA
MBSOct2019CologneDE

DynaPDF Manual - Page 138

Previous Page 137   Index   Next Page 139

Function Reference
Page 138 of 766
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):
implementation
{$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:
PChar; ErrType: Integer): Integer; stdcall;
var s: String;
begin
s := Format('%s'#13'Abort processing?', [ErrMessage]);
if MessageDlg(s, mtError, [mbYes, mbNo], 0) = mrYes then
Result := -1 // break processing
else
Result := 0; // try to continue
end;
procedure TForm1.Button1Click(Sender: TObject);
var pdf: TPDF; pat: Integer; cw, h: Single;
begin
pdf := nil;
try
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);
pdf.CreateNewPDFA('c:\dout.pdf');
pdf.Append;
// 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.SetFillColor(clRed);
pdf.WriteTextA(0, 0, #171);
pdf.SetFillColor(clGreen);
pdf.WriteText(cw +2, 0, #170);
pdf.SetFillColor(clBlue);
 

Previous topic: ApplyPattern

Next topic: ApplyShading