PDF SDK Documentation

Comprehensive Guide for Developers: Features, Integration, and API Reference

Loading...
Searching...
No Matches
core.h
1// Copyright (c) 2009-2025 Avanquest Software. All rights reserved.
2
3#ifndef PDFSDK_CXX_CORE_H_INCLUDED_
4#define PDFSDK_CXX_CORE_H_INCLUDED_
5
6#include <pdfsdk/core.h>
7#include <pdfsdk/cxx/action.h>
8#include <pdfsdk/cxx/annot.h>
9#include <pdfsdk/cxx/bookmark.h>
10#include <pdfsdk/cxx/clip.h>
11#include <pdfsdk/cxx/collection.h>
12#include <pdfsdk/cxx/color.h>
13#include <pdfsdk/cxx/color_space.h>
14#include <pdfsdk/cxx/content.h>
15#include <pdfsdk/cxx/dest.h>
16#include <pdfsdk/cxx/document.h>
17#include <pdfsdk/cxx/element.h>
18#include <pdfsdk/cxx/filespec.h>
19#include <pdfsdk/cxx/font.h>
20#include <pdfsdk/cxx/form_field.h>
21#include <pdfsdk/cxx/function.h>
22#include <pdfsdk/cxx/gstate.h>
23#include <pdfsdk/cxx/object.h>
24#include <pdfsdk/cxx/optional_content.h>
25#include <pdfsdk/cxx/page.h>
26#include <pdfsdk/cxx/page_text.h>
27#include <pdfsdk/cxx/pattern.h>
28#include <pdfsdk/cxx/progress_monitor.h>
29#include <pdfsdk/cxx/read_stream.h>
30#include <pdfsdk/cxx/shading.h>
31#include <pdfsdk/cxx/soft_mask.h>
32#include <pdfsdk/cxx/standard_security.h>
33#include <pdfsdk/cxx/text_run.h>
34#include <pdfsdk/cxx/write_stream.h>
35#include <pdfsdk/cxx/xgroup.h>
36#include <pdfsdk/cxx/xobject.h>
37
38namespace PDF {
39
48inline void Init(const std::string& licenseKey,
49 const std::filesystem::path& resourcesDir = std::filesystem::path(),
50 const std::filesystem::path& tempDir = std::filesystem::path(),
51 const std::filesystem::path& appDataDir = std::filesystem::path()) {
52 std::wstring resourcesDirStr = resourcesDir.wstring();
53 std::wstring tempDirStr = tempDir.wstring();
54 std::wstring appDataDirStr = appDataDir.wstring();
55
56 PDInitData initdata = {};
57 initdata.resourcesDirectoryPath = resourcesDirStr.c_str();
58 initdata.tempDirectoryPath = tempDirStr.c_str();
59 initdata.appDataDirectoryPath = appDataDirStr.c_str();
60
61 PDF_CHECK_SUCCESS_X(PDInit(licenseKey.c_str(), &initdata, "cxx"));
62}
63
70inline void Done() noexcept {
71 PDDone();
72}
73
81struct InitScope {
90 InitScope(const std::string& licenseKey,
91 const std::filesystem::path& resourcesDir = std::filesystem::path(),
92 const std::filesystem::path& tempDir = std::filesystem::path(),
93 const std::filesystem::path& appDataDir = std::filesystem::path()) {
94 Init(licenseKey, resourcesDir, tempDir, appDataDir);
95 }
96
103 ~InitScope() { Done(); }
104
105 InitScope(const InitScope&) = delete;
106 InitScope& operator=(const InitScope&) = delete;
107
108 InitScope(InitScope&&) = delete;
109 InitScope& operator=(InitScope&&) = delete;
110};
111
121inline PDAtom Atomize(const char* c_str) {
122 PDAtom atom = kPDAtomNull;
123 PDF_CHECK_SUCCESS_X(PDAtomPutString(c_str, &atom));
124 return atom;
125}
126
136inline PDAtom Atomize(const std::string& str) {
137 return Atomize(str.c_str());
138}
139
149inline std::string AtomToString(PDAtom atom) {
150 const char* str = "";
151 PDF_CHECK_SUCCESS_X(PDAtomGetString(atom, &str));
152 return str;
153}
154
155} // namespace PDF
156
157#endif // PDFSDK_CXX_CORE_H_INCLUDED_
Represents a scope for initializing and cleaning up the PDF SDK.
Definition core.h:81
InitScope(const std::string &licenseKey, const std::filesystem::path &resourcesDir=std::filesystem::path(), const std::filesystem::path &tempDir=std::filesystem::path(), const std::filesystem::path &appDataDir=std::filesystem::path())
Constructs an InitScope object and initializes the PDF SDK.
Definition core.h:90
~InitScope()
Destructs the InitScope object and cleans up the PDF SDK.
Definition core.h:103
Definition init.h:19