Exception codes and error messages for the Adobe PDF Library are listed in the AcroErr.h header file. You will find this in the product installation package, in the directory called /CPlusPlus/Include/Headers.
The Adobe PDF Library creates error messages using a macro defined in AcroErr.h (lines 291-316). The product provides each error code as a series of bit field values, concatenated together into a single larger number.
Interpreting error messages with the ASGetErrorString API
The Adobe PDF Library offers an API, ASGetErrorString, that translates error codes into error messages that are easy to read and prints them to a command line monitor.
const char *ASGetErrorString(ASErrorCode errorCode, char *buffer, ASTArraySize lenBuffer);
ASGetErrorString() has three parameters:
- errorCode. The error number that you want to translate into an error message text string. You must pass to the function the full error code number created with the ErrBuildCode() macro, or a user-defined exception returned with ASRegisterErrorString().
- buffer. The buffer where ASGetErrorString will write the text string ( char buffer[256]; ). Make sure that you memset this buffer to 0 before you call ASGetErrorString.
- lenBuffer. The number of characters that the buffer can hold. You can pass ASGetErrorString() sizeof(buffer) here.
ASGetErrorString() returns a pointer to buffer, but this pointer does not by itself indicate that the function worked. If the buffer was memset to 0, call strlen on the returned buffer to determine if the error code was valid.
For example, the following code will convert an error code into an error message string, and print that string to stderr:
char buf[256]; ... DURING ... HANDLER ASGetErrorString(ERRORCODE, buf, sizeof(buf)); fprintf(stderr, "Error code: %ld, Error Message: %sn", ERRORCODE, buf); return; END_HANDLER
The use of the ASGetErrorString API is demonstrated in the sample program APDFLDoc.cpp. Find this sample program in your Adobe PDF Library software installation package:
/CPlusPlus/Sample_Source/_Common
The samples found in this directory are called by other Library sample programs.
When using the Java and .NET interfaces, errors are represented with the LibraryException class. A user should see the message portion when the system catches an exception:
try {...} catch (Exception e) { Console.Writeline("Library error: "+ e); }
Translating the Adobe PDF Library error code manually
We describe how error messages are formatted in the Library below.
Adobe PDF Library provides each error code as a series of bit field values concatenated together. It is easier to read if you use a decimal to hexadecimal code converter utility to convert the error code to hex notation, and then parse the hex version of the error code.
For example, 1073938471 can be converted to hex code 40030027. You can then parse that hex code into four fields:
40030027 | 4 | Severity Level. None, Warning, or Severe. The width of the field is 4 bits, and the format is designed to allow for up to 16 possible Severity Levels (2 to the 4th power). The Library provides three levels, but you can your own custom Severity levels if you like. | ||
40030027 | 0 | Unused | ||
40030027 | 03 | System Number. This refers to internal systems within the Adobe PDF Library, or categories of the type of errors displayed. Adobe PDF Library provides 19 default System types, but provides room for up to 256, so you can add many more System types to your APDFL application. The default error messages provided by the Library are listed below. |
ErrSysNone | General errors | |||
ErrSysCos | General Cos errors | |||
ErrSysCosSyntax | Cos syntax errors | |||
ErrSysPDDoc | PDDoc and family, Page tree, outlines errors | |||
ErrSysPDPage | PDPage and family, thumbs, annotations errors | |||
ErrSysPDModel | Global PD errors | |||
ErrSysAcroView | AcroView errors | |||
ErrSysPage | Page parsing and RIPping errors | |||
ErrSysFontSvr | Font Server errors | |||
ErrSysRaster | Rasterizer errors | |||
ErrSysASFile | ASFile I/O errors | |||
ErrSysXtnMgr | Extension Manager errors | |||
ErrSysXtn | New error codes added by extensions | |||
ErrSysMDSystem | Platform-specific system errors | |||
ErrSysMDApp | Platform-specific application errors | |||
ErrSysPDFX | PDFX-specific errors | |||
ErrSysPDFEdit | PDFEdit errors | |||
ErrSysPDSEdit | PDSEdit (structure) errors | |||
ErrSysPDMetadata | XAP Metadata errors |
40030027 | 0027 | Error Number. This code maps to the individual error message, such as "pdErrNeedPassword," which means that a required password is missing. The error number refers to the position of the error message in the list of error messages for the System. In this example, error number 0027 would be the 27th message found under system number 3, Cos Syntax Errors. So each error number is unique. |
Note: If you have a question about an error message, please contact your Datalogics Support Representative.
Error code examples
Error code 1073741825
Step | ||||
1 | Convert number to Hex | 4000 0001 | ||
2 | Count to the severity item | 4 | ErrAlways | |
3 | Count to the system item | 0 | ErrSysNone | |
4 | Count to error item | 1 | genErrGeneral |
Error code 537067605
Step | ||||
1 | Convert number to Hex | 2003 0555 | ||
2 | Count to the severity item | 2 | ErrSuppressable | |
3 | Count to the system item | 3 | ErrSysPDDoc | |
4 | Count to error item | 85* | cosSynErrBadCharInHexString |
*hex 55 is decimal 85