Skip to content

Commit 2f143f2

Browse files
committed
Initialization sample
1 parent 99ed0cb commit 2f143f2

1 file changed

Lines changed: 47 additions & 0 deletions

File tree

src/Initialization.hpp

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
////////////////////////////////////////////////////////////////////////////////////////////////////
2+
// AddComment.cpp
3+
// Copyright (c) 2018 Pdfix. All Rights Reserved.
4+
////////////////////////////////////////////////////////////////////////////////////////////////////
5+
/*!
6+
\page CPP_Samples C++ Samples
7+
- \subpage Initialization_cpp
8+
*/
9+
/*!
10+
\page Initialization_cpp Add Comment Sample
11+
Example how to add a text annotation with a reply.
12+
\snippet /Initialization.hpp Initialization_cpp
13+
*/
14+
15+
#pragma once
16+
17+
//! [Initialization_cpp]
18+
#include <string>
19+
#include <iostream>
20+
#include "Pdfix.h"
21+
22+
// Adds a new text annotation.
23+
void Initialization(
24+
std::wstring email, // authorization email
25+
std::wstring license_key // authorization license key
26+
) {
27+
// initialize Pdfix
28+
if (!Pdfix_init(Pdfix_MODULE_NAME))
29+
throw std::runtime_error("Pdfix initialization fail.");
30+
31+
Pdfix* pdfix = GetPdfix();
32+
if (!pdfix)
33+
throw std::runtime_error("GetPdfix fail");
34+
35+
if (pdfix->GetVersionMajor() != PDFIX_VERSION_MAJOR ||
36+
pdfix->GetVersionMinor() != PDFIX_VERSION_MINOR ||
37+
pdfix->GetVersionPatch() != PDFIX_VERSION_PATCH)
38+
throw std::runtime_error("Incompatible version");
39+
40+
if (!pdfix->Authorize(email.c_str(), license_key.c_str()))
41+
throw std::runtime_error(pdfix->GetError());
42+
43+
// ...
44+
45+
pdfix->Destroy();
46+
}
47+
//! [Initialization_cpp]

0 commit comments

Comments
 (0)