mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-12-03 00:17:18 +01:00
A simple example of generating a PDF file with CairoCanvas.
git-svn-id: trunk@47675 -
This commit is contained in:
parent
d457ad2a3e
commit
5b2a9ea16a
2
.gitattributes
vendored
2
.gitattributes
vendored
@ -630,6 +630,8 @@ components/cairocanvas/cairocanvas_pkg.pas svneol=native#text/plain
|
||||
components/cairocanvas/cairocanvasall.pas svneol=native#text/plain
|
||||
components/cairocanvas/cairographics.pas svneol=native#text/plain
|
||||
components/cairocanvas/cairoprinter.pas svneol=native#text/pascal
|
||||
components/cairocanvas/example/cairoprog.lpi svneol=native#text/plain
|
||||
components/cairocanvas/example/cairoprog.lpr svneol=native#text/pascal
|
||||
components/cairocanvas/tests/24217/project1.lpi svneol=native#text/plain
|
||||
components/cairocanvas/tests/24217/project1.lpr svneol=native#text/pascal
|
||||
components/cairocanvas/tests/24217/unit1.lfm svneol=native#text/plain
|
||||
|
||||
69
components/cairocanvas/example/cairoprog.lpi
Normal file
69
components/cairocanvas/example/cairoprog.lpi
Normal file
@ -0,0 +1,69 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<Version Value="9"/>
|
||||
<General>
|
||||
<Flags>
|
||||
<MainUnitHasCreateFormStatements Value="False"/>
|
||||
<MainUnitHasTitleStatement Value="False"/>
|
||||
</Flags>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<MainUnit Value="0"/>
|
||||
<Title Value="cairoprog"/>
|
||||
<UseAppBundle Value="False"/>
|
||||
<ResourceType Value="res"/>
|
||||
</General>
|
||||
<i18n>
|
||||
<EnableI18N LFM="False"/>
|
||||
</i18n>
|
||||
<VersionInfo>
|
||||
<StringTable ProductVersion=""/>
|
||||
</VersionInfo>
|
||||
<BuildModes Count="1">
|
||||
<Item1 Name="Default" Default="True"/>
|
||||
</BuildModes>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
</PublishOptions>
|
||||
<RunParams>
|
||||
<local>
|
||||
<FormatVersion Value="1"/>
|
||||
</local>
|
||||
</RunParams>
|
||||
<RequiredPackages Count="1">
|
||||
<Item1>
|
||||
<PackageName Value="cairocanvas_pkg"/>
|
||||
</Item1>
|
||||
</RequiredPackages>
|
||||
<Units Count="1">
|
||||
<Unit0>
|
||||
<Filename Value="cairoprog.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="cairoprog"/>
|
||||
</Unit0>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<Target>
|
||||
<Filename Value="cairoprog"/>
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||
<UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
</CompilerOptions>
|
||||
<Debugging>
|
||||
<Exceptions Count="3">
|
||||
<Item1>
|
||||
<Name Value="EAbort"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<Name Value="ECodetoolError"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<Name Value="EFOpenError"/>
|
||||
</Item3>
|
||||
</Exceptions>
|
||||
</Debugging>
|
||||
</CONFIG>
|
||||
28
components/cairocanvas/example/cairoprog.lpr
Normal file
28
components/cairocanvas/example/cairoprog.lpr
Normal file
@ -0,0 +1,28 @@
|
||||
program cairoprog;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
uses
|
||||
Classes, CairoCanvas;
|
||||
|
||||
var // This could also be TCairoSvgCanvas, TCairoPngCanvas or TCairoPsCanvas
|
||||
PrinterCanvas: TCairoPdfCanvas;
|
||||
begin
|
||||
PrinterCanvas := TCairoPdfCanvas.Create;
|
||||
try
|
||||
PrinterCanvas.OutputFileName := 'CairoCanvas.pdf';
|
||||
PrinterCanvas.Ellipse(20, 20, 170, 120);
|
||||
//PrinterCanvas.XDPI := 75; // These have valid default values.
|
||||
//PrinterCanvas.YDPI := 75;
|
||||
//PrinterCanvas.PaperWidth := 250;
|
||||
//PrinterCanvas.PaperHeight := 500;
|
||||
PrinterCanvas.Font.Name := 'Arial'; // Font properties must be set, does not work otherwise.
|
||||
PrinterCanvas.Font.Height := 24;
|
||||
PrinterCanvas.TextOut(50, 150, 'abcdefghijklmnopqrstuvwxyzåäö');
|
||||
WriteLn('Written file ' + PrinterCanvas.OutputFileName);
|
||||
ReadLn;
|
||||
finally
|
||||
PrinterCanvas.Free;
|
||||
end;
|
||||
end.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user