Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
pdfix_sdk_example_cpp/src/LicenseStatus.cpp
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
46 lines (36 sloc)
1.21 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//////////////////////////////////////////////////////////////////////////////////////////////////// | |
// 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(); | |
} | |
} |