Last change
on this file was 455, checked in by chronos, 12 years ago |
- Modified: PrintPreview should use TVectorCanvas instead of raster TCanvas dependent on DPI of printer. But some font function as TextWidth and TextHeight cannot be easily implemented without use of OS API.
|
File size:
1.2 KB
|
Line | |
---|
1 | unit UFormMain;
|
---|
2 |
|
---|
3 | {$mode objfpc}{$H+}
|
---|
4 |
|
---|
5 | interface
|
---|
6 |
|
---|
7 | uses
|
---|
8 | Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
|
---|
9 | UPrintPreview;
|
---|
10 |
|
---|
11 | type
|
---|
12 |
|
---|
13 | { TFormMain }
|
---|
14 |
|
---|
15 | TFormMain = class(TForm)
|
---|
16 | ButtonPreview: TButton;
|
---|
17 | PrintPreview1: TPrintPreview;
|
---|
18 | procedure ButtonPreviewClick(Sender: TObject);
|
---|
19 | procedure PrintPreview1Print(Sender: TObject);
|
---|
20 | private
|
---|
21 | { private declarations }
|
---|
22 | public
|
---|
23 | { public declarations }
|
---|
24 | end;
|
---|
25 |
|
---|
26 | var
|
---|
27 | FormMain: TFormMain;
|
---|
28 |
|
---|
29 | implementation
|
---|
30 |
|
---|
31 | {$R *.lfm}
|
---|
32 |
|
---|
33 | { TFormMain }
|
---|
34 |
|
---|
35 | procedure TFormMain.ButtonPreviewClick(Sender: TObject);
|
---|
36 | begin
|
---|
37 | PrintPreview1.Execute;
|
---|
38 | end;
|
---|
39 |
|
---|
40 | procedure TFormMain.PrintPreview1Print(Sender: TObject);
|
---|
41 | begin
|
---|
42 | with PrintPreview1, Canvas do begin
|
---|
43 | Font.Name := 'Arial';
|
---|
44 | Font.Height := -Round(Font.PixelsPerInch / SizeDivider);
|
---|
45 | Font.Color := clBlack;
|
---|
46 | PageTitle := 'Print preview demo';
|
---|
47 | Line(MMToPixels(10), MMToPixels(10), MMToPixels(100), MMToPixels(100));
|
---|
48 | TextOut(MMToPixels(50), MMToPixels(100), 'Some simple text');
|
---|
49 | Font.Height := -Round(Font.PixelsPerInch / SizeDivider * 4);
|
---|
50 | TextOut(MMToPixels(100), MMToPixels(150), 'Big text');
|
---|
51 | end;
|
---|
52 | end;
|
---|
53 |
|
---|
54 | end.
|
---|
55 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.