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.Common.pas
More file actions
140 lines (124 loc) · 5.17 KB
/
UberPDFExample.Common.pas
File metadata and controls
140 lines (124 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
unit UberPDFExample.Common;
{$mode objfpc}{$H+}
//------------------------------------------------------------------------------
// These are the paths for the *.a in order to get a static compile
//------------------------------------------------------------------------------
{$IFNDEF UBER_PDFSDK_USE_DYNAMIC_LIB_LOADER}
{$IFDEF UNIX}
{$LINKLIB libuberpdfsdk.a}
{$LINKLIB libqpdf.a}
{$LINKLIB libjpeg.a}
{$LINKLIB libpng.a}
{$LINKLIB libz.a}
{$ENDIF}
{$IFDEF WINDOWS}
{$LINKLIB libuberpdfsdk.lib}
{$LINKLIB libqpdf.lib}
{$LINKLIB libjpeg.lib}
{$LINKLIB libpng.lib}
{$LINKLIB libz.lib}
{$ENDIF}
{$ENDIF}
//------------------------------------------------------------------------------
interface
//------------------------------------------------------------------------------
// include the file to let uber figure out what compiler and version is used
//------------------------------------------------------------------------------
{$INCLUDE 'uber_base_unit_compiler_version_defs.pascal-inc'}
//------------------------------------------------------------------------------
// AFTER THE "USES" CLAUSE BELOW YOU MUST DEFINE THE PATH TO THE UBER_PDFSDK_SO
// using the const UBER_PDFSDK_SO_NAME = 'PATH_TO_UBER_PDFSDK_DYN_LIB';
// (see below).
//------------------------------------------------------------------------------
uses
Classes, SysUtils
{$IFDEF UBER_PDFSDK_USE_DYNAMIC_LIB_LOADER}
,libuberpdfsdkdyn_pascal;
{$ELSE}
;
{$ENDIF}
//------------------------------------------------------------------------------
// Include the Uber base types
//------------------------------------------------------------------------------
{$INCLUDE 'uber_base_unit_defs.pascal-inc'}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// If we dynamic link, define the path to the UberPDF-SDK .dll, .so, or .bundle
//------------------------------------------------------------------------------
{$IFDEF UBER_PDFSDK_USE_DYNAMIC_LIB_LOADER}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// Update these paths acording to your path to the UberPDF folders
//------------------------------------------------------------------------------
{$IFDEF UBER_LINTEL32_GCC_LINTEL32}
const UBER_PDFSDK_SO_NAME = './uber/uberbaselibs/uberpdfsdk/lib/lintel32/gcc/librtl/libuberpdfsdkdyn.so';
{$ENDIF}
{$IFDEF UBER_LINTEL64_GCC_LINTEL64}
const UBER_PDFSDK_SO_NAME = './uber/uberbaselibs/uberpdfsdk/lib/lintel64/gcc/librtl/libuberpdfsdkdyn.so';
{$ENDIF}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// Update these paths acording to your path to the UberPDF folders
//------------------------------------------------------------------------------
{$IFDEF UBER_LINARM32_GCC_LINARM32}
const UBER_PDFSDK_SO_NAME = './uber/uberbaselibs/uberpdfsdk/lib/linarm32/gcc/librtl/libuberpdfsdkdyn.so';
{$ENDIF}
{$IFDEF UBER_LINARM64_GCC_LINARM64}
const UBER_PDFSDK_SO_NAME = './uber/uberbaselibs/uberpdfsdk/lib/linarm64/gcc/librtl/libuberpdfsdkdyn.so';
{$ENDIF}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// Update these paths acording to your path to the UberPDF folders
//------------------------------------------------------------------------------
{$IFDEF UBER_WINTEL32_MSVC_WINTEL32}
const UBER_PDFSDK_SO_NAME = '.\uber\uberbaselibs\uberpdfsdk\lib\wintel32\msvc\libmd\libuberpdfsdkdyn.dll';
{$ENDIF}
{$IFDEF UBER_WINTEL64_MSVC_WINTEL64}
const UBER_PDFSDK_SO_NAME = '.\uber\uberbaselibs\uberpdfsdk\lib\wintel64\msvc\libmd\libuberpdfsdkdyn.dll';
{$ENDIF}
//------------------------------------------------------------------------------
{$ENDIF}
//------------------------------------------------------------------------------
function LoadUberPDFSdk: Boolean;
function UnLoadUberPDFSdk: Boolean;
function IsUberPDFSdkLoaded: Boolean;
implementation
{$IFDEF UBER_PDFSDK_USE_DYNAMIC_LIB_LOADER}
uses
UberPDFExample.Forms.Main;
{$ENDIF}
function LoadUberPDFSdk: Boolean;
{$IFDEF UBER_PDFSDK_USE_DYNAMIC_LIB_LOADER}
var
FileName : AnsiString;
{$ENDIF}
begin
// Load the DLL (if we are dynamic linking) else return true
{$IFDEF UBER_PDFSDK_USE_DYNAMIC_LIB_LOADER}
frmMain.Log('Loading Dynamic Library');
FileName := UBER_PDFSDK_SO_NAME;
Result := (UberPdfSdkDynLibLoad(pAnsiChar(FileName)) <> UBER_FALSE);
exit;
{$ENDIF}
Result := True;
end;
function UnLoadUberPDFSdk: Boolean;
begin
// unload the DLL (if we are dynamic linking) else return true
{$IFDEF UBER_PDFSDK_USE_DYNAMIC_LIB_LOADER}
frmMain.Log('Unloading Dynamic Library');
Result := (UberPdfSdkDynLibUnload() <> UBER_FALSE);
exit;
{$ENDIF}
result := True;
end;
function IsUberPDFSdkLoaded: Boolean;
begin
// test if the DLL is loaded (if we are dynamic linking) else return true
{$IFDEF UBER_PDFSDK_USE_DYNAMIC_LIB_LOADER}
Result := (IsUberPdfSdkDynLibLoaded() <> UBER_FALSE);
exit;
{$ENDIF}
Result := True;
end;
end.