From 25f5e28e56200f70b40c5dbc60da7fc0f88e586e Mon Sep 17 00:00:00 2001
From: Michael R Sweet The error callback is called for both errors and warnings and accepts the The error callback is called for both errors and warnings and accepts the The default error callback ( Note: Many errors are unrecoverable, so PDFio ignores the return value from the error callback and always stops processing the PDF file. Warning messages start with the prefix "WARNING:" while errors have no prefix. Each PDF file contains one or more pages. The pdfio_file_t
pointer, a message string, and the callback pointer value, for example:pdfio_file_t
pointer, a message string, and the callback pointer value. It returns true
to continue processing the file or false
to stop, for example:bool
error_cb(pdfio_file_t *pdf, const char *message, void *data)
{
@@ -736,11 +736,14 @@ error_cb(pdfio_file_t *pdf, const "%s: %s\n", pdfioFileGetName(pdf), message);
- // Return false to treat warnings as errors
- return (false);
+ // Return true for warning messages (continue) and false for errors (stop)
+ return (!strncmp(message, "WARNING:", 8));
}
NULL
) does the equivalent of the above.
+
pdfioFileGetNumPages
function returns the number of pages in the file while the pdfioFileGetPage
function gets the specified page in the PDF file:pdfio_file_t *pdf; // PDF file
size_t i; // Looping var
@@ -2746,7 +2749,7 @@ size_t pdfioArrayGetSize(pdfio_array_t *a);
Value type
-Remove an array entry.
bool pdfioArrayRemove(pdfio_array_t *a, size_t n);
@@ -2951,7 +2954,7 @@ using thepdfioPageDictAddImage
true
on success, false
on failure
Clear the current path.
bool pdfioContentPathEnd(pdfio_stream_t *st);
@@ -3441,7 +3444,7 @@ are 0, a solid line is drawn.true
on success, false
on failure
Measure a text string and return its width.
double pdfioContentTextMeasure(pdfio_obj_t *font, const char *s, double size);
@@ -3459,7 +3462,9 @@ are 0, a solid line is drawn.This function measures the given text string "s" and returns its width based on "size". The text string must always use the UTF-8 (Unicode) encoding but -any control characters (such as newlines) are ignored.
+any control characters (such as newlines) are ignored. + +Move to the next line and offset.
@@ -3490,7 +3495,7 @@ any control characters (such as newlines) are ignored.
true
on success, false
on failure
Move to the next line.
bool pdfioContentTextNewLine(pdfio_stream_t *st);
@@ -3501,7 +3506,7 @@ any control characters (such as newlines) are ignored.true
on success, false
on failure
Move to the next line and show text.
bool pdfioContentTextNewLineShow(pdfio_stream_t *st, double ws, double cs, bool unicode, const char *s);
@@ -3524,8 +3529,10 @@ any control characters (such as newlines) are ignored.This function moves to the next line and then shows some text with optional word and character spacing in a PDF content stream. The "unicode" argument specifies that the current font maps to full Unicode. The "s" argument -specifies a UTF-8 encoded string.
-Show formatted text.
bool pdfioContentTextNewLineShowf(pdfio_stream_t *st, double ws, double cs, bool unicode, const char *format, ...);
@@ -3550,7 +3557,9 @@ specifies a UTF-8 encoded string.This function moves to the next line and shows some formatted text with
optional word and character spacing in a PDF content stream. The "unicode"
argument specifies that the current font maps to full Unicode. The "format"
-argument specifies a UTF-8 encoded printf
-style format string.
printf
-style format string.
+
+
Show text.
@@ -3613,7 +3622,7 @@ argument specifies an array of UTF-8 encoded strings.
This function shows some formatted text in a PDF content stream. The
"unicode" argument specifies that the current font maps to full Unicode.
The "format" argument specifies a UTF-8 encoded printf
-style format string.
Remove a key/value pair from a dictionary.
bool pdfioDictClear(pdfio_dict_t *dict, const char *key);
@@ -3717,7 +3726,7 @@ time_t pdfioDictGetDate(pdfio_dict_t *dict,Value
-Get the key for the specified pair.
const char *pdfioDictGetKey(pdfio_dict_t *dict, size_t n);
@@ -3743,7 +3752,7 @@ time_t pdfioDictGetDate(pdfio_dict_t *dict,Value
-Get the number of key/value pairs in a dictionary.
size_t pdfioDictGetNumPairs(pdfio_dict_t *dict);
@@ -3821,7 +3830,7 @@ size_t pdfioDictGetNumPairs(pdfio_dict_t *dict);Value type
-Iterate the keys in a dictionary.
void pdfioDictIterateKeys(pdfio_dict_t *dict, pdfio_dict_cb_t cb, void *cb_data);
@@ -3848,7 +3857,9 @@ my_dict_cb(pdfio_dict_t *dict, const char *key, void *cb_data) The iteration continues as long as the callback returnstrue
or all keys
-have been iterated.
+have been iterated.
+
+
Set a key array in a dictionary.
@@ -4076,8 +4087,9 @@ CropBox for pages in the PDF file - if NULL
then a default "Un
of 8.27x11in (the intersection of US Letter and ISO A4) is used.
The "error_cb" and "error_cbdata" arguments specify an error handler callback
-and its data pointer - if NULL
the default error handler is used that
-writes error messages to stderr
.
NULL
then the default error handler is used that
+writes error messages to stderr
. The error handler callback should return
+true
to continue writing the PDF file or false
to stop.
Create a new object in a PDF file containing an array.
@@ -4260,7 +4272,7 @@ image on the page.
Note: Currently PNG support is limited to grayscale, RGB, or indexed files
without interlacing or alpha. Transparency (masking) based on color/index
is supported.
-
Create a new object in a PDF file containing a name.
pdfio_obj_t *pdfioFileCreateNameObj(pdfio_file_t *pdf, const char *name);
@@ -4275,8 +4287,10 @@ is supported.New object
This function creates a new object with a name value in a PDF file.
-You must call pdfioObjClose
to write the object to the file.
pdfioObjClose
to write the object to the file.
+
+
+Create a new object in a PDF file containing a number.
pdfio_obj_t *pdfioFileCreateNumberObj(pdfio_file_t *pdf, double number);
@@ -4291,7 +4305,9 @@ You must callpdfioObjClose
to write t
New object
This function creates a new object with a number value in a PDF file.
-You must call pdfioObjClose
to write the object to the file.
pdfioObjClose
to write the object to the file.
+
+
Create a new object in a PDF file.
@@ -4352,8 +4368,9 @@ CropBox for pages in the PDF file - if NULL
then a default "Un
of 8.27x11in (the intersection of US Letter and ISO A4) is used.
The "error_cb" and "error_cbdata" arguments specify an error handler callback
-and its data pointer - if NULL
the default error handler is used that
-writes error messages to stderr
.
+and its data pointer - if NULL
then the default error handler is used that
+writes error messages to stderr
. The error handler callback should return
+true
to continue writing the PDF file or false
to stop.
Note: Files created using this API are slightly larger than those @@ -4372,7 +4389,7 @@ stored as indirect object references.
Contents stream
-Create a new object in a PDF file containing a string.
pdfio_obj_t *pdfioFileCreateStringObj(pdfio_file_t *pdf, const char *string);
@@ -4387,7 +4404,9 @@ stored as indirect object references.New object
This function creates a new object with a string value in a PDF file.
-You must call pdfioObjClose
to write the object to the file.
pdfioObjClose
to write the object to the file.
+
+
@@ -4670,8 +4689,15 @@ cancel the open. If NULL
is specified for the callback function an
PDF file requires a password, the open will always fail.
The "error_cb" and "error_cbdata" arguments specify an error handler callback
-and its data pointer - if NULL
the default error handler is used that
-writes error messages to stderr
.
NULL
then the default error handler is used that
+writes error messages to stderr
. The error handler callback should return
+true
to continue reading the PDF file or false
to stop.
+Note: Error messages starting with "WARNING:" are actually warning
+messages - the callback should normally return true
to allow PDFio to
+try to resolve the issue. In addition, some errors are unrecoverable and
+ignore the return value of the error callback.
Set the author for a PDF file.
@@ -4892,7 +4918,7 @@ size_t pdfioObjGetLength(pdfio_obj_t *obj);
Length in bytes or 0
for none
Get the name value associated with an object.
const char *pdfioObjGetName(pdfio_obj_t *obj);
@@ -5168,8 +5194,9 @@ ssize_t pdfioStreamPeek(pdfio_stream_t *st,true
on success, false
on failure
This function writes a formatted string to a stream. In addition to the
-standard printf
format characters, you can use "%N" to format a PDF name
-value ("/Name") and "%S" to format a PDF string ("(String)") value.
printf
format characters, you can use "%H" to format a HTML/XML
+string value, "%N" to format a PDF name value ("/Name"), and "%S" to format
+a PDF string ("(String)") value.
Write a single character to a stream.
@@ -5403,7 +5430,7 @@ typedef enum pdfio_valtype_e pdfio_valtype_t;
Compression/decompression filters for streams