DynaPDF Manual - Page 452

Previous Page 451   Index   Next Page 453

Function Reference
Page 452 of 839
Width and Height are passed to the member xExt, yExt of the structure METAFILEPICT which is
required to convert WMF files to EMF. The default size is 0, 0, that means the GDI calculates the size
automatically but mostly incorrect.
Because the GDI function SetWinMeatFileBits() is used to convert WMF files to EMF, WMF files are
not supported under Linux or UNIX.
Return Values:
If the function succeeds the return value is 1. If the function fails the return value is 0.
Example (Delphi):
// In this example, we have a paintbox (TPaintBox) on the form
// into which we paint an EMF file. The user can draw a rectangle when
// pressing the left mouse button, this rectangle is our cutting area.
// FView is a private variable of the type TRectL. Note that this
// rectangle must also be drawn in the OnPaint event of the paintbox.
procedure TForm1.PaintBoxMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y:
Integer);
var dc: HDC;
begin
dc := PaintBox.Canvas.Handle;
SetROP2(dc, R2_NOT);
SelectObject(dc, GetStockObject(NULL_BRUSH));
Rectangle(dc, FView.Left, FView.Top, FView.Right, FView.Bottom);
FView.Left
:= X;
FView.Top
:= Y;
FView.Right
:= X;
FView.Bottom := Y;
end;
procedure TForm1.PaintBoxMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
var dc: HDC;
begin
// The rectangle must be drawn twice, one time to delete the
// previous one, and the next time to draw the rectangle with the
// new size. There is no need to redraw the paintbox.
if (ssLeft in Shift) then begin
dc := PaintBox.Canvas.Handle;
SetROP2(dc, R2_NOT);
SelectObject(dc, GetStockObject(NULL_BRUSH));
Rectangle(dc, FView.Left, FView.Top, FView.Right, FView.Bottom);
FView.Right
:= X;
FView.Bottom := Y;
Rectangle(dc, FView.Left, FView.Top, FView.Right, FView.Bottom);
end;
end;
// ViewRect holds the current size of the graphic on screen.
procedure TForm1.CreatePDF(const EMF: String; const ViewRect: TRectL)
var pdf: TPDF; r: TRectL; sx, sy: Double; tmp: Integer;
begin
pdf := nil;
try
pdf := pdf.Create;
pdf.CreateNewPDFA('c:\dout.pdf');
pdf.SetDocInfo(diSubject, 'EMF-Files');
pdf.SetDocInfo(diTitle, 'Metafiles');
pdf.SetDocInfo(diCreator, 'Delphi Test Application');
pdf.Append;
pdf.SetPageCoords(pcTopDown);
pdf.GetLogMetafileSize(EMF, r);
// Make sure that the rectangle contains correct values
if (FView.Left > FView.Right) then begin
tmp := FView.Left;
 

Previous topic: GetLineWidth, GetLinkHighlightMode, GetLogMetafileSize

Next topic: GetLogMetafileSizeEx