// PDF library
// ActiveX Edition
// Copyright 2007-2017 losLab

// PDFlibAX.cpp
// C++ import header
// https://www.loslab.com/

#include "stdafx.h"
#include "PDFlibAX.h"
#include <string>
#include <vector>
#include "Windows.h"
#include "objbase.h"
#include "comdef.h"

PDFlibAX::PDFlibAX() {
	CoInitialize(0);
	CLSID clsid;
	loaded = false;
	HRESULT hr = CLSIDFromProgID(L"PDFlibAX.PDFlibrary", &clsid);
	if (hr == S_OK) {
		hr = CoCreateInstance(clsid, NULL, CLSCTX_SERVER, IID_IDispatch,
			(void**)&pDisp);
		if (hr == S_OK) {
			loaded = true;
		}
	}
}

PDFlibAX::~PDFlibAX() {
	if (loaded) {
		pDisp->Release();
	}
	CoUninitialize();
}

bool PDFlibAX::LibraryLoaded() {
	return loaded;
}

std::wstring PDFlibAX::GetString() {
	if (result.bstrVal != NULL) {
		return std::wstring(result.bstrVal, SysStringLen(result.bstrVal));
	}
	else {
		std::wstring blank;
		return blank;
	}
}

std::vector<BYTE>PDFlibAX::GetByteArray() {
	if ((result.vt & VT_ARRAY) != VT_ARRAY) {
		std::vector<BYTE>v;
		return v;
	}

	SAFEARRAY * psa = result.parray;

	long lStartBound;
	long lEndBound;
	SafeArrayGetLBound(psa, 1, &lStartBound);
	SafeArrayGetUBound(psa, 1, &lEndBound);

	BYTE * arrayAccess = NULL;
	SafeArrayAccessData(psa, (void**)&arrayAccess);

	int size = lEndBound - lStartBound + 1;
	std::vector<BYTE>vec(arrayAccess, arrayAccess + size - 1);

	SafeArrayUnaccessData(psa);

	return vec;
}

VARIANT PDFlibAX::MakeByteArray(std::vector<BYTE> &vector) {
	int vectorSize = (int)vector.size();
	VARIANT arSource;
	VariantInit(&arSource);
	SAFEARRAY * theArray;
	SAFEARRAYBOUND dim[1];
	dim[0].lLbound = 0;
	dim[0].cElements = vectorSize;
	theArray = SafeArrayCreate(VT_UI1, 1, dim);
	char * p;
	SafeArrayAccessData(theArray, (void **)&p);
	memcpy(p, &vector[0], vectorSize);
	SafeArrayUnaccessData(theArray);
	arSource.vt = VT_ARRAY | VT_UI1;
	arSource.parray = theArray;
	return arSource;
}

void PDFlibAX::RunFunction(WCHAR * functionName, _variant_t p1, _variant_t p2,
	_variant_t p3, _variant_t p4, _variant_t p5, _variant_t p6, _variant_t p7,
	_variant_t p8, _variant_t p9, _variant_t p10, _variant_t p11,
	_variant_t p12, _variant_t p13) {
	if (loaded) {
		DISPID dispID;
		pDisp->GetIDsOfNames(IID_NULL, &functionName, 1, LOCALE_USER_DEFAULT,
			&dispID);

		DISPPARAMS dp = {NULL, NULL, 0, 0};

		dp.cArgs = 13;
		if (p13.vt == VT_ERROR)
			dp.cArgs = 12;
		if (p12.vt == VT_ERROR)
			dp.cArgs = 11;
		if (p11.vt == VT_ERROR)
			dp.cArgs = 10;
		if (p10.vt == VT_ERROR)
			dp.cArgs = 9;
		if (p9.vt == VT_ERROR)
			dp.cArgs = 8;
		if (p8.vt == VT_ERROR)
			dp.cArgs = 7;
		if (p7.vt == VT_ERROR)
			dp.cArgs = 6;
		if (p6.vt == VT_ERROR)
			dp.cArgs = 5;
		if (p5.vt == VT_ERROR)
			dp.cArgs = 4;
		if (p4.vt == VT_ERROR)
			dp.cArgs = 3;
		if (p3.vt == VT_ERROR)
			dp.cArgs = 2;
		if (p2.vt == VT_ERROR)
			dp.cArgs = 1;
		if (p1.vt == VT_ERROR)
			dp.cArgs = 0;

		VARIANTARG vargs[13];

		if (dp.cArgs >= 1)
			vargs[dp.cArgs - 1] = p1;
		if (dp.cArgs >= 2)
			vargs[dp.cArgs - 2] = p2;
		if (dp.cArgs >= 3)
			vargs[dp.cArgs - 3] = p3;
		if (dp.cArgs >= 4)
			vargs[dp.cArgs - 4] = p4;
		if (dp.cArgs >= 5)
			vargs[dp.cArgs - 5] = p5;
		if (dp.cArgs >= 6)
			vargs[dp.cArgs - 6] = p6;
		if (dp.cArgs >= 7)
			vargs[dp.cArgs - 7] = p7;
		if (dp.cArgs >= 8)
			vargs[dp.cArgs - 8] = p8;
		if (dp.cArgs >= 9)
			vargs[dp.cArgs - 9] = p9;
		if (dp.cArgs >= 10)
			vargs[dp.cArgs - 10] = p10;
		if (dp.cArgs >= 11)
			vargs[dp.cArgs - 11] = p11;
		if (dp.cArgs >= 12)
			vargs[dp.cArgs - 12] = p12;
		if (dp.cArgs >= 13)
			vargs[dp.cArgs - 13] = p13;
		if (dp.cArgs > 0)
			dp.rgvarg = vargs;

		unsigned int argErr = 0;
		HRESULT callResult = pDisp->Invoke(dispID, IID_NULL,
			LOCALE_USER_DEFAULT, DISPATCH_METHOD, &dp, &result, 0, &argErr);
	}
}

int PDFlibAX::AddArcToPath(double CenterX, double CenterY, double TotalAngle) {
	RunFunction(L"AddArcToPath", CenterX, CenterY, TotalAngle);
	return result.intVal;
}

int PDFlibAX::AddCJKFont(int CJKFontID) {
	RunFunction(L"AddCJKFont", CJKFontID);
	return result.intVal;
}

int PDFlibAX::AddCurveToPath(double CtAX, double CtAY, double CtBX, double CtBY,
	double EndX, double EndY) {
	RunFunction(L"AddCurveToPath", CtAX, CtAY, CtBX, CtBY, EndX, EndY);
	return result.intVal;
}

int PDFlibAX::AddEmbeddedFile(const std::wstring& FileName,
	const std::wstring& MIMEType) {
	BSTR bStrFileName = SysAllocStringLen(FileName.c_str(),
		(int)(FileName.length()));
	BSTR bstrMIMEType = SysAllocStringLen(MIMEType.c_str(),
		(int)(MIMEType.length()));
	RunFunction(L"AddEmbeddedFile", bStrFileName, bstrMIMEType);
	SysFreeString(bStrFileName);
	SysFreeString(bstrMIMEType);
	return result.intVal;
}

int PDFlibAX::AddFileAttachment(const std::wstring& Title, int EmbeddedFileID) {
	BSTR bstrTitle = SysAllocStringLen(Title.c_str(), (int)(Title.length()));
	RunFunction(L"AddFileAttachment", bstrTitle, EmbeddedFileID);
	SysFreeString(bstrTitle);
	return result.intVal;
}

int PDFlibAX::AddFormFieldSub(int Index, const std::wstring& SubName) {
	BSTR bstrSubName = SysAllocStringLen(SubName.c_str(),
		(int)(SubName.length()));
	RunFunction(L"AddFormFieldSub", Index, bstrSubName);
	SysFreeString(bstrSubName);
	return result.intVal;
}

int PDFlibAX::AddFormFont(int FontID) {
	RunFunction(L"AddFormFont", FontID);
	return result.intVal;
}

int PDFlibAX::AddGlobalJavaScript(const std::wstring& PackageName,
	const std::wstring& JavaScript) {
	BSTR bstrPackageName = SysAllocStringLen(PackageName.c_str(),
		(int)(PackageName.length()));
	BSTR bstrJavaScript = SysAllocStringLen(JavaScript.c_str(),
		(int)(JavaScript.length()));
	RunFunction(L"AddGlobalJavaScript", bstrPackageName, bstrJavaScript);
	SysFreeString(bstrPackageName);
	SysFreeString(bstrJavaScript);
	return result.intVal;
}

int PDFlibAX::AddImageFromFile(const std::wstring& FileName, int Options) {
	BSTR bStrFileName = SysAllocStringLen(FileName.c_str(),
		(int)(FileName.length()));
	RunFunction(L"AddImageFromFile", bStrFileName, Options);
	SysFreeString(bStrFileName);
	return result.intVal;
}

int PDFlibAX::AddImageFromFileOffset(const std::wstring& FileName, int Offset,
	int DataLength, int Options) {
	BSTR bStrFileName = SysAllocStringLen(FileName.c_str(),
		(int)(FileName.length()));
	RunFunction(L"AddImageFromFileOffset", bStrFileName, Offset, DataLength,
		Options);
	SysFreeString(bStrFileName);
	return result.intVal;
}

int PDFlibAX::AddImageFromVariant(std::vector<BYTE>& SourceData, int Options) {
	VARIANT arSourceData = MakeByteArray(SourceData);
	RunFunction(L"AddImageFromVariant", arSourceData, Options);
	SafeArrayDestroy(arSourceData.parray);
	return result.intVal;
}

int PDFlibAX::AddLGIDictToPage(const std::wstring& DictContent) {
	BSTR bstrDictContent = SysAllocStringLen(DictContent.c_str(),
		(int)(DictContent.length()));
	RunFunction(L"AddLGIDictToPage", bstrDictContent);
	SysFreeString(bstrDictContent);
	return result.intVal;
}

int PDFlibAX::AddLineToPath(double EndX, double EndY) {
	RunFunction(L"AddLineToPath", EndX, EndY);
	return result.intVal;
}

int PDFlibAX::AddLinkToEmbeddedFile(double Left, double Top, double Width,
	double Height, int EmbeddedFileID, const std::wstring& Title, int Options) {
	BSTR bstrTitle = SysAllocStringLen(Title.c_str(), (int)(Title.length()));
	RunFunction(L"AddLinkToEmbeddedFile", Left, Top, Width, Height,
		EmbeddedFileID, bstrTitle, Options);
	SysFreeString(bstrTitle);
	return result.intVal;
}

int PDFlibAX::AddLinkToFile(double Left, double Top, double Width,
	double Height, const std::wstring& FileName, int Page, double Position,
	int NewWindow, int Options) {
	BSTR bStrFileName = SysAllocStringLen(FileName.c_str(),
		(int)(FileName.length()));
	RunFunction(L"AddLinkToFile", Left, Top, Width, Height, bStrFileName, Page,
		Position, NewWindow, Options);
	SysFreeString(bStrFileName);
	return result.intVal;
}

int PDFlibAX::AddLinkToJavaScript(double Left, double Top, double Width,
	double Height, const std::wstring& JavaScript, int Options) {
	BSTR bstrJavaScript = SysAllocStringLen(JavaScript.c_str(),
		(int)(JavaScript.length()));
	RunFunction(L"AddLinkToJavaScript", Left, Top, Width, Height,
		bstrJavaScript, Options);
	SysFreeString(bstrJavaScript);
	return result.intVal;
}

int PDFlibAX::AddLinkToPage(double Left, double Top, double Width,
	double Height, int Page, double Position, int Options) {
	RunFunction(L"AddLinkToPage", Left, Top, Width, Height, Page, Position,
		Options);
	return result.intVal;
}

int PDFlibAX::AddLinkToWeb(double Left, double Top, double Width, double Height,
	const std::wstring& Link, int Options) {
	BSTR bstrLink = SysAllocStringLen(Link.c_str(), (int)(Link.length()));
	RunFunction(L"AddLinkToWeb", Left, Top, Width, Height, bstrLink, Options);
	SysFreeString(bstrLink);
	return result.intVal;
}

int PDFlibAX::AddNoteAnnotation(double Left, double Top, int AnnotType,
	double PopupLeft, double PopupTop, double PopupWidth, double PopupHeight,
	const std::wstring& Title, const std::wstring& Contents, double Red,
	double Green, double Blue, int Open) {
	BSTR bstrTitle = SysAllocStringLen(Title.c_str(), (int)(Title.length()));
	BSTR bstrContents = SysAllocStringLen(Contents.c_str(),
		(int)(Contents.length()));
	RunFunction(L"AddNoteAnnotation", Left, Top, AnnotType, PopupLeft, PopupTop,
		PopupWidth, PopupHeight, bstrTitle, bstrContents, Red, Green,
		Blue, Open);
	SysFreeString(bstrTitle);
	SysFreeString(bstrContents);
	return result.intVal;
}

int PDFlibAX::AddPageLabels(int Start, int Style, int Offset,
	const std::wstring& Prefix) {
	BSTR bstrPrefix = SysAllocStringLen(Prefix.c_str(), (int)(Prefix.length()));
	RunFunction(L"AddPageLabels", Start, Style, Offset, bstrPrefix);
	SysFreeString(bstrPrefix);
	return result.intVal;
}

int PDFlibAX::AddSVGAnnotationFromFile(double Left, double Top, double Width,
	double Height, const std::wstring& FileName, int Options) {
	BSTR bStrFileName = SysAllocStringLen(FileName.c_str(),
		(int)(FileName.length()));
	RunFunction(L"AddSVGAnnotationFromFile", Left, Top, Width, Height,
		bStrFileName, Options);
	SysFreeString(bStrFileName);
	return result.intVal;
}

int PDFlibAX::AddSeparationColor(const std::wstring& ColorName, double C,
	double M, double Y, double K, int Options) {
	BSTR bstrColorName = SysAllocStringLen(ColorName.c_str(),
		(int)(ColorName.length()));
	RunFunction(L"AddSeparationColor", bstrColorName, C, M, Y, K, Options);
	SysFreeString(bstrColorName);
	return result.intVal;
}

int PDFlibAX::AddStandardFont(int StandardFontID) {
	RunFunction(L"AddStandardFont", StandardFontID);
	return result.intVal;
}

int PDFlibAX::AddSubsettedFont(const std::wstring& FontName, int CharSet,
	const std::wstring& SubsetChars) {
	BSTR bstrFontName = SysAllocStringLen(FontName.c_str(),
		(int)(FontName.length()));
	BSTR bstrSubsetChars = SysAllocStringLen(SubsetChars.c_str(),
		(int)(SubsetChars.length()));
	RunFunction(L"AddSubsettedFont", bstrFontName, CharSet, bstrSubsetChars);
	SysFreeString(bstrFontName);
	SysFreeString(bstrSubsetChars);
	return result.intVal;
}

int PDFlibAX::AddToFileList(const std::wstring& ListName,
	const std::wstring& FileName) {
	BSTR bstrListName = SysAllocStringLen(ListName.c_str(),
		(int)(ListName.length()));
	BSTR bStrFileName = SysAllocStringLen(FileName.c_str(),
		(int)(FileName.length()));
	RunFunction(L"AddToFileList", bstrListName, bStrFileName);
	SysFreeString(bstrListName);
	SysFreeString(bStrFileName);
	return result.intVal;
}

int PDFlibAX::AddTrueTypeFont(const std::wstring& FontName, int Embed) {
	BSTR bstrFontName = SysAllocStringLen(FontName.c_str(),
		(int)(FontName.length()));
	RunFunction(L"AddTrueTypeFont", bstrFontName, Embed);
	SysFreeString(bstrFontName);
	return result.intVal;
}

int PDFlibAX::AddTrueTypeFontFromFile(const std::wstring& FileName) {
	BSTR bStrFileName = SysAllocStringLen(FileName.c_str(),
		(int)(FileName.length()));
	RunFunction(L"AddTrueTypeFontFromFile", bStrFileName);
	SysFreeString(bStrFileName);
	return result.intVal;
}

int PDFlibAX::AddType1Font(const std::wstring& FileName) {
	BSTR bStrFileName = SysAllocStringLen(FileName.c_str(),
		(int)(FileName.length()));
	RunFunction(L"AddType1Font", bStrFileName);
	SysFreeString(bStrFileName);
	return result.intVal;
}

int PDFlibAX::AddU3DAnnotationFromFile(double Left, double Top, double Width,
	double Height, const std::wstring& FileName, int Options) {
	BSTR bStrFileName = SysAllocStringLen(FileName.c_str(),
		(int)(FileName.length()));
	RunFunction(L"AddU3DAnnotationFromFile", Left, Top, Width, Height,
		bStrFileName, Options);
	SysFreeString(bStrFileName);
	return result.intVal;
}

int PDFlibAX::AnalyseFile(const std::wstring& InputFileName,
	const std::wstring& Password) {
	BSTR bstrInputFileName = SysAllocStringLen(InputFileName.c_str(),
		(int)(InputFileName.length()));
	BSTR bstrPassword = SysAllocStringLen(Password.c_str(),
		(int)(Password.length()));
	RunFunction(L"AnalyseFile", bstrInputFileName, bstrPassword);
	SysFreeString(bstrInputFileName);
	SysFreeString(bstrPassword);
	return result.intVal;
}

int PDFlibAX::AnnotationCount() {
	RunFunction(L"AnnotationCount");
	return result.intVal;
}

int PDFlibAX::AppendSpace(double RelativeSpace) {
	RunFunction(L"AppendSpace", RelativeSpace);
	return result.intVal;
}

int PDFlibAX::AppendTableColumns(int TableID, int NewColumnCount) {
	RunFunction(L"AppendTableColumns", TableID, NewColumnCount);
	return result.intVal;
}

int PDFlibAX::AppendTableRows(int TableID, int NewRowCount) {
	RunFunction(L"AppendTableRows", TableID, NewRowCount);
	return result.intVal;
}

int PDFlibAX::AppendText(const std::wstring& Text) {
	BSTR bstrText = SysAllocStringLen(Text.c_str(), (int)(Text.length()));
	RunFunction(L"AppendText", bstrText);
	SysFreeString(bstrText);
	return result.intVal;
}

int PDFlibAX::ApplyStyle(const std::wstring& StyleName) {
	BSTR bstrStyleName = SysAllocStringLen(StyleName.c_str(),
		(int)(StyleName.length()));
	RunFunction(L"ApplyStyle", bstrStyleName);
	SysFreeString(bstrStyleName);
	return result.intVal;
}

int PDFlibAX::BeginPageUpdate() {
	RunFunction(L"BeginPageUpdate");
	return result.intVal;
}

int PDFlibAX::CapturePage(int Page) {
	RunFunction(L"CapturePage", Page);
	return result.intVal;
}

int PDFlibAX::CapturePageEx(int Page, int Options) {
	RunFunction(L"CapturePageEx", Page, Options);
	return result.intVal;
}

int PDFlibAX::CharWidth(int CharCode) {
	RunFunction(L"CharWidth", CharCode);
	return result.intVal;
}

int PDFlibAX::CheckObjects() {
	RunFunction(L"CheckObjects");
	return result.intVal;
}

int PDFlibAX::CheckPageAnnots() {
	RunFunction(L"CheckPageAnnots");
	return result.intVal;
}

int PDFlibAX::ClearFileList(const std::wstring& ListName) {
	BSTR bstrListName = SysAllocStringLen(ListName.c_str(),
		(int)(ListName.length()));
	RunFunction(L"ClearFileList", bstrListName);
	SysFreeString(bstrListName);
	return result.intVal;
}

int PDFlibAX::ClearPageLabels() {
	RunFunction(L"ClearPageLabels");
	return result.intVal;
}

int PDFlibAX::ClearTextFormatting() {
	RunFunction(L"ClearTextFormatting");
	return result.intVal;
}

int PDFlibAX::CloneOutlineAction(int OutlineID) {
	RunFunction(L"CloneOutlineAction", OutlineID);
	return result.intVal;
}

int PDFlibAX::ClonePages(int StartPage, int EndPage, int RepeatCount) {
	RunFunction(L"ClonePages", StartPage, EndPage, RepeatCount);
	return result.intVal;
}

int PDFlibAX::CloseOutline(int OutlineID) {
	RunFunction(L"CloseOutline", OutlineID);
	return result.intVal;
}

int PDFlibAX::ClosePath() {
	RunFunction(L"ClosePath");
	return result.intVal;
}

int PDFlibAX::CombineLayers() {
	RunFunction(L"CombineLayers");
	return result.intVal;
}

int PDFlibAX::CompressContent() {
	RunFunction(L"CompressContent");
	return result.intVal;
}

int PDFlibAX::CompressFonts(int Compress) {
	RunFunction(L"CompressFonts", Compress);
	return result.intVal;
}

int PDFlibAX::CompressImages(int Compress) {
	RunFunction(L"CompressImages", Compress);
	return result.intVal;
}

int PDFlibAX::CompressPage() {
	RunFunction(L"CompressPage");
	return result.intVal;
}

int PDFlibAX::CopyPageRanges(int DocumentID, const std::wstring& RangeList) {
	BSTR bstrRangeList = SysAllocStringLen(RangeList.c_str(),
		(int)(RangeList.length()));
	RunFunction(L"CopyPageRanges", DocumentID, bstrRangeList);
	SysFreeString(bstrRangeList);
	return result.intVal;
}

int PDFlibAX::CreateTable(int RowCount, int ColumnCount) {
	RunFunction(L"CreateTable", RowCount, ColumnCount);
	return result.intVal;
}

int PDFlibAX::DAAppendFile(int FileHandle) {
	RunFunction(L"DAAppendFile", FileHandle);
	return result.intVal;
}

int PDFlibAX::DACapturePage(int FileHandle, int PageRef) {
	RunFunction(L"DACapturePage", FileHandle, PageRef);
	return result.intVal;
}

int PDFlibAX::DACapturePageEx(int FileHandle, int PageRef, int Options) {
	RunFunction(L"DACapturePageEx", FileHandle, PageRef, Options);
	return result.intVal;
}

int PDFlibAX::DACloseFile(int FileHandle) {
	RunFunction(L"DACloseFile", FileHandle);
	return result.intVal;
}

int PDFlibAX::DADrawCapturedPage(int FileHandle, int DACaptureID,
	int DestPageRef, double PntLeft, double PntBottom, double PntWidth,
	double PntHeight) {
	RunFunction(L"DADrawCapturedPage", FileHandle, DACaptureID, DestPageRef,
		PntLeft, PntBottom, PntWidth, PntHeight);
	return result.intVal;
}

std::wstring PDFlibAX::DAExtractPageText(int FileHandle, int PageRef,
	int Options) {
	RunFunction(L"DAExtractPageText", FileHandle, PageRef, Options);
	return GetString();
}

int PDFlibAX::DAFindPage(int FileHandle, int Page) {
	RunFunction(L"DAFindPage", FileHandle, Page);
	return result.intVal;
}

int PDFlibAX::DAGetFormFieldCount(int FileHandle) {
	RunFunction(L"DAGetFormFieldCount", FileHandle);
	return result.intVal;
}

std::wstring PDFlibAX::DAGetFormFieldTitle(int FileHandle, int FieldIndex) {
	RunFunction(L"DAGetFormFieldTitle", FileHandle, FieldIndex);
	return GetString();
}

std::wstring PDFlibAX::DAGetFormFieldValue(int FileHandle, int FieldIndex) {
	RunFunction(L"DAGetFormFieldValue", FileHandle, FieldIndex);
	return GetString();
}

std::vector<BYTE>PDFlibAX::DAGetImageDataToVariant(int FileHandle,
	int ImageListID, int ImageIndex) {
	RunFunction(L"DAGetImageDataToVariant", FileHandle, ImageListID,
		ImageIndex);
	return GetByteArray();
}

double PDFlibAX::DAGetImageDblProperty(int FileHandle, int ImageListID,
	int ImageIndex, int PropertyID) {
	RunFunction(L"DAGetImageDblProperty", FileHandle, ImageListID, ImageIndex,
		PropertyID);
	return result.dblVal;
}

int PDFlibAX::DAGetImageIntProperty(int FileHandle, int ImageListID,
	int ImageIndex, int PropertyID) {
	RunFunction(L"DAGetImageIntProperty", FileHandle, ImageListID, ImageIndex,
		PropertyID);
	return result.intVal;
}

int PDFlibAX::DAGetImageListCount(int FileHandle, int ImageListID) {
	RunFunction(L"DAGetImageListCount", FileHandle, ImageListID);
	return result.intVal;
}

std::wstring PDFlibAX::DAGetInformation(int FileHandle, const std::wstring& Key)
{
	BSTR bstrKey = SysAllocStringLen(Key.c_str(), (int)(Key.length()));
	RunFunction(L"DAGetInformation", FileHandle, bstrKey);
	SysFreeString(bstrKey);
	return GetString();
}

int PDFlibAX::DAGetObjectCount(int FileHandle) {
	RunFunction(L"DAGetObjectCount", FileHandle);
	return result.intVal;
}

std::wstring PDFlibAX::DAGetObjectSource(int FileHandle, int ObjectNumber) {
	RunFunction(L"DAGetObjectSource", FileHandle, ObjectNumber);
	return GetString();
}

std::wstring PDFlibAX::DAGetPageContent(int FileHandle, int PageRef) {
	RunFunction(L"DAGetPageContent", FileHandle, PageRef);
	return GetString();
}

int PDFlibAX::DAGetPageCount(int FileHandle) {
	RunFunction(L"DAGetPageCount", FileHandle);
	return result.intVal;
}

double PDFlibAX::DAGetPageHeight(int FileHandle, int PageRef) {
	RunFunction(L"DAGetPageHeight", FileHandle, PageRef);
	return result.dblVal;
}

int PDFlibAX::DAGetPageImageList(int FileHandle, int PageRef) {
	RunFunction(L"DAGetPageImageList", FileHandle, PageRef);
	return result.intVal;
}

double PDFlibAX::DAGetPageWidth(int FileHandle, int PageRef) {
	RunFunction(L"DAGetPageWidth", FileHandle, PageRef);
	return result.dblVal;
}

int PDFlibAX::DAHidePage(int FileHandle, int PageRef) {
	RunFunction(L"DAHidePage", FileHandle, PageRef);
	return result.intVal;
}

int PDFlibAX::DAMovePage(int FileHandle, int PageRef, int TargetPageRef,
	int Options) {
	RunFunction(L"DAMovePage", FileHandle, PageRef, TargetPageRef, Options);
	return result.intVal;
}

int PDFlibAX::DANewPage(int FileHandle) {
	RunFunction(L"DANewPage", FileHandle);
	return result.intVal;
}

int PDFlibAX::DANewPages(int FileHandle, int PageCount) {
	RunFunction(L"DANewPages", FileHandle, PageCount);
	return result.intVal;
}

int PDFlibAX::DAOpenFile(const std::wstring& InputFileName,
	const std::wstring& Password) {
	BSTR bstrInputFileName = SysAllocStringLen(InputFileName.c_str(),
		(int)(InputFileName.length()));
	BSTR bstrPassword = SysAllocStringLen(Password.c_str(),
		(int)(Password.length()));
	RunFunction(L"DAOpenFile", bstrInputFileName, bstrPassword);
	SysFreeString(bstrInputFileName);
	SysFreeString(bstrPassword);
	return result.intVal;
}

int PDFlibAX::DAOpenFileReadOnly(const std::wstring& InputFileName,
	const std::wstring& Password) {
	BSTR bstrInputFileName = SysAllocStringLen(InputFileName.c_str(),
		(int)(InputFileName.length()));
	BSTR bstrPassword = SysAllocStringLen(Password.c_str(),
		(int)(Password.length()));
	RunFunction(L"DAOpenFileReadOnly", bstrInputFileName, bstrPassword);
	SysFreeString(bstrInputFileName);
	SysFreeString(bstrPassword);
	return result.intVal;
}

int PDFlibAX::DAPageRotation(int FileHandle, int PageRef) {
	RunFunction(L"DAPageRotation", FileHandle, PageRef);
	return result.intVal;
}

int PDFlibAX::DARenderPageToDC(int FileHandle, int PageRef, int DPI, int DC) {
	RunFunction(L"DARenderPageToDC", FileHandle, PageRef, DPI, DC);
	return result.intVal;
}

int PDFlibAX::DARenderPageToFile(int FileHandle, int PageRef, int Options,
	int DPI, const std::wstring& FileName) {
	BSTR bStrFileName = SysAllocStringLen(FileName.c_str(),
		(int)(FileName.length()));
	RunFunction(L"DARenderPageToFile", FileHandle, PageRef, Options, DPI,
		bStrFileName);
	SysFreeString(bStrFileName);
	return result.intVal;
}

std::vector<BYTE>PDFlibAX::DARenderPageToVariant(int FileHandle, int PageRef,
	int Options, int DPI) {
	RunFunction(L"DARenderPageToVariant", FileHandle, PageRef, Options, DPI);
	return GetByteArray();
}

int PDFlibAX::DARotatePage(int FileHandle, int PageRef, int Angle, int Options)
{
	RunFunction(L"DARotatePage", FileHandle, PageRef, Angle, Options);
	return result.intVal;
}

int PDFlibAX::DASaveAsFile(int FileHandle, const std::wstring& OutputFileName) {
	BSTR bstrOutputFileName = SysAllocStringLen(OutputFileName.c_str(),
		(int)(OutputFileName.length()));
	RunFunction(L"DASaveAsFile", FileHandle, bstrOutputFileName);
	SysFreeString(bstrOutputFileName);
	return result.intVal;
}

int PDFlibAX::DASaveImageDataToFile(int FileHandle, int ImageListID,
	int ImageIndex, const std::wstring& ImageFileName) {
	BSTR bstrImageFileName = SysAllocStringLen(ImageFileName.c_str(),
		(int)(ImageFileName.length()));
	RunFunction(L"DASaveImageDataToFile", FileHandle, ImageListID, ImageIndex,
		bstrImageFileName);
	SysFreeString(bstrImageFileName);
	return result.intVal;
}

int PDFlibAX::DASetInformation(int FileHandle, const std::wstring& Key,
	const std::wstring& NewValue) {
	BSTR bstrKey = SysAllocStringLen(Key.c_str(), (int)(Key.length()));
	BSTR bstrNewValue = SysAllocStringLen(NewValue.c_str(),
		(int)(NewValue.length()));
	RunFunction(L"DASetInformation", FileHandle, bstrKey, bstrNewValue);
	SysFreeString(bstrKey);
	SysFreeString(bstrNewValue);
	return result.intVal;
}

int PDFlibAX::DASetPageSize(int FileHandle, int PageRef, double PntWidth,
	double PntHeight) {
	RunFunction(L"DASetPageSize", FileHandle, PageRef, PntWidth, PntHeight);
	return result.intVal;
}

int PDFlibAX::Decrypt() {
	RunFunction(L"Decrypt");
	return result.intVal;
}

int PDFlibAX::DecryptFile(const std::wstring& InputFileName,
	const std::wstring& OutputFileName, const std::wstring& Password) {
	BSTR bstrInputFileName = SysAllocStringLen(InputFileName.c_str(),
		(int)(InputFileName.length()));
	BSTR bstrOutputFileName = SysAllocStringLen(OutputFileName.c_str(),
		(int)(OutputFileName.length()));
	BSTR bstrPassword = SysAllocStringLen(Password.c_str(),
		(int)(Password.length()));
	RunFunction(L"DecryptFile", bstrInputFileName, bstrOutputFileName,
		bstrPassword);
	SysFreeString(bstrInputFileName);
	SysFreeString(bstrOutputFileName);
	SysFreeString(bstrPassword);
	return result.intVal;
}

int PDFlibAX::DeleteAnalysis(int AnalysisID) {
	RunFunction(L"DeleteAnalysis", AnalysisID);
	return result.intVal;
}

int PDFlibAX::DeleteAnnotation(int Index) {
	RunFunction(L"DeleteAnnotation", Index);
	return result.intVal;
}

int PDFlibAX::DeleteFormField(int Index) {
	RunFunction(L"DeleteFormField", Index);
	return result.intVal;
}

int PDFlibAX::DeleteLayer() {
	RunFunction(L"DeleteLayer");
	return result.intVal;
}

int PDFlibAX::DeleteOptionalContentGroup(int OptionalContentGroupID) {
	RunFunction(L"DeleteOptionalContentGroup", OptionalContentGroupID);
	return result.intVal;
}

int PDFlibAX::DeletePageLGIDict(int DictIndex) {
	RunFunction(L"DeletePageLGIDict", DictIndex);
	return result.intVal;
}

int PDFlibAX::DeletePages(int StartPage, int PageCount) {
	RunFunction(L"DeletePages", StartPage, PageCount);
	return result.intVal;
}

int PDFlibAX::DocJavaScriptAction(const std::wstring& ActionType,
	const std::wstring& JavaScript) {
	BSTR bstrActionType = SysAllocStringLen(ActionType.c_str(),
		(int)(ActionType.length()));
	BSTR bstrJavaScript = SysAllocStringLen(JavaScript.c_str(),
		(int)(JavaScript.length()));
	RunFunction(L"DocJavaScriptAction", bstrActionType, bstrJavaScript);
	SysFreeString(bstrActionType);
	SysFreeString(bstrJavaScript);
	return result.intVal;
}

int PDFlibAX::DocumentCount() {
	RunFunction(L"DocumentCount");
	return result.intVal;
}

int PDFlibAX::DrawArc(double XPos, double YPos, double Radius,
	double StartAngle, double EndAngle, int Pie, int DrawOptions) {
	RunFunction(L"DrawArc", XPos, YPos, Radius, StartAngle, EndAngle, Pie,
		DrawOptions);
	return result.intVal;
}

int PDFlibAX::DrawBarcode(double Left, double Top, double Width, double Height,
	const std::wstring& Text, int Barcode, int Options) {
	BSTR bstrText = SysAllocStringLen(Text.c_str(), (int)(Text.length()));
	RunFunction(L"DrawBarcode", Left, Top, Width, Height, bstrText, Barcode,
		Options);
	SysFreeString(bstrText);
	return result.intVal;
}

int PDFlibAX::DrawBox(double Left, double Top, double Width, double Height,
	int DrawOptions) {
	RunFunction(L"DrawBox", Left, Top, Width, Height, DrawOptions);
	return result.intVal;
}

int PDFlibAX::DrawCapturedPage(int CaptureID, double Left, double Top,
	double Width, double Height) {
	RunFunction(L"DrawCapturedPage", CaptureID, Left, Top, Width, Height);
	return result.intVal;
}

int PDFlibAX::DrawCircle(double XPos, double YPos, double Radius,
	int DrawOptions) {
	RunFunction(L"DrawCircle", XPos, YPos, Radius, DrawOptions);
	return result.intVal;
}

int PDFlibAX::DrawDataMatrixSymbol(double Left, double Top, double ModuleSize,
	const std::wstring& Text, int Encoding, int SymbolSize, int Options) {
	BSTR bstrText = SysAllocStringLen(Text.c_str(), (int)(Text.length()));
	RunFunction(L"DrawDataMatrixSymbol", Left, Top, ModuleSize, bstrText,
		Encoding, SymbolSize, Options);
	SysFreeString(bstrText);
	return result.intVal;
}

int PDFlibAX::DrawEllipse(double XPos, double YPos, double Width, double Height,
	int DrawOptions) {
	RunFunction(L"DrawEllipse", XPos, YPos, Width, Height, DrawOptions);
	return result.intVal;
}

int PDFlibAX::DrawEllipticArc(double XPos, double YPos, double Width,
	double Height, double StartAngle, double EndAngle, int Pie, int DrawOptions)
{
	RunFunction(L"DrawEllipticArc", XPos, YPos, Width, Height, StartAngle,
		EndAngle, Pie, DrawOptions);
	return result.intVal;
}

int PDFlibAX::DrawHTMLText(double Left, double Top, double Width,
	const std::wstring& HTMLText) {
	BSTR bstrHTMLText = SysAllocStringLen(HTMLText.c_str(),
		(int)(HTMLText.length()));
	RunFunction(L"DrawHTMLText", Left, Top, Width, bstrHTMLText);
	SysFreeString(bstrHTMLText);
	return result.intVal;
}

std::wstring PDFlibAX::DrawHTMLTextBox(double Left, double Top, double Width,
	double Height, const std::wstring& HTMLText) {
	BSTR bstrHTMLText = SysAllocStringLen(HTMLText.c_str(),
		(int)(HTMLText.length()));
	RunFunction(L"DrawHTMLTextBox", Left, Top, Width, Height, bstrHTMLText);
	SysFreeString(bstrHTMLText);
	return GetString();
}

int PDFlibAX::DrawImage(double Left, double Top, double Width, double Height) {
	RunFunction(L"DrawImage", Left, Top, Width, Height);
	return result.intVal;
}

int PDFlibAX::DrawLine(double StartX, double StartY, double EndX, double EndY) {
	RunFunction(L"DrawLine", StartX, StartY, EndX, EndY);
	return result.intVal;
}

int PDFlibAX::DrawMultiLineText(double XPos, double YPos,
	const std::wstring& Delimiter, const std::wstring& Text) {
	BSTR bstrDelimiter = SysAllocStringLen(Delimiter.c_str(),
		(int)(Delimiter.length()));
	BSTR bstrText = SysAllocStringLen(Text.c_str(), (int)(Text.length()));
	RunFunction(L"DrawMultiLineText", XPos, YPos, bstrDelimiter, bstrText);
	SysFreeString(bstrDelimiter);
	SysFreeString(bstrText);
	return result.intVal;
}

int PDFlibAX::DrawPath(int PathOptions) {
	RunFunction(L"DrawPath", PathOptions);
	return result.intVal;
}

int PDFlibAX::DrawPathEvenOdd(int PathOptions) {
	RunFunction(L"DrawPathEvenOdd", PathOptions);
	return result.intVal;
}

int PDFlibAX::DrawPostScriptXObject(int PSRef) {
	RunFunction(L"DrawPostScriptXObject", PSRef);
	return result.intVal;
}

int PDFlibAX::DrawRotatedCapturedPage(int CaptureID, double Left, double Bottom,
	double Width, double Height, double Angle) {
	RunFunction(L"DrawRotatedCapturedPage", CaptureID, Left, Bottom, Width,
		Height, Angle);
	return result.intVal;
}

int PDFlibAX::DrawRotatedImage(double Left, double Bottom, double Width,
	double Height, double Angle) {
	RunFunction(L"DrawRotatedImage", Left, Bottom, Width, Height, Angle);
	return result.intVal;
}

int PDFlibAX::DrawRotatedText(double XPos, double YPos, double Angle,
	const std::wstring& Text) {
	BSTR bstrText = SysAllocStringLen(Text.c_str(), (int)(Text.length()));
	RunFunction(L"DrawRotatedText", XPos, YPos, Angle, bstrText);
	SysFreeString(bstrText);
	return result.intVal;
}

int PDFlibAX::DrawRotatedTextBox(double Left, double Top, double Width,
	double Height, double Angle, const std::wstring& Text, int Options) {
	BSTR bstrText = SysAllocStringLen(Text.c_str(), (int)(Text.length()));
	RunFunction(L"DrawRotatedTextBox", Left, Top, Width, Height, Angle,
		bstrText, Options);
	SysFreeString(bstrText);
	return result.intVal;
}

int PDFlibAX::DrawRoundedBox(double Left, double Top, double Width,
	double Height, double Radius, int DrawOptions) {
	RunFunction(L"DrawRoundedBox", Left, Top, Width, Height, Radius,
		DrawOptions);
	return result.intVal;
}

int PDFlibAX::DrawScaledImage(double Left, double Top, double Scale) {
	RunFunction(L"DrawScaledImage", Left, Top, Scale);
	return result.intVal;
}

int PDFlibAX::DrawSpacedText(double XPos, double YPos, double Spacing,
	const std::wstring& Text) {
	BSTR bstrText = SysAllocStringLen(Text.c_str(), (int)(Text.length()));
	RunFunction(L"DrawSpacedText", XPos, YPos, Spacing, bstrText);
	SysFreeString(bstrText);
	return result.intVal;
}

double PDFlibAX::DrawTableRows(int TableID, double Left, double Top,
	double Height, int FirstRow, int LastRow) {
	RunFunction(L"DrawTableRows", TableID, Left, Top, Height, FirstRow,
		LastRow);
	return result.dblVal;
}

int PDFlibAX::DrawText(double XPos, double YPos, const std::wstring& Text) {
	BSTR bstrText = SysAllocStringLen(Text.c_str(), (int)(Text.length()));
	RunFunction(L"DrawText", XPos, YPos, bstrText);
	SysFreeString(bstrText);
	return result.intVal;
}

int PDFlibAX::DrawTextArc(double XPos, double YPos, double Radius, double Angle,
	const std::wstring& Text, int DrawOptions) {
	BSTR bstrText = SysAllocStringLen(Text.c_str(), (int)(Text.length()));
	RunFunction(L"DrawTextArc", XPos, YPos, Radius, Angle, bstrText,
		DrawOptions);
	SysFreeString(bstrText);
	return result.intVal;
}

int PDFlibAX::DrawTextBox(double Left, double Top, double Width, double Height,
	const std::wstring& Text, int Options) {
	BSTR bstrText = SysAllocStringLen(Text.c_str(), (int)(Text.length()));
	RunFunction(L"DrawTextBox", Left, Top, Width, Height, bstrText, Options);
	SysFreeString(bstrText);
	return result.intVal;
}

int PDFlibAX::DrawWrappedText(double XPos, double YPos, double Width,
	const std::wstring& Text) {
	BSTR bstrText = SysAllocStringLen(Text.c_str(), (int)(Text.length()));
	RunFunction(L"DrawWrappedText", XPos, YPos, Width, bstrText);
	SysFreeString(bstrText);
	return result.intVal;
}

int PDFlibAX::EditableLayer() {
	RunFunction(L"EditableLayer");
	return result.intVal;
}

int PDFlibAX::EmbedFile(const std::wstring& Title, const std::wstring& FileName,
	const std::wstring& MIMEType) {
	BSTR bstrTitle = SysAllocStringLen(Title.c_str(), (int)(Title.length()));
	BSTR bStrFileName = SysAllocStringLen(FileName.c_str(),
		(int)(FileName.length()));
	BSTR bstrMIMEType = SysAllocStringLen(MIMEType.c_str(),
		(int)(MIMEType.length()));
	RunFunction(L"EmbedFile", bstrTitle, bStrFileName, bstrMIMEType);
	SysFreeString(bstrTitle);
	SysFreeString(bStrFileName);
	SysFreeString(bstrMIMEType);
	return result.intVal;
}

int PDFlibAX::EmbeddedFileCount() {
	RunFunction(L"EmbeddedFileCount");
	return result.intVal;
}

int PDFlibAX::EncapsulateLayer() {
	RunFunction(L"EncapsulateLayer");
	return result.intVal;
}

int PDFlibAX::EncodePermissions(int CanPrint, int CanCopy, int CanChange,
	int CanAddNotes, int CanFillFields, int CanCopyAccess, int CanAssemble,
	int CanPrintFull) {
	RunFunction(L"EncodePermissions", CanPrint, CanCopy, CanChange, CanAddNotes,
		CanFillFields, CanCopyAccess, CanAssemble, CanPrintFull);
	return result.intVal;
}

int PDFlibAX::Encrypt(const std::wstring& Owner, const std::wstring& User,
	int Strength, int Permissions) {
	BSTR bstrOwner = SysAllocStringLen(Owner.c_str(), (int)(Owner.length()));
	BSTR bstrUser = SysAllocStringLen(User.c_str(), (int)(User.length()));
	RunFunction(L"Encrypt", bstrOwner, bstrUser, Strength, Permissions);
	SysFreeString(bstrOwner);
	SysFreeString(bstrUser);
	return result.intVal;
}

int PDFlibAX::EncryptFile(const std::wstring& InputFileName,
	const std::wstring& OutputFileName, const std::wstring& Owner,
	const std::wstring& User, int Strength, int Permissions) {
	BSTR bstrInputFileName = SysAllocStringLen(InputFileName.c_str(),
		(int)(InputFileName.length()));
	BSTR bstrOutputFileName = SysAllocStringLen(OutputFileName.c_str(),
		(int)(OutputFileName.length()));
	BSTR bstrOwner = SysAllocStringLen(Owner.c_str(), (int)(Owner.length()));
	BSTR bstrUser = SysAllocStringLen(User.c_str(), (int)(User.length()));
	RunFunction(L"EncryptFile", bstrInputFileName, bstrOutputFileName,
		bstrOwner, bstrUser, Strength, Permissions);
	SysFreeString(bstrInputFileName);
	SysFreeString(bstrOutputFileName);
	SysFreeString(bstrOwner);
	SysFreeString(bstrUser);
	return result.intVal;
}

int PDFlibAX::EncryptWithFingerprint(const std::wstring& Fingerprint) {
	BSTR bstrFingerprint = SysAllocStringLen(Fingerprint.c_str(),
		(int)(Fingerprint.length()));
	RunFunction(L"EncryptWithFingerprint", bstrFingerprint);
	SysFreeString(bstrFingerprint);
	return result.intVal;
}

int PDFlibAX::EncryptionAlgorithm() {
	RunFunction(L"EncryptionAlgorithm");
	return result.intVal;
}

int PDFlibAX::EncryptionStatus() {
	RunFunction(L"EncryptionStatus");
	return result.intVal;
}

int PDFlibAX::EncryptionStrength() {
	RunFunction(L"EncryptionStrength");
	return result.intVal;
}

int PDFlibAX::EndPageUpdate() {
	RunFunction(L"EndPageUpdate");
	return result.intVal;
}

std::wstring PDFlibAX::ExtractFilePageContent(const std::wstring& InputFileName,
	const std::wstring& Password, int Page) {
	BSTR bstrInputFileName = SysAllocStringLen(InputFileName.c_str(),
		(int)(InputFileName.length()));
	BSTR bstrPassword = SysAllocStringLen(Password.c_str(),
		(int)(Password.length()));
	RunFunction(L"ExtractFilePageContent", bstrInputFileName,
		bstrPassword, Page);
	SysFreeString(bstrInputFileName);
	SysFreeString(bstrPassword);
	return GetString();
}

std::wstring PDFlibAX::ExtractFilePageText(const std::wstring& InputFileName,
	const std::wstring& Password, int Page, int Options) {
	BSTR bstrInputFileName = SysAllocStringLen(InputFileName.c_str(),
		(int)(InputFileName.length()));
	BSTR bstrPassword = SysAllocStringLen(Password.c_str(),
		(int)(Password.length()));
	RunFunction(L"ExtractFilePageText", bstrInputFileName, bstrPassword, Page,
		Options);
	SysFreeString(bstrInputFileName);
	SysFreeString(bstrPassword);
	return GetString();
}

int PDFlibAX::ExtractFilePages(const std::wstring& InputFileName,
	const std::wstring& OutputFileName, const std::wstring& RangeList) {
	BSTR bstrInputFileName = SysAllocStringLen(InputFileName.c_str(),
		(int)(InputFileName.length()));
	BSTR bstrOutputFileName = SysAllocStringLen(OutputFileName.c_str(),
		(int)(OutputFileName.length()));
	BSTR bstrRangeList = SysAllocStringLen(RangeList.c_str(),
		(int)(RangeList.length()));
	RunFunction(L"ExtractFilePages", bstrInputFileName, bstrOutputFileName,
		bstrRangeList);
	SysFreeString(bstrInputFileName);
	SysFreeString(bstrOutputFileName);
	SysFreeString(bstrRangeList);
	return result.intVal;
}

int PDFlibAX::ExtractPageRanges(const std::wstring& RangeList) {
	BSTR bstrRangeList = SysAllocStringLen(RangeList.c_str(),
		(int)(RangeList.length()));
	RunFunction(L"ExtractPageRanges", bstrRangeList);
	SysFreeString(bstrRangeList);
	return result.intVal;
}

int PDFlibAX::ExtractPages(int StartPage, int PageCount) {
	RunFunction(L"ExtractPages", StartPage, PageCount);
	return result.intVal;
}

int PDFlibAX::FileListCount(const std::wstring& ListName) {
	BSTR bstrListName = SysAllocStringLen(ListName.c_str(),
		(int)(ListName.length()));
	RunFunction(L"FileListCount", bstrListName);
	SysFreeString(bstrListName);
	return result.intVal;
}

std::wstring PDFlibAX::FileListItem(const std::wstring& ListName, int Index) {
	BSTR bstrListName = SysAllocStringLen(ListName.c_str(),
		(int)(ListName.length()));
	RunFunction(L"FileListItem", bstrListName, Index);
	SysFreeString(bstrListName);
	return GetString();
}

int PDFlibAX::FindFonts() {
	RunFunction(L"FindFonts");
	return result.intVal;
}

int PDFlibAX::FindFormFieldByTitle(const std::wstring& Title) {
	BSTR bstrTitle = SysAllocStringLen(Title.c_str(), (int)(Title.length()));
	RunFunction(L"FindFormFieldByTitle", bstrTitle);
	SysFreeString(bstrTitle);
	return result.intVal;
}

int PDFlibAX::FindImages() {
	RunFunction(L"FindImages");
	return result.intVal;
}

int PDFlibAX::FitImage(double Left, double Top, double Width, double Height,
	int HAlign, int VAlign, int Rotate) {
	RunFunction(L"FitImage", Left, Top, Width, Height, HAlign, VAlign, Rotate);
	return result.intVal;
}

int PDFlibAX::FitRotatedTextBox(double Left, double Top, double Width,
	double Height, double Angle, const std::wstring& Text, int Options) {
	BSTR bstrText = SysAllocStringLen(Text.c_str(), (int)(Text.length()));
	RunFunction(L"FitRotatedTextBox", Left, Top, Width, Height, Angle, bstrText,
		Options);
	SysFreeString(bstrText);
	return result.intVal;
}

int PDFlibAX::FitTextBox(double Left, double Top, double Width, double Height,
	const std::wstring& Text, int Options) {
	BSTR bstrText = SysAllocStringLen(Text.c_str(), (int)(Text.length()));
	RunFunction(L"FitTextBox", Left, Top, Width, Height, bstrText, Options);
	SysFreeString(bstrText);
	return result.intVal;
}

int PDFlibAX::FlattenFormField(int Index) {
	RunFunction(L"FlattenFormField", Index);
	return result.intVal;
}

int PDFlibAX::FontCount() {
	RunFunction(L"FontCount");
	return result.intVal;
}

std::wstring PDFlibAX::FontFamily() {
	RunFunction(L"FontFamily");
	return GetString();
}

int PDFlibAX::FontHasKerning() {
	RunFunction(L"FontHasKerning");
	return result.intVal;
}

std::wstring PDFlibAX::FontName() {
	RunFunction(L"FontName");
	return GetString();
}

std::wstring PDFlibAX::FontReference() {
	RunFunction(L"FontReference");
	return GetString();
}

int PDFlibAX::FontSize() {
	RunFunction(L"FontSize");
	return result.intVal;
}

int PDFlibAX::FontType() {
	RunFunction(L"FontType");
	return result.intVal;
}

int PDFlibAX::FormFieldCount() {
	RunFunction(L"FormFieldCount");
	return result.intVal;
}

int PDFlibAX::FormFieldHasParent(int Index) {
	RunFunction(L"FormFieldHasParent", Index);
	return result.intVal;
}

int PDFlibAX::FormFieldJavaScriptAction(int Index,
	const std::wstring& ActionType, const std::wstring& JavaScript) {
	BSTR bstrActionType = SysAllocStringLen(ActionType.c_str(),
		(int)(ActionType.length()));
	BSTR bstrJavaScript = SysAllocStringLen(JavaScript.c_str(),
		(int)(JavaScript.length()));
	RunFunction(L"FormFieldJavaScriptAction", Index, bstrActionType,
		bstrJavaScript);
	SysFreeString(bstrActionType);
	SysFreeString(bstrJavaScript);
	return result.intVal;
}

int PDFlibAX::FormFieldWebLinkAction(int Index, const std::wstring& ActionType,
	const std::wstring& Link) {
	BSTR bstrActionType = SysAllocStringLen(ActionType.c_str(),
		(int)(ActionType.length()));
	BSTR bstrLink = SysAllocStringLen(Link.c_str(), (int)(Link.length()));
	RunFunction(L"FormFieldWebLinkAction", Index, bstrActionType, bstrLink);
	SysFreeString(bstrActionType);
	SysFreeString(bstrLink);
	return result.intVal;
}

std::wstring PDFlibAX::GetActionType(int ActionID) {
	RunFunction(L"GetActionType", ActionID);
	return GetString();
}

std::wstring PDFlibAX::GetAnalysisInfo(int AnalysisID, int AnalysisItem) {
	RunFunction(L"GetAnalysisInfo", AnalysisID, AnalysisItem);
	return GetString();
}

int PDFlibAX::GetAnnotActionID(int Index) {
	RunFunction(L"GetAnnotActionID", Index);
	return result.intVal;
}

double PDFlibAX::GetAnnotDblProperty(int Index, int Tag) {
	RunFunction(L"GetAnnotDblProperty", Index, Tag);
	return result.dblVal;
}

int PDFlibAX::GetAnnotIntProperty(int Index, int Tag) {
	RunFunction(L"GetAnnotIntProperty", Index, Tag);
	return result.intVal;
}

std::wstring PDFlibAX::GetAnnotStrProperty(int Index, int Tag) {
	RunFunction(L"GetAnnotStrProperty", Index, Tag);
	return GetString();
}

double PDFlibAX::GetBarcodeWidth(double NominalWidth, const std::wstring& Text,
	int Barcode) {
	BSTR bstrText = SysAllocStringLen(Text.c_str(), (int)(Text.length()));
	RunFunction(L"GetBarcodeWidth", NominalWidth, bstrText, Barcode);
	SysFreeString(bstrText);
	return result.dblVal;
}

int PDFlibAX::GetCanvasDC(int Width, int Height) {
	RunFunction(L"GetCanvasDC", Width, Height);
	return result.intVal;
}

std::wstring PDFlibAX::GetCatalogInformation(const std::wstring& Key) {
	BSTR bstrKey = SysAllocStringLen(Key.c_str(), (int)(Key.length()));
	RunFunction(L"GetCatalogInformation", bstrKey);
	SysFreeString(bstrKey);
	return GetString();
}

std::wstring PDFlibAX::GetCustomInformation(const std::wstring& Key) {
	BSTR bstrKey = SysAllocStringLen(Key.c_str(), (int)(Key.length()));
	RunFunction(L"GetCustomInformation", bstrKey);
	SysFreeString(bstrKey);
	return GetString();
}

std::wstring PDFlibAX::GetCustomKeys(int Location) {
	RunFunction(L"GetCustomKeys", Location);
	return GetString();
}

std::wstring PDFlibAX::GetDefaultPrinterName() {
	RunFunction(L"GetDefaultPrinterName");
	return GetString();
}

int PDFlibAX::GetDestPage(int DestID) {
	RunFunction(L"GetDestPage", DestID);
	return result.intVal;
}

int PDFlibAX::GetDestType(int DestID) {
	RunFunction(L"GetDestType", DestID);
	return result.intVal;
}

double PDFlibAX::GetDestValue(int DestID, int ValueKey) {
	RunFunction(L"GetDestValue", DestID, ValueKey);
	return result.dblVal;
}

std::wstring PDFlibAX::GetDocJavaScript(const std::wstring& ActionType) {
	BSTR bstrActionType = SysAllocStringLen(ActionType.c_str(),
		(int)(ActionType.length()));
	RunFunction(L"GetDocJavaScript", bstrActionType);
	SysFreeString(bstrActionType);
	return GetString();
}

int PDFlibAX::GetDocumentID(int Index) {
	RunFunction(L"GetDocumentID", Index);
	return result.intVal;
}

std::wstring PDFlibAX::GetDocumentIdentifier(int Part, int Options) {
	RunFunction(L"GetDocumentIdentifier", Part, Options);
	return GetString();
}

std::wstring PDFlibAX::GetDocumentMetadata() {
	RunFunction(L"GetDocumentMetadata");
	return GetString();
}

std::wstring PDFlibAX::GetDocumentResourceList() {
	RunFunction(L"GetDocumentResourceList");
	return GetString();
}

int PDFlibAX::GetEmbeddedFileContentToFile(int Index,
	const std::wstring& FileName) {
	BSTR bStrFileName = SysAllocStringLen(FileName.c_str(),
		(int)(FileName.length()));
	RunFunction(L"GetEmbeddedFileContentToFile", Index, bStrFileName);
	SysFreeString(bStrFileName);
	return result.intVal;
}

std::vector<BYTE>PDFlibAX::GetEmbeddedFileContentToVariant(int Index) {
	RunFunction(L"GetEmbeddedFileContentToVariant", Index);
	return GetByteArray();
}

int PDFlibAX::GetEmbeddedFileIntProperty(int Index, int Tag) {
	RunFunction(L"GetEmbeddedFileIntProperty", Index, Tag);
	return result.intVal;
}

std::wstring PDFlibAX::GetEmbeddedFileStrProperty(int Index, int Tag) {
	RunFunction(L"GetEmbeddedFileStrProperty", Index, Tag);
	return GetString();
}

std::wstring PDFlibAX::GetEncryptionFingerprint() {
	RunFunction(L"GetEncryptionFingerprint");
	return GetString();
}

std::wstring PDFlibAX::GetFileMetadata(const std::wstring& InputFileName) {
	BSTR bstrInputFileName = SysAllocStringLen(InputFileName.c_str(),
		(int)(InputFileName.length()));
	RunFunction(L"GetFileMetadata", bstrInputFileName);
	SysFreeString(bstrInputFileName);
	return GetString();
}

int PDFlibAX::GetFirstChildOutline(int OutlineID) {
	RunFunction(L"GetFirstChildOutline", OutlineID);
	return result.intVal;
}

int PDFlibAX::GetFirstOutline() {
	RunFunction(L"GetFirstOutline");
	return result.intVal;
}

int PDFlibAX::GetFontID(int Index) {
	RunFunction(L"GetFontID", Index);
	return result.intVal;
}

int PDFlibAX::GetFontObjectNumber() {
	RunFunction(L"GetFontObjectNumber");
	return result.intVal;
}

int PDFlibAX::GetFormFieldAlignment(int Index) {
	RunFunction(L"GetFormFieldAlignment", Index);
	return result.intVal;
}

int PDFlibAX::GetFormFieldAnnotFlags(int Index) {
	RunFunction(L"GetFormFieldAnnotFlags", Index);
	return result.intVal;
}

double PDFlibAX::GetFormFieldBackgroundColor(int Index, int ColorComponent) {
	RunFunction(L"GetFormFieldBackgroundColor", Index, ColorComponent);
	return result.dblVal;
}

double PDFlibAX::GetFormFieldBorderColor(int Index, int ColorComponent) {
	RunFunction(L"GetFormFieldBorderColor", Index, ColorComponent);
	return result.dblVal;
}

double PDFlibAX::GetFormFieldBorderProperty(int Index, int PropKey) {
	RunFunction(L"GetFormFieldBorderProperty", Index, PropKey);
	return result.dblVal;
}

int PDFlibAX::GetFormFieldBorderStyle(int Index) {
	RunFunction(L"GetFormFieldBorderStyle", Index);
	return result.intVal;
}

double PDFlibAX::GetFormFieldBound(int Index, int Edge) {
	RunFunction(L"GetFormFieldBound", Index, Edge);
	return result.dblVal;
}

std::wstring PDFlibAX::GetFormFieldCaption(int Index) {
	RunFunction(L"GetFormFieldCaption", Index);
	return GetString();
}

std::wstring PDFlibAX::GetFormFieldChildTitle(int Index) {
	RunFunction(L"GetFormFieldChildTitle", Index);
	return GetString();
}

int PDFlibAX::GetFormFieldChoiceType(int Index) {
	RunFunction(L"GetFormFieldChoiceType", Index);
	return result.intVal;
}

double PDFlibAX::GetFormFieldColor(int Index, int ColorComponent) {
	RunFunction(L"GetFormFieldColor", Index, ColorComponent);
	return result.dblVal;
}

int PDFlibAX::GetFormFieldComb(int Index) {
	RunFunction(L"GetFormFieldComb", Index);
	return result.intVal;
}

std::wstring PDFlibAX::GetFormFieldDefaultValue(int Index) {
	RunFunction(L"GetFormFieldDefaultValue", Index);
	return GetString();
}

std::wstring PDFlibAX::GetFormFieldDescription(int Index) {
	RunFunction(L"GetFormFieldDescription", Index);
	return GetString();
}

int PDFlibAX::GetFormFieldFlags(int Index) {
	RunFunction(L"GetFormFieldFlags", Index);
	return result.intVal;
}

std::wstring PDFlibAX::GetFormFieldFontName(int Index) {
	RunFunction(L"GetFormFieldFontName", Index);
	return GetString();
}

std::wstring PDFlibAX::GetFormFieldJavaScript(int Index,
	const std::wstring& ActionType) {
	BSTR bstrActionType = SysAllocStringLen(ActionType.c_str(),
		(int)(ActionType.length()));
	RunFunction(L"GetFormFieldJavaScript", Index, bstrActionType);
	SysFreeString(bstrActionType);
	return GetString();
}

int PDFlibAX::GetFormFieldKidCount(int Index) {
	RunFunction(L"GetFormFieldKidCount", Index);
	return result.intVal;
}

int PDFlibAX::GetFormFieldMaxLen(int Index) {
	RunFunction(L"GetFormFieldMaxLen", Index);
	return result.intVal;
}

int PDFlibAX::GetFormFieldPage(int Index) {
	RunFunction(L"GetFormFieldPage", Index);
	return result.intVal;
}

int PDFlibAX::GetFormFieldPrintable(int Index) {
	RunFunction(L"GetFormFieldPrintable", Index);
	return result.intVal;
}

int PDFlibAX::GetFormFieldReadOnly(int Index) {
	RunFunction(L"GetFormFieldReadOnly", Index);
	return result.intVal;
}

int PDFlibAX::GetFormFieldRotation(int Index) {
	RunFunction(L"GetFormFieldRotation", Index);
	return result.intVal;
}

int PDFlibAX::GetFormFieldSubCount(int Index) {
	RunFunction(L"GetFormFieldSubCount", Index);
	return result.intVal;
}

std::wstring PDFlibAX::GetFormFieldSubName(int Index, int SubIndex) {
	RunFunction(L"GetFormFieldSubName", Index, SubIndex);
	return GetString();
}

int PDFlibAX::GetFormFieldSubTempIndex(int Index, int SubIndex) {
	RunFunction(L"GetFormFieldSubTempIndex", Index, SubIndex);
	return result.intVal;
}

int PDFlibAX::GetFormFieldTabOrder(int Index) {
	RunFunction(L"GetFormFieldTabOrder", Index);
	return result.intVal;
}

int PDFlibAX::GetFormFieldTextFlags(int Index, int ValueKey) {
	RunFunction(L"GetFormFieldTextFlags", Index, ValueKey);
	return result.intVal;
}

double PDFlibAX::GetFormFieldTextSize(int Index) {
	RunFunction(L"GetFormFieldTextSize", Index);
	return result.dblVal;
}

std::wstring PDFlibAX::GetFormFieldTitle(int Index) {
	RunFunction(L"GetFormFieldTitle", Index);
	return GetString();
}

int PDFlibAX::GetFormFieldType(int Index) {
	RunFunction(L"GetFormFieldType", Index);
	return result.intVal;
}

std::wstring PDFlibAX::GetFormFieldValue(int Index) {
	RunFunction(L"GetFormFieldValue", Index);
	return GetString();
}

std::wstring PDFlibAX::GetFormFieldValueByTitle(const std::wstring& Title) {
	BSTR bstrTitle = SysAllocStringLen(Title.c_str(), (int)(Title.length()));
	RunFunction(L"GetFormFieldValueByTitle", bstrTitle);
	SysFreeString(bstrTitle);
	return GetString();
}

int PDFlibAX::GetFormFieldVisible(int Index) {
	RunFunction(L"GetFormFieldVisible", Index);
	return result.intVal;
}

std::wstring PDFlibAX::GetFormFieldWebLink(int Index,
	const std::wstring& ActionType) {
	BSTR bstrActionType = SysAllocStringLen(ActionType.c_str(),
		(int)(ActionType.length()));
	RunFunction(L"GetFormFieldWebLink", Index, bstrActionType);
	SysFreeString(bstrActionType);
	return GetString();
}

int PDFlibAX::GetFormFontCount() {
	RunFunction(L"GetFormFontCount");
	return result.intVal;
}

std::wstring PDFlibAX::GetFormFontName(int FontIndex) {
	RunFunction(L"GetFormFontName", FontIndex);
	return GetString();
}

std::wstring PDFlibAX::GetGlobalJavaScript(const std::wstring& PackageName) {
	BSTR bstrPackageName = SysAllocStringLen(PackageName.c_str(),
		(int)(PackageName.length()));
	RunFunction(L"GetGlobalJavaScript", bstrPackageName);
	SysFreeString(bstrPackageName);
	return GetString();
}

double PDFlibAX::GetHTMLTextHeight(double Width, const std::wstring& HTMLText) {
	BSTR bstrHTMLText = SysAllocStringLen(HTMLText.c_str(),
		(int)(HTMLText.length()));
	RunFunction(L"GetHTMLTextHeight", Width, bstrHTMLText);
	SysFreeString(bstrHTMLText);
	return result.dblVal;
}

int PDFlibAX::GetHTMLTextLineCount(double Width, const std::wstring& HTMLText) {
	BSTR bstrHTMLText = SysAllocStringLen(HTMLText.c_str(),
		(int)(HTMLText.length()));
	RunFunction(L"GetHTMLTextLineCount", Width, bstrHTMLText);
	SysFreeString(bstrHTMLText);
	return result.intVal;
}

double PDFlibAX::GetHTMLTextWidth(double MaxWidth, const std::wstring& HTMLText)
{
	BSTR bstrHTMLText = SysAllocStringLen(HTMLText.c_str(),
		(int)(HTMLText.length()));
	RunFunction(L"GetHTMLTextWidth", MaxWidth, bstrHTMLText);
	SysFreeString(bstrHTMLText);
	return result.dblVal;
}

int PDFlibAX::GetImageID(int Index) {
	RunFunction(L"GetImageID", Index);
	return result.intVal;
}

int PDFlibAX::GetImagePageCount(const std::wstring& FileName) {
	BSTR bStrFileName = SysAllocStringLen(FileName.c_str(),
		(int)(FileName.length()));
	RunFunction(L"GetImagePageCount", bStrFileName);
	SysFreeString(bStrFileName);
	return result.intVal;
}

std::wstring PDFlibAX::GetInformation(int Key) {
	RunFunction(L"GetInformation", Key);
	return GetString();
}

int PDFlibAX::GetKerning(const std::wstring& CharPair) {
	BSTR bstrCharPair = SysAllocStringLen(CharPair.c_str(),
		(int)(CharPair.length()));
	RunFunction(L"GetKerning", bstrCharPair);
	SysFreeString(bstrCharPair);
	return result.intVal;
}

int PDFlibAX::GetNamedDestination(const std::wstring& DestName) {
	BSTR bstrDestName = SysAllocStringLen(DestName.c_str(),
		(int)(DestName.length()));
	RunFunction(L"GetNamedDestination", bstrDestName);
	SysFreeString(bstrDestName);
	return result.intVal;
}

int PDFlibAX::GetNextOutline(int OutlineID) {
	RunFunction(L"GetNextOutline", OutlineID);
	return result.intVal;
}

int PDFlibAX::GetObjectCount() {
	RunFunction(L"GetObjectCount");
	return result.intVal;
}

std::wstring PDFlibAX::GetObjectSource(int ObjectNumber) {
	RunFunction(L"GetObjectSource", ObjectNumber);
	return GetString();
}

int PDFlibAX::GetOpenActionDestination() {
	RunFunction(L"GetOpenActionDestination");
	return result.intVal;
}

std::wstring PDFlibAX::GetOpenActionJavaScript() {
	RunFunction(L"GetOpenActionJavaScript");
	return GetString();
}

int PDFlibAX::GetOptionalContentGroupID(int Index) {
	RunFunction(L"GetOptionalContentGroupID", Index);
	return result.intVal;
}

std::wstring PDFlibAX::GetOptionalContentGroupName(int OptionalContentGroupID) {
	RunFunction(L"GetOptionalContentGroupName", OptionalContentGroupID);
	return GetString();
}

int PDFlibAX::GetOrigin() {
	RunFunction(L"GetOrigin");
	return result.intVal;
}

int PDFlibAX::GetOutlineActionID(int OutlineID) {
	RunFunction(L"GetOutlineActionID", OutlineID);
	return result.intVal;
}

double PDFlibAX::GetOutlineColor(int OutlineID, int ColorComponent) {
	RunFunction(L"GetOutlineColor", OutlineID, ColorComponent);
	return result.dblVal;
}

int PDFlibAX::GetOutlineDest(int OutlineID) {
	RunFunction(L"GetOutlineDest", OutlineID);
	return result.intVal;
}

int PDFlibAX::GetOutlineID(int Index) {
	RunFunction(L"GetOutlineID", Index);
	return result.intVal;
}

std::wstring PDFlibAX::GetOutlineJavaScript(int OutlineID) {
	RunFunction(L"GetOutlineJavaScript", OutlineID);
	return GetString();
}

std::wstring PDFlibAX::GetOutlineOpenFile(int OutlineID) {
	RunFunction(L"GetOutlineOpenFile", OutlineID);
	return GetString();
}

int PDFlibAX::GetOutlinePage(int OutlineID) {
	RunFunction(L"GetOutlinePage", OutlineID);
	return result.intVal;
}

int PDFlibAX::GetOutlineStyle(int OutlineID) {
	RunFunction(L"GetOutlineStyle", OutlineID);
	return result.intVal;
}

std::wstring PDFlibAX::GetOutlineWebLink(int OutlineID) {
	RunFunction(L"GetOutlineWebLink", OutlineID);
	return GetString();
}

double PDFlibAX::GetPageBox(int BoxType, int Dimension) {
	RunFunction(L"GetPageBox", BoxType, Dimension);
	return result.dblVal;
}

std::wstring PDFlibAX::GetPageContent() {
	RunFunction(L"GetPageContent");
	return GetString();
}

std::wstring PDFlibAX::GetPageJavaScript(const std::wstring& ActionType) {
	BSTR bstrActionType = SysAllocStringLen(ActionType.c_str(),
		(int)(ActionType.length()));
	RunFunction(L"GetPageJavaScript", bstrActionType);
	SysFreeString(bstrActionType);
	return GetString();
}

std::wstring PDFlibAX::GetPageLGIDictContent(int DictIndex) {
	RunFunction(L"GetPageLGIDictContent", DictIndex);
	return GetString();
}

int PDFlibAX::GetPageLGIDictCount() {
	RunFunction(L"GetPageLGIDictCount");
	return result.intVal;
}

std::wstring PDFlibAX::GetPageLabel(int Page) {
	RunFunction(L"GetPageLabel", Page);
	return GetString();
}

int PDFlibAX::GetPageLayout() {
	RunFunction(L"GetPageLayout");
	return result.intVal;
}

int PDFlibAX::GetPageMode() {
	RunFunction(L"GetPageMode");
	return result.intVal;
}

std::wstring PDFlibAX::GetPageText(int ExtractOptions) {
	RunFunction(L"GetPageText", ExtractOptions);
	return GetString();
}

int PDFlibAX::GetParentOutline(int OutlineID) {
	RunFunction(L"GetParentOutline", OutlineID);
	return result.intVal;
}

int PDFlibAX::GetPrevOutline(int OutlineID) {
	RunFunction(L"GetPrevOutline", OutlineID);
	return result.intVal;
}

std::wstring PDFlibAX::GetPrinterBins(const std::wstring& PrinterName) {
	BSTR bstrPrinterName = SysAllocStringLen(PrinterName.c_str(),
		(int)(PrinterName.length()));
	RunFunction(L"GetPrinterBins", bstrPrinterName);
	SysFreeString(bstrPrinterName);
	return GetString();
}

std::wstring PDFlibAX::GetPrinterNames() {
	RunFunction(L"GetPrinterNames");
	return GetString();
}

std::wstring PDFlibAX::GetSubsetString(const std::wstring& InputStr) {
	BSTR bstrInputStr = SysAllocStringLen(InputStr.c_str(),
		(int)(InputStr.length()));
	RunFunction(L"GetSubsetString", bstrInputStr);
	SysFreeString(bstrInputStr);
	return GetString();
}

double PDFlibAX::GetTableCellDblProperty(int TableID, int RowNumber,
	int ColumnNumber, int Tag) {
	RunFunction(L"GetTableCellDblProperty", TableID, RowNumber,
		ColumnNumber, Tag);
	return result.dblVal;
}

int PDFlibAX::GetTableCellIntProperty(int TableID, int RowNumber,
	int ColumnNumber, int Tag) {
	RunFunction(L"GetTableCellIntProperty", TableID, RowNumber,
		ColumnNumber, Tag);
	return result.intVal;
}

std::wstring PDFlibAX::GetTableCellStrProperty(int TableID, int RowNumber,
	int ColumnNumber, int Tag) {
	RunFunction(L"GetTableCellStrProperty", TableID, RowNumber,
		ColumnNumber, Tag);
	return GetString();
}

int PDFlibAX::GetTableColumnCount(int TableID) {
	RunFunction(L"GetTableColumnCount", TableID);
	return result.intVal;
}

int PDFlibAX::GetTableLastDrawnRow(int TableID) {
	RunFunction(L"GetTableLastDrawnRow", TableID);
	return result.intVal;
}

int PDFlibAX::GetTableRowCount(int TableID) {
	RunFunction(L"GetTableRowCount", TableID);
	return result.intVal;
}

std::wstring PDFlibAX::GetTempPath() {
	RunFunction(L"GetTempPath");
	return GetString();
}

double PDFlibAX::GetTextAscent() {
	RunFunction(L"GetTextAscent");
	return result.dblVal;
}

double PDFlibAX::GetTextBound(int Edge) {
	RunFunction(L"GetTextBound", Edge);
	return result.dblVal;
}

double PDFlibAX::GetTextDescent() {
	RunFunction(L"GetTextDescent");
	return result.dblVal;
}

double PDFlibAX::GetTextHeight() {
	RunFunction(L"GetTextHeight");
	return result.dblVal;
}

double PDFlibAX::GetTextSize() {
	RunFunction(L"GetTextSize");
	return result.dblVal;
}

double PDFlibAX::GetTextWidth(const std::wstring& Text) {
	BSTR bstrText = SysAllocStringLen(Text.c_str(), (int)(Text.length()));
	RunFunction(L"GetTextWidth", bstrText);
	SysFreeString(bstrText);
	return result.dblVal;
}

int PDFlibAX::GetViewerPreferences(int Option) {
	RunFunction(L"GetViewerPreferences", Option);
	return result.intVal;
}

std::wstring PDFlibAX::GetWrappedText(double Width,
	const std::wstring& Delimiter, const std::wstring& Text) {
	BSTR bstrDelimiter = SysAllocStringLen(Delimiter.c_str(),
		(int)(Delimiter.length()));
	BSTR bstrText = SysAllocStringLen(Text.c_str(), (int)(Text.length()));
	RunFunction(L"GetWrappedText", Width, bstrDelimiter, bstrText);
	SysFreeString(bstrDelimiter);
	SysFreeString(bstrText);
	return GetString();
}

std::wstring PDFlibAX::GetWrappedTextBreakString(double Width,
	const std::wstring& Delimiter, const std::wstring& Text) {
	BSTR bstrDelimiter = SysAllocStringLen(Delimiter.c_str(),
		(int)(Delimiter.length()));
	BSTR bstrText = SysAllocStringLen(Text.c_str(), (int)(Text.length()));
	RunFunction(L"GetWrappedTextBreakString", Width, bstrDelimiter, bstrText);
	SysFreeString(bstrDelimiter);
	SysFreeString(bstrText);
	return GetString();
}

double PDFlibAX::GetWrappedTextHeight(double Width, const std::wstring& Text) {
	BSTR bstrText = SysAllocStringLen(Text.c_str(), (int)(Text.length()));
	RunFunction(L"GetWrappedTextHeight", Width, bstrText);
	SysFreeString(bstrText);
	return result.dblVal;
}

int PDFlibAX::GetWrappedTextLineCount(double Width, const std::wstring& Text) {
	BSTR bstrText = SysAllocStringLen(Text.c_str(), (int)(Text.length()));
	RunFunction(L"GetWrappedTextLineCount", Width, bstrText);
	SysFreeString(bstrText);
	return result.intVal;
}

int PDFlibAX::GetXFAFormFieldCount() {
	RunFunction(L"GetXFAFormFieldCount");
	return result.intVal;
}

std::wstring PDFlibAX::GetXFAFormFieldName(int Index) {
	RunFunction(L"GetXFAFormFieldName", Index);
	return GetString();
}

std::wstring PDFlibAX::GetXFAFormFieldNames(const std::wstring& Delimiter) {
	BSTR bstrDelimiter = SysAllocStringLen(Delimiter.c_str(),
		(int)(Delimiter.length()));
	RunFunction(L"GetXFAFormFieldNames", bstrDelimiter);
	SysFreeString(bstrDelimiter);
	return GetString();
}

std::wstring PDFlibAX::GetXFAFormFieldValue(const std::wstring& XFAFieldName) {
	BSTR bstrXFAFieldName = SysAllocStringLen(XFAFieldName.c_str(),
		(int)(XFAFieldName.length()));
	RunFunction(L"GetXFAFormFieldValue", bstrXFAFieldName);
	SysFreeString(bstrXFAFieldName);
	return GetString();
}

int PDFlibAX::GlobalJavaScriptCount() {
	RunFunction(L"GlobalJavaScriptCount");
	return result.intVal;
}

std::wstring PDFlibAX::GlobalJavaScriptPackageName(int Index) {
	RunFunction(L"GlobalJavaScriptPackageName", Index);
	return GetString();
}

int PDFlibAX::HasFontResources() {
	RunFunction(L"HasFontResources");
	return result.intVal;
}

int PDFlibAX::HasPageBox(int BoxType) {
	RunFunction(L"HasPageBox", BoxType);
	return result.intVal;
}

int PDFlibAX::HidePage() {
	RunFunction(L"HidePage");
	return result.intVal;
}

int PDFlibAX::ImageCount() {
	RunFunction(L"ImageCount");
	return result.intVal;
}

int PDFlibAX::ImageFillColor() {
	RunFunction(L"ImageFillColor");
	return result.intVal;
}

int PDFlibAX::ImageHeight() {
	RunFunction(L"ImageHeight");
	return result.intVal;
}

int PDFlibAX::ImageHorizontalResolution() {
	RunFunction(L"ImageHorizontalResolution");
	return result.intVal;
}

int PDFlibAX::ImageResolutionUnits() {
	RunFunction(L"ImageResolutionUnits");
	return result.intVal;
}

int PDFlibAX::ImageType() {
	RunFunction(L"ImageType");
	return result.intVal;
}

int PDFlibAX::ImageVerticalResolution() {
	RunFunction(L"ImageVerticalResolution");
	return result.intVal;
}

int PDFlibAX::ImageWidth() {
	RunFunction(L"ImageWidth");
	return result.intVal;
}

int PDFlibAX::ImportEMFFromFile(const std::wstring& FileName, int FontOptions,
	int GeneralOptions) {
	BSTR bStrFileName = SysAllocStringLen(FileName.c_str(),
		(int)(FileName.length()));
	RunFunction(L"ImportEMFFromFile", bStrFileName, FontOptions,
		GeneralOptions);
	SysFreeString(bStrFileName);
	return result.intVal;
}

int PDFlibAX::InsertPages(int StartPage, int PageCount) {
	RunFunction(L"InsertPages", StartPage, PageCount);
	return result.intVal;
}

int PDFlibAX::InsertTableColumns(int TableID, int Position, int NewColumnCount)
{
	RunFunction(L"InsertTableColumns", TableID, Position, NewColumnCount);
	return result.intVal;
}

int PDFlibAX::InsertTableRows(int TableID, int Position, int NewRowCount) {
	RunFunction(L"InsertTableRows", TableID, Position, NewRowCount);
	return result.intVal;
}

int PDFlibAX::LastErrorCode() {
	RunFunction(L"LastErrorCode");
	return result.intVal;
}

std::wstring PDFlibAX::LastRenderError() {
	RunFunction(L"LastRenderError");
	return GetString();
}

int PDFlibAX::LayerCount() {
	RunFunction(L"LayerCount");
	return result.intVal;
}

std::wstring PDFlibAX::LibraryVersion() {
	RunFunction(L"LibraryVersion");
	return GetString();
}

int PDFlibAX::Linearized() {
	RunFunction(L"Linearized");
	return result.intVal;
}

int PDFlibAX::LoadFromCanvasDC(double DPI, int Options) {
	RunFunction(L"LoadFromCanvasDC", DPI, Options);
	return result.intVal;
}

int PDFlibAX::LoadFromFile(const std::wstring& FileName) {
	BSTR bStrFileName = SysAllocStringLen(FileName.c_str(),
		(int)(FileName.length()));
	RunFunction(L"LoadFromFile", bStrFileName);
	SysFreeString(bStrFileName);
	return result.intVal;
}

int PDFlibAX::LoadFromVariant(std::vector<BYTE>& Source) {
	VARIANT arSource = MakeByteArray(Source);
	RunFunction(L"LoadFromVariant", arSource);
	SafeArrayDestroy(arSource.parray);
	return result.intVal;
}

int PDFlibAX::LoadState() {
	RunFunction(L"LoadState");
	return result.intVal;
}

int PDFlibAX::MergeDocument(int DocumentID) {
	RunFunction(L"MergeDocument", DocumentID);
	return result.intVal;
}

int PDFlibAX::MergeFileList(const std::wstring& ListName,
	const std::wstring& OutputFileName) {
	BSTR bstrListName = SysAllocStringLen(ListName.c_str(),
		(int)(ListName.length()));
	BSTR bstrOutputFileName = SysAllocStringLen(OutputFileName.c_str(),
		(int)(OutputFileName.length()));
	RunFunction(L"MergeFileList", bstrListName, bstrOutputFileName);
	SysFreeString(bstrListName);
	SysFreeString(bstrOutputFileName);
	return result.intVal;
}

int PDFlibAX::MergeFileListFast(const std::wstring& ListName,
	const std::wstring& OutputFileName) {
	BSTR bstrListName = SysAllocStringLen(ListName.c_str(),
		(int)(ListName.length()));
	BSTR bstrOutputFileName = SysAllocStringLen(OutputFileName.c_str(),
		(int)(OutputFileName.length()));
	RunFunction(L"MergeFileListFast", bstrListName, bstrOutputFileName);
	SysFreeString(bstrListName);
	SysFreeString(bstrOutputFileName);
	return result.intVal;
}

int PDFlibAX::MergeFiles(const std::wstring& FirstFileName,
	const std::wstring& SecondFileName, const std::wstring& OutputFileName) {
	BSTR bstrFirstFileName = SysAllocStringLen(FirstFileName.c_str(),
		(int)(FirstFileName.length()));
	BSTR bstrSecondFileName = SysAllocStringLen(SecondFileName.c_str(),
		(int)(SecondFileName.length()));
	BSTR bstrOutputFileName = SysAllocStringLen(OutputFileName.c_str(),
		(int)(OutputFileName.length()));
	RunFunction(L"MergeFiles", bstrFirstFileName, bstrSecondFileName,
		bstrOutputFileName);
	SysFreeString(bstrFirstFileName);
	SysFreeString(bstrSecondFileName);
	SysFreeString(bstrOutputFileName);
	return result.intVal;
}

int PDFlibAX::MergeTableCells(int TableID, int FirstRow, int FirstColumn,
	int LastRow, int LastColumn) {
	RunFunction(L"MergeTableCells", TableID, FirstRow, FirstColumn, LastRow,
		LastColumn);
	return result.intVal;
}

int PDFlibAX::MoveLayer(int FromPosition, int ToPosition) {
	RunFunction(L"MoveLayer", FromPosition, ToPosition);
	return result.intVal;
}

int PDFlibAX::MoveOutlineAfter(int OutlineID, int SiblingID) {
	RunFunction(L"MoveOutlineAfter", OutlineID, SiblingID);
	return result.intVal;
}

int PDFlibAX::MoveOutlineBefore(int OutlineID, int SiblingID) {
	RunFunction(L"MoveOutlineBefore", OutlineID, SiblingID);
	return result.intVal;
}

int PDFlibAX::MovePage(int NewPosition) {
	RunFunction(L"MovePage", NewPosition);
	return result.intVal;
}

int PDFlibAX::MovePath(double NewX, double NewY) {
	RunFunction(L"MovePath", NewX, NewY);
	return result.intVal;
}

int PDFlibAX::MultiplyScale(double MultScaleBy) {
	RunFunction(L"MultiplyScale", MultScaleBy);
	return result.intVal;
}

std::wstring PDFlibAX::NewCustomPrinter(const std::wstring& OriginalPrinterName)
{
	BSTR bstrOriginalPrinterName =
		SysAllocStringLen(OriginalPrinterName.c_str(),
		(int)(OriginalPrinterName.length()));
	RunFunction(L"NewCustomPrinter", bstrOriginalPrinterName);
	SysFreeString(bstrOriginalPrinterName);
	return GetString();
}

int PDFlibAX::NewDocument() {
	RunFunction(L"NewDocument");
	return result.intVal;
}

int PDFlibAX::NewFormField(const std::wstring& Title, int FieldType) {
	BSTR bstrTitle = SysAllocStringLen(Title.c_str(), (int)(Title.length()));
	RunFunction(L"NewFormField", bstrTitle, FieldType);
	SysFreeString(bstrTitle);
	return result.intVal;
}

int PDFlibAX::NewLayer() {
	RunFunction(L"NewLayer");
	return result.intVal;
}

int PDFlibAX::NewOptionalContentGroup(const std::wstring& GroupName) {
	BSTR bstrGroupName = SysAllocStringLen(GroupName.c_str(),
		(int)(GroupName.length()));
	RunFunction(L"NewOptionalContentGroup", bstrGroupName);
	SysFreeString(bstrGroupName);
	return result.intVal;
}

int PDFlibAX::NewOutline(int Parent, const std::wstring& Title, int DestPage,
	double DestPosition) {
	BSTR bstrTitle = SysAllocStringLen(Title.c_str(), (int)(Title.length()));
	RunFunction(L"NewOutline", Parent, bstrTitle, DestPage, DestPosition);
	SysFreeString(bstrTitle);
	return result.intVal;
}

int PDFlibAX::NewPage() {
	RunFunction(L"NewPage");
	return result.intVal;
}

int PDFlibAX::NewPages(int PageCount) {
	RunFunction(L"NewPages", PageCount);
	return result.intVal;
}

int PDFlibAX::NewPostScriptXObject(const std::wstring& PS) {
	BSTR bstrPS = SysAllocStringLen(PS.c_str(), (int)(PS.length()));
	RunFunction(L"NewPostScriptXObject", bstrPS);
	SysFreeString(bstrPS);
	return result.intVal;
}

int PDFlibAX::NewRGBAxialShader(const std::wstring& ShaderName, double StartX,
	double StartY, double StartRed, double StartGreen, double StartBlue,
	double EndX, double EndY, double EndRed, double EndGreen, double EndBlue,
	int Extend) {
	BSTR bstrShaderName = SysAllocStringLen(ShaderName.c_str(),
		(int)(ShaderName.length()));
	RunFunction(L"NewRGBAxialShader", bstrShaderName, StartX, StartY, StartRed,
		StartGreen, StartBlue, EndX, EndY, EndRed, EndGreen, EndBlue, Extend);
	SysFreeString(bstrShaderName);
	return result.intVal;
}

int PDFlibAX::NewStaticOutline(int Parent, const std::wstring& Title) {
	BSTR bstrTitle = SysAllocStringLen(Title.c_str(), (int)(Title.length()));
	RunFunction(L"NewStaticOutline", Parent, bstrTitle);
	SysFreeString(bstrTitle);
	return result.intVal;
}

int PDFlibAX::OpenOutline(int OutlineID) {
	RunFunction(L"OpenOutline", OutlineID);
	return result.intVal;
}

int PDFlibAX::OptionalContentGroupCount() {
	RunFunction(L"OptionalContentGroupCount");
	return result.intVal;
}

int PDFlibAX::OutlineCount() {
	RunFunction(L"OutlineCount");
	return result.intVal;
}

std::wstring PDFlibAX::OutlineTitle(int OutlineID) {
	RunFunction(L"OutlineTitle", OutlineID);
	return GetString();
}

int PDFlibAX::PageCount() {
	RunFunction(L"PageCount");
	return result.intVal;
}

double PDFlibAX::PageHeight() {
	RunFunction(L"PageHeight");
	return result.dblVal;
}

int PDFlibAX::PageJavaScriptAction(const std::wstring& ActionType,
	const std::wstring& JavaScript) {
	BSTR bstrActionType = SysAllocStringLen(ActionType.c_str(),
		(int)(ActionType.length()));
	BSTR bstrJavaScript = SysAllocStringLen(JavaScript.c_str(),
		(int)(JavaScript.length()));
	RunFunction(L"PageJavaScriptAction", bstrActionType, bstrJavaScript);
	SysFreeString(bstrActionType);
	SysFreeString(bstrJavaScript);
	return result.intVal;
}

int PDFlibAX::PageRotation() {
	RunFunction(L"PageRotation");
	return result.intVal;
}

double PDFlibAX::PageWidth() {
	RunFunction(L"PageWidth");
	return result.dblVal;
}

int PDFlibAX::PrintDocument(const std::wstring& PrinterName, int StartPage,
	int EndPage, int Options) {
	BSTR bstrPrinterName = SysAllocStringLen(PrinterName.c_str(),
		(int)(PrinterName.length()));
	RunFunction(L"PrintDocument", bstrPrinterName, StartPage, EndPage, Options);
	SysFreeString(bstrPrinterName);
	return result.intVal;
}

int PDFlibAX::PrintOptions(int PageScaling, int AutoRotateCenter,
	const std::wstring& Title) {
	BSTR bstrTitle = SysAllocStringLen(Title.c_str(), (int)(Title.length()));
	RunFunction(L"PrintOptions", PageScaling, AutoRotateCenter, bstrTitle);
	SysFreeString(bstrTitle);
	return result.intVal;
}

int PDFlibAX::RemoveAppearanceStream(int Index) {
	RunFunction(L"RemoveAppearanceStream", Index);
	return result.intVal;
}

int PDFlibAX::RemoveDocument(int DocumentID) {
	RunFunction(L"RemoveDocument", DocumentID);
	return result.intVal;
}

int PDFlibAX::RemoveOutline(int OutlineID) {
	RunFunction(L"RemoveOutline", OutlineID);
	return result.intVal;
}

int PDFlibAX::RemoveSharedLayers() {
	RunFunction(L"RemoveSharedLayers");
	return result.intVal;
}

int PDFlibAX::RemoveStyle(const std::wstring& StyleName) {
	BSTR bstrStyleName = SysAllocStringLen(StyleName.c_str(),
		(int)(StyleName.length()));
	RunFunction(L"RemoveStyle", bstrStyleName);
	SysFreeString(bstrStyleName);
	return result.intVal;
}

int PDFlibAX::RenderDocumentToFile(int DPI, int StartPage, int EndPage,
	int Options, const std::wstring& FileName) {
	BSTR bStrFileName = SysAllocStringLen(FileName.c_str(),
		(int)(FileName.length()));
	RunFunction(L"RenderDocumentToFile", DPI, StartPage, EndPage, Options,
		bStrFileName);
	SysFreeString(bStrFileName);
	return result.intVal;
}

int PDFlibAX::RenderPageToDC(int DPI, int Page, int DC) {
	RunFunction(L"RenderPageToDC", DPI, Page, DC);
	return result.intVal;
}

int PDFlibAX::RenderPageToFile(int DPI, int Page, int Options,
	const std::wstring& FileName) {
	BSTR bStrFileName = SysAllocStringLen(FileName.c_str(),
		(int)(FileName.length()));
	RunFunction(L"RenderPageToFile", DPI, Page, Options, bStrFileName);
	SysFreeString(bStrFileName);
	return result.intVal;
}

std::vector<BYTE>PDFlibAX::RenderPageToVariant(int DPI, int Page, int Options) {
	RunFunction(L"RenderPageToVariant", DPI, Page, Options);
	return GetByteArray();
}

int PDFlibAX::ReplaceFonts() {
	RunFunction(L"ReplaceFonts");
	return result.intVal;
}

int PDFlibAX::ReplaceImage(int OriginalImageID, int NewImageID) {
	RunFunction(L"ReplaceImage", OriginalImageID, NewImageID);
	return result.intVal;
}

int PDFlibAX::ReplaceTag(const std::wstring& Tag, const std::wstring& NewValue)
{
	BSTR bstrTag = SysAllocStringLen(Tag.c_str(), (int)(Tag.length()));
	BSTR bstrNewValue = SysAllocStringLen(NewValue.c_str(),
		(int)(NewValue.length()));
	RunFunction(L"ReplaceTag", bstrTag, bstrNewValue);
	SysFreeString(bstrTag);
	SysFreeString(bstrNewValue);
	return result.intVal;
}

int PDFlibAX::RetrieveCustomDataToFile(const std::wstring& Key,
	const std::wstring& FileName, int Location) {
	BSTR bstrKey = SysAllocStringLen(Key.c_str(), (int)(Key.length()));
	BSTR bStrFileName = SysAllocStringLen(FileName.c_str(),
		(int)(FileName.length()));
	RunFunction(L"RetrieveCustomDataToFile", bstrKey, bStrFileName, Location);
	SysFreeString(bstrKey);
	SysFreeString(bStrFileName);
	return result.intVal;
}

std::wstring PDFlibAX::RetrieveCustomDataToString(const std::wstring& Key,
	int Location) {
	BSTR bstrKey = SysAllocStringLen(Key.c_str(), (int)(Key.length()));
	RunFunction(L"RetrieveCustomDataToString", bstrKey, Location);
	SysFreeString(bstrKey);
	return GetString();
}

std::vector<BYTE>PDFlibAX::RetrieveCustomDataToVariant(const std::wstring& Key,
	int Location) {
	BSTR bstrKey = SysAllocStringLen(Key.c_str(), (int)(Key.length()));
	RunFunction(L"RetrieveCustomDataToVariant", bstrKey, Location);
	SysFreeString(bstrKey);
	return GetByteArray();
}

int PDFlibAX::ReverseImage(int Reset) {
	RunFunction(L"ReverseImage", Reset);
	return result.intVal;
}

int PDFlibAX::RotatePage(int PageRotation) {
	RunFunction(L"RotatePage", PageRotation);
	return result.intVal;
}

int PDFlibAX::SaveFontToFile(const std::wstring& FileName) {
	BSTR bStrFileName = SysAllocStringLen(FileName.c_str(),
		(int)(FileName.length()));
	RunFunction(L"SaveFontToFile", bStrFileName);
	SysFreeString(bStrFileName);
	return result.intVal;
}

int PDFlibAX::SaveImageToFile(const std::wstring& FileName) {
	BSTR bStrFileName = SysAllocStringLen(FileName.c_str(),
		(int)(FileName.length()));
	RunFunction(L"SaveImageToFile", bStrFileName);
	SysFreeString(bStrFileName);
	return result.intVal;
}

int PDFlibAX::SaveState() {
	RunFunction(L"SaveState");
	return result.intVal;
}

int PDFlibAX::SaveStyle(const std::wstring& StyleName) {
	BSTR bstrStyleName = SysAllocStringLen(StyleName.c_str(),
		(int)(StyleName.length()));
	RunFunction(L"SaveStyle", bstrStyleName);
	SysFreeString(bstrStyleName);
	return result.intVal;
}

int PDFlibAX::SaveToFile(const std::wstring& FileName) {
	BSTR bStrFileName = SysAllocStringLen(FileName.c_str(),
		(int)(FileName.length()));
	RunFunction(L"SaveToFile", bStrFileName);
	SysFreeString(bStrFileName);
	return result.intVal;
}

std::vector<BYTE>PDFlibAX::SaveToVariant() {
	RunFunction(L"SaveToVariant");
	return GetByteArray();
}

int PDFlibAX::SecurityInfo(int SecurityItem) {
	RunFunction(L"SecurityInfo", SecurityItem);
	return result.intVal;
}

int PDFlibAX::SelectDocument(int DocumentID) {
	RunFunction(L"SelectDocument", DocumentID);
	return result.intVal;
}

int PDFlibAX::SelectFont(int FontID) {
	RunFunction(L"SelectFont", FontID);
	return result.intVal;
}

int PDFlibAX::SelectImage(int ImageID) {
	RunFunction(L"SelectImage", ImageID);
	return result.intVal;
}

int PDFlibAX::SelectLayer(int NewLayer) {
	RunFunction(L"SelectLayer", NewLayer);
	return result.intVal;
}

int PDFlibAX::SelectPage(int PageNumber) {
	RunFunction(L"SelectPage", PageNumber);
	return result.intVal;
}

int PDFlibAX::SelectedDocument() {
	RunFunction(L"SelectedDocument");
	return result.intVal;
}

int PDFlibAX::SelectedFont() {
	RunFunction(L"SelectedFont");
	return result.intVal;
}

int PDFlibAX::SelectedImage() {
	RunFunction(L"SelectedImage");
	return result.intVal;
}

int PDFlibAX::SelectedPage() {
	RunFunction(L"SelectedPage");
	return result.intVal;
}

int PDFlibAX::SetAdvancePassword(const std::wstring& Password) {
	BSTR bstrPassword = SysAllocStringLen(Password.c_str(),
		(int)(Password.length()));
	RunFunction(L"SetAdvancePassword", bstrPassword);
	SysFreeString(bstrPassword);
	return result.intVal;
}

int PDFlibAX::SetAnnotContents(int Index, const std::wstring& NewContents) {
	BSTR bstrNewContents = SysAllocStringLen(NewContents.c_str(),
		(int)(NewContents.length()));
	RunFunction(L"SetAnnotContents", Index, bstrNewContents);
	SysFreeString(bstrNewContents);
	return result.intVal;
}

int PDFlibAX::SetAnnotStrProperty(int Index, int Tag,
	const std::wstring& NewValue) {
	BSTR bstrNewValue = SysAllocStringLen(NewValue.c_str(),
		(int)(NewValue.length()));
	RunFunction(L"SetAnnotStrProperty", Index, Tag, bstrNewValue);
	SysFreeString(bstrNewValue);
	return result.intVal;
}

int PDFlibAX::SetBaseURL(const std::wstring& NewBaseURL) {
	BSTR bstrNewBaseURL = SysAllocStringLen(NewBaseURL.c_str(),
		(int)(NewBaseURL.length()));
	RunFunction(L"SetBaseURL", bstrNewBaseURL);
	SysFreeString(bstrNewBaseURL);
	return result.intVal;
}

int PDFlibAX::SetBlendMode(int BlendMode) {
	RunFunction(L"SetBlendMode", BlendMode);
	return result.intVal;
}

int PDFlibAX::SetBreakString(const std::wstring& NewBreakString) {
	BSTR bstrNewBreakString = SysAllocStringLen(NewBreakString.c_str(),
		(int)(NewBreakString.length()));
	RunFunction(L"SetBreakString", bstrNewBreakString);
	SysFreeString(bstrNewBreakString);
	return result.intVal;
}

int PDFlibAX::SetCapturedPageOptional(int CaptureID, int OptionalContentGroupID)
{
	RunFunction(L"SetCapturedPageOptional", CaptureID, OptionalContentGroupID);
	return result.intVal;
}

int PDFlibAX::SetCatalogInformation(const std::wstring& Key,
	const std::wstring& NewValue) {
	BSTR bstrKey = SysAllocStringLen(Key.c_str(), (int)(Key.length()));
	BSTR bstrNewValue = SysAllocStringLen(NewValue.c_str(),
		(int)(NewValue.length()));
	RunFunction(L"SetCatalogInformation", bstrKey, bstrNewValue);
	SysFreeString(bstrKey);
	SysFreeString(bstrNewValue);
	return result.intVal;
}

int PDFlibAX::SetCharWidth(int CharCode, int NewWidth) {
	RunFunction(L"SetCharWidth", CharCode, NewWidth);
	return result.intVal;
}

int PDFlibAX::SetClippingPath() {
	RunFunction(L"SetClippingPath");
	return result.intVal;
}

int PDFlibAX::SetClippingPathEvenOdd() {
	RunFunction(L"SetClippingPathEvenOdd");
	return result.intVal;
}

int PDFlibAX::SetCropBox(double Left, double Top, double Width, double Height) {
	RunFunction(L"SetCropBox", Left, Top, Width, Height);
	return result.intVal;
}

int PDFlibAX::SetCustomInformation(const std::wstring& Key,
	const std::wstring& NewValue) {
	BSTR bstrKey = SysAllocStringLen(Key.c_str(), (int)(Key.length()));
	BSTR bstrNewValue = SysAllocStringLen(NewValue.c_str(),
		(int)(NewValue.length()));
	RunFunction(L"SetCustomInformation", bstrKey, bstrNewValue);
	SysFreeString(bstrKey);
	SysFreeString(bstrNewValue);
	return result.intVal;
}

int PDFlibAX::SetCustomLineDash(const std::wstring& DashPattern,
	double DashPhase) {
	BSTR bstrDashPattern = SysAllocStringLen(DashPattern.c_str(),
		(int)(DashPattern.length()));
	RunFunction(L"SetCustomLineDash", bstrDashPattern, DashPhase);
	SysFreeString(bstrDashPattern);
	return result.intVal;
}

int PDFlibAX::SePDFiumFileNamee(const std::wstring& FileName) {
	BSTR bStrFileName = SysAllocStringLen(FileName.c_str(),
		(int)(FileName.length()));
	RunFunction(L"SePDFiumFileNamee", bStrFileName);
	SysFreeString(bStrFileName);
	return result.intVal;
}

int PDFlibAX::SetDocumentMetadata(const std::wstring& XMP) {
	BSTR bstrXMP = SysAllocStringLen(XMP.c_str(), (int)(XMP.length()));
	RunFunction(L"SetDocumentMetadata", bstrXMP);
	SysFreeString(bstrXMP);
	return result.intVal;
}

int PDFlibAX::SetFillColor(double Red, double Green, double Blue) {
	RunFunction(L"SetFillColor", Red, Green, Blue);
	return result.intVal;
}

int PDFlibAX::SetFillColorCMYK(double C, double M, double Y, double K) {
	RunFunction(L"SetFillColorCMYK", C, M, Y, K);
	return result.intVal;
}

int PDFlibAX::SetFillColorSep(const std::wstring& ColorName, double Tint) {
	BSTR bstrColorName = SysAllocStringLen(ColorName.c_str(),
		(int)(ColorName.length()));
	RunFunction(L"SetFillColorSep", bstrColorName, Tint);
	SysFreeString(bstrColorName);
	return result.intVal;
}

int PDFlibAX::SetFillShader(const std::wstring& ShaderName) {
	BSTR bstrShaderName = SysAllocStringLen(ShaderName.c_str(),
		(int)(ShaderName.length()));
	RunFunction(L"SetFillShader", bstrShaderName);
	SysFreeString(bstrShaderName);
	return result.intVal;
}

int PDFlibAX::SetFontEncoding(int Encoding) {
	RunFunction(L"SetFontEncoding", Encoding);
	return result.intVal;
}

int PDFlibAX::SetFontFlags(int Fixed, int Serif, int Symbolic, int Script,
	int Italic, int AllCap, int SmallCap, int ForceBold) {
	RunFunction(L"SetFontFlags", Fixed, Serif, Symbolic, Script, Italic, AllCap,
		SmallCap, ForceBold);
	return result.intVal;
}

int PDFlibAX::SetFormFieldAlignment(int Index, int Alignment) {
	RunFunction(L"SetFormFieldAlignment", Index, Alignment);
	return result.intVal;
}

int PDFlibAX::SetFormFieldAnnotFlags(int Index, int NewFlags) {
	RunFunction(L"SetFormFieldAnnotFlags", Index, NewFlags);
	return result.intVal;
}

int PDFlibAX::SetFormFieldBackgroundColor(int Index, double Red, double Green,
	double Blue) {
	RunFunction(L"SetFormFieldBackgroundColor", Index, Red, Green, Blue);
	return result.intVal;
}

int PDFlibAX::SetFormFieldBackgroundColorCMYK(int Index, double C, double M,
	double Y, double K) {
	RunFunction(L"SetFormFieldBackgroundColorCMYK", Index, C, M, Y, K);
	return result.intVal;
}

int PDFlibAX::SetFormFieldBackgroundColorSep(int Index,
	const std::wstring& ColorName, double Tint) {
	BSTR bstrColorName = SysAllocStringLen(ColorName.c_str(),
		(int)(ColorName.length()));
	RunFunction(L"SetFormFieldBackgroundColorSep", Index, bstrColorName, Tint);
	SysFreeString(bstrColorName);
	return result.intVal;
}

int PDFlibAX::SetFormFieldBorderColor(int Index, double Red, double Green,
	double Blue) {
	RunFunction(L"SetFormFieldBorderColor", Index, Red, Green, Blue);
	return result.intVal;
}

int PDFlibAX::SetFormFieldBorderColorCMYK(int Index, double C, double M,
	double Y, double K) {
	RunFunction(L"SetFormFieldBorderColorCMYK", Index, C, M, Y, K);
	return result.intVal;
}

int PDFlibAX::SetFormFieldBorderColorSep(int Index,
	const std::wstring& ColorName, double Tint) {
	BSTR bstrColorName = SysAllocStringLen(ColorName.c_str(),
		(int)(ColorName.length()));
	RunFunction(L"SetFormFieldBorderColorSep", Index, bstrColorName, Tint);
	SysFreeString(bstrColorName);
	return result.intVal;
}

int PDFlibAX::SetFormFieldBorderStyle(int Index, double Width, int Style,
	double DashOn, double DashOff) {
	RunFunction(L"SetFormFieldBorderStyle", Index, Width, Style, DashOn,
		DashOff);
	return result.intVal;
}

int PDFlibAX::SetFormFieldBounds(int Index, double Left, double Top,
	double Width, double Height) {
	RunFunction(L"SetFormFieldBounds", Index, Left, Top, Width, Height);
	return result.intVal;
}

int PDFlibAX::SetFormFieldCalcOrder(int Index, int Order) {
	RunFunction(L"SetFormFieldCalcOrder", Index, Order);
	return result.intVal;
}

int PDFlibAX::SetFormFieldCaption(int Index, const std::wstring& NewCaption) {
	BSTR bstrNewCaption = SysAllocStringLen(NewCaption.c_str(),
		(int)(NewCaption.length()));
	RunFunction(L"SetFormFieldCaption", Index, bstrNewCaption);
	SysFreeString(bstrNewCaption);
	return result.intVal;
}

int PDFlibAX::SetFormFieldCheckStyle(int Index, int CheckStyle, int Position) {
	RunFunction(L"SetFormFieldCheckStyle", Index, CheckStyle, Position);
	return result.intVal;
}

int PDFlibAX::SetFormFieldChildTitle(int Index, const std::wstring& NewTitle) {
	BSTR bstrNewTitle = SysAllocStringLen(NewTitle.c_str(),
		(int)(NewTitle.length()));
	RunFunction(L"SetFormFieldChildTitle", Index, bstrNewTitle);
	SysFreeString(bstrNewTitle);
	return result.intVal;
}

int PDFlibAX::SetFormFieldColor(int Index, double Red, double Green,
	double Blue) {
	RunFunction(L"SetFormFieldColor", Index, Red, Green, Blue);
	return result.intVal;
}

int PDFlibAX::SetFormFieldColorCMYK(int Index, double C, double M, double Y,
	double K) {
	RunFunction(L"SetFormFieldColorCMYK", Index, C, M, Y, K);
	return result.intVal;
}

int PDFlibAX::SetFormFieldColorSep(int Index, const std::wstring& ColorName,
	double Tint) {
	BSTR bstrColorName = SysAllocStringLen(ColorName.c_str(),
		(int)(ColorName.length()));
	RunFunction(L"SetFormFieldColorSep", Index, bstrColorName, Tint);
	SysFreeString(bstrColorName);
	return result.intVal;
}

int PDFlibAX::SetFormFieldComb(int Index, int Comb) {
	RunFunction(L"SetFormFieldComb", Index, Comb);
	return result.intVal;
}

int PDFlibAX::SetFormFieldDefaultValue(int Index,
	const std::wstring& NewDefaultValue) {
	BSTR bstrNewDefaultValue = SysAllocStringLen(NewDefaultValue.c_str(),
		(int)(NewDefaultValue.length()));
	RunFunction(L"SetFormFieldDefaultValue", Index, bstrNewDefaultValue);
	SysFreeString(bstrNewDefaultValue);
	return result.intVal;
}

int PDFlibAX::SetFormFieldDescription(int Index, const std::wstring& NewValue) {
	BSTR bstrNewValue = SysAllocStringLen(NewValue.c_str(),
		(int)(NewValue.length()));
	RunFunction(L"SetFormFieldDescription", Index, bstrNewValue);
	SysFreeString(bstrNewValue);
	return result.intVal;
}

int PDFlibAX::SetFormFieldFlags(int Index, int NewFlags) {
	RunFunction(L"SetFormFieldFlags", Index, NewFlags);
	return result.intVal;
}

int PDFlibAX::SetFormFieldFont(int Index, int FontIndex) {
	RunFunction(L"SetFormFieldFont", Index, FontIndex);
	return result.intVal;
}

int PDFlibAX::SetFormFieldHighlightMode(int Index, int NewMode) {
	RunFunction(L"SetFormFieldHighlightMode", Index, NewMode);
	return result.intVal;
}

int PDFlibAX::SetFormFieldIcon(int Index, int IconType, int CaptureID) {
	RunFunction(L"SetFormFieldIcon", Index, IconType, CaptureID);
	return result.intVal;
}

int PDFlibAX::SetFormFieldIconStyle(int Index, int Placement, int Scale,
	int ScaleType, int HorizontalShift, int VerticalShift) {
	RunFunction(L"SetFormFieldIconStyle", Index, Placement, Scale, ScaleType,
		HorizontalShift, VerticalShift);
	return result.intVal;
}

int PDFlibAX::SetFormFieldMaxLen(int Index, int NewMaxLen) {
	RunFunction(L"SetFormFieldMaxLen", Index, NewMaxLen);
	return result.intVal;
}

int PDFlibAX::SetFormFieldOptional(int Index, int OptionalContentGroupID) {
	RunFunction(L"SetFormFieldOptional", Index, OptionalContentGroupID);
	return result.intVal;
}

int PDFlibAX::SetFormFieldPage(int Index, int NewPage) {
	RunFunction(L"SetFormFieldPage", Index, NewPage);
	return result.intVal;
}

int PDFlibAX::SetFormFieldPrintable(int Index, int Printable) {
	RunFunction(L"SetFormFieldPrintable", Index, Printable);
	return result.intVal;
}

int PDFlibAX::SetFormFieldReadOnly(int Index, int ReadOnly) {
	RunFunction(L"SetFormFieldReadOnly", Index, ReadOnly);
	return result.intVal;
}

int PDFlibAX::SetFormFieldRotation(int Index, int Angle) {
	RunFunction(L"SetFormFieldRotation", Index, Angle);
	return result.intVal;
}

int PDFlibAX::SetFormFieldStandardFont(int Index, int StandardFontID) {
	RunFunction(L"SetFormFieldStandardFont", Index, StandardFontID);
	return result.intVal;
}

int PDFlibAX::SetFormFieldTabOrder(int Index, int Order) {
	RunFunction(L"SetFormFieldTabOrder", Index, Order);
	return result.intVal;
}

int PDFlibAX::SetFormFieldTextFlags(int Index, int Multiline, int Password,
	int FileSelect, int DoNotSpellCheck, int DoNotScroll) {
	RunFunction(L"SetFormFieldTextFlags", Index, Multiline, Password,
		FileSelect, DoNotSpellCheck, DoNotScroll);
	return result.intVal;
}

int PDFlibAX::SetFormFieldTextSize(int Index, double NewTextSize) {
	RunFunction(L"SetFormFieldTextSize", Index, NewTextSize);
	return result.intVal;
}

int PDFlibAX::SetFormFieldValue(int Index, const std::wstring& NewValue) {
	BSTR bstrNewValue = SysAllocStringLen(NewValue.c_str(),
		(int)(NewValue.length()));
	RunFunction(L"SetFormFieldValue", Index, bstrNewValue);
	SysFreeString(bstrNewValue);
	return result.intVal;
}

int PDFlibAX::SetFormFieldValueByTitle(const std::wstring& Title,
	const std::wstring& NewValue) {
	BSTR bstrTitle = SysAllocStringLen(Title.c_str(), (int)(Title.length()));
	BSTR bstrNewValue = SysAllocStringLen(NewValue.c_str(),
		(int)(NewValue.length()));
	RunFunction(L"SetFormFieldValueByTitle", bstrTitle, bstrNewValue);
	SysFreeString(bstrTitle);
	SysFreeString(bstrNewValue);
	return result.intVal;
}

int PDFlibAX::SetFormFieldVisible(int Index, int Visible) {
	RunFunction(L"SetFormFieldVisible", Index, Visible);
	return result.intVal;
}

int PDFlibAX::SetGDIPlusFileName(const std::wstring& DLLFileName) {
	BSTR bstrDLLFileName = SysAllocStringLen(DLLFileName.c_str(),
		(int)(DLLFileName.length()));
	RunFunction(L"SetGDIPlusFileName", bstrDLLFileName);
	SysFreeString(bstrDLLFileName);
	return result.intVal;
}

int PDFlibAX::SetGDIPlusOptions(int OptionID, int NewValue) {
	RunFunction(L"SetGDIPlusOptions", OptionID, NewValue);
	return result.intVal;
}

int PDFlibAX::SetHTMLBoldFont(const std::wstring& FontSet, int FontID) {
	BSTR bstrFontSet = SysAllocStringLen(FontSet.c_str(),
		(int)(FontSet.length()));
	RunFunction(L"SetHTMLBoldFont", bstrFontSet, FontID);
	SysFreeString(bstrFontSet);
	return result.intVal;
}

int PDFlibAX::SetHTMLBoldItalicFont(const std::wstring& FontSet, int FontID) {
	BSTR bstrFontSet = SysAllocStringLen(FontSet.c_str(),
		(int)(FontSet.length()));
	RunFunction(L"SetHTMLBoldItalicFont", bstrFontSet, FontID);
	SysFreeString(bstrFontSet);
	return result.intVal;
}

int PDFlibAX::SetHTMLItalicFont(const std::wstring& FontSet, int FontID) {
	BSTR bstrFontSet = SysAllocStringLen(FontSet.c_str(),
		(int)(FontSet.length()));
	RunFunction(L"SetHTMLItalicFont", bstrFontSet, FontID);
	SysFreeString(bstrFontSet);
	return result.intVal;
}

int PDFlibAX::SetHTMLNormalFont(const std::wstring& FontSet, int FontID) {
	BSTR bstrFontSet = SysAllocStringLen(FontSet.c_str(),
		(int)(FontSet.length()));
	RunFunction(L"SetHTMLNormalFont", bstrFontSet, FontID);
	SysFreeString(bstrFontSet);
	return result.intVal;
}

int PDFlibAX::SetImageAsMask(int MaskType) {
	RunFunction(L"SetImageAsMask", MaskType);
	return result.intVal;
}

int PDFlibAX::SetImageMask(double FromRed, double FromGreen, double FromBlue,
	double ToRed, double ToGreen, double ToBlue) {
	RunFunction(L"SetImageMask", FromRed, FromGreen, FromBlue, ToRed, ToGreen,
		ToBlue);
	return result.intVal;
}

int PDFlibAX::SetImageMaskCMYK(double FromC, double FromM, double FromY,
	double FromK, double ToC, double ToM, double ToY, double ToK) {
	RunFunction(L"SetImageMaskCMYK", FromC, FromM, FromY, FromK, ToC, ToM,
		ToY, ToK);
	return result.intVal;
}

int PDFlibAX::SetImageMaskFromImage(int ImageID) {
	RunFunction(L"SetImageMaskFromImage", ImageID);
	return result.intVal;
}

int PDFlibAX::SetImageOptional(int OptionalContentGroupID) {
	RunFunction(L"SetImageOptional", OptionalContentGroupID);
	return result.intVal;
}

int PDFlibAX::SetInformation(int Key, const std::wstring& NewValue) {
	BSTR bstrNewValue = SysAllocStringLen(NewValue.c_str(),
		(int)(NewValue.length()));
	RunFunction(L"SetInformation", Key, bstrNewValue);
	SysFreeString(bstrNewValue);
	return result.intVal;
}

int PDFlibAX::SetJPEGQuality(int Quality) {
	RunFunction(L"SetJPEGQuality", Quality);
	return result.intVal;
}

int PDFlibAX::SetJavaScriptMode(int JSMode) {
	RunFunction(L"SetJavaScriptMode", JSMode);
	return result.intVal;
}

int PDFlibAX::SetKerning(const std::wstring& CharPair, int Adjustment) {
	BSTR bstrCharPair = SysAllocStringLen(CharPair.c_str(),
		(int)(CharPair.length()));
	RunFunction(L"SetKerning", bstrCharPair, Adjustment);
	SysFreeString(bstrCharPair);
	return result.intVal;
}

int PDFlibAX::SetLayerOptional(int OptionalContentGroupID) {
	RunFunction(L"SetLayerOptional", OptionalContentGroupID);
	return result.intVal;
}

int PDFlibAX::SetLineCap(int LineCap) {
	RunFunction(L"SetLineCap", LineCap);
	return result.intVal;
}

int PDFlibAX::SetLineColor(double Red, double Green, double Blue) {
	RunFunction(L"SetLineColor", Red, Green, Blue);
	return result.intVal;
}

int PDFlibAX::SetLineColorCMYK(double C, double M, double Y, double K) {
	RunFunction(L"SetLineColorCMYK", C, M, Y, K);
	return result.intVal;
}

int PDFlibAX::SetLineColorSep(const std::wstring& ColorName, double Tint) {
	BSTR bstrColorName = SysAllocStringLen(ColorName.c_str(),
		(int)(ColorName.length()));
	RunFunction(L"SetLineColorSep", bstrColorName, Tint);
	SysFreeString(bstrColorName);
	return result.intVal;
}

int PDFlibAX::SetLineDash(double DashOn, double DashOff) {
	RunFunction(L"SetLineDash", DashOn, DashOff);
	return result.intVal;
}

int PDFlibAX::SetLineJoin(int LineJoin) {
	RunFunction(L"SetLineJoin", LineJoin);
	return result.intVal;
}

int PDFlibAX::SetLineShader(const std::wstring& ShaderName) {
	BSTR bstrShaderName = SysAllocStringLen(ShaderName.c_str(),
		(int)(ShaderName.length()));
	RunFunction(L"SetLineShader", bstrShaderName);
	SysFreeString(bstrShaderName);
	return result.intVal;
}

int PDFlibAX::SetLineWidth(double LineWidth) {
	RunFunction(L"SetLineWidth", LineWidth);
	return result.intVal;
}

int PDFlibAX::SetMeasurementUnits(int MeasurementUnits) {
	RunFunction(L"SetMeasurementUnits", MeasurementUnits);
	return result.intVal;
}

int PDFlibAX::SetNeedAppearances(int NewValue) {
	RunFunction(L"SetNeedAppearances", NewValue);
	return result.intVal;
}

int PDFlibAX::SetOpenActionDestination(int OpenPage, int Zoom) {
	RunFunction(L"SetOpenActionDestination", OpenPage, Zoom);
	return result.intVal;
}

int PDFlibAX::SetOpenActionDestinationFull(int OpenPage, int Zoom, int DestType,
	double Left, double Top, double Right, double Bottom) {
	RunFunction(L"SetOpenActionDestinationFull", OpenPage, Zoom, DestType, Left,
		Top, Right, Bottom);
	return result.intVal;
}

int PDFlibAX::SetOpenActionJavaScript(const std::wstring& JavaScript) {
	BSTR bstrJavaScript = SysAllocStringLen(JavaScript.c_str(),
		(int)(JavaScript.length()));
	RunFunction(L"SetOpenActionJavaScript", bstrJavaScript);
	SysFreeString(bstrJavaScript);
	return result.intVal;
}

int PDFlibAX::SetOpenActionMenu(const std::wstring& MenuItem) {
	BSTR bstrMenuItem = SysAllocStringLen(MenuItem.c_str(),
		(int)(MenuItem.length()));
	RunFunction(L"SetOpenActionMenu", bstrMenuItem);
	SysFreeString(bstrMenuItem);
	return result.intVal;
}

int PDFlibAX::SetOptionalContentGroupPrintable(int OptionalContentGroupID,
	int Printable) {
	RunFunction(L"SetOptionalContentGroupPrintable", OptionalContentGroupID,
		Printable);
	return result.intVal;
}

int PDFlibAX::SetOptionalContentGroupVisible(int OptionalContentGroupID,
	int Visible) {
	RunFunction(L"SetOptionalContentGroupVisible", OptionalContentGroupID,
		Visible);
	return result.intVal;
}

int PDFlibAX::SetOrigin(int Origin) {
	RunFunction(L"SetOrigin", Origin);
	return result.intVal;
}

int PDFlibAX::SetOutlineColor(int OutlineID, double Red, double Green,
	double Blue) {
	RunFunction(L"SetOutlineColor", OutlineID, Red, Green, Blue);
	return result.intVal;
}

int PDFlibAX::SetOutlineDestination(int OutlineID, int DestPage,
	double DestPosition) {
	RunFunction(L"SetOutlineDestination", OutlineID, DestPage, DestPosition);
	return result.intVal;
}

int PDFlibAX::SetOutlineDestinationFull(int OutlineID, int DestPage, int Zoom,
	int DestType, double Left, double Top, double Right, double Bottom) {
	RunFunction(L"SetOutlineDestinationFull", OutlineID, DestPage, Zoom,
		DestType, Left, Top, Right, Bottom);
	return result.intVal;
}

int PDFlibAX::SetOutlineDestinationZoom(int OutlineID, int DestPage,
	double DestPosition, int Zoom) {
	RunFunction(L"SetOutlineDestinationZoom", OutlineID, DestPage,
		DestPosition, Zoom);
	return result.intVal;
}

int PDFlibAX::SetOutlineJavaScript(int OutlineID,
	const std::wstring& JavaScript) {
	BSTR bstrJavaScript = SysAllocStringLen(JavaScript.c_str(),
		(int)(JavaScript.length()));
	RunFunction(L"SetOutlineJavaScript", OutlineID, bstrJavaScript);
	SysFreeString(bstrJavaScript);
	return result.intVal;
}

int PDFlibAX::SetOutlineOpenFile(int OutlineID, const std::wstring& FileName) {
	BSTR bStrFileName = SysAllocStringLen(FileName.c_str(),
		(int)(FileName.length()));
	RunFunction(L"SetOutlineOpenFile", OutlineID, bStrFileName);
	SysFreeString(bStrFileName);
	return result.intVal;
}

int PDFlibAX::SetOutlineStyle(int OutlineID, int SetItalic, int SetBold) {
	RunFunction(L"SetOutlineStyle", OutlineID, SetItalic, SetBold);
	return result.intVal;
}

int PDFlibAX::SetOutlineTitle(int OutlineID, const std::wstring& NewTitle) {
	BSTR bstrNewTitle = SysAllocStringLen(NewTitle.c_str(),
		(int)(NewTitle.length()));
	RunFunction(L"SetOutlineTitle", OutlineID, bstrNewTitle);
	SysFreeString(bstrNewTitle);
	return result.intVal;
}

int PDFlibAX::SetOutlineWebLink(int OutlineID, const std::wstring& Link) {
	BSTR bstrLink = SysAllocStringLen(Link.c_str(), (int)(Link.length()));
	RunFunction(L"SetOutlineWebLink", OutlineID, bstrLink);
	SysFreeString(bstrLink);
	return result.intVal;
}

int PDFlibAX::SetPNGTransparencyColor(int RedByte, int GreenByte, int BlueByte)
{
	RunFunction(L"SetPNGTransparencyColor", RedByte, GreenByte, BlueByte);
	return result.intVal;
}

int PDFlibAX::SetPageActionMenu(const std::wstring& MenuItem) {
	BSTR bstrMenuItem = SysAllocStringLen(MenuItem.c_str(),
		(int)(MenuItem.length()));
	RunFunction(L"SetPageActionMenu", bstrMenuItem);
	SysFreeString(bstrMenuItem);
	return result.intVal;
}

int PDFlibAX::SetPageContent(const std::wstring& NewContent) {
	BSTR bstrNewContent = SysAllocStringLen(NewContent.c_str(),
		(int)(NewContent.length()));
	RunFunction(L"SetPageContent", bstrNewContent);
	SysFreeString(bstrNewContent);
	return result.intVal;
}

int PDFlibAX::SetPageDimensions(double NewPageWidth, double NewPageHeight) {
	RunFunction(L"SetPageDimensions", NewPageWidth, NewPageHeight);
	return result.intVal;
}

int PDFlibAX::SetPageLayout(int NewPageLayout) {
	RunFunction(L"SetPageLayout", NewPageLayout);
	return result.intVal;
}

int PDFlibAX::SetPageMode(int NewPageMode) {
	RunFunction(L"SetPageMode", NewPageMode);
	return result.intVal;
}

int PDFlibAX::SetPageSize(const std::wstring& PaperName) {
	BSTR bstrPaperName = SysAllocStringLen(PaperName.c_str(),
		(int)(PaperName.length()));
	RunFunction(L"SetPageSize", bstrPaperName);
	SysFreeString(bstrPaperName);
	return result.intVal;
}

int PDFlibAX::SetPageThumbnail() {
	RunFunction(L"SetPageThumbnail");
	return result.intVal;
}

int PDFlibAX::SetPageTransparencyGroup(int CS, int Isolate, int Knockout) {
	RunFunction(L"SetPageTransparencyGroup", CS, Isolate, Knockout);
	return result.intVal;
}

int PDFlibAX::SetPassword(const std::wstring& Password) {
	BSTR bstrPassword = SysAllocStringLen(Password.c_str(),
		(int)(Password.length()));
	RunFunction(L"SetPassword", bstrPassword);
	SysFreeString(bstrPassword);
	return result.intVal;
}

int PDFlibAX::SetPrecision(int NewPrecision) {
	RunFunction(L"SetPrecision", NewPrecision);
	return result.intVal;
}

int PDFlibAX::SetScale(double NewScale) {
	RunFunction(L"SetScale", NewScale);
	return result.intVal;
}

int PDFlibAX::SetTableBorderColor(int TableID, int BorderIndex, double Red,
	double Green, double Blue) {
	RunFunction(L"SetTableBorderColor", TableID, BorderIndex, Red, Green, Blue);
	return result.intVal;
}

int PDFlibAX::SetTableBorderColorCMYK(int TableID, int BorderIndex, double C,
	double M, double Y, double K) {
	RunFunction(L"SetTableBorderColorCMYK", TableID, BorderIndex, C, M, Y, K);
	return result.intVal;
}

int PDFlibAX::SetTableBorderWidth(int TableID, int BorderIndex, double NewWidth)
{
	RunFunction(L"SetTableBorderWidth", TableID, BorderIndex, NewWidth);
	return result.intVal;
}

int PDFlibAX::SetTableCellAlignment(int TableID, int FirstRow, int FirstColumn,
	int LastRow, int LastColumn, int NewCellAlignment) {
	RunFunction(L"SetTableCellAlignment", TableID, FirstRow, FirstColumn,
		LastRow, LastColumn, NewCellAlignment);
	return result.intVal;
}

int PDFlibAX::SetTableCellBackgroundColor(int TableID, int FirstRow,
	int FirstColumn, int LastRow, int LastColumn, double Red, double Green,
	double Blue) {
	RunFunction(L"SetTableCellBackgroundColor", TableID, FirstRow, FirstColumn,
		LastRow, LastColumn, Red, Green, Blue);
	return result.intVal;
}

int PDFlibAX::SetTableCellBackgroundColorCMYK(int TableID, int FirstRow,
	int FirstColumn, int LastRow, int LastColumn, double C, double M, double Y,
	double K) {
	RunFunction(L"SetTableCellBackgroundColorCMYK", TableID, FirstRow,
		FirstColumn, LastRow, LastColumn, C, M, Y, K);
	return result.intVal;
}

int PDFlibAX::SetTableCellBorderColor(int TableID, int FirstRow,
	int FirstColumn, int LastRow, int LastColumn, int BorderIndex, double Red,
	double Green, double Blue) {
	RunFunction(L"SetTableCellBorderColor", TableID, FirstRow, FirstColumn,
		LastRow, LastColumn, BorderIndex, Red, Green, Blue);
	return result.intVal;
}

int PDFlibAX::SetTableCellBorderColorCMYK(int TableID, int FirstRow,
	int FirstColumn, int LastRow, int LastColumn, int BorderIndex, double C,
	double M, double Y, double K) {
	RunFunction(L"SetTableCellBorderColorCMYK", TableID, FirstRow, FirstColumn,
		LastRow, LastColumn, BorderIndex, C, M, Y, K);
	return result.intVal;
}

int PDFlibAX::SetTableCellBorderWidth(int TableID, int FirstRow,
	int FirstColumn, int LastRow, int LastColumn, int BorderIndex,
	double NewWidth) {
	RunFunction(L"SetTableCellBorderWidth", TableID, FirstRow, FirstColumn,
		LastRow, LastColumn, BorderIndex, NewWidth);
	return result.intVal;
}

int PDFlibAX::SetTableCellContent(int TableID, int RowNumber, int ColumnNumber,
	const std::wstring& HTMLText) {
	BSTR bstrHTMLText = SysAllocStringLen(HTMLText.c_str(),
		(int)(HTMLText.length()));
	RunFunction(L"SetTableCellContent", TableID, RowNumber, ColumnNumber,
		bstrHTMLText);
	SysFreeString(bstrHTMLText);
	return result.intVal;
}

int PDFlibAX::SetTableCellPadding(int TableID, int FirstRow, int FirstColumn,
	int LastRow, int LastColumn, int BorderIndex, double NewPadding) {
	RunFunction(L"SetTableCellPadding", TableID, FirstRow, FirstColumn, LastRow,
		LastColumn, BorderIndex, NewPadding);
	return result.intVal;
}

int PDFlibAX::SetTableCellTextColor(int TableID, int FirstRow, int FirstColumn,
	int LastRow, int LastColumn, double Red, double Green, double Blue) {
	RunFunction(L"SetTableCellTextColor", TableID, FirstRow, FirstColumn,
		LastRow, LastColumn, Red, Green, Blue);
	return result.intVal;
}

int PDFlibAX::SetTableCellTextColorCMYK(int TableID, int FirstRow,
	int FirstColumn, int LastRow, int LastColumn, double C, double M, double Y,
	double K) {
	RunFunction(L"SetTableCellTextColorCMYK", TableID, FirstRow, FirstColumn,
		LastRow, LastColumn, C, M, Y, K);
	return result.intVal;
}

int PDFlibAX::SetTableCellTextSize(int TableID, int FirstRow, int FirstColumn,
	int LastRow, int LastColumn, double NewTextSize) {
	RunFunction(L"SetTableCellTextSize", TableID, FirstRow, FirstColumn,
		LastRow, LastColumn, NewTextSize);
	return result.intVal;
}

int PDFlibAX::SetTableColumnWidth(int TableID, int FirstColumn, int LastColumn,
	double NewWidth) {
	RunFunction(L"SetTableColumnWidth", TableID, FirstColumn, LastColumn,
		NewWidth);
	return result.intVal;
}

int PDFlibAX::SetTableRowHeight(int TableID, int FirstRow, int LastRow,
	double NewHeight) {
	RunFunction(L"SetTableRowHeight", TableID, FirstRow, LastRow, NewHeight);
	return result.intVal;
}

int PDFlibAX::SetTempFile(const std::wstring& FileName) {
	BSTR bStrFileName = SysAllocStringLen(FileName.c_str(),
		(int)(FileName.length()));
	RunFunction(L"SetTempFile", bStrFileName);
	SysFreeString(bStrFileName);
	return result.intVal;
}

int PDFlibAX::SetTempPath(const std::wstring& NewPath) {
	BSTR bstrNewPath = SysAllocStringLen(NewPath.c_str(),
		(int)(NewPath.length()));
	RunFunction(L"SetTempPath", bstrNewPath);
	SysFreeString(bstrNewPath);
	return result.intVal;
}

int PDFlibAX::SetTextAlign(int TextAlign) {
	RunFunction(L"SetTextAlign", TextAlign);
	return result.intVal;
}

int PDFlibAX::SetTextCharSpacing(double CharSpacing) {
	RunFunction(L"SetTextCharSpacing", CharSpacing);
	return result.intVal;
}

int PDFlibAX::SetTextColor(double Red, double Green, double Blue) {
	RunFunction(L"SetTextColor", Red, Green, Blue);
	return result.intVal;
}

int PDFlibAX::SetTextColorCMYK(double C, double M, double Y, double K) {
	RunFunction(L"SetTextColorCMYK", C, M, Y, K);
	return result.intVal;
}

int PDFlibAX::SetTextColorSep(const std::wstring& ColorName, double Tint) {
	BSTR bstrColorName = SysAllocStringLen(ColorName.c_str(),
		(int)(ColorName.length()));
	RunFunction(L"SetTextColorSep", bstrColorName, Tint);
	SysFreeString(bstrColorName);
	return result.intVal;
}

int PDFlibAX::SetTextHighlight(int Highlight) {
	RunFunction(L"SetTextHighlight", Highlight);
	return result.intVal;
}

int PDFlibAX::SetTextHighlightColor(double Red, double Green, double Blue) {
	RunFunction(L"SetTextHighlightColor", Red, Green, Blue);
	return result.intVal;
}

int PDFlibAX::SetTextHighlightColorCMYK(double C, double M, double Y, double K)
{
	RunFunction(L"SetTextHighlightColorCMYK", C, M, Y, K);
	return result.intVal;
}

int PDFlibAX::SetTextHighlightColorSep(const std::wstring& ColorName,
	double Tint) {
	BSTR bstrColorName = SysAllocStringLen(ColorName.c_str(),
		(int)(ColorName.length()));
	RunFunction(L"SetTextHighlightColorSep", bstrColorName, Tint);
	SysFreeString(bstrColorName);
	return result.intVal;
}

int PDFlibAX::SetTextMode(int TextMode) {
	RunFunction(L"SetTextMode", TextMode);
	return result.intVal;
}

int PDFlibAX::SetTextRise(double Rise) {
	RunFunction(L"SetTextRise", Rise);
	return result.intVal;
}

int PDFlibAX::SetTextScaling(double ScalePercentage) {
	RunFunction(L"SetTextScaling", ScalePercentage);
	return result.intVal;
}

int PDFlibAX::SetTextShader(const std::wstring& ShaderName) {
	BSTR bstrShaderName = SysAllocStringLen(ShaderName.c_str(),
		(int)(ShaderName.length()));
	RunFunction(L"SetTextShader", bstrShaderName);
	SysFreeString(bstrShaderName);
	return result.intVal;
}

int PDFlibAX::SetTextSize(double TextSize) {
	RunFunction(L"SetTextSize", TextSize);
	return result.intVal;
}

int PDFlibAX::SetTextSpacing(double Spacing) {
	RunFunction(L"SetTextSpacing", Spacing);
	return result.intVal;
}

int PDFlibAX::SetTextUnderline(int Underline) {
	RunFunction(L"SetTextUnderline", Underline);
	return result.intVal;
}

int PDFlibAX::SetTextUnderlineColor(double Red, double Green, double Blue) {
	RunFunction(L"SetTextUnderlineColor", Red, Green, Blue);
	return result.intVal;
}

int PDFlibAX::SetTextUnderlineColorCMYK(double C, double M, double Y, double K)
{
	RunFunction(L"SetTextUnderlineColorCMYK", C, M, Y, K);
	return result.intVal;
}

int PDFlibAX::SetTextUnderlineColorSep(const std::wstring& ColorName,
	double Tint) {
	BSTR bstrColorName = SysAllocStringLen(ColorName.c_str(),
		(int)(ColorName.length()));
	RunFunction(L"SetTextUnderlineColorSep", bstrColorName, Tint);
	SysFreeString(bstrColorName);
	return result.intVal;
}

int PDFlibAX::SetTextUnderlineDash(double DashOn, double DashOff) {
	RunFunction(L"SetTextUnderlineDash", DashOn, DashOff);
	return result.intVal;
}

int PDFlibAX::SetTextWordSpacing(double WordSpacing) {
	RunFunction(L"SetTextWordSpacing", WordSpacing);
	return result.intVal;
}

int PDFlibAX::SetTransparency(int Transparency) {
	RunFunction(L"SetTransparency", Transparency);
	return result.intVal;
}

int PDFlibAX::SetViewerPreferences(int Option, int NewValue) {
	RunFunction(L"SetViewerPreferences", Option, NewValue);
	return result.intVal;
}

int PDFlibAX::SetXFAFormFieldAccess(const std::wstring& XFAFieldName,
	int NewAccess) {
	BSTR bstrXFAFieldName = SysAllocStringLen(XFAFieldName.c_str(),
		(int)(XFAFieldName.length()));
	RunFunction(L"SetXFAFormFieldAccess", bstrXFAFieldName, NewAccess);
	SysFreeString(bstrXFAFieldName);
	return result.intVal;
}

int PDFlibAX::SetXFAFormFieldBorderColor(const std::wstring& XFAFieldName,
	double Red, double Green, double Blue) {
	BSTR bstrXFAFieldName = SysAllocStringLen(XFAFieldName.c_str(),
		(int)(XFAFieldName.length()));
	RunFunction(L"SetXFAFormFieldBorderColor", bstrXFAFieldName, Red,
		Green, Blue);
	SysFreeString(bstrXFAFieldName);
	return result.intVal;
}

int PDFlibAX::SetXFAFormFieldBorderPresence(const std::wstring& XFAFieldName,
	int NewPresence) {
	BSTR bstrXFAFieldName = SysAllocStringLen(XFAFieldName.c_str(),
		(int)(XFAFieldName.length()));
	RunFunction(L"SetXFAFormFieldBorderPresence", bstrXFAFieldName,
		NewPresence);
	SysFreeString(bstrXFAFieldName);
	return result.intVal;
}

int PDFlibAX::SetXFAFormFieldBorderWidth(const std::wstring& XFAFieldName,
	double BorderWidth) {
	BSTR bstrXFAFieldName = SysAllocStringLen(XFAFieldName.c_str(),
		(int)(XFAFieldName.length()));
	RunFunction(L"SetXFAFormFieldBorderWidth", bstrXFAFieldName, BorderWidth);
	SysFreeString(bstrXFAFieldName);
	return result.intVal;
}

int PDFlibAX::SetXFAFormFieldValue(const std::wstring& XFAFieldName,
	const std::wstring& NewValue) {
	BSTR bstrXFAFieldName = SysAllocStringLen(XFAFieldName.c_str(),
		(int)(XFAFieldName.length()));
	BSTR bstrNewValue = SysAllocStringLen(NewValue.c_str(),
		(int)(NewValue.length()));
	RunFunction(L"SetXFAFormFieldValue", bstrXFAFieldName, bstrNewValue);
	SysFreeString(bstrXFAFieldName);
	SysFreeString(bstrNewValue);
	return result.intVal;
}

int PDFlibAX : SetupPrinterr(const std::wstring& CustomPrinterName, int Setting,
	int NewValue) {
	BSTR bstrCustomPrinterName = SysAllocStringLen(CustomPrinterName.c_str(),
		(int)(CustomPrinterName.length()));
	RunFunction(LSetupPrinterr ", bstrCustomPrinterName, Setting, 
	NewValue);
	SysFreeString(bstrCustomPrinterName);
	return result.intVal;
}

int PDFlibAX::SignFile(const std::wstring& InputFileName, const std::wstring& OpenPassword, const std::wstring& SignatureFieldName, const std::wstring& OutputFileName, const std::wstring& PFXFileName, const std::wstring& PFXPassword, const std::wstring& Reason, const std::wstring& Location, const std::wstring& ContactInfo)
{
	BSTR bstrInputFileName = SysAllocStringLen(InputFileName.c_str(), (int)(InputFileName.length()));
	BSTR bstrOpenPassword = SysAllocStringLen(OpenPassword.c_str(), (int)(OpenPassword.length()));
	BSTR bstrSignatureFieldName = SysAllocStringLen(SignatureFieldName.c_str(), (int)(SignatureFieldName.length()));
	BSTR bstrOutputFileName = SysAllocStringLen(OutputFileName.c_str(), (int)(OutputFileName.length()));
	BSTR bstrPFXFileName = SysAllocStringLen(PFXFileName.c_str(), (int)(PFXFileName.length()));
	BSTR bstrPFXPassword = SysAllocStringLen(PFXPassword.c_str(), (int)(PFXPassword.length()));
	BSTR bstrReason = SysAllocStringLen(Reason.c_str(), (int)(Reason.length()));
	BSTR bstrLocation = SysAllocStringLen(Location.c_str(), (int)(Location.length()));
	BSTR bstrContactInfo = SysAllocStringLen(ContactInfo.c_str(), (int)(ContactInfo.length()));
	RunFunction(L" SignFile ", bstrInputFileName, bstrOpenPassword, 
	bstrSignatureFieldName, bstrOutputFileName, bstrPFXFileName, bstrPFXPassword, 
	bstrReason, bstrLocation, bstrContactInfo);
	SysFreeString(bstrInputFileName);
	SysFreeString(bstrOpenPassword);
	SysFreeString(bstrSignatureFieldName);
	SysFreeString(bstrOutputFileName);
	SysFreeString(bstrPFXFileName);
	SysFreeString(bstrPFXPassword);
	SysFreeString(bstrReason);
	SysFreeString(bstrLocation);
	SysFreeString(bstrContactInfo);
	return result.intVal;
}

int PDFlibAX::SplitPageText(int Options)
{
	RunFunction(L" SplitPageText ", Options);
	return result.intVal;
}

int PDFlibAX::StartPath(double StartX, double StartY)
{
	RunFunction(L" StartPath ", StartX, StartY);
	return result.intVal;
}

int PDFlibAX::StoreCustomDataFromFile(const std::wstring& Key, const std::wstring& FileName, int Location, int Options)
{
	BSTR bstrKey = SysAllocStringLen(Key.c_str(), (int)(Key.length()));
	BSTR bStrFileName = SysAllocStringLen(FileName.c_str(), (int)(FileName.length()));
	RunFunction(L" StoreCustomDataFromFile ", bstrKey, bStrFileName, Location, 
	Options);
	SysFreeString(bstrKey);
	SysFreeString(bStrFileName);
	return result.intVal;
}

int PDFlibAX::StoreCustomDataFromString(const std::wstring& Key, const std::wstring& NewValue, int Location, int Options)
{
	BSTR bstrKey = SysAllocStringLen(Key.c_str(), (int)(Key.length()));
	BSTR bstrNewValue = SysAllocStringLen(NewValue.c_str(), (int)(NewValue.length()));
	RunFunction(L" StoreCustomDataFromString ", bstrKey, bstrNewValue, 
	Location, Options);
	SysFreeString(bstrKey);
	SysFreeString(bstrNewValue);
	return result.intVal;
}

int PDFlibAX::StoreCustomDataFromVariant(const std::wstring& Key, std::vector<BYTE>& NewValue, int Location, int Options)
{
	BSTR bstrKey = SysAllocStringLen(Key.c_str(), (int)(Key.length()));
	VARIANT arNewValue = MakeByteArray(NewValue);
	RunFunction(L" StoreCustomDataFromVariant ", bstrKey, arNewValue, Location, 
	Options);
	SysFreeString(bstrKey);
	SafeArrayDestroy(arNewValue.parray);
	return result.intVal;
}

int PDFlibAX::TestTempPath()
{
	RunFunction(L" TestTempPath ");
	return result.intVal;
}

std::wstring PDFlibAX::ToPDFUnicode(const std::wstring& Input)
{
	BSTR bstrInput = SysAllocStringLen(Input.c_str(), (int)(Input.length()));
	RunFunction(L" ToPDFUnicode ", bstrInput);
	SysFreeString(bstrInput);
	return GetString();
}

int PDFlibAX::UpdateAppearanceStream(int Index)
{
	RunFunction(L" UpdateAppearanceStream ", Index);
	return result.intVal;
}

int PDFlibAX::UseKerning(int Kern)
{
	RunFunction(L" UseKerning ", Kern);
	return result.intVal;
}

int PDFlibAX::UseUnsafeLayers(int SafetyLevel)
{
	RunFunction(L" UseUnsafeLayers ", SafetyLevel);
	return result.intVal;
}





