This repository was archived by the owner on Mar 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathUberPDFExample.Forms.Main.pas
More file actions
165 lines (141 loc) · 5.17 KB
/
UberPDFExample.Forms.Main.pas
File metadata and controls
165 lines (141 loc) · 5.17 KB
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
unit UberPDFExample.Forms.Main;
{$mode objfpc}{$H+}
//------------------------------------------------------------------------------
// Example producing various PDF files in the working directory:
// hello-world.pdf
// add-jpeg.pdf
// split-document.pdf
//------------------------------------------------------------------------------
// Written using Lazarus 1.9.0 / FPC 3.1.1.
//------------------------------------------------------------------------------
// Tested: Lazarus 1.9.0 / FPC 3.1.1 - Linux 64 (Ubuntu 17.10)
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// NOTES:
//------------------------------------------------------------------------------
// YOU MUST ADD TO PROJECT DEFINES the toolchain you are linking to. Examples:
// Menu->Project->Project Options->Compiler Options->Custom Options: (Linux 32)
// -dUBER_LINTEL32_GCC_LINTEL32
// Menu->Project->Project Options->Compiler Options->Custom Options: (Linux 64)
// -dUBER_LINTEL64_GCC_LINTEL64
//
// All these have been added under the Build Options available on the project.
// I've also adjusted the OS and CPU in each Build Option.
// Make sure you select the correct Build Option for your system.
// YOU MUST ADD TO PROJECT SEARCHPATH the include you are linking to. Examples:
// Menu->Project->Project Options->Other Unit Files (-Fu): (Linux 64bits)
// Path/To/UberPDFSDK/userbaselibs/uberpdfsdk/include/lintel64/gcc
// Menu->Project->Project Options->Include Files (-Fi):
// $(ProjOutDir);Path/To/UberPDFSDK/uberbaselibs/uberpdfsdk/include/lintel64/gcc
// Menu->Project->Project Options->Libraries (-FU):
// Path/To/UberPDFSDK/userbaselibs/uberpdfsdk/lib/lintel64/gcc/librtl
//
// Menu->Project->Project Options->Other Unit Files (-Fu): (Linux 32bits)
// Path/To/UberPDFSDK/userbaselibs/uberpdfsdk/include/lintel32/gcc
// Menu->Project->Project Options->Include Files (-Fi):
// $(ProjOutDir);Path/To/UberPDFSDK/uberbaselibs/uberpdfsdk/include/lintel32/gcc
// Menu->Project->Project Options->Libraries (-FU):
// Path/To/UberPDFSDK/userbaselibs/uberpdfsdk/lib/lintel32/gcc/librtl
//
// All these have been added under the Build Options available on the project.
// Make sure you select the correct Build Option for your system.
//------------------------------------------------------------------------------
// IMPORTANT:
// Please have a look at unit UberPDFExample.Common.pas for more paths to be
// taken care of.
//------------------------------------------------------------------------------
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, PairSplitter, StdCtrls,
ActnList, StdActns, UberPDFExample.Common, UberPDFExample.Examples.HelloWorld,
UberPDFExample.Examples.AddJPEG, UberPDFExample.Examples.SplitDocument,
UberPDFExample.Examples.StampedDocument;
type
{ TfrmMain }
TfrmMain = class(TForm)
alMain: TActionList;
btnEx_HelloWorld: TButton;
btnEx_AddJPG: TButton;
btnEx_SplitDocument: TButton;
btnEx_StampedDocument: TButton;
actFileExit: TFileExit;
lblFileQuit: TLabel;
lblHeader: TLabel;
memlog: TMemo;
psMain: TPairSplitter;
pssButtons: TPairSplitterSide;
pssLog: TPairSplitterSide;
procedure btnEx_AddJPGClick(Sender: TObject);
procedure btnEx_HelloWorldClick(Sender: TObject);
procedure btnEx_SplitDocumentClick(Sender: TObject);
procedure btnEx_StampedDocumentClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
procedure LogClear;
public
procedure Log(aMSG: String);
end;
var
frmMain: TfrmMain;
implementation
uses
LCLType;
{$R *.lfm}
{ TfrmMain }
procedure TfrmMain.FormCreate(Sender: TObject);
begin
Top := 100;
Left := 100;
{$IFDEF LINUX}
actFileExit.ShortCut := KeyToShortCut(VK_Q, [ssCtrl]);
lblFileQuit.Caption := 'To quit: Ctrl+Q, Alt+F4';
{$ENDIF}
{$IFDEF WINDOWS}
actFileExit.ShortCut := KeyToShortCut(VK_X, [ssAlt]);
lblFileQuit.Caption := 'To quit: Alt+X, Alt+F4';
{$ENDIF}
LogClear;
if (LoadUberPDFSdk()) then begin
Log('LoadUberPDFSdk() Succeeded');
end else begin
Log('LoadUberPDFSdk() Failed');
end;
end;
procedure TfrmMain.FormDestroy(Sender: TObject);
begin
UnLoadUberPDFSdk();
end;
procedure TfrmMain.btnEx_HelloWorldClick(Sender: TObject);
begin
btnEx_HelloWorld.Enabled := False;
UberPDFExample.Examples.HelloWorld.CreatePdfDocument;
btnEx_HelloWorld.Enabled := True;
end;
procedure TfrmMain.btnEx_SplitDocumentClick(Sender: TObject);
begin
btnEx_SplitDocument.Enabled := False;
UberPDFExample.Examples.SplitDocument.CreatePdfDocument;
btnEx_SplitDocument.Enabled := True;
end;
procedure TfrmMain.btnEx_StampedDocumentClick(Sender: TObject);
begin
btnEx_StampedDocument.Enabled := False;
UberPDFExample.Examples.StampedDocument.CreatePdfDocument;
btnEx_StampedDocument.Enabled := True;
end;
procedure TfrmMain.btnEx_AddJPGClick(Sender: TObject);
begin
btnEx_AddJPG.Enabled := False;
UberPDFExample.Examples.AddJPEG.CreatePdfDocument;
btnEx_AddJPG.Enabled := True;
end;
procedure TfrmMain.LogClear;
begin
memLog.Clear;
end;
procedure TfrmMain.Log(aMSG: String);
begin
memLog.Lines.Add(aMSG);
end;
end.