mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-08 16:28:24 +02:00
* Example for monospace fonts and subsetting
git-svn-id: trunk@48697 -
This commit is contained in:
parent
aa4fd5e6b1
commit
e08a2ea86b
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -3882,6 +3882,7 @@ packages/fcl-pdf/Makefile svneol=native#text/plain
|
||||
packages/fcl-pdf/Makefile.fpc svneol=native#text/plain
|
||||
packages/fcl-pdf/examples/diamond.png -text svneol=unset#image/png
|
||||
packages/fcl-pdf/examples/metautf16.pp svneol=native#text/plain
|
||||
packages/fcl-pdf/examples/monospacetext.pp svneol=native#text/plain
|
||||
packages/fcl-pdf/examples/poppy.jpg -text
|
||||
packages/fcl-pdf/examples/testfppdf.lpi svneol=native#text/plain
|
||||
packages/fcl-pdf/examples/testfppdf.lpr svneol=native#text/plain
|
||||
|
56
packages/fcl-pdf/examples/monospacetext.pp
Normal file
56
packages/fcl-pdf/examples/monospacetext.pp
Normal file
@ -0,0 +1,56 @@
|
||||
program monospacetext;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
{$codepage UTF8}
|
||||
|
||||
uses
|
||||
Classes, SysUtils,
|
||||
fpPDF;
|
||||
|
||||
var
|
||||
PDF: TPDFDocument;
|
||||
Font1, Font2, Font3, Font4: integer;
|
||||
begin
|
||||
if ParamCount<1 then
|
||||
begin
|
||||
Writeln(stderr,'Usage : monospacetext <fontdir>');
|
||||
Writeln(stderr,'Needed fonts : cour.ttf, arial.ttf, verdanab.ttf consola.ttf');
|
||||
Halt(1);
|
||||
end;
|
||||
PDF := TPDFDocument.Create(nil);
|
||||
PDF.Infos.Producer := '';
|
||||
PDF.Infos.CreationDate := Now;
|
||||
PDF.Options := [poPageOriginAtTop, {poNoEmbeddedFonts,} poSubsetFont, poCompressFonts, poCompressImages];
|
||||
PDF.DefaultOrientation := ppoPortrait;
|
||||
PDF.DefaultPaperType := ptA4;
|
||||
PDF.DefaultUnitOfMeasure := uomMillimeters;
|
||||
PDF.FontDirectory := paramstr(1);
|
||||
PDF.StartDocument;
|
||||
PDF.Sections.AddSection;
|
||||
PDF.Sections[0].AddPage(PDF.Pages.AddPage);;
|
||||
|
||||
//FontIndex := PDF.AddFont('Courier');
|
||||
Font1 := PDF.AddFont('cour.ttf', 'Courier New');
|
||||
Font2 := PDF.AddFont('arial.ttf', 'Arial');
|
||||
Font3 := PDF.AddFont('verdanab.ttf', 'Verdana');
|
||||
Font4 := PDF.AddFont('consola.ttf', 'Consolas');
|
||||
PDF.Pages[0].SetFont(Font1, 10);
|
||||
PDF.Pages[0].WriteText(10,10,'AEIOU-ÁÉÍÓÚ-ČŠŇŽ');
|
||||
PDF.Pages[0].WriteText(10,15,'----------------');
|
||||
|
||||
PDF.Pages[0].SetFont(Font2, 10);
|
||||
PDF.Pages[0].WriteText(10,30,'AEIOU-ÁÉÍÓÚ-ČŠŇŽ');
|
||||
PDF.Pages[0].WriteText(10,35,'----------------');
|
||||
|
||||
PDF.Pages[0].SetFont(Font3, 10);
|
||||
PDF.Pages[0].WriteText(10,40,'AEIOU-ÁÉÍÓÚ-ČŠŇŽ');
|
||||
PDF.Pages[0].WriteText(10,45,'----------------');
|
||||
|
||||
PDF.Pages[0].SetFont(Font4, 10);
|
||||
PDF.Pages[0].WriteText(10,50,'AEIOU-ÁÉÍÓÚ-ČŠŇŽ');
|
||||
PDF.Pages[0].WriteText(10,55,'----------------');
|
||||
|
||||
PDF.SaveToFile('test.pdf');
|
||||
PDF.Free;
|
||||
end.
|
||||
|
Loading…
Reference in New Issue
Block a user