All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PDFNet.h
Go to the documentation of this file.
1 //---------------------------------------------------------------------------------------
2 // Copyright (c) 2001-2021 by PDFTron Systems Inc. All Rights Reserved.
3 // Consult legal.txt regarding legal and license information.
4 //---------------------------------------------------------------------------------------
5 #ifndef PDFTRON_H_CPPPDFPDFNet
6 #define PDFTRON_H_CPPPDFPDFNet
7 
8 #include <C/PDF/TRN_PDFNet.h>
9 #include <Common/UString.h>
10 #include <Common/Iterator.h>
11 #include <Filters/Filter.h>
12 #ifdef SWIG
13 #include <PDF/Callback.h>
14 #endif
15 namespace pdftron {
16 
24 class PDFNet
25 {
26 public:
27 
41  static void Initialize(const char* license_key = 0);
42 
43 #ifdef SWIG
44 
56  static void Initialize(const char* license_key, const char* json_string);
57 #endif
58 
68  static void Terminate(const int termination_level);
69 
75  static void EnableJavaScript(bool enable);
76 
82  static bool IsJavaScriptEnabled();
83 
84 //#ifndef SWIG
92  static void Terminate();
93 //#endif
94 
109  static bool SetResourcesPath(const UString& path);
110 
115  static UString GetResourcesPath();
116 
127  static void AddResourceSearchPath(const UString& path);
128 
132  static double GetVersion();
133 
134  enum CMSType
135  {
139  };
140 
147  static void SetColorManagement(CMSType t = e_lcms);
148 
159  static void SetDefaultDeviceCMYKProfile(const UString& icc_filename);
160 
171  static void SetDefaultDeviceCMYKProfile(Filters::Filter stream);
172 
173 
184  static void SetDefaultDeviceRGBProfile(const UString& icc_filename);
185 
196  static void SetDefaultDeviceRGBProfile(Filters::Filter stream);
197 
204  static void SetDefaultDiskCachingEnabled( bool use_disk );
205 
207  {
212  };
225  static void SetDefaultFlateCompressionLevel(int level);
226 
237  static void SetViewerCache(size_t max_cache_size, bool on_disk);
238 
246  e_Japan1 = 1,
247  e_Japan2 = 2,
248  e_GB1 = 3,
249  e_CNS1 = 4,
250  e_Korea1 = 5
251  };
252 
280  static bool AddFontSubst(const char* fontname, const UString& fontpath);
314  static bool AddFontSubst(CharacterOrdering ordering, const UString& fontpath);
315 
322  static void SetTempPath(const UString& temp_path);
323 
330  static void SetPersistentCachePath(const UString& persistent_path);
331 
337  static UString GetSystemFontList();
338 
339 #ifndef SWIG
340 
345  typedef TRN_PDFNetCreateSecurityHandler CreateSecurityHandler;
346 
355  static void RegisterSecurityHandler(const char* handler_name, const char* gui_name, CreateSecurityHandler factory_method);
356 
360  class SecurityDescriptor : public TRN_SecHdlrInfo {
361  public:
362  const char* GetName() { return m_name; }
363  const char* GetGuiName() { return m_gui_name; }
364  CreateSecurityHandler GetCreateFunct() { return m_factory_method; }
365  };
366 
368 
374 
387  static void SetNumberWriteProc(char* (*WriteProc) (double num, char *in_buf, int in_buf_size));
388 
397  static void SetNumberReadProc(TRN_Bool (*ReadProc) (const TRN_UChar *buf, double *output));
398 #endif
399 
401  typedef enum _LogLevel
402  {
403  e_LogLevel_Off = -1,
404  e_LogLevel_Fatal = 5,
405  e_LogLevel_Error = 4,
406  e_LogLevel_Warning = 3,
407  e_LogLevel_Info = 2,
408  e_LogLevel_Trace = 1,
409  e_LogLevel_Debug = 0
410  }
411  LogLevel;
412 
413  static void SetLogLevel(LogLevel level = e_LogLevel_Fatal);
415 
422  static void AddPDFTronCustomHandler(UInt32 custom_id);
423 
424  /*
425  * @return PDFNet version as a string.
426  */
427  static const char* GetVersionString();
428 
435  static void SetWriteAPIUsageLocally(bool write_usage);
436 
438  {
439  e_continue, // PDFTron SDK will continue running and if necessary switch to demo mode when encountering an unresolvable connection error
440  e_continue_unless_switching_to_demo, // PDFTron SDK will continue as long as it doesn't need to switch to demo mode in response to the connection error
441  // If continuing without switching to demo mode is not possible, PDFTron SDK functions will throw exceptions.
442  e_stop // PDFTron SDK will throw exceptions from subsequent usage if a connection error occurs
443  };
444 
452 
463  typedef void(*ConnectionErrorProc) (const char* message, const int error_code, UChar switch_to_demo, void* user_data);
464 
472 #ifdef SWIG
473  static void SetConnectionErrorProc(PDF::Callback* instance);
474 #else
475  static void SetConnectionErrorProc(ConnectionErrorProc error_proc, void* data);
476 #endif
477 
478 };
479 
480 
481 
482 #include <Impl/PDFNet.inl>
483 
484 }; // namespace pdftron
485 
486 #endif // PDFTRON_H_CPPPDFPDFNet
static void SetConnectionErrorHandlingMode(ConnectionErrorHandlingMode mode)
static void SetViewerCache(size_t max_cache_size, bool on_disk)
No ICC color management.
Definition: PDFNet.h:138
static void SetConnectionErrorProc(ConnectionErrorProc error_proc, void *data)
static void SetDefaultDeviceCMYKProfile(const UString &icc_filename)
static bool IsJavaScriptEnabled()
static void SetWriteAPIUsageLocally(bool write_usage)
static void AddPDFTronCustomHandler(UInt32 custom_id)
TRN_PDFNetCreateSecurityHandler CreateSecurityHandler
Definition: PDFNet.h:345
Use Windows ICM2 (available only on Windows platforms).
Definition: PDFNet.h:137
static void Terminate()
static void SetDefaultFlateCompressionLevel(int level)
static void SetNumberReadProc(TRN_Bool(*ReadProc)(const TRN_UChar *buf, double *output))
Common::Iterator< SecurityDescriptor > SecurityDescriptorIterator
Definition: PDFNet.h:367
Use LittleCMS (available on all supported platforms).
Definition: PDFNet.h:136
static bool AddFontSubst(const char *fontname, const UString &fontpath)
static void EnableJavaScript(bool enable)
TRN_UInt32 UInt32
Definition: BasicTypes.h:13
static void Initialize(const char *license_key=0)
void(* ConnectionErrorProc)(const char *message, const int error_code, UChar switch_to_demo, void *user_data)
Definition: PDFNet.h:463
static void SetTempPath(const UString &temp_path)
TRN_UChar UChar
Definition: BasicTypes.h:12
static const char * GetVersionString()
ConnectionErrorHandlingMode
Definition: PDFNet.h:437
static UString GetSystemFontList()
static bool SetResourcesPath(const UString &path)
static double GetVersion()
static void SetDefaultDeviceRGBProfile(const UString &icc_filename)
static void SetColorManagement(CMSType t=e_lcms)
static void SetPersistentCachePath(const UString &persistent_path)
Chinese; Traditional.
Definition: PDFNet.h:249
CreateSecurityHandler GetCreateFunct()
Definition: PDFNet.h:364
Chinese; Simplified.
Definition: PDFNet.h:248
static void SetDefaultDiskCachingEnabled(bool use_disk)
static void AddResourceSearchPath(const UString &path)
static SecurityDescriptorIterator GetSecHdlrInfoIterator()
static void RegisterSecurityHandler(const char *handler_name, const char *gui_name, CreateSecurityHandler factory_method)
Generic/Unicode.
Definition: PDFNet.h:245
static void SetNumberWriteProc(char *(*WriteProc)(double num, char *in_buf, int in_buf_size))
static UString GetResourcesPath()