Error Codes
Many of the functions (particularly the load... functions) will throw Xpdf-specific errors in certain circumstances. The error codes are available as (read-only) properties:errOpenFile
: The PDF file couldn't be opened. This typically means that the file name was misspelled, or that the file permissions prevented it from being opened.errBadCatalog
: The PDF page catalog couldn't be read. This error can be treated the same way aserrDamaged
.errDamaged
: The PDF file was damaged and couldn't be repaired.errEncrypted
: The PDF file was encrypted and the password was incorrect or not supplied.eErrHighlightFile
: The highlight file was nonexistent or invalid.errBadPrinter
: The specified printer was invalid. This typically means that the printer name was incorrect, or that permissions prevented printing to that printer.errPrinting
: Error during printing.errPermission
: Operation not allowed by the PDF permission settings.errBadPageNum
: Invalid page number requested.errFileIO
: File I/O error.errBadArg
: An invalid argument was passed to the function.
Using error codes
Error codes are accessed as read-only properties on the component. VB6:
On Error GoTo err
...
pdf.loadFile fileName ...
err:
If Err = pdf.errOpenFile Then
' ... couldn't open the file ...
End If
VB.net:
Try
pdf.loadFile(fileName)
Catch e As System.Runtime.InteropServices.COMException
If e.ErrorCode = pdf.errOpenFile Then
' ... couldn't open the file ...
End If
End Try
C#:
using System.Runtime.InteropServices;
...
try {
pdf.loadFile(fileName);
} catch (COMException e) {
if (e.ErrorCode == pdf.errOpenFile) {
// ... couldn't open the file ...
}
}
Unmanaged C++:
try {
pdf->loadFile(fileName);
} catch (_com_error e) {
if (e.Error() == pdf->errOpenFile) {
// ... couldn't open the file ...
}
}