1program monospacetext;
2
3{$mode objfpc}{$H+}
4{$codepage UTF8}
5
6uses
7  Classes, SysUtils,
8  fpPDF;
9
10var
11  PDF: TPDFDocument;
12  Font1, Font2, Font3, Font4: integer;
13begin
14  if ParamCount<1 then
15    begin
16    Writeln(stderr,'Usage : monospacetext <fontdir>');
17    Writeln(stderr,'Needed fonts : cour.ttf, arial.ttf, verdanab.ttf consola.ttf');
18    Halt(1);
19    end;
20  PDF := TPDFDocument.Create(nil);
21  PDF.Infos.Producer := '';
22  PDF.Infos.CreationDate := Now;
23  PDF.Options := [poPageOriginAtTop, {poNoEmbeddedFonts,} poSubsetFont, poCompressFonts, poCompressImages];
24  PDF.DefaultOrientation := ppoPortrait;
25  PDF.DefaultPaperType := ptA4;
26  PDF.DefaultUnitOfMeasure := uomMillimeters;
27  PDF.FontDirectory := paramstr(1);
28  PDF.StartDocument;
29  PDF.Sections.AddSection;
30  PDF.Sections[0].AddPage(PDF.Pages.AddPage);;
31
32  //FontIndex := PDF.AddFont('Courier');
33  Font1 := PDF.AddFont('cour.ttf', 'Courier New');
34  Font2 := PDF.AddFont('arial.ttf', 'Arial');
35  Font3 := PDF.AddFont('verdanab.ttf', 'Verdana');
36  Font4 := PDF.AddFont('consola.ttf', 'Consolas');
37  PDF.Pages[0].SetFont(Font1, 10);
38  PDF.Pages[0].WriteText(10,10,'AEIOU-ÁÉÍÓÚ-ČŠŇŽ');
39  PDF.Pages[0].WriteText(10,15,'----------------');
40
41  PDF.Pages[0].SetFont(Font2, 10);
42  PDF.Pages[0].WriteText(10,30,'AEIOU-ÁÉÍÓÚ-ČŠŇŽ');
43  PDF.Pages[0].WriteText(10,35,'----------------');
44
45  PDF.Pages[0].SetFont(Font3, 10);
46  PDF.Pages[0].WriteText(10,40,'AEIOU-ÁÉÍÓÚ-ČŠŇŽ');
47  PDF.Pages[0].WriteText(10,45,'----------------');
48
49  PDF.Pages[0].SetFont(Font4, 10);
50  PDF.Pages[0].WriteText(10,50,'AEIOU-ÁÉÍÓÚ-ČŠŇŽ');
51  PDF.Pages[0].WriteText(10,55,'----------------');
52
53  PDF.SaveToFile('test.pdf');
54  PDF.Free;
55end.
56
57