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):
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:
PAnsiChar; 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);
 

Previous topic: ApplyAppEvent, ApplyPattern

Next topic: ApplyShading


Start Chat