-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathLicenseStatus.cpp
46 lines (36 loc) · 1.21 KB
/
LicenseStatus.cpp
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
////////////////////////////////////////////////////////////////////////////////////////////////////
// LicenseStatus.cpp
// Copyright (c) 2019 Pdfix. All Rights Reserved.
////////////////////////////////////////////////////////////////////////////////////////////////////
#include "pdfixsdksamples/LicenseStatus.h"
// system
#include <string>
#include <iostream>
// other libraries
#include "Pdfix.h"
using namespace PDFixSDK;
namespace LicenseStatus {
// write license status into an output stream
void Run(std::ostream& os) {
// initialize Pdfix
if (!Pdfix_init(Pdfix_MODULE_NAME))
throw std::runtime_error("Pdfix initialization fail");
Pdfix* pdfix = GetPdfix();
if (!pdfix)
throw std::runtime_error("GetPdfix fail");
auto authorization = pdfix->GetAuthorization();
if (!authorization)
throw PdfixException();
auto stm = pdfix->CreateMemStream();
if (!stm)
throw PdfixException();
if (!authorization->SaveToStream(stm, kDataFormatJson))
throw PdfixException();
std::string json;
json.resize((int)stm->GetSize());
stm->Read(0, (uint8_t*)&json[0], (int)json.size());
os << json;
stm->Destroy();
pdfix->Destroy();
}
}