File: cairoprog.lpr

package info (click to toggle)
lazarus 4.0%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 275,760 kB
  • sloc: pascal: 2,341,904; xml: 509,420; makefile: 348,726; cpp: 93,608; sh: 3,387; java: 609; perl: 297; sql: 222; ansic: 137
file content (164 lines) | stat: -rw-r--r-- 6,842 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
program cairoprog;

{$mode objfpc}{$H+}

uses
  Classes, Printers, Graphics, CairoCanvas;

var // This could also be TCairoSvgCanvas, TCairoPngCanvas or TCairoPsCanvas
  PrinterPDFCanvas: TCairoPdfCanvas;
  PrinterPSCanvas : TCairoPSCanvas;
  ImgSVG          : TCairoSvgCanvas;
  ImgPNG          : TCairoPngCanvas;
begin
  PrinterPDFCanvas := TCairoPdfCanvas.Create;
  try
    PrinterPDFCanvas.OutputFileName := 'CairoCanvas.pdf'; // OutputFileName must set before BeginDoc; Otherwise use stream property
    PrinterPDFCanvas.BeginDoc;
    // Font properties must be set, does not work otherwise.
    {$IFDEF MSWindows}
    PrinterPDFCanvas.Font.Name := 'Arial Unicode MS';
    {$ELSE}
    PrinterPDFCanvas.Font.Name := 'Arial'; // Font properties must be set, does not work otherwise.
    {$ENDIF}

    PrinterPDFCanvas.Brush.Color:=clYellow;
    PrinterPDFCanvas.Font.Height := 24;

    PrinterPDFCanvas.Ellipse(10, 20, 260, 120);

    PrinterPDFCanvas.TextOut(50, 60, 'Portrait');
    PrinterPDFCanvas.TextOut(50, 150, 'abcdefghijklmnopqrstuvwxyzåäö');
    PrinterPDFCanvas.TextOut(50, 220, 'ฉันหิวแล้ว');
    PrinterPDFCanvas.TextOut(50, 290, 'К нам в око́шко застучи́т');
    PrinterPDFCanvas.TextOut(50, 360, 'لا أتَكَلّمُ الْعَرَبيّة');

    PrinterPDFCanvas.Orientation:=poLandscape; //Orientation must set before new page
    PrinterPDFCanvas.NewPage;
    PrinterPDFCanvas.Ellipse(10, 20, 260, 120);
    PrinterPDFCanvas.Font.Color:=clnavy;
    PrinterPDFCanvas.TextOut(50, 60, 'Landscape');
    PrinterPDFCanvas.Font.Color:=clBlack;
    PrinterPDFCanvas.TextOut(50, 150, 'Finnish: wxyzåäö1234567890');
    PrinterPDFCanvas.TextOut(50, 220, 'Thai: ฉันหิวแล้ว');
    PrinterPDFCanvas.TextOut(50, 290, 'Russian: К нам в око́шко застучи́т');
    PrinterPDFCanvas.TextOut(50, 360, 'Arabic: لا أتَكَلّمُ الْعَرَبيّة');

    WriteLn('Written file ' + PrinterPDFCanvas.OutputFileName);
    PrinterPDFCanvas.EndDoc;
  finally
    PrinterPDFCanvas.Free;
  end;

  PrinterPSCanvas := TCairoPSCanvas.Create;
  try
    PrinterPDFCanvas.OutputFileName := 'CairoCanvas.ps'; // OutputFileName must set before BeginDoc; Otherwise use stream property
    PrinterPSCanvas.BeginDoc;
    // Font properties must be set, does not work otherwise.
    {$IFDEF MSWindows}
    PrinterPSCanvas.Font.Name := 'Arial Unicode MS';
    {$ELSE}
    PrinterPSCanvas.Font.Name := 'Arial'; // Font properties must be set, does not work otherwise.
    {$ENDIF}
    PrinterPSCanvas.Brush.Color:=clYellow;
    PrinterPSCanvas.Font.Height := 24;

    PrinterPSCanvas.Ellipse(10, 20, 260, 120);

    PrinterPSCanvas.TextOut(50, 60, 'Portrait');
    PrinterPSCanvas.TextOut(50, 150, 'abcdefghijklmnopqrstuvwxyzåäö');
    PrinterPSCanvas.TextOut(50, 220, 'ฉันหิวแล้ว');
    PrinterPSCanvas.TextOut(50, 290, 'К нам в око́шко застучи́т');
    PrinterPSCanvas.TextOut(50, 360, 'لا أتَكَلّمُ الْعَرَبيّة');

    PrinterPSCanvas.Orientation:=poLandscape; //Orientation must set before new page
    PrinterPSCanvas.NewPage;
    PrinterPSCanvas.Orientation:=poLandscape; //Orientation must set before new page
    PrinterPSCanvas.Ellipse(10, 20, 260, 120);
    PrinterPSCanvas.Font.Color:=clnavy;
    PrinterPSCanvas.TextOut(50, 60, 'Landscape');
    PrinterPSCanvas.Font.Color:=clBlack;
    PrinterPSCanvas.TextOut(50, 150, 'Finnish: wxyzåäö1234567890');
    PrinterPSCanvas.TextOut(50, 220, 'Thai: ฉันหิวแล้ว');
    PrinterPSCanvas.TextOut(50, 290, 'Russian: К нам в око́шко застучи́т');
    PrinterPSCanvas.TextOut(50, 360, 'Arabic: لا أتَكَلّمُ الْعَرَبيّة');

    WriteLn('Written file ' + PrinterPSCanvas.OutputFileName);
    PrinterPSCanvas.EndDoc;
  finally
    PrinterPSCanvas.Free;
  end;

  ImgSVG := TCairoSvgCanvas.Create;
  try
    ImgSVG.OutputFileName := 'CairoCanvas.svg'; // OutputFileName must set before BeginDoc; Otherwise use stream property
    ImgSVG.BeginDoc;
    // Font properties must be set, does not work otherwise.
    {$IFDEF MSWindows}
    ImgSVG.Font.Name := 'Arial Unicode MS';
    {$ELSE}
    ImgSVG.Font.Name := 'Arial'; // Font properties must be set, does not work otherwise.
    {$ENDIF}
    ImgSVG.Brush.Color:=clYellow;
    ImgSVG.Font.Height := 24;

    ImgSVG.Orientation:=poLandscape; //Orientation must set before new page
    ImgSVG.NewPage;
    ImgSVG.Ellipse(10, 20, 260, 120);
    ImgSVG.Font.Color:=clnavy;
    ImgSVG.TextOut(50, 60, 'Landscape');
    ImgSVG.Font.Color:=clBlack;
    ImgSVG.TextOut(50, 150, 'Finnish: wxyzåäö1234567890');
    ImgSVG.TextOut(50, 220, 'Thai: ฉันหิวแล้ว');
    ImgSVG.TextOut(50, 290, 'Russian: К нам в око́шко застучи́т');
    ImgSVG.TextOut(50, 360, 'Arabic: لا أتَكَلّمُ الْعَرَبيّة');

    ImgSVG.Orientation:=poLandscape; //Orientation must set before new page
    ImgSVG.NewPage;
    ImgSVG.Orientation:=poLandscape; //Orientation must set before new page
    ImgSVG.Ellipse(10, 20, 260, 120);
    ImgSVG.Font.Color:=clnavy;
    ImgSVG.TextOut(50, 60, 'Landscape');
    ImgSVG.Font.Color:=clBlack;
    ImgSVG.TextOut(50, 150, 'Finnish: wxyzåäö1234567890');
    ImgSVG.TextOut(50, 220, 'Thai: ฉันหิวแล้ว');
    ImgSVG.TextOut(50, 290, 'Russian: К нам в око́шко застучи́т');
    ImgSVG.TextOut(50, 360, 'Arabic: لا أتَكَلّمُ الْعَرَبيّة');

    WriteLn('Written file ' + ImgSVG.OutputFileName);
    ImgSVG.EndDoc;
  finally
    ImgSVG.Free;
  end;
  ImgPNG := TCairoPNGCanvas.Create;
  try
    ImgPNG.OutputFileName := 'CairoCanvas.png'; // OutputFileName must set before BeginDoc; Otherwise use stream property
    ImgPNG.BeginDoc;
    // Font properties must be set, does not work otherwise.
    {$IFDEF MSWindows}
    ImgPNG.Font.Name := 'Arial Unicode MS';
    {$ELSE}
    ImgPNG.Font.Name := 'Arial'; // Font properties must be set, does not work otherwise.
    {$ENDIF}
    ImgPNG.Brush.Color:=clYellow;
    ImgPNG.Font.Height := 24;

    ImgPNG.Orientation:=poLandscape; //Orientation must set before new page
    ImgPNG.NewPage;
    ImgPNG.Ellipse(10, 20, 260, 120);
    ImgPNG.Font.Color:=clnavy;
    ImgPNG.TextOut(50, 60, 'Landscape');
    ImgPNG.Font.Color:=clBlack;
    ImgPNG.TextOut(50, 150, 'Finnish: wxyzåäö1234567890');
    ImgPNG.TextOut(50, 220, 'Thai: ฉันหิวแล้ว');
    ImgPNG.TextOut(50, 290, 'Russian: К нам в око́шко застучи́т');
    ImgPNG.TextOut(50, 360, 'Arabic: لا أتَكَلّمُ الْعَرَبيّة');

    WriteLn('Written file ' + ImgPNG.OutputFileName);
    ImgPNG.EndDoc;
  finally
    ImgPNG.Free;
  end;

end.