Getting Started: LIB Edition
Installation
The LIB Edition of Quick PDF Library is generated automatically by converting the DLL Edition into a static link library.
The static link library file is called QuickPDFLIB0815.lib and a header file called QuickPDFLIB0815.h is included.
Link dependencies
The following resource files must be linked into the final executable:
QuickPDFDingbats.res
QuickPDFGlyphList.res
QuickPDFColorProfiles.res
The following import libraries must be added to your project:
GDI32.LIB
ADVAPI32.LIB
OLE32.LIB
USER32.LIB
CRYPT32.LIB
OLEAUT32.LIB
WINSPOOL.LIB
In previous versions of the library, these import libraries were also required: MSVCRT.LIB, VERSION.LIB, COMCTL32.LIB but from version 8.15 they are no longer needed.
Initializing/releasing the library
The QUICKPDFLIB0815_DllMain function should be called once before using any of the other functions, using the DLL_PROCESS_ATTACH constant for the fdwReason parameter.
The QuickPDFCreateLibrary function must be called to initialize the library. An InstanceID will be returned which must be passed as the first parameter to all the other functions.
When you are finished with the library, call QuickPDFReleaseLibrary to release all allocated memory.
Finally, before the application ends the QUICKPDFLIB0815_DllMain function should be called again. This time the DLL_PROCESS_DETACH constant should be used.
Unlocking the library
Once you have an InstanceID, you should call the QuickPDFUnlockKey function, passing it your license key, to unlock the library.
int InstanceID = QuickPDFCreateLibrary();
if (QuickPDFUnlockKey(InstanceID, L"your license key") == 1) {
QuickPDFDrawText(InstanceID, 100, 500, L"Hello world");
QuickPDFSaveToFile(InstanceID, L"C:\\Docs\\HelloFromLIB.pdf");
}
QuickPDFReleaseLibrary(InstanceID);
QUICKPDFLIB0815_DllMain(GetModuleHandle(NULL), DLL_PROCESS_DETACH, NULL);
Sending strings to Quick PDF Library
Most Quick PDF Library string parameters are defined as PWideChars, which are pointers to 16-bit null-terminated Unicode strings (UTF-16BE).
Some functions accept 8-bit binary data. If the data you need to send to the library may contain null characters, you can ask Quick PDF Library to create a temporary buffer of a certain size.
Use the QuickPDFCreateBuffer and QuickPDFAddToBuffer functions to create the buffer and fill it with data. The value returned by the QuickPDFCreateBuffer function can then be used for any 8-bit or 16-bit string parameter:
char * Content = ...; // pointer to the data
Buffer = QuickPDFCreateBuffer(10000);
QuickPDFAddToBuffer(InstanceID, Buffer, Content, 10000);
QuickPDFStoreCustomDataFromString(InstanceID,
"MyData", Buffer, 1, 0);
QuickPDFReleaseBuffer(InstanceID, Buffer);
Receiving strings from Quick PDF Library
Most functions that return string data will return a PWideChar, a pointer to a Unicode string. The memory for this string is contained within the Quick PDF Library instance.
The data in the string should be copied out immediately as the same memory will be used for subsequent calls to the library.
To get the length of the returned string, use the QuickPDFStringResultLength function. This function returns the number of Unicode characters (multiply by 2 to get the size in bytes).
Some functions may return data that contains 8-bit data, possibly including null characters.
To get the length of the binary data, use the QuickPDFAnsiStringResultLength function:
int ContentLength;
Content = QuickPDFRetrieveCustomDataToString(InstanceID,
"MyData", 1);
ContentLength = QuickPDFAnsiStringResultLength(InstanceID);
// copy the data in Content now


