API cleanup, more work on documentation.

This commit is contained in:
Michael R Sweet 2021-06-07 08:34:30 -04:00
parent c158587070
commit a698b9c1a2
No known key found for this signature in database
GPG Key ID: 999559A027815955
13 changed files with 1031 additions and 281 deletions

View File

@ -1,4 +1,4 @@
.TH pdfio 3 "pdf read/write library" "2021-05-30" "pdf read/write library"
.TH pdfio 3 "pdf read/write library" "2021-06-07" "pdf read/write library"
.SH NAME
pdfio \- pdf read/write library
.SH Introduction
@ -29,6 +29,191 @@ Provide access to objects used for each page
PDFio is
.I not
concerned with rendering or viewing a PDF file, although a PDF RIP or viewer could be written using it.
.PP
PDFio is Copyright \[co] 2021 by Michael R Sweet and is licensed under the Apache License Version 2.0 with an (optional) exception to allow linking against GPL2/LGPL2 software. See the files "LICENSE" and "NOTICE" for more information.
.SS Requirements
.PP
PDFio requires the following to build the software:
.IP \(bu 5
.PP
A C99 compiler such as Clang, GCC, or MS Visual C
.IP \(bu 5
.PP
A POSIX\-compliant make program
.IP \(bu 5
.PP
ZLIB (https://www.zlib.net) 1.0 or higher
.PP
IDE files for Xcode (macOS/iOS) and Visual Studio (Windows) are also provided.
.SS Installing pdfio
.PP
PDFio comes with a portable makefile that will work on any POSIX\-compliant system with ZLIB installed. To make it, run:
.nf
make all
.fi
.PP
To test it, run:
.nf
make test
.fi
.PP
To install it, run:
.nf
make install
.fi
.PP
If you want a shared library, run:
.nf
make all\-shared
make install\-shared
.fi
.PP
The default installation location is "/usr/local". Pass the prefix variable to make to install it to another location:
.nf
make install prefix=/some/other/directory
.fi
.PP
The makefile installs the pdfio header to "${prefix}/include", the library to "${prefix}/lib", the pkg\-config file to "${prefix}/lib/pkgconfig", the man page to "${prefix}/share/man/man3", and the documentation to "${prefix}/share/doc/pdfio".
.PP
The makefile supports the following variables that can be specified in the make command or as environment variables:
.IP \(bu 5
.PP
AR: the library archiver (default "ar")
.IP \(bu 5
.PP
ARFLAGS: options for the library archiver (default "cr")
.IP \(bu 5
.PP
CC: the C compiler (default "cc")
.IP \(bu 5
.PP
CFLAGS: options for the C compiler (default "")
.IP \(bu 5
.PP
CODESIGN_IDENTITY: the identity to use when code signing the shared library on macOS (default "Developer ID")
.IP \(bu 5
.PP
COMMONFLAGS: options for the C compiler and linker (typically architecture and optimization options, default is "\-Os \-g")
.IP \(bu 5
.PP
CPPFLAGS: options for the C preprocessor (default "")
.IP \(bu 5
.PP
DESTDIR" and "DSTROOT: specifies a root directory when installing (default is "", specify only one)
.IP \(bu 5
.PP
DSOFLAGS: options for the C compiler when linking the shared library (default "")
.IP \(bu 5
.PP
LDFLAGS: options for the C compiler when linking the test programs (default "")
.IP \(bu 5
.PP
LIBS: library options when linking the test programs (default "\-lz")
.IP \(bu 5
.PP
RANLIB: program that generates a table\-of\-contents in a library (default "ranlib")
.IP \(bu 5
.PP
prefix: specifies the installation directory (default "/usr/local")
.SS Visual Studio Project
.PP
Note: I haven't yet added this...
.PP
The Visual Studio solution ("pdfio.sln") is provided for Windows developers generates both a static library and DLL.
.SS Xcode Project
.PP
There is also an Xcode project ("pdfio.xcodeproj") you can use on macOS which generates a static library that will be installed under "/usr/local" with:
.nf
sudo xcodebuild install
.fi
.PP
You can reproduce this with the makefile using:
.nf
sudo make 'COMMONFLAGS="\-Os \-mmacosx\-version\-min=10.14 \-arch x86_64 \-arch arm64"' install
.fi
.SS Detecting PDFio
.PP
PDFio can be detected using the pkg\-config command, for example:
.nf
if pkg\-config \-\-exists pdfio; then
...
fi
.fi
.PP
In a makefile you can add the necessary compiler and linker options with:
.nf
CFLAGS += `pkg\-config \-\-cflags pdfio`
LIBS += `pkg\-config \-\-libs pdfio`
.fi
.SS Header Files
.PP
PDFio provides a primary header file that is always used:
.nf
#include <pdfio.h>
.fi
.PP
PDFio also provides content helper functions that are defined in a separate header file:
.nf
#include <pdfio\-content.h>
.fi
.SH API Overview
.PP
PDFio exposes several types:
.IP \(bu 5
.PP
pdfio_file_t: A PDF file (for reading or writing)
.IP \(bu 5
.PP
pdfio_array_t: An array of values
.IP \(bu 5
.PP
pdfio_dict_t: A dictionary of key/value pairs in a PDF file, object, etc.
.IP \(bu 5
.PP
pdfio_obj_t: An object in a PDF file
.IP \(bu 5
.PP
pdfio_stream_t: An object stream
.SS PDF Files
.SS PDF Values
.SS PDF Objects
.SS PDF Streams
.SH ENUMERATIONS
.SS pdfio_filter_e
@ -139,7 +324,7 @@ Add a binary string value to an array.
.nf
bool pdfioArrayAppendBinary (
pdfio_array_t *a,
unsigned char *value,
const unsigned char *value,
size_t valuelen
);
.fi
@ -179,11 +364,11 @@ bool pdfioArrayAppendNumber (
double value
);
.fi
.SS pdfioArrayAppendObject
.SS pdfioArrayAppendObj
Add an indirect object reference to an array.
.PP
.nf
bool pdfioArrayAppendObject (
bool pdfioArrayAppendObj (
pdfio_array_t *a,
pdfio_obj_t *value
);
@ -214,6 +399,55 @@ pdfio_array_t * pdfioArrayCreate (
pdfio_file_t *pdf
);
.fi
.SS pdfioArrayCreateCalibratedColorFromMatrix
Create a calibrated color space array using a CIE XYZ transform matrix.
.PP
.nf
pdfio_array_t * pdfioArrayCreateCalibratedColorFromMatrix (
pdfio_file_t *pdf,
size_t num_colors,
double gamma,
const double matrix[3][3],
const double white_point[3]
);
.fi
.SS pdfioArrayCreateCalibratedColorFromPrimaries
Create a calibrated color sapce array using CIE xy primary chromacities.
.PP
.nf
pdfio_array_t * pdfioArrayCreateCalibratedColorFromPrimaries (
pdfio_file_t *pdf,
size_t num_colors,
double gamma,
double wx,
double wy,
double rx,
double ry,
double gx,
double gy,
double bx,
double by
);
.fi
.SS pdfioArrayCreateICCBasedColor
Create an ICC-based color space array.
.PP
.nf
pdfio_array_t * pdfioArrayCreateICCBasedColor (
pdfio_file_t *pdf,
pdfio_obj_t *icc_object
);
.fi
.SS pdfioArrayCreateIndexedColor
Create an indexed color space array.
.PP
.nf
pdfio_array_t * pdfioArrayCreateIndexedColor (
pdfio_file_t *pdf,
size_t num_colors,
const unsigned char *colors
);
.fi
.SS pdfioArrayGetArray
Get an array value from an array.
.PP
@ -269,11 +503,11 @@ double pdfioArrayGetNumber (
size_t n
);
.fi
.SS pdfioArrayGetObject
.SS pdfioArrayGetObj
Get an indirect object reference from an array.
.PP
.nf
pdfio_obj_t * pdfioArrayGetObject (
pdfio_obj_t * pdfioArrayGetObj (
pdfio_array_t *a,
size_t n
);
@ -304,14 +538,6 @@ pdfio_valtype_t pdfioArrayGetType (
size_t n
);
.fi
.SS pdfioContentBeginText
Begin a text block.
.PP
.nf
bool pdfioContentBeginText (
pdfio_stream_t *st
);
.fi
.SS pdfioContentClip
Clip output to the current path.
.PP
@ -330,21 +556,13 @@ bool pdfioContentDrawImage (
const char *name,
double x,
double y,
double w,
double h
double width,
double height
);
.fi
.PP
The object name must be part of the page dictionary resources, typically
using the \fIpdfioPageDictAddImage\fR function.
.SS pdfioContentEndText
End a text block.
.PP
.nf
bool pdfioContentEndText (
pdfio_stream_t *st
);
.fi
.SS pdfioContentFill
Fill the current path.
.PP
@ -474,7 +692,10 @@ Add a rectangle to the current path.
.nf
bool pdfioContentPathRect (
pdfio_stream_t *st,
pdfio_rect_t *rect
double x,
double y,
double width,
double height
);
.fi
.SS pdfioContentRestore
@ -752,6 +973,22 @@ bool pdfioContentStroke (
pdfio_stream_t *st
);
.fi
.SS pdfioContentTextBegin
Begin a text block.
.PP
.nf
bool pdfioContentTextBegin (
pdfio_stream_t *st
);
.fi
.SS pdfioContentTextEnd
End a text block.
.PP
.nf
bool pdfioContentTextEnd (
pdfio_stream_t *st
);
.fi
.SS pdfioContentTextMoveLine
Move to the next line and offset.
.PP
@ -786,8 +1023,7 @@ Show text.
.nf
bool pdfioContentTextShow (
pdfio_stream_t *st,
const char *s,
bool new_line
const char *s
);
.fi
.SS pdfioContentTextShowJustified
@ -801,6 +1037,16 @@ bool pdfioContentTextShowJustified (
const char *const *fragments
);
.fi
.SS pdfioContentTextShowf
.PP
.nf
bool pdfioContentTextShowf (
pdfio_stream_t *st,
const char *format,
...
);
.fi
.SS pdfioDictCopy
Copy a dictionary to a PDF file.
.PP
@ -873,11 +1119,11 @@ double pdfioDictGetNumber (
const char *key
);
.fi
.SS pdfioDictGetObject
.SS pdfioDictGetObj
Get a key indirect object value from a dictionary.
.PP
.nf
pdfio_obj_t * pdfioDictGetObject (
pdfio_obj_t * pdfioDictGetObj (
pdfio_dict_t *dict,
const char *key
);
@ -927,7 +1173,7 @@ Set a key binary string in a dictionary.
bool pdfioDictSetBinary (
pdfio_dict_t *dict,
const char *key,
unsigned char *value,
const unsigned char *value,
size_t valuelen
);
.fi
@ -980,11 +1226,11 @@ bool pdfioDictSetNumber (
double value
);
.fi
.SS pdfioDictSetObject
.SS pdfioDictSetObj
Set a key indirect object reference in a dictionary.
.PP
.nf
bool pdfioDictSetObject (
bool pdfioDictSetObj (
pdfio_dict_t *dict,
const char *key,
pdfio_obj_t *value
@ -1042,29 +1288,72 @@ pdfio_file_t * pdfioFileCreate (
void *error_data
);
.fi
.SS pdfioFileCreateFontObject
.SS pdfioFileCreateBaseFontObj
Create one of the base 14 PDF fonts.
.PP
.nf
pdfio_obj_t * pdfioFileCreateBaseFontObj (
pdfio_file_t *pdf,
const char *name
);
.fi
.PP
This function creates one of the base 14 PDF fonts. The "name" parameter
specifies the font nane:
.PP
.IP \(bu 5
\fBCourier\fR
.IP \(bu 5
\fBCourier-Bold\fR
.IP \(bu 5
\fBCourier-BoldItalic\fR
.IP \(bu 5
\fBCourier-Italic\fR
.IP \(bu 5
\fBHelvetica\fR
.IP \(bu 5
\fBHelvetica-Bold\fR
.IP \(bu 5
\fBHelvetica-BoldOblique\fR
.IP \(bu 5
\fBHelvetica-Oblique\fR
.IP \(bu 5
\fBSymbol\fR
.IP \(bu 5
\fBTimes-Bold\fR
.IP \(bu 5
\fBTimes-BoldItalic\fR
.IP \(bu 5
\fBTimes-Italic\fR
.IP \(bu 5
\fBTimes-Roman\fR
.IP \(bu 5
\fBZapfDingbats\fR</li>
</ul>
.SS pdfioFileCreateFontObj
Add a font object to a PDF file.
.PP
.nf
pdfio_obj_t * pdfioFileCreateFontObject (
pdfio_obj_t * pdfioFileCreateFontObj (
pdfio_file_t *pdf,
const char *filename
const char *filename,
bool unicode
);
.fi
.SS pdfioFileCreateICCProfileObject
.SS pdfioFileCreateICCProfileObj
Add an ICC profile object to a PDF file.
.PP
.nf
pdfio_obj_t * pdfioFileCreateICCProfileObject (
pdfio_obj_t * pdfioFileCreateICCProfileObj (
pdfio_file_t *pdf,
const char *filename
);
.fi
.SS pdfioFileCreateImageObject
.SS pdfioFileCreateImageObj
Add an image object to a PDF file.
.PP
.nf
pdfio_obj_t * pdfioFileCreateImageObject (
pdfio_obj_t * pdfioFileCreateImageObj (
pdfio_file_t *pdf,
const char *filename,
bool interpolate
@ -1072,11 +1361,11 @@ pdfio_obj_t * pdfioFileCreateImageObject (
.fi
.PP
Currently only GIF, JPEG, and PNG files are supported.
.SS pdfioFileCreateObject
.SS pdfioFileCreateObj
Create a new object in a PDF file.
.PP
.nf
pdfio_obj_t * pdfioFileCreateObject (
pdfio_obj_t * pdfioFileCreateObj (
pdfio_file_t *pdf,
pdfio_dict_t *dict
);
@ -1090,17 +1379,17 @@ pdfio_stream_t * pdfioFileCreatePage (
pdfio_dict_t *dict
);
.fi
.SS pdfioFileFindObject
.SS pdfioFileFindObj
Find an object using its object number.
.PP
.nf
pdfio_obj_t * pdfioFileFindObject (
pdfio_obj_t * pdfioFileFindObj (
pdfio_file_t *pdf,
size_t number
);
.fi
.PP
This differs from \fIpdfioFileGetObject\fR which takes an index into the
This differs from \fIpdfioFileGetObj\fR which takes an index into the
list of objects while this function takes the object number.
.SS pdfioFileGetID
Get the PDF file's ID strings.
@ -1118,11 +1407,11 @@ const char * pdfioFileGetName (
pdfio_file_t *pdf
);
.fi
.SS pdfioFileGetNumObjects
.SS pdfioFileGetNumObjs
Get the number of objects in a PDF file.
.PP
.nf
size_t pdfioFileGetNumObjects (
size_t pdfioFileGetNumObjs (
pdfio_file_t *pdf
);
.fi
@ -1134,11 +1423,11 @@ size_t pdfioFileGetNumPages (
pdfio_file_t *pdf
);
.fi
.SS pdfioFileGetObject
.SS pdfioFileGetObj
Get an object from a PDF file.
.PP
.nf
pdfio_obj_t * pdfioFileGetObject (
pdfio_obj_t * pdfioFileGetObj (
pdfio_file_t *pdf,
size_t n
);
@ -1170,6 +1459,14 @@ pdfio_file_t * pdfioFileOpen (
void *error_data
);
.fi
.SS pdfioImageGetBytesPerLine
Get the number of bytes to read for each line.
.PP
.nf
size_t pdfioImageGetBytesPerLine (
pdfio_obj_t *obj
);
.fi
.SS pdfioImageGetHeight
Get the height of an image object.
.PP
@ -1253,6 +1550,14 @@ size_t pdfioObjGetNumber (
pdfio_obj_t *obj
);
.fi
.SS pdfioObjGetSubtype
Get an object's subtype.
.PP
.nf
const char * pdfioObjGetSubtype (
pdfio_obj_t *obj
);
.fi
.SS pdfioObjGetType
Get an object's type.
.PP
@ -1279,19 +1584,28 @@ bool pdfioPageCopy (
pdfio_obj_t *srcpage
);
.fi
.SS pdfioPageDictAddCalibratedColorSpace
Add a calibrated color space to
the page dictionary.
.SS pdfioPageDictAddColorSpace
Add a color space to the page dictionary.
.PP
.nf
bool pdfioPageDictAddCalibratedColorSpace (
bool pdfioPageDictAddColorSpace (
pdfio_dict_t *dict,
const char *name,
size_t num_colors,
const double *white_point,
double gamma
pdfio_array_t *data
);
.fi
.PP
This function adds a named color space to the page dictionary.
.PP
The names "DefaultCMYK", "DefaultGray", and "DefaultRGB" specify the default
device color space used for the page.
.PP
The "data" array contains a calibrated, indexed, or ICC-based color space
array that was created using the
\fIpdfioArrayCreateCalibratedColorFromMatrix\fR,
\fIpdfioArrayCreateCalibratedColorFromPrimaries\fR,
\fIpdfioArrayCreateICCBasedColor\fR, or
\fIpdfioArrayCreateIndexedColor\fR functions.
.SS pdfioPageDictAddFont
Add a font object to the page dictionary.
.PP
@ -1302,17 +1616,6 @@ bool pdfioPageDictAddFont (
pdfio_obj_t *obj
);
.fi
.SS pdfioPageDictAddICCColorSpace
Add an ICC color space to the page
dictionary.
.PP
.nf
bool pdfioPageDictAddICCColorSpace (
pdfio_dict_t *dict,
const char *name,
pdfio_obj_t *obj
);
.fi
.SS pdfioPageDictAddImage
Add an image object to the page dictionary.
.PP
@ -1389,6 +1692,11 @@ ssize_t pdfioStreamRead (
size_t bytes
);
.fi
.PP
This function reads data from a stream. When reading decoded image data
from a stream, you \fImust\fR read whole scanlines. The
\fIpdfioImageGetBytesPerLine\fR function can be used to determine the
proper read length.
.SS pdfioStreamWrite
Write data to a stream.
.PP

View File

@ -252,7 +252,20 @@ span.string {
<div class="contents">
<h2 class="title">Contents</h2>
<ul class="contents">
<li><a href="#introduction">Introduction</a></li>
<li><a href="#introduction">Introduction</a><ul class="subcontents">
<li><a href="#requirements">Requirements</a></li>
<li><a href="#installing-pdfio">Installing pdfio</a></li>
<li><a href="#visual-studio-project">Visual Studio Project</a></li>
<li><a href="#xcode-project">Xcode Project</a></li>
<li><a href="#detecting-pdfio">Detecting PDFio</a></li>
<li><a href="#header-files">Header Files</a></li>
</ul></li>
<li><a href="#api-overview">API Overview</a><ul class="subcontents">
<li><a href="#pdf-files">PDF Files</a></li>
<li><a href="#pdf-values">PDF Values</a></li>
<li><a href="#pdf-objects">PDF Objects</a></li>
<li><a href="#pdf-streams">PDF Streams</a></li>
</ul></li>
<li><a href="#FUNCTIONS">Functions</a><ul class="subcontents">
<li><a href="#pdfioArrayAppendArray">pdfioArrayAppendArray</a></li>
<li><a href="#pdfioArrayAppendBinary">pdfioArrayAppendBinary</a></li>
@ -260,24 +273,26 @@ span.string {
<li><a href="#pdfioArrayAppendDict">pdfioArrayAppendDict</a></li>
<li><a href="#pdfioArrayAppendName">pdfioArrayAppendName</a></li>
<li><a href="#pdfioArrayAppendNumber">pdfioArrayAppendNumber</a></li>
<li><a href="#pdfioArrayAppendObject">pdfioArrayAppendObject</a></li>
<li><a href="#pdfioArrayAppendObj">pdfioArrayAppendObj</a></li>
<li><a href="#pdfioArrayAppendString">pdfioArrayAppendString</a></li>
<li><a href="#pdfioArrayCopy">pdfioArrayCopy</a></li>
<li><a href="#pdfioArrayCreate">pdfioArrayCreate</a></li>
<li><a href="#pdfioArrayCreateCalibratedColorFromMatrix">pdfioArrayCreateCalibratedColorFromMatrix</a></li>
<li><a href="#pdfioArrayCreateCalibratedColorFromPrimaries">pdfioArrayCreateCalibratedColorFromPrimaries</a></li>
<li><a href="#pdfioArrayCreateICCBasedColor">pdfioArrayCreateICCBasedColor</a></li>
<li><a href="#pdfioArrayCreateIndexedColor">pdfioArrayCreateIndexedColor</a></li>
<li><a href="#pdfioArrayGetArray">pdfioArrayGetArray</a></li>
<li><a href="#pdfioArrayGetBinary">pdfioArrayGetBinary</a></li>
<li><a href="#pdfioArrayGetBoolean">pdfioArrayGetBoolean</a></li>
<li><a href="#pdfioArrayGetDict">pdfioArrayGetDict</a></li>
<li><a href="#pdfioArrayGetName">pdfioArrayGetName</a></li>
<li><a href="#pdfioArrayGetNumber">pdfioArrayGetNumber</a></li>
<li><a href="#pdfioArrayGetObject">pdfioArrayGetObject</a></li>
<li><a href="#pdfioArrayGetObj">pdfioArrayGetObj</a></li>
<li><a href="#pdfioArrayGetSize">pdfioArrayGetSize</a></li>
<li><a href="#pdfioArrayGetString">pdfioArrayGetString</a></li>
<li><a href="#pdfioArrayGetType">pdfioArrayGetType</a></li>
<li><a href="#pdfioContentBeginText">pdfioContentBeginText</a></li>
<li><a href="#pdfioContentClip">pdfioContentClip</a></li>
<li><a href="#pdfioContentDrawImage">pdfioContentDrawImage</a></li>
<li><a href="#pdfioContentEndText">pdfioContentEndText</a></li>
<li><a href="#pdfioContentFill">pdfioContentFill</a></li>
<li><a href="#pdfioContentFillAndStroke">pdfioContentFillAndStroke</a></li>
<li><a href="#pdfioContentMatrixConcat">pdfioContentMatrixConcat</a></li>
@ -320,11 +335,14 @@ span.string {
<li><a href="#pdfioContentSetTextWordSpacing">pdfioContentSetTextWordSpacing</a></li>
<li><a href="#pdfioContentSetTextXScaling">pdfioContentSetTextXScaling</a></li>
<li><a href="#pdfioContentStroke">pdfioContentStroke</a></li>
<li><a href="#pdfioContentTextBegin">pdfioContentTextBegin</a></li>
<li><a href="#pdfioContentTextEnd">pdfioContentTextEnd</a></li>
<li><a href="#pdfioContentTextMoveLine">pdfioContentTextMoveLine</a></li>
<li><a href="#pdfioContentTextMoveTo">pdfioContentTextMoveTo</a></li>
<li><a href="#pdfioContentTextNextLine">pdfioContentTextNextLine</a></li>
<li><a href="#pdfioContentTextShow">pdfioContentTextShow</a></li>
<li><a href="#pdfioContentTextShowJustified">pdfioContentTextShowJustified</a></li>
<li><a href="#pdfioContentTextShowf">pdfioContentTextShowf</a></li>
<li><a href="#pdfioDictCopy">pdfioDictCopy</a></li>
<li><a href="#pdfioDictCreate">pdfioDictCreate</a></li>
<li><a href="#pdfioDictGetArray">pdfioDictGetArray</a></li>
@ -333,7 +351,7 @@ span.string {
<li><a href="#pdfioDictGetDict">pdfioDictGetDict</a></li>
<li><a href="#pdfioDictGetName">pdfioDictGetName</a></li>
<li><a href="#pdfioDictGetNumber">pdfioDictGetNumber</a></li>
<li><a href="#pdfioDictGetObject">pdfioDictGetObject</a></li>
<li><a href="#pdfioDictGetObj">pdfioDictGetObj</a></li>
<li><a href="#pdfioDictGetRect">pdfioDictGetRect</a></li>
<li><a href="#pdfioDictGetString">pdfioDictGetString</a></li>
<li><a href="#pdfioDictGetType">pdfioDictGetType</a></li>
@ -344,26 +362,28 @@ span.string {
<li><a href="#pdfioDictSetName">pdfioDictSetName</a></li>
<li><a href="#pdfioDictSetNull">pdfioDictSetNull</a></li>
<li><a href="#pdfioDictSetNumber">pdfioDictSetNumber</a></li>
<li><a href="#pdfioDictSetObject">pdfioDictSetObject</a></li>
<li><a href="#pdfioDictSetObj">pdfioDictSetObj</a></li>
<li><a href="#pdfioDictSetRect">pdfioDictSetRect</a></li>
<li><a href="#pdfioDictSetString">pdfioDictSetString</a></li>
<li><a href="#pdfioDictSetStringf">pdfioDictSetStringf</a></li>
<li><a href="#pdfioFileClose">pdfioFileClose</a></li>
<li><a href="#pdfioFileCreate">pdfioFileCreate</a></li>
<li><a href="#pdfioFileCreateFontObject">pdfioFileCreateFontObject</a></li>
<li><a href="#pdfioFileCreateICCProfileObject">pdfioFileCreateICCProfileObject</a></li>
<li><a href="#pdfioFileCreateImageObject">pdfioFileCreateImageObject</a></li>
<li><a href="#pdfioFileCreateObject">pdfioFileCreateObject</a></li>
<li><a href="#pdfioFileCreateBaseFontObj">pdfioFileCreateBaseFontObj</a></li>
<li><a href="#pdfioFileCreateFontObj">pdfioFileCreateFontObj</a></li>
<li><a href="#pdfioFileCreateICCProfileObj">pdfioFileCreateICCProfileObj</a></li>
<li><a href="#pdfioFileCreateImageObj">pdfioFileCreateImageObj</a></li>
<li><a href="#pdfioFileCreateObj">pdfioFileCreateObj</a></li>
<li><a href="#pdfioFileCreatePage">pdfioFileCreatePage</a></li>
<li><a href="#pdfioFileFindObject">pdfioFileFindObject</a></li>
<li><a href="#pdfioFileFindObj">pdfioFileFindObj</a></li>
<li><a href="#pdfioFileGetID">pdfioFileGetID</a></li>
<li><a href="#pdfioFileGetName">pdfioFileGetName</a></li>
<li><a href="#pdfioFileGetNumObjects">pdfioFileGetNumObjects</a></li>
<li><a href="#pdfioFileGetNumObjs">pdfioFileGetNumObjs</a></li>
<li><a href="#pdfioFileGetNumPages">pdfioFileGetNumPages</a></li>
<li><a href="#pdfioFileGetObject">pdfioFileGetObject</a></li>
<li><a href="#pdfioFileGetObj">pdfioFileGetObj</a></li>
<li><a href="#pdfioFileGetPage">pdfioFileGetPage</a></li>
<li><a href="#pdfioFileGetVersion">pdfioFileGetVersion</a></li>
<li><a href="#pdfioFileOpen">pdfioFileOpen</a></li>
<li><a href="#pdfioImageGetBytesPerLine">pdfioImageGetBytesPerLine</a></li>
<li><a href="#pdfioImageGetHeight">pdfioImageGetHeight</a></li>
<li><a href="#pdfioImageGetWidth">pdfioImageGetWidth</a></li>
<li><a href="#pdfioObjClose">pdfioObjClose</a></li>
@ -374,12 +394,12 @@ span.string {
<li><a href="#pdfioObjGetGeneration">pdfioObjGetGeneration</a></li>
<li><a href="#pdfioObjGetLength">pdfioObjGetLength</a></li>
<li><a href="#pdfioObjGetNumber">pdfioObjGetNumber</a></li>
<li><a href="#pdfioObjGetSubtype">pdfioObjGetSubtype</a></li>
<li><a href="#pdfioObjGetType">pdfioObjGetType</a></li>
<li><a href="#pdfioObjOpenStream">pdfioObjOpenStream</a></li>
<li><a href="#pdfioPageCopy">pdfioPageCopy</a></li>
<li><a href="#pdfioPageDictAddCalibratedColorSpace">pdfioPageDictAddCalibratedColorSpace</a></li>
<li><a href="#pdfioPageDictAddColorSpace">pdfioPageDictAddColorSpace</a></li>
<li><a href="#pdfioPageDictAddFont">pdfioPageDictAddFont</a></li>
<li><a href="#pdfioPageDictAddICCColorSpace">pdfioPageDictAddICCColorSpace</a></li>
<li><a href="#pdfioPageDictAddImage">pdfioPageDictAddImage</a></li>
<li><a href="#pdfioStreamClose">pdfioStreamClose</a></li>
<li><a href="#pdfioStreamConsume">pdfioStreamConsume</a></li>
@ -429,6 +449,112 @@ span.string {
</li>
</ul>
<p>PDFio is <em>not</em> concerned with rendering or viewing a PDF file, although a PDF RIP or viewer could be written using it.</p>
<p>PDFio is Copyright © 2021 by Michael R Sweet and is licensed under the Apache License Version 2.0 with an (optional) exception to allow linking against GPL2/LGPL2 software. See the files &quot;LICENSE&quot; and &quot;NOTICE&quot; for more information.</p>
<h3 class="title" id="requirements">Requirements</h3>
<p>PDFio requires the following to build the software:</p>
<ul>
<li><p>A C99 compiler such as Clang, GCC, or MS Visual C</p>
</li>
<li><p>A POSIX-compliant <code>make</code> program</p>
</li>
<li><p>ZLIB (<a href="https://www.zlib.net">https://www.zlib.net</a>) 1.0 or higher</p>
</li>
</ul>
<p>IDE files for Xcode (macOS/iOS) and Visual Studio (Windows) are also provided.</p>
<h3 class="title" id="installing-pdfio">Installing pdfio</h3>
<p>PDFio comes with a portable makefile that will work on any POSIX-compliant system with ZLIB installed. To make it, run:</p>
<pre><code>make all
</code></pre>
<p>To test it, run:</p>
<pre><code>make test
</code></pre>
<p>To install it, run:</p>
<pre><code>make install
</code></pre>
<p>If you want a shared library, run:</p>
<pre><code>make all-shared
make install-shared
</code></pre>
<p>The default installation location is &quot;/usr/local&quot;. Pass the <code>prefix</code> variable to make to install it to another location:</p>
<pre><code>make install prefix=/some/other/directory
</code></pre>
<p>The makefile installs the pdfio header to &quot;${prefix}/include&quot;, the library to &quot;${prefix}/lib&quot;, the <code>pkg-config</code> file to &quot;${prefix}/lib/pkgconfig&quot;, the man page to &quot;${prefix}/share/man/man3&quot;, and the documentation to &quot;${prefix}/share/doc/pdfio&quot;.</p>
<p>The makefile supports the following variables that can be specified in the make command or as environment variables:</p>
<ul>
<li><p><code>AR</code>: the library archiver (default &quot;ar&quot;)</p>
</li>
<li><p><code>ARFLAGS</code>: options for the library archiver (default &quot;cr&quot;)</p>
</li>
<li><p><code>CC</code>: the C compiler (default &quot;cc&quot;)</p>
</li>
<li><p><code>CFLAGS</code>: options for the C compiler (default &quot;&quot;)</p>
</li>
<li><p><code>CODESIGN_IDENTITY</code>: the identity to use when code signing the shared library on macOS (default &quot;Developer ID&quot;)</p>
</li>
<li><p><code>COMMONFLAGS</code>: options for the C compiler and linker (typically architecture and optimization options, default is &quot;-Os -g&quot;)</p>
</li>
<li><p><code>CPPFLAGS</code>: options for the C preprocessor (default &quot;&quot;)</p>
</li>
<li><p><code>DESTDIR&quot; and &quot;DSTROOT</code>: specifies a root directory when installing (default is &quot;&quot;, specify only one)</p>
</li>
<li><p><code>DSOFLAGS</code>: options for the C compiler when linking the shared library (default &quot;&quot;)</p>
</li>
<li><p><code>LDFLAGS</code>: options for the C compiler when linking the test programs (default &quot;&quot;)</p>
</li>
<li><p><code>LIBS</code>: library options when linking the test programs (default &quot;-lz&quot;)</p>
</li>
<li><p><code>RANLIB</code>: program that generates a table-of-contents in a library (default &quot;ranlib&quot;)</p>
</li>
<li><p><code>prefix</code>: specifies the installation directory (default &quot;/usr/local&quot;)</p>
</li>
</ul>
<h3 class="title" id="visual-studio-project">Visual Studio Project</h3>
<blockquote>
<p>Note: I haven't yet added this...</p>
</blockquote>
<p>The Visual Studio solution (&quot;pdfio.sln&quot;) is provided for Windows developers generates both a static library and DLL.</p>
<h3 class="title" id="xcode-project">Xcode Project</h3>
<p>There is also an Xcode project (&quot;pdfio.xcodeproj&quot;) you can use on macOS which generates a static library that will be installed under &quot;/usr/local&quot; with:</p>
<pre><code>sudo xcodebuild install
</code></pre>
<p>You can reproduce this with the makefile using:</p>
<pre><code>sudo make 'COMMONFLAGS=&quot;-Os -mmacosx-version-min=10.14 -arch x86_64 -arch arm64&quot;' install
</code></pre>
<h3 class="title" id="detecting-pdfio">Detecting PDFio</h3>
<p>PDFio can be detected using the <code>pkg-config</code> command, for example:</p>
<pre><code>if pkg-config --exists pdfio; then
...
fi
</code></pre>
<p>In a makefile you can add the necessary compiler and linker options with:</p>
<pre><code class="language-make">CFLAGS += `pkg-config --cflags pdfio`
LIBS += `pkg-config --libs pdfio`
</code></pre>
<h3 class="title" id="header-files">Header Files</h3>
<p>PDFio provides a primary header file that is always used:</p>
<pre><code class="language-c"><span class="directive">#include &lt;pdfio.h&gt;</span>
</code></pre>
<p>PDFio also provides content helper functions that are defined in a separate header file:</p>
<pre><code class="language-c"><span class="directive">#include &lt;pdfio-content.h&gt;</span>
</code></pre>
<h2 class="title" id="api-overview">API Overview</h2>
<p>PDFio exposes several types:</p>
<ul>
<li><p><code>pdfio_file_t</code>: A PDF file (for reading or writing)</p>
</li>
<li><p><code>pdfio_array_t</code>: An array of values</p>
</li>
<li><p><code>pdfio_dict_t</code>: A dictionary of key/value pairs in a PDF file, object, etc.</p>
</li>
<li><p><code>pdfio_obj_t</code>: An object in a PDF file</p>
</li>
<li><p><code>pdfio_stream_t</code>: An object stream</p>
</li>
</ul>
<h3 class="title" id="pdf-files">PDF Files</h3>
<h3 class="title" id="pdf-values">PDF Values</h3>
<h3 class="title" id="pdf-objects">PDF Objects</h3>
<h3 class="title" id="pdf-streams">PDF Streams</h3>
<h2 class="title"><a id="FUNCTIONS">Functions</a></h2>
<h3 class="function"><a id="pdfioArrayAppendArray">pdfioArrayAppendArray</a></h3>
<p class="description">Add an array value to an array.</p>
@ -446,7 +572,7 @@ bool pdfioArrayAppendArray(<a href="#pdfio_array_t">pdfio_array_t</a> *a, <a hre
<h3 class="function"><a id="pdfioArrayAppendBinary">pdfioArrayAppendBinary</a></h3>
<p class="description">Add a binary string value to an array.</p>
<p class="code">
bool pdfioArrayAppendBinary(<a href="#pdfio_array_t">pdfio_array_t</a> *a, unsigned char *value, size_t valuelen);</p>
bool pdfioArrayAppendBinary(<a href="#pdfio_array_t">pdfio_array_t</a> *a, const unsigned char *value, size_t valuelen);</p>
<h4 class="parameters">Parameters</h4>
<table class="list"><tbody>
<tr><th>a</th>
@ -510,10 +636,10 @@ bool pdfioArrayAppendNumber(<a href="#pdfio_array_t">pdfio_array_t</a> *a, doubl
</tbody></table>
<h4 class="returnvalue">Return Value</h4>
<p class="description"><code>true</code> on success, <code>false</code> on failure</p>
<h3 class="function"><a id="pdfioArrayAppendObject">pdfioArrayAppendObject</a></h3>
<h3 class="function"><a id="pdfioArrayAppendObj">pdfioArrayAppendObj</a></h3>
<p class="description">Add an indirect object reference to an array.</p>
<p class="code">
bool pdfioArrayAppendObject(<a href="#pdfio_array_t">pdfio_array_t</a> *a, <a href="#pdfio_obj_t">pdfio_obj_t</a> *value);</p>
bool pdfioArrayAppendObj(<a href="#pdfio_array_t">pdfio_array_t</a> *a, <a href="#pdfio_obj_t">pdfio_obj_t</a> *value);</p>
<h4 class="parameters">Parameters</h4>
<table class="list"><tbody>
<tr><th>a</th>
@ -560,6 +686,84 @@ bool pdfioArrayAppendString(<a href="#pdfio_array_t">pdfio_array_t</a> *a, const
</tbody></table>
<h4 class="returnvalue">Return Value</h4>
<p class="description">New array or <code>NULL</code> on error</p>
<h3 class="function"><a id="pdfioArrayCreateCalibratedColorFromMatrix">pdfioArrayCreateCalibratedColorFromMatrix</a></h3>
<p class="description">Create a calibrated color space array using a CIE XYZ transform matrix.</p>
<p class="code">
<a href="#pdfio_array_t">pdfio_array_t</a> *pdfioArrayCreateCalibratedColorFromMatrix(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf, size_t num_colors, double gamma, const double matrix[3][3], const double white_point[3]);</p>
<h4 class="parameters">Parameters</h4>
<table class="list"><tbody>
<tr><th>pdf</th>
<td class="description">PDF file</td></tr>
<tr><th>num_colors</th>
<td class="description">Number of colors (1 or 3)</td></tr>
<tr><th>gamma</th>
<td class="description">Gamma value</td></tr>
<tr><th>matrix[3][3]</th>
<td class="description">XYZ transform</td></tr>
<tr><th>white_point[3]</th>
<td class="description">White point</td></tr>
</tbody></table>
<h4 class="returnvalue">Return Value</h4>
<p class="description">Color space array</p>
<h3 class="function"><a id="pdfioArrayCreateCalibratedColorFromPrimaries">pdfioArrayCreateCalibratedColorFromPrimaries</a></h3>
<p class="description">Create a calibrated color sapce array using CIE xy primary chromacities.</p>
<p class="code">
<a href="#pdfio_array_t">pdfio_array_t</a> *pdfioArrayCreateCalibratedColorFromPrimaries(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf, size_t num_colors, double gamma, double wx, double wy, double rx, double ry, double gx, double gy, double bx, double by);</p>
<h4 class="parameters">Parameters</h4>
<table class="list"><tbody>
<tr><th>pdf</th>
<td class="description">PDF file</td></tr>
<tr><th>num_colors</th>
<td class="description">Number of colors (1 or 3)</td></tr>
<tr><th>gamma</th>
<td class="description">Gama value</td></tr>
<tr><th>wx</th>
<td class="description">White point X chromacity</td></tr>
<tr><th>wy</th>
<td class="description">White point Y chromacity</td></tr>
<tr><th>rx</th>
<td class="description">Red X chromacity</td></tr>
<tr><th>ry</th>
<td class="description">Red Y chromacity</td></tr>
<tr><th>gx</th>
<td class="description">Green X chromacity</td></tr>
<tr><th>gy</th>
<td class="description">Green Y chromacity</td></tr>
<tr><th>bx</th>
<td class="description">Blue X chromacity</td></tr>
<tr><th>by</th>
<td class="description">Blue Y chromacity</td></tr>
</tbody></table>
<h4 class="returnvalue">Return Value</h4>
<p class="description">Color space array</p>
<h3 class="function"><a id="pdfioArrayCreateICCBasedColor">pdfioArrayCreateICCBasedColor</a></h3>
<p class="description">Create an ICC-based color space array.</p>
<p class="code">
<a href="#pdfio_array_t">pdfio_array_t</a> *pdfioArrayCreateICCBasedColor(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf, <a href="#pdfio_obj_t">pdfio_obj_t</a> *icc_object);</p>
<h4 class="parameters">Parameters</h4>
<table class="list"><tbody>
<tr><th>pdf</th>
<td class="description">PDF file</td></tr>
<tr><th>icc_object</th>
<td class="description">ICC profile object</td></tr>
</tbody></table>
<h4 class="returnvalue">Return Value</h4>
<p class="description">Color array</p>
<h3 class="function"><a id="pdfioArrayCreateIndexedColor">pdfioArrayCreateIndexedColor</a></h3>
<p class="description">Create an indexed color space array.</p>
<p class="code">
<a href="#pdfio_array_t">pdfio_array_t</a> *pdfioArrayCreateIndexedColor(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf, size_t num_colors, const unsigned char *colors);</p>
<h4 class="parameters">Parameters</h4>
<table class="list"><tbody>
<tr><th>pdf</th>
<td class="description">PDF file</td></tr>
<tr><th>num_colors</th>
<td class="description">Number of colors</td></tr>
<tr><th>colors</th>
<td class="description">RGB values for colors</td></tr>
</tbody></table>
<h4 class="returnvalue">Return Value</h4>
<p class="description">Color array</p>
<h3 class="function"><a id="pdfioArrayGetArray">pdfioArrayGetArray</a></h3>
<p class="description">Get an array value from an array.</p>
<p class="code">
@ -640,10 +844,10 @@ double pdfioArrayGetNumber(<a href="#pdfio_array_t">pdfio_array_t</a> *a, size_t
</tbody></table>
<h4 class="returnvalue">Return Value</h4>
<p class="description">Value</p>
<h3 class="function"><a id="pdfioArrayGetObject">pdfioArrayGetObject</a></h3>
<h3 class="function"><a id="pdfioArrayGetObj">pdfioArrayGetObj</a></h3>
<p class="description">Get an indirect object reference from an array.</p>
<p class="code">
<a href="#pdfio_obj_t">pdfio_obj_t</a> *pdfioArrayGetObject(<a href="#pdfio_array_t">pdfio_array_t</a> *a, size_t n);</p>
<a href="#pdfio_obj_t">pdfio_obj_t</a> *pdfioArrayGetObj(<a href="#pdfio_array_t">pdfio_array_t</a> *a, size_t n);</p>
<h4 class="parameters">Parameters</h4>
<table class="list"><tbody>
<tr><th>a</th>
@ -690,17 +894,6 @@ const char *pdfioArrayGetString(<a href="#pdfio_array_t">pdfio_array_t</a> *a, s
</tbody></table>
<h4 class="returnvalue">Return Value</h4>
<p class="description">Value type</p>
<h3 class="function"><a id="pdfioContentBeginText">pdfioContentBeginText</a></h3>
<p class="description">Begin a text block.</p>
<p class="code">
bool pdfioContentBeginText(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st);</p>
<h4 class="parameters">Parameters</h4>
<table class="list"><tbody>
<tr><th>st</th>
<td class="description">Stream</td></tr>
</tbody></table>
<h4 class="returnvalue">Return Value</h4>
<p class="description"><code>true</code> on success, <code>false</code> on failure</p>
<h3 class="function"><a id="pdfioContentClip">pdfioContentClip</a></h3>
<p class="description">Clip output to the current path.</p>
<p class="code">
@ -717,7 +910,7 @@ bool pdfioContentClip(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, bool eve
<h3 class="function"><a id="pdfioContentDrawImage">pdfioContentDrawImage</a></h3>
<p class="description">Draw an image object.</p>
<p class="code">
bool pdfioContentDrawImage(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, const char *name, double x, double y, double w, double h);</p>
bool pdfioContentDrawImage(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, const char *name, double x, double y, double width, double height);</p>
<h4 class="parameters">Parameters</h4>
<table class="list"><tbody>
<tr><th>st</th>
@ -728,9 +921,9 @@ bool pdfioContentDrawImage(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, con
<td class="description">X offset of image</td></tr>
<tr><th>y</th>
<td class="description">Y offset of image</td></tr>
<tr><th>w</th>
<tr><th>width</th>
<td class="description">Width of image</td></tr>
<tr><th>h</th>
<tr><th>height</th>
<td class="description">Height of image</td></tr>
</tbody></table>
<h4 class="returnvalue">Return Value</h4>
@ -738,17 +931,6 @@ bool pdfioContentDrawImage(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, con
<h4 class="discussion">Discussion</h4>
<p class="discussion">The object name must be part of the page dictionary resources, typically
using the <a href="#pdfioPageDictAddImage"><code>pdfioPageDictAddImage</code></a> function.</p>
<h3 class="function"><a id="pdfioContentEndText">pdfioContentEndText</a></h3>
<p class="description">End a text block.</p>
<p class="code">
bool pdfioContentEndText(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st);</p>
<h4 class="parameters">Parameters</h4>
<table class="list"><tbody>
<tr><th>st</th>
<td class="description">Stream</td></tr>
</tbody></table>
<h4 class="returnvalue">Return Value</h4>
<p class="description"><code>true</code> on success, <code>false</code> on failure</p>
<h3 class="function"><a id="pdfioContentFill">pdfioContentFill</a></h3>
<p class="description">Fill the current path.</p>
<p class="code">
@ -937,13 +1119,19 @@ bool pdfioContentPathMoveTo(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, do
<h3 class="function"><a id="pdfioContentPathRect">pdfioContentPathRect</a></h3>
<p class="description">Add a rectangle to the current path.</p>
<p class="code">
bool pdfioContentPathRect(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, <a href="#pdfio_rect_t">pdfio_rect_t</a> *rect);</p>
bool pdfioContentPathRect(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, double x, double y, double width, double height);</p>
<h4 class="parameters">Parameters</h4>
<table class="list"><tbody>
<tr><th>st</th>
<td class="description">Stream</td></tr>
<tr><th>rect</th>
<td class="description">Rectangle</td></tr>
<tr><th>x</th>
<td class="description">X offset</td></tr>
<tr><th>y</th>
<td class="description">Y offset</td></tr>
<tr><th>width</th>
<td class="description">Width</td></tr>
<tr><th>height</th>
<td class="description">Height</td></tr>
</tbody></table>
<h4 class="returnvalue">Return Value</h4>
<p class="description"><code>true</code> on success, <code>false</code> on failure</p>
@ -1352,6 +1540,28 @@ bool pdfioContentStroke(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st);</p>
</tbody></table>
<h4 class="returnvalue">Return Value</h4>
<p class="description"><code>true</code> on success, <code>false</code> on failure</p>
<h3 class="function"><a id="pdfioContentTextBegin">pdfioContentTextBegin</a></h3>
<p class="description">Begin a text block.</p>
<p class="code">
bool pdfioContentTextBegin(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st);</p>
<h4 class="parameters">Parameters</h4>
<table class="list"><tbody>
<tr><th>st</th>
<td class="description">Stream</td></tr>
</tbody></table>
<h4 class="returnvalue">Return Value</h4>
<p class="description"><code>true</code> on success, <code>false</code> on failure</p>
<h3 class="function"><a id="pdfioContentTextEnd">pdfioContentTextEnd</a></h3>
<p class="description">End a text block.</p>
<p class="code">
bool pdfioContentTextEnd(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st);</p>
<h4 class="parameters">Parameters</h4>
<table class="list"><tbody>
<tr><th>st</th>
<td class="description">Stream</td></tr>
</tbody></table>
<h4 class="returnvalue">Return Value</h4>
<p class="description"><code>true</code> on success, <code>false</code> on failure</p>
<h3 class="function"><a id="pdfioContentTextMoveLine">pdfioContentTextMoveLine</a></h3>
<p class="description">Move to the next line and offset.</p>
<p class="code">
@ -1396,15 +1606,13 @@ bool pdfioContentTextNextLine(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st);
<h3 class="function"><a id="pdfioContentTextShow">pdfioContentTextShow</a></h3>
<p class="description">Show text.</p>
<p class="code">
bool pdfioContentTextShow(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, const char *s, bool new_line);</p>
bool pdfioContentTextShow(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, const char *s);</p>
<h4 class="parameters">Parameters</h4>
<table class="list"><tbody>
<tr><th>st</th>
<td class="description">Stream</td></tr>
<tr><th>s</th>
<td class="description">String to show</td></tr>
<tr><th>new_line</th>
<td class="description">Advance to the next line afterwards</td></tr>
</tbody></table>
<h4 class="returnvalue">Return Value</h4>
<p class="description"><code>true</code> on success, <code>false</code> on failure</p>
@ -1425,6 +1633,21 @@ bool pdfioContentTextShowJustified(<a href="#pdfio_stream_t">pdfio_stream_t</a>
</tbody></table>
<h4 class="returnvalue">Return Value</h4>
<p class="description"><code>true</code> on success, <code>false</code> on failure</p>
<h3 class="function"><a id="pdfioContentTextShowf">pdfioContentTextShowf</a></h3>
<p class="description"></p>
<p class="code">
bool pdfioContentTextShowf(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, const char *format, ...);</p>
<h4 class="parameters">Parameters</h4>
<table class="list"><tbody>
<tr><th>st</th>
<td class="description">Stream</td></tr>
<tr><th>format</th>
<td class="description"><code>printf</code>-style format string</td></tr>
<tr><th>...</th>
<td class="description">Additional arguments as needed</td></tr>
</tbody></table>
<h4 class="returnvalue">Return Value</h4>
<p class="description">Show formatted text.</p>
<h3 class="function"><a id="pdfioDictCopy">pdfioDictCopy</a></h3>
<p class="description">Copy a dictionary to a PDF file.</p>
<p class="code">
@ -1529,10 +1752,10 @@ double pdfioDictGetNumber(<a href="#pdfio_dict_t">pdfio_dict_t</a> *dict, const
</tbody></table>
<h4 class="returnvalue">Return Value</h4>
<p class="description">Value</p>
<h3 class="function"><a id="pdfioDictGetObject">pdfioDictGetObject</a></h3>
<h3 class="function"><a id="pdfioDictGetObj">pdfioDictGetObj</a></h3>
<p class="description">Get a key indirect object value from a dictionary.</p>
<p class="code">
<a href="#pdfio_obj_t">pdfio_obj_t</a> *pdfioDictGetObject(<a href="#pdfio_dict_t">pdfio_dict_t</a> *dict, const char *key);</p>
<a href="#pdfio_obj_t">pdfio_obj_t</a> *pdfioDictGetObj(<a href="#pdfio_dict_t">pdfio_dict_t</a> *dict, const char *key);</p>
<h4 class="parameters">Parameters</h4>
<table class="list"><tbody>
<tr><th>dict</th>
@ -1601,7 +1824,7 @@ bool pdfioDictSetArray(<a href="#pdfio_dict_t">pdfio_dict_t</a> *dict, const cha
<h3 class="function"><a id="pdfioDictSetBinary">pdfioDictSetBinary</a></h3>
<p class="description">Set a key binary string in a dictionary.</p>
<p class="code">
bool pdfioDictSetBinary(<a href="#pdfio_dict_t">pdfio_dict_t</a> *dict, const char *key, unsigned char *value, size_t valuelen);</p>
bool pdfioDictSetBinary(<a href="#pdfio_dict_t">pdfio_dict_t</a> *dict, const char *key, const unsigned char *value, size_t valuelen);</p>
<h4 class="parameters">Parameters</h4>
<table class="list"><tbody>
<tr><th>dict</th>
@ -1688,10 +1911,10 @@ bool pdfioDictSetNumber(<a href="#pdfio_dict_t">pdfio_dict_t</a> *dict, const ch
</tbody></table>
<h4 class="returnvalue">Return Value</h4>
<p class="description"><code>true</code> on success, <code>false</code> on failure</p>
<h3 class="function"><a id="pdfioDictSetObject">pdfioDictSetObject</a></h3>
<h3 class="function"><a id="pdfioDictSetObj">pdfioDictSetObj</a></h3>
<p class="description">Set a key indirect object reference in a dictionary.</p>
<p class="code">
bool pdfioDictSetObject(<a href="#pdfio_dict_t">pdfio_dict_t</a> *dict, const char *key, <a href="#pdfio_obj_t">pdfio_obj_t</a> *value);</p>
bool pdfioDictSetObj(<a href="#pdfio_dict_t">pdfio_dict_t</a> *dict, const char *key, <a href="#pdfio_obj_t">pdfio_obj_t</a> *value);</p>
<h4 class="parameters">Parameters</h4>
<table class="list"><tbody>
<tr><th>dict</th>
@ -1782,23 +2005,71 @@ bool pdfioFileClose(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf);</p>
</tbody></table>
<h4 class="returnvalue">Return Value</h4>
<p class="description">PDF file or <code>NULL</code> on error</p>
<h3 class="function"><a id="pdfioFileCreateFontObject">pdfioFileCreateFontObject</a></h3>
<h3 class="function"><a id="pdfioFileCreateBaseFontObj">pdfioFileCreateBaseFontObj</a></h3>
<p class="description">Create one of the base 14 PDF fonts.</p>
<p class="code">
<a href="#pdfio_obj_t">pdfio_obj_t</a> *pdfioFileCreateBaseFontObj(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf, const char *name);</p>
<h4 class="parameters">Parameters</h4>
<table class="list"><tbody>
<tr><th>pdf</th>
<td class="description">PDF file</td></tr>
<tr><th>name</th>
<td class="description">Font name</td></tr>
</tbody></table>
<h4 class="returnvalue">Return Value</h4>
<p class="description">Font object</p>
<h4 class="discussion">Discussion</h4>
<p class="discussion">This function creates one of the base 14 PDF fonts. The &quot;name&quot; parameter
specifies the font nane:
</p><ul>
<li><code>Courier</code>
</li>
<li><code>Courier-Bold</code>
</li>
<li><code>Courier-BoldItalic</code>
</li>
<li><code>Courier-Italic</code>
</li>
<li><code>Helvetica</code>
</li>
<li><code>Helvetica-Bold</code>
</li>
<li><code>Helvetica-BoldOblique</code>
</li>
<li><code>Helvetica-Oblique</code>
</li>
<li><code>Symbol</code>
</li>
<li><code>Times-Bold</code>
</li>
<li><code>Times-BoldItalic</code>
</li>
<li><code>Times-Italic</code>
</li>
<li><code>Times-Roman</code>
</li>
<li><code>ZapfDingbats</code></li>
</ul>
<h3 class="function"><a id="pdfioFileCreateFontObj">pdfioFileCreateFontObj</a></h3>
<p class="description">Add a font object to a PDF file.</p>
<p class="code">
<a href="#pdfio_obj_t">pdfio_obj_t</a> *pdfioFileCreateFontObject(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf, const char *filename);</p>
<a href="#pdfio_obj_t">pdfio_obj_t</a> *pdfioFileCreateFontObj(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf, const char *filename, bool unicode);</p>
<h4 class="parameters">Parameters</h4>
<table class="list"><tbody>
<tr><th>pdf</th>
<td class="description">PDF file</td></tr>
<tr><th>filename</th>
<td class="description">Filename</td></tr>
<tr><th>unicode</th>
<td class="description">Unicode font?</td></tr>
</tbody></table>
<h4 class="returnvalue">Return Value</h4>
<p class="description">Object</p>
<h3 class="function"><a id="pdfioFileCreateICCProfileObject">pdfioFileCreateICCProfileObject</a></h3>
<p class="description">Font object</p>
<h3 class="function"><a id="pdfioFileCreateICCProfileObj">pdfioFileCreateICCProfileObj</a></h3>
<p class="description">Add an ICC profile object to a PDF file.</p>
<p class="code">
<a href="#pdfio_obj_t">pdfio_obj_t</a> *pdfioFileCreateICCProfileObject(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf, const char *filename);</p>
<a href="#pdfio_obj_t">pdfio_obj_t</a> *pdfioFileCreateICCProfileObj(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf, const char *filename);</p>
<h4 class="parameters">Parameters</h4>
<table class="list"><tbody>
<tr><th>pdf</th>
@ -1808,10 +2079,10 @@ bool pdfioFileClose(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf);</p>
</tbody></table>
<h4 class="returnvalue">Return Value</h4>
<p class="description">Object</p>
<h3 class="function"><a id="pdfioFileCreateImageObject">pdfioFileCreateImageObject</a></h3>
<h3 class="function"><a id="pdfioFileCreateImageObj">pdfioFileCreateImageObj</a></h3>
<p class="description">Add an image object to a PDF file.</p>
<p class="code">
<a href="#pdfio_obj_t">pdfio_obj_t</a> *pdfioFileCreateImageObject(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf, const char *filename, bool interpolate);</p>
<a href="#pdfio_obj_t">pdfio_obj_t</a> *pdfioFileCreateImageObj(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf, const char *filename, bool interpolate);</p>
<h4 class="parameters">Parameters</h4>
<table class="list"><tbody>
<tr><th>pdf</th>
@ -1825,10 +2096,10 @@ bool pdfioFileClose(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf);</p>
<p class="description">Object</p>
<h4 class="discussion">Discussion</h4>
<p class="discussion">Currently only GIF, JPEG, and PNG files are supported.</p>
<h3 class="function"><a id="pdfioFileCreateObject">pdfioFileCreateObject</a></h3>
<h3 class="function"><a id="pdfioFileCreateObj">pdfioFileCreateObj</a></h3>
<p class="description">Create a new object in a PDF file.</p>
<p class="code">
<a href="#pdfio_obj_t">pdfio_obj_t</a> *pdfioFileCreateObject(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf, <a href="#pdfio_dict_t">pdfio_dict_t</a> *dict);</p>
<a href="#pdfio_obj_t">pdfio_obj_t</a> *pdfioFileCreateObj(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf, <a href="#pdfio_dict_t">pdfio_dict_t</a> *dict);</p>
<h4 class="parameters">Parameters</h4>
<table class="list"><tbody>
<tr><th>pdf</th>
@ -1851,10 +2122,10 @@ bool pdfioFileClose(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf);</p>
</tbody></table>
<h4 class="returnvalue">Return Value</h4>
<p class="description">Contents stream</p>
<h3 class="function"><a id="pdfioFileFindObject">pdfioFileFindObject</a></h3>
<h3 class="function"><a id="pdfioFileFindObj">pdfioFileFindObj</a></h3>
<p class="description">Find an object using its object number.</p>
<p class="code">
<a href="#pdfio_obj_t">pdfio_obj_t</a> *pdfioFileFindObject(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf, size_t number);</p>
<a href="#pdfio_obj_t">pdfio_obj_t</a> *pdfioFileFindObj(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf, size_t number);</p>
<h4 class="parameters">Parameters</h4>
<table class="list"><tbody>
<tr><th>pdf</th>
@ -1865,7 +2136,7 @@ bool pdfioFileClose(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf);</p>
<h4 class="returnvalue">Return Value</h4>
<p class="description">Object or <code>NULL</code> if not found</p>
<h4 class="discussion">Discussion</h4>
<p class="discussion">This differs from <a href="#pdfioFileGetObject"><code>pdfioFileGetObject</code></a> which takes an index into the
<p class="discussion">This differs from <a href="#pdfioFileGetObj"><code>pdfioFileGetObj</code></a> which takes an index into the
list of objects while this function takes the object number.</p>
<h3 class="function"><a id="pdfioFileGetID">pdfioFileGetID</a></h3>
<p class="description">Get the PDF file's ID strings.</p>
@ -1889,10 +2160,10 @@ const char *pdfioFileGetName(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf);</p>
</tbody></table>
<h4 class="returnvalue">Return Value</h4>
<p class="description">Filename</p>
<h3 class="function"><a id="pdfioFileGetNumObjects">pdfioFileGetNumObjects</a></h3>
<h3 class="function"><a id="pdfioFileGetNumObjs">pdfioFileGetNumObjs</a></h3>
<p class="description">Get the number of objects in a PDF file.</p>
<p class="code">
size_t pdfioFileGetNumObjects(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf);</p>
size_t pdfioFileGetNumObjs(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf);</p>
<h4 class="parameters">Parameters</h4>
<table class="list"><tbody>
<tr><th>pdf</th>
@ -1911,10 +2182,10 @@ size_t pdfioFileGetNumPages(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf);</p>
</tbody></table>
<h4 class="returnvalue">Return Value</h4>
<p class="description">Number of pages</p>
<h3 class="function"><a id="pdfioFileGetObject">pdfioFileGetObject</a></h3>
<h3 class="function"><a id="pdfioFileGetObj">pdfioFileGetObj</a></h3>
<p class="description">Get an object from a PDF file.</p>
<p class="code">
<a href="#pdfio_obj_t">pdfio_obj_t</a> *pdfioFileGetObject(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf, size_t n);</p>
<a href="#pdfio_obj_t">pdfio_obj_t</a> *pdfioFileGetObj(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf, size_t n);</p>
<h4 class="parameters">Parameters</h4>
<table class="list"><tbody>
<tr><th>pdf</th>
@ -1963,6 +2234,17 @@ const char *pdfioFileGetVersion(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf);<
</tbody></table>
<h4 class="returnvalue">Return Value</h4>
<p class="description">PDF file</p>
<h3 class="function"><a id="pdfioImageGetBytesPerLine">pdfioImageGetBytesPerLine</a></h3>
<p class="description">Get the number of bytes to read for each line.</p>
<p class="code">
size_t pdfioImageGetBytesPerLine(<a href="#pdfio_obj_t">pdfio_obj_t</a> *obj);</p>
<h4 class="parameters">Parameters</h4>
<table class="list"><tbody>
<tr><th>obj</th>
<td class="description">Image object</td></tr>
</tbody></table>
<h4 class="returnvalue">Return Value</h4>
<p class="description">Number of bytes per line</p>
<h3 class="function"><a id="pdfioImageGetHeight">pdfioImageGetHeight</a></h3>
<p class="description">Get the height of an image object.</p>
<p class="code">
@ -2078,6 +2360,17 @@ size_t pdfioObjGetNumber(<a href="#pdfio_obj_t">pdfio_obj_t</a> *obj);</p>
</tbody></table>
<h4 class="returnvalue">Return Value</h4>
<p class="description">Object number (1 to 9999999999)</p>
<h3 class="function"><a id="pdfioObjGetSubtype">pdfioObjGetSubtype</a></h3>
<p class="description">Get an object's subtype.</p>
<p class="code">
const char *pdfioObjGetSubtype(<a href="#pdfio_obj_t">pdfio_obj_t</a> *obj);</p>
<h4 class="parameters">Parameters</h4>
<table class="list"><tbody>
<tr><th>obj</th>
<td class="description">Object</td></tr>
</tbody></table>
<h4 class="returnvalue">Return Value</h4>
<p class="description">Object subtype</p>
<h3 class="function"><a id="pdfioObjGetType">pdfioObjGetType</a></h3>
<p class="description">Get an object's type.</p>
<p class="code">
@ -2115,26 +2408,33 @@ bool pdfioPageCopy(<a href="#pdfio_file_t">pdfio_file_t</a> *pdf, <a href="#pdfi
</tbody></table>
<h4 class="returnvalue">Return Value</h4>
<p class="description"><code>true</code> on success, <code>false</code> on failure</p>
<h3 class="function"><a id="pdfioPageDictAddCalibratedColorSpace">pdfioPageDictAddCalibratedColorSpace</a></h3>
<p class="description">Add a calibrated color space to
the page dictionary.</p>
<h3 class="function"><a id="pdfioPageDictAddColorSpace">pdfioPageDictAddColorSpace</a></h3>
<p class="description">Add a color space to the page dictionary.</p>
<p class="code">
bool pdfioPageDictAddCalibratedColorSpace(<a href="#pdfio_dict_t">pdfio_dict_t</a> *dict, const char *name, size_t num_colors, const double *white_point, double gamma);</p>
bool pdfioPageDictAddColorSpace(<a href="#pdfio_dict_t">pdfio_dict_t</a> *dict, const char *name, <a href="#pdfio_array_t">pdfio_array_t</a> *data);</p>
<h4 class="parameters">Parameters</h4>
<table class="list"><tbody>
<tr><th>dict</th>
<td class="description">Page dictionary</td></tr>
<tr><th>name</th>
<td class="description">Color space name</td></tr>
<tr><th>num_colors</th>
<td class="description">Number of color components</td></tr>
<tr><th>white_point</th>
<td class="description">CIE XYZ white point</td></tr>
<tr><th>gamma</th>
<td class="description">Gamma value</td></tr>
<tr><th>data</th>
<td class="description">Color space array</td></tr>
</tbody></table>
<h4 class="returnvalue">Return Value</h4>
<p class="description"><code>true</code> on success, <code>false</code> on failure</p>
<h4 class="discussion">Discussion</h4>
<p class="discussion">This function adds a named color space to the page dictionary.<br>
<br>
The names &quot;DefaultCMYK&quot;, &quot;DefaultGray&quot;, and &quot;DefaultRGB&quot; specify the default
device color space used for the page.<br>
<br>
The &quot;data&quot; array contains a calibrated, indexed, or ICC-based color space
array that was created using the
<a href="#pdfioArrayCreateCalibratedColorFromMatrix"><code>pdfioArrayCreateCalibratedColorFromMatrix</code></a>,
<a href="#pdfioArrayCreateCalibratedColorFromPrimaries"><code>pdfioArrayCreateCalibratedColorFromPrimaries</code></a>,
<a href="#pdfioArrayCreateICCBasedColor"><code>pdfioArrayCreateICCBasedColor</code></a>, or
<a href="#pdfioArrayCreateIndexedColor"><code>pdfioArrayCreateIndexedColor</code></a> functions.</p>
<h3 class="function"><a id="pdfioPageDictAddFont">pdfioPageDictAddFont</a></h3>
<p class="description">Add a font object to the page dictionary.</p>
<p class="code">
@ -2150,22 +2450,6 @@ bool pdfioPageDictAddFont(<a href="#pdfio_dict_t">pdfio_dict_t</a> *dict, const
</tbody></table>
<h4 class="returnvalue">Return Value</h4>
<p class="description"><code>true</code> on success, <code>false</code> on failure</p>
<h3 class="function"><a id="pdfioPageDictAddICCColorSpace">pdfioPageDictAddICCColorSpace</a></h3>
<p class="description">Add an ICC color space to the page
dictionary.</p>
<p class="code">
bool pdfioPageDictAddICCColorSpace(<a href="#pdfio_dict_t">pdfio_dict_t</a> *dict, const char *name, <a href="#pdfio_obj_t">pdfio_obj_t</a> *obj);</p>
<h4 class="parameters">Parameters</h4>
<table class="list"><tbody>
<tr><th>dict</th>
<td class="description">Page dictionary</td></tr>
<tr><th>name</th>
<td class="description">Color space name</td></tr>
<tr><th>obj</th>
<td class="description">ICC profile object</td></tr>
</tbody></table>
<h4 class="returnvalue">Return Value</h4>
<p class="description"><code>true</code> on success, <code>false</code> on failure</p>
<h3 class="function"><a id="pdfioPageDictAddImage">pdfioPageDictAddImage</a></h3>
<p class="description">Add an image object to the page dictionary.</p>
<p class="code">
@ -2278,6 +2562,11 @@ ssize_t pdfioStreamRead(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, void *
</tbody></table>
<h4 class="returnvalue">Return Value</h4>
<p class="description">Number of bytes read or <code>-1</code> on error</p>
<h4 class="discussion">Discussion</h4>
<p class="discussion">This function reads data from a stream. When reading decoded image data
from a stream, you <em>must</em> read whole scanlines. The
<a href="#pdfioImageGetBytesPerLine"><code>pdfioImageGetBytesPerLine</code></a> function can be used to determine the
proper read length.</p>
<h3 class="function"><a id="pdfioStreamWrite">pdfioStreamWrite</a></h3>
<p class="description">Write data to a stream.</p>
<p class="code">

View File

@ -13,3 +13,158 @@ goals of pdfio are:
PDFio is *not* concerned with rendering or viewing a PDF file, although a PDF
RIP or viewer could be written using it.
PDFio is Copyright © 2021 by Michael R Sweet and is licensed under the Apache
License Version 2.0 with an (optional) exception to allow linking against
GPL2/LGPL2 software. See the files "LICENSE" and "NOTICE" for more information.
Requirements
------------
PDFio requires the following to build the software:
- A C99 compiler such as Clang, GCC, or MS Visual C
- A POSIX-compliant `make` program
- ZLIB (<https://www.zlib.net>) 1.0 or higher
IDE files for Xcode (macOS/iOS) and Visual Studio (Windows) are also provided.
Installing pdfio
----------------
PDFio comes with a portable makefile that will work on any POSIX-compliant
system with ZLIB installed. To make it, run:
make all
To test it, run:
make test
To install it, run:
make install
If you want a shared library, run:
make all-shared
make install-shared
The default installation location is "/usr/local". Pass the `prefix` variable
to make to install it to another location:
make install prefix=/some/other/directory
The makefile installs the pdfio header to "${prefix}/include", the library to
"${prefix}/lib", the `pkg-config` file to "${prefix}/lib/pkgconfig", the man
page to "${prefix}/share/man/man3", and the documentation to
"${prefix}/share/doc/pdfio".
The makefile supports the following variables that can be specified in the make
command or as environment variables:
- `AR`: the library archiver (default "ar")
- `ARFLAGS`: options for the library archiver (default "cr")
- `CC`: the C compiler (default "cc")
- `CFLAGS`: options for the C compiler (default "")
- `CODESIGN_IDENTITY`: the identity to use when code signing the shared library
on macOS (default "Developer ID")
- `COMMONFLAGS`: options for the C compiler and linker (typically architecture
and optimization options, default is "-Os -g")
- `CPPFLAGS`: options for the C preprocessor (default "")
- `DESTDIR" and "DSTROOT`: specifies a root directory when installing
(default is "", specify only one)
- `DSOFLAGS`: options for the C compiler when linking the shared library
(default "")
- `LDFLAGS`: options for the C compiler when linking the test programs
(default "")
- `LIBS`: library options when linking the test programs (default "-lz")
- `RANLIB`: program that generates a table-of-contents in a library
(default "ranlib")
- `prefix`: specifies the installation directory (default "/usr/local")
Visual Studio Project
---------------------
> Note: I haven't yet added this...
The Visual Studio solution ("pdfio.sln") is provided for Windows developers
generates both a static library and DLL.
Xcode Project
-------------
There is also an Xcode project ("pdfio.xcodeproj") you can use on macOS which
generates a static library that will be installed under "/usr/local" with:
sudo xcodebuild install
You can reproduce this with the makefile using:
sudo make 'COMMONFLAGS="-Os -mmacosx-version-min=10.14 -arch x86_64 -arch arm64"' install
Detecting PDFio
---------------
PDFio can be detected using the `pkg-config` command, for example:
if pkg-config --exists pdfio; then
...
fi
In a makefile you can add the necessary compiler and linker options with:
```make
CFLAGS += `pkg-config --cflags pdfio`
LIBS += `pkg-config --libs pdfio`
```
Header Files
------------
PDFio provides a primary header file that is always used:
```c
#include <pdfio.h>
```
PDFio also provides content helper functions that are defined in a separate
header file:
```c
#include <pdfio-content.h>
```
API Overview
============
PDFio exposes several types:
- `pdfio_file_t`: A PDF file (for reading or writing)
- `pdfio_array_t`: An array of values
- `pdfio_dict_t`: A dictionary of key/value pairs in a PDF file, object, etc.
- `pdfio_obj_t`: An object in a PDF file
- `pdfio_stream_t`: An object stream
PDF Files
---------
PDF Values
----------
PDF Objects
-----------
PDF Streams
-----------

View File

@ -180,11 +180,11 @@ pdfioArrayAppendNumber(
//
// 'pdfioArrayAppendObject()' - Add an indirect object reference to an array.
// 'pdfioArrayAppendObj()' - Add an indirect object reference to an array.
//
bool // O - `true` on success, `false` on failure
pdfioArrayAppendObject(
pdfioArrayAppendObj(
pdfio_array_t *a, // I - Array
pdfio_obj_t *value) // I - Value
{
@ -445,13 +445,13 @@ pdfioArrayGetNumber(pdfio_array_t *a, // I - Array
//
pdfio_obj_t * // O - Value
pdfioArrayGetObject(pdfio_array_t *a, // I - Array
pdfioArrayGetObj(pdfio_array_t *a, // I - Array
size_t n) // I - Index
{
if (!a || n >= a->num_values || a->values[n].type != PDFIO_VALTYPE_INDIRECT)
return (NULL);
else
return (pdfioFileFindObject(a->pdf, a->values[n].value.indirect.number));
return (pdfioFileFindObj(a->pdf, a->values[n].value.indirect.number));
}

View File

@ -299,7 +299,7 @@ pdfioArrayCreateICCBasedColor(
return (NULL);
pdfioArrayAppendName(icc_color, "ICCBased");
pdfioArrayAppendObject(icc_color, icc_object);
pdfioArrayAppendObj(icc_color, icc_object);
return (icc_color);
}
@ -1104,7 +1104,7 @@ pdfioContentTextShowJustified(
//
// 'pdfioFileCreateBaseFontObject()' - Create one of the base 14 PDF fonts.
// 'pdfioFileCreateBaseFontObj()' - Create one of the base 14 PDF fonts.
//
// This function creates one of the base 14 PDF fonts. The "name" parameter
// specifies the font nane:
@ -1126,7 +1126,7 @@ pdfioContentTextShowJustified(
//
pdfio_obj_t * // O - Font object
pdfioFileCreateBaseFontObject(
pdfioFileCreateBaseFontObj(
pdfio_file_t *pdf, // I - PDF file
const char *name) // I - Font name
{
@ -1142,7 +1142,7 @@ pdfioFileCreateBaseFontObject(
pdfioDictSetName(dict, "BaseFont", pdfioStringCreate(pdf, name));
pdfioDictSetName(dict, "Encoding", "WinAnsiEncoding");
if ((obj = pdfioFileCreateObject(dict->pdf, dict)) != NULL)
if ((obj = pdfioFileCreateObj(dict->pdf, dict)) != NULL)
pdfioObjClose(obj);
return (obj);
@ -1150,11 +1150,11 @@ pdfioFileCreateBaseFontObject(
//
// 'pdfioFileCreateFontObject()' - Add a font object to a PDF file.
// 'pdfioFileCreateFontObj()' - Add a font object to a PDF file.
//
pdfio_obj_t * // O - Font object
pdfioFileCreateFontObject(
pdfioFileCreateFontObj(
pdfio_file_t *pdf, // I - PDF file
const char *filename, // I - Filename
bool unicode) // I - Unicode font?
@ -1177,11 +1177,11 @@ pdfioFileCreateFontObject(
//
// 'pdfioFileCreateICCProfileObject()' - Add an ICC profile object to a PDF file.
// 'pdfioFileCreateICCProfileObj()' - Add an ICC profile object to a PDF file.
//
pdfio_obj_t * // O - Object
pdfioFileCreateICCProfileObject(
pdfioFileCreateICCProfileObj(
pdfio_file_t *pdf, // I - PDF file
const char *filename) // I - Filename
{
@ -1193,13 +1193,13 @@ pdfioFileCreateICCProfileObject(
//
// 'pdfioFileCreateImageObject()' - Add an image object to a PDF file.
// 'pdfioFileCreateImageObj()' - Add an image object to a PDF file.
//
// Currently only GIF, JPEG, and PNG files are supported.
//
pdfio_obj_t * // O - Object
pdfioFileCreateImageObject(
pdfioFileCreateImageObj(
pdfio_file_t *pdf, // I - PDF file
const char *filename, // I - Filename
bool interpolate) // I - Interpolate image data?
@ -1445,7 +1445,7 @@ pdfioPageDictAddFont(
}
// Now set the image reference in the Font resource dictionary and return...
return (pdfioDictSetObject(font, name, obj));
return (pdfioDictSetObj(font, name, obj));
}
@ -1488,7 +1488,7 @@ pdfioPageDictAddImage(
}
// Now set the image reference in the XObject resource dictionary and return...
return (pdfioDictSetObject(xobject, name, obj));
return (pdfioDictSetObj(xobject, name, obj));
}
@ -1606,7 +1606,7 @@ copy_jpeg(pdfio_dict_t *dict, // I - Dictionary
pdfioDictSetArray(dict, "ColorSpace", pdfioArrayCreateCalibratedColorFromMatrix(dict->pdf, num_colors, pdfioSRGBGamma, pdfioSRGBMatrix, pdfioSRGBWhitePoint));
pdfioDictSetName(dict, "Filter", "DCTDecode");
obj = pdfioFileCreateObject(dict->pdf, dict);
obj = pdfioFileCreateObj(dict->pdf, dict);
st = pdfioObjCreateStream(obj, PDFIO_FILTER_NONE);
// Copy the file to a stream...
@ -1671,7 +1671,7 @@ copy_png(pdfio_dict_t *dict, // I - Dictionary
if (!st)
{
obj = pdfioFileCreateObject(dict->pdf, dict);
obj = pdfioFileCreateObj(dict->pdf, dict);
if ((st = pdfioObjCreateStream(obj, PDFIO_FILTER_NONE)) == NULL)
{

View File

@ -144,10 +144,10 @@ extern bool pdfioContentTextShowf(pdfio_stream_t *st, const char *format, ...)
extern bool pdfioContentTextShowJustified(pdfio_stream_t *st, size_t num_fragments, const double *offsets, const char * const *fragments) PDFIO_PUBLIC;
// Resource helpers...
extern pdfio_obj_t *pdfioFileCreateBaseFontObject(pdfio_file_t *pdf, const char *name) PDFIO_PUBLIC;
extern pdfio_obj_t *pdfioFileCreateFontObject(pdfio_file_t *pdf, const char *filename, bool unicode) PDFIO_PUBLIC;
extern pdfio_obj_t *pdfioFileCreateICCProfileObject(pdfio_file_t *pdf, const char *filename) PDFIO_PUBLIC;
extern pdfio_obj_t *pdfioFileCreateImageObject(pdfio_file_t *pdf, const char *filename, bool interpolate) PDFIO_PUBLIC;
extern pdfio_obj_t *pdfioFileCreateBaseFontObj(pdfio_file_t *pdf, const char *name) PDFIO_PUBLIC;
extern pdfio_obj_t *pdfioFileCreateFontObj(pdfio_file_t *pdf, const char *filename, bool unicode) PDFIO_PUBLIC;
extern pdfio_obj_t *pdfioFileCreateICCProfileObj(pdfio_file_t *pdf, const char *filename) PDFIO_PUBLIC;
extern pdfio_obj_t *pdfioFileCreateImageObj(pdfio_file_t *pdf, const char *filename, bool interpolate) PDFIO_PUBLIC;
// Image object helpers...
extern size_t pdfioImageGetBytesPerLine(pdfio_obj_t *obj) PDFIO_PUBLIC;

View File

@ -54,7 +54,7 @@ pdfioDictCopy(pdfio_file_t *pdf, // I - PDF file
if (!strcmp(p->key, "Length") && p->value.type == PDFIO_VALTYPE_INDIRECT && dict->pdf != pdf)
{
// Don't use indirect stream lengths for copied objects...
pdfio_obj_t *lenobj = pdfioFileFindObject(dict->pdf, p->value.value.indirect.number);
pdfio_obj_t *lenobj = pdfioFileFindObj(dict->pdf, p->value.value.indirect.number);
// Length object
v.type = PDFIO_VALTYPE_NUMBER;
@ -273,17 +273,17 @@ pdfioDictGetNumber(pdfio_dict_t *dict, // I - Dictionary
//
// 'pdfioDictGetObject()' - Get a key indirect object value from a dictionary.
// 'pdfioDictGetObj()' - Get a key indirect object value from a dictionary.
//
pdfio_obj_t * // O - Value
pdfioDictGetObject(pdfio_dict_t *dict, // I - Dictionary
pdfioDictGetObj(pdfio_dict_t *dict, // I - Dictionary
const char *key) // I - Key
{
_pdfio_value_t *value = _pdfioDictGetValue(dict, key);
if (value && value->type == PDFIO_VALTYPE_INDIRECT)
return (pdfioFileFindObject(dict->pdf, value->value.indirect.number));
return (pdfioFileFindObj(dict->pdf, value->value.indirect.number));
else
return (NULL);
}
@ -618,13 +618,13 @@ pdfioDictSetNumber(pdfio_dict_t *dict, // I - Dictionary
//
// 'pdfioDictSetObject()' - Set a key indirect object reference in a dictionary.
// 'pdfioDictSetObj()' - Set a key indirect object reference in a dictionary.
//
bool // O - `true` on success, `false` on failure
pdfioDictSetObject(pdfio_dict_t *dict, // I - Dictionary
pdfioDictSetObj(pdfio_dict_t *dict, // I - Dictionary
const char *key, // I - Key
pdfio_obj_t *value)// I - Value
pdfio_obj_t *value) // I - Value
{
_pdfio_value_t temp; // New value

View File

@ -33,11 +33,11 @@ static bool write_trailer(pdfio_file_t *pdf);
//
// '_pdfioFileAddMappedObject()' - Add a mapped object.
// '_pdfioFileAddMappedObj()' - Add a mapped object.
//
bool // O - `true` on success, `false` on failure
_pdfioFileAddMappedObject(
_pdfioFileAddMappedObj(
pdfio_file_t *pdf, // I - Destination PDF file
pdfio_obj_t *dst_obj, // I - Destination object
pdfio_obj_t *src_obj) // I - Source object
@ -262,7 +262,7 @@ pdfioFileCreate(
pdfioDictSetName(dict, "Type", "Pages");
if ((pdf->pages_root = pdfioFileCreateObject(pdf, dict)) == NULL)
if ((pdf->pages_root = pdfioFileCreateObj(pdf, dict)) == NULL)
{
pdfioFileClose(pdf);
unlink(filename);
@ -274,11 +274,11 @@ pdfioFileCreate(
//
// 'pdfioFileCreateObject()' - Create a new object in a PDF file.
// 'pdfioFileCreateObj()' - Create a new object in a PDF file.
//
pdfio_obj_t * // O - New object
pdfioFileCreateObject(
pdfioFileCreateObj(
pdfio_file_t *pdf, // I - PDF file
pdfio_dict_t *dict) // I - Object dictionary
{
@ -288,16 +288,16 @@ pdfioFileCreateObject(
value.type = PDFIO_VALTYPE_DICT;
value.value.dict = dict;
return (_pdfioFileCreateObject(pdf, dict->pdf, &value));
return (_pdfioFileCreateObj(pdf, dict->pdf, &value));
}
//
// '_pdfioFileCreateObject()' - Create a new object in a PDF file with a value.
// '_pdfioFileCreateObj()' - Create a new object in a PDF file with a value.
//
pdfio_obj_t * // O - New object
_pdfioFileCreateObject(
_pdfioFileCreateObj(
pdfio_file_t *pdf, // I - PDF file
pdfio_file_t *srcpdf, // I - Source PDF file, if any
_pdfio_value_t *value) // I - Object dictionary
@ -379,7 +379,7 @@ pdfioFileCreatePage(pdfio_file_t *pdf, // I - PDF file
if (!_pdfioDictGetValue(dict, "MediaBox"))
pdfioDictSetRect(dict, "MediaBox", &pdf->media_box);
pdfioDictSetObject(dict, "Parent", pdf->pages_root);
pdfioDictSetObj(dict, "Parent", pdf->pages_root);
if (!_pdfioDictGetValue(dict, "Resources"))
pdfioDictSetDict(dict, "Resources", pdfioDictCreate(pdf));
@ -388,7 +388,7 @@ pdfioFileCreatePage(pdfio_file_t *pdf, // I - PDF file
pdfioDictSetName(dict, "Type", "Page");
// Create the page object...
page = pdfioFileCreateObject(pdf, dict);
page = pdfioFileCreateObj(pdf, dict);
// Create a contents object to hold the contents of the page...
contents_dict = pdfioDictCreate(pdf);
@ -396,10 +396,10 @@ pdfioFileCreatePage(pdfio_file_t *pdf, // I - PDF file
pdfioDictSetName(contents_dict, "Filter", "FlateDecode");
#endif // !DEBUG
contents = pdfioFileCreateObject(pdf, contents_dict);
contents = pdfioFileCreateObj(pdf, contents_dict);
// Add the contents stream to the pages object and write it...
pdfioDictSetObject(dict, "Contents", contents);
pdfioDictSetObj(dict, "Contents", contents);
if (!pdfioObjClose(page))
return (NULL);
@ -416,11 +416,11 @@ pdfioFileCreatePage(pdfio_file_t *pdf, // I - PDF file
//
// '_pdfioFileFindMappedObject()' - Find a mapped object.
// '_pdfioFileFindMappedObj()' - Find a mapped object.
//
pdfio_obj_t * // O - Match object or `NULL` if none
_pdfioFileFindMappedObject(
_pdfioFileFindMappedObj(
pdfio_file_t *pdf, // I - Destination PDF file
pdfio_file_t *src_pdf, // I - Source PDF file
size_t src_number) // I - Source object number
@ -445,14 +445,14 @@ _pdfioFileFindMappedObject(
//
// 'pdfioFileFindObject()' - Find an object using its object number.
// 'pdfioFileFindObj()' - Find an object using its object number.
//
// This differs from @link pdfioFileGetObject@ which takes an index into the
// This differs from @link pdfioFileGetObj@ which takes an index into the
// list of objects while this function takes the object number.
//
pdfio_obj_t * // O - Object or `NULL` if not found
pdfioFileFindObject(
pdfioFileFindObj(
pdfio_file_t *pdf, // I - PDF file
size_t number) // I - Object number (1 to N)
{
@ -497,11 +497,11 @@ pdfioFileGetName(pdfio_file_t *pdf) // I - PDF file
//
// 'pdfioFileGetNumObjects()' - Get the number of objects in a PDF file.
// 'pdfioFileGetNumObjs()' - Get the number of objects in a PDF file.
//
size_t // O - Number of objects
pdfioFileGetNumObjects(
pdfioFileGetNumObjs(
pdfio_file_t *pdf) // I - PDF file
{
return (pdf ? pdf->num_objs : 0);
@ -520,11 +520,11 @@ pdfioFileGetNumPages(pdfio_file_t *pdf) // I - PDF file
//
// 'pdfioFileGetObject()' - Get an object from a PDF file.
// 'pdfioFileGetObj()' - Get an object from a PDF file.
//
pdfio_obj_t * // O - Object
pdfioFileGetObject(pdfio_file_t *pdf, // I - PDF file
pdfioFileGetObj(pdfio_file_t *pdf, // I - PDF file
size_t n) // I - Object index (starting at 0)
{
if (!pdf || n >= pdf->num_objs)
@ -876,7 +876,7 @@ load_pages(pdfio_file_t *pdf, // I - PDF file
for (i = 0, num_kids = pdfioArrayGetSize(kids); i < num_kids; i ++)
{
if (!load_pages(pdf, pdfioArrayGetObject(kids, i)))
if (!load_pages(pdf, pdfioArrayGetObj(kids, i)))
return (false);
}
}
@ -1080,7 +1080,7 @@ load_xref(pdfio_file_t *pdf, // I - PDF file
}
// Create a placeholder for the object in memory...
if (pdfioFileFindObject(pdf, (size_t)number))
if (pdfioFileFindObj(pdf, (size_t)number))
{
number ++;
continue; // Don't replace newer object...
@ -1089,7 +1089,7 @@ load_xref(pdfio_file_t *pdf, // I - PDF file
if (w[0] > 0 && buffer[0] == 2)
{
// Object streams need to be loaded into memory...
if ((obj = pdfioFileFindObject(pdf, (size_t)offset)) != NULL)
if ((obj = pdfioFileFindObj(pdf, (size_t)offset)) != NULL)
{
// Load it now...
if (!load_obj_stream(obj))
@ -1121,7 +1121,7 @@ load_xref(pdfio_file_t *pdf, // I - PDF file
for (i = 0; i < num_sobjs; i ++)
{
if ((obj = pdfioFileFindObject(pdf, sobjs[i])) != NULL)
if ((obj = pdfioFileFindObj(pdf, sobjs[i])) != NULL)
{
PDFIO_DEBUG("load_xref: Loading compressed object stream %lu (pdf=%p, obj->pdf=%p).\n", (unsigned long)sobjs[i], pdf, obj->pdf);
@ -1195,7 +1195,7 @@ load_xref(pdfio_file_t *pdf, // I - PDF file
continue; // Don't care about free objects...
// Create a placeholder for the object in memory...
if (pdfioFileFindObject(pdf, (size_t)number))
if (pdfioFileFindObj(pdf, (size_t)number))
continue; // Don't replace newer object...
if (!add_obj(pdf, (size_t)number, (unsigned short)generation, offset))
@ -1248,7 +1248,7 @@ load_xref(pdfio_file_t *pdf, // I - PDF file
// Once we have all of the xref tables loaded, get the important objects and
// build the pages array...
if ((pdf->root = pdfioDictGetObject(pdf->trailer, "Root")) == NULL)
if ((pdf->root = pdfioDictGetObj(pdf->trailer, "Root")) == NULL)
{
_pdfioFileError(pdf, "Missing Root object.");
return (false);
@ -1256,11 +1256,11 @@ load_xref(pdfio_file_t *pdf, // I - PDF file
PDFIO_DEBUG("load_xref: Root=%p(%lu)\n", pdf->root, (unsigned long)pdf->root->number);
pdf->info = pdfioDictGetObject(pdf->trailer, "Info");
pdf->encrypt = pdfioDictGetObject(pdf->trailer, "Encrypt");
pdf->info = pdfioDictGetObj(pdf->trailer, "Info");
pdf->encrypt = pdfioDictGetObj(pdf->trailer, "Encrypt");
pdf->id_array = pdfioDictGetArray(pdf->trailer, "ID");
return (load_pages(pdf, pdfioDictGetObject(pdfioObjGetDict(pdf->root), "Pages")));
return (load_pages(pdf, pdfioDictGetObj(pdfioObjGetDict(pdf->root), "Pages")));
}
@ -1278,10 +1278,10 @@ write_catalog(pdfio_file_t *pdf) // I - PDF file
return (false);
pdfioDictSetName(dict, "Type", "Catalog");
pdfioDictSetObject(dict, "Pages", pdf->pages_root);
pdfioDictSetObj(dict, "Pages", pdf->pages_root);
// TODO: Add support for all of the root object dictionary keys
if ((pdf->root = pdfioFileCreateObject(pdf, dict)) == NULL)
if ((pdf->root = pdfioFileCreateObj(pdf, dict)) == NULL)
return (false);
else
return (pdfioObjClose(pdf->root));
@ -1304,7 +1304,7 @@ write_pages(pdfio_file_t *pdf) // I - PDF file
return (false);
for (i = 0; i < pdf->num_pages; i ++)
pdfioArrayAppendObject(kids, pdf->pages[i]);
pdfioArrayAppendObj(kids, pdf->pages[i]);
pdfioDictSetNumber(pdf->pages_root->value.value.dict, "Count", pdf->num_pages);
pdfioDictSetArray(pdf->pages_root->value.value.dict, "Kids", kids);
@ -1374,11 +1374,11 @@ write_trailer(pdfio_file_t *pdf) // I - PDF file
pdf->trailer = pdfioDictCreate(pdf);
if (pdf->encrypt)
pdfioDictSetObject(pdf->trailer, "Encrypt", pdf->encrypt);
pdfioDictSetObj(pdf->trailer, "Encrypt", pdf->encrypt);
if (pdf->id_array)
pdfioDictSetArray(pdf->trailer, "ID", pdf->id_array);
pdfioDictSetObject(pdf->trailer, "Info", pdf->info);
pdfioDictSetObject(pdf->trailer, "Root", pdf->root);
pdfioDictSetObj(pdf->trailer, "Info", pdf->info);
pdfioDictSetObj(pdf->trailer, "Root", pdf->root);
pdfioDictSetNumber(pdf->trailer, "Size", pdf->num_objs + 1);
if (!_pdfioDictWrite(pdf->trailer, NULL))

View File

@ -85,11 +85,11 @@ pdfioObjCopy(pdfio_file_t *pdf, // I - PDF file
_pdfioObjLoad(srcobj);
// Create the new object...
if ((dstobj = _pdfioFileCreateObject(pdf, srcobj->pdf, NULL)) == NULL)
if ((dstobj = _pdfioFileCreateObj(pdf, srcobj->pdf, NULL)) == NULL)
return (NULL);
// Add new object to the cache of copied objects...
if (!_pdfioFileAddMappedObject(pdf, dstobj, srcobj))
if (!_pdfioFileAddMappedObj(pdf, dstobj, srcobj))
return (NULL);
// Copy the object's value...
@ -267,7 +267,7 @@ pdfioObjGetLength(pdfio_obj_t *obj) // I - Object
return (length);
}
if ((lenobj = pdfioDictGetObject(obj->value.value.dict, "Length")) == NULL)
if ((lenobj = pdfioDictGetObj(obj->value.value.dict, "Length")) == NULL)
{
_pdfioFileError(obj->pdf, "Unable to get length of stream.");
return (0);

View File

@ -287,13 +287,13 @@ extern pdfio_dict_t *_pdfioDictRead(pdfio_file_t *pdf, _pdfio_token_t *ts) PDFIO
extern bool _pdfioDictSetValue(pdfio_dict_t *dict, const char *key, _pdfio_value_t *value) PDFIO_INTERNAL;
extern bool _pdfioDictWrite(pdfio_dict_t *dict, off_t *length) PDFIO_INTERNAL;
extern bool _pdfioFileAddMappedObject(pdfio_file_t *pdf, pdfio_obj_t *dst_obj, pdfio_obj_t *src_obj) PDFIO_INTERNAL;
extern bool _pdfioFileAddMappedObj(pdfio_file_t *pdf, pdfio_obj_t *dst_obj, pdfio_obj_t *src_obj) PDFIO_INTERNAL;
extern bool _pdfioFileAddPage(pdfio_file_t *pdf, pdfio_obj_t *obj) PDFIO_INTERNAL;
extern bool _pdfioFileConsume(pdfio_file_t *pdf, size_t bytes) PDFIO_INTERNAL;
extern pdfio_obj_t *_pdfioFileCreateObject(pdfio_file_t *pdf, pdfio_file_t *srcpdf, _pdfio_value_t *value) PDFIO_INTERNAL;
extern pdfio_obj_t *_pdfioFileCreateObj(pdfio_file_t *pdf, pdfio_file_t *srcpdf, _pdfio_value_t *value) PDFIO_INTERNAL;
extern bool _pdfioFileDefaultError(pdfio_file_t *pdf, const char *message, void *data) PDFIO_INTERNAL;
extern bool _pdfioFileError(pdfio_file_t *pdf, const char *format, ...) PDFIO_FORMAT(2,3) PDFIO_INTERNAL;
extern pdfio_obj_t *_pdfioFileFindMappedObject(pdfio_file_t *pdf, pdfio_file_t *src_pdf, size_t src_number) PDFIO_INTERNAL;
extern pdfio_obj_t *_pdfioFileFindMappedObj(pdfio_file_t *pdf, pdfio_file_t *src_pdf, size_t src_number) PDFIO_INTERNAL;
extern bool _pdfioFileFlush(pdfio_file_t *pdf) PDFIO_INTERNAL;
extern int _pdfioFileGetChar(pdfio_file_t *pdf) PDFIO_INTERNAL;
extern bool _pdfioFileGets(pdfio_file_t *pdf, char *buffer, size_t bufsize) PDFIO_INTERNAL;

View File

@ -57,9 +57,9 @@ _pdfioValueCopy(pdfio_file_t *pdfdst, // I - Destination PDF file
switch (vsrc->type)
{
case PDFIO_VALTYPE_INDIRECT :
if ((obj = _pdfioFileFindMappedObject(pdfdst, pdfsrc, vsrc->value.indirect.number)) == NULL)
if ((obj = _pdfioFileFindMappedObj(pdfdst, pdfsrc, vsrc->value.indirect.number)) == NULL)
{
obj = pdfioObjCopy(pdfdst, pdfioFileFindObject(pdfsrc, vsrc->value.indirect.number));
obj = pdfioObjCopy(pdfdst, pdfioFileFindObj(pdfsrc, vsrc->value.indirect.number));
}
if (!obj)

16
pdfio.h
View File

@ -107,7 +107,7 @@ extern bool pdfioArrayAppendBoolean(pdfio_array_t *a, bool value) PDFIO_PUBLIC;
extern bool pdfioArrayAppendDict(pdfio_array_t *a, pdfio_dict_t *value) PDFIO_PUBLIC;
extern bool pdfioArrayAppendName(pdfio_array_t *a, const char *value) PDFIO_PUBLIC;
extern bool pdfioArrayAppendNumber(pdfio_array_t *a, double value) PDFIO_PUBLIC;
extern bool pdfioArrayAppendObject(pdfio_array_t *a, pdfio_obj_t *value) PDFIO_PUBLIC;
extern bool pdfioArrayAppendObj(pdfio_array_t *a, pdfio_obj_t *value) PDFIO_PUBLIC;
extern bool pdfioArrayAppendString(pdfio_array_t *a, const char *value) PDFIO_PUBLIC;
extern pdfio_array_t *pdfioArrayCopy(pdfio_file_t *pdf, pdfio_array_t *a) PDFIO_PUBLIC;
extern pdfio_array_t *pdfioArrayCreate(pdfio_file_t *pdf) PDFIO_PUBLIC;
@ -117,7 +117,7 @@ extern bool pdfioArrayGetBoolean(pdfio_array_t *a, size_t n) PDFIO_PUBLIC;
extern pdfio_dict_t *pdfioArrayGetDict(pdfio_array_t *a, size_t n) PDFIO_PUBLIC;
extern const char *pdfioArrayGetName(pdfio_array_t *a, size_t n) PDFIO_PUBLIC;
extern double pdfioArrayGetNumber(pdfio_array_t *a, size_t n) PDFIO_PUBLIC;
extern pdfio_obj_t *pdfioArrayGetObject(pdfio_array_t *a, size_t n) PDFIO_PUBLIC;
extern pdfio_obj_t *pdfioArrayGetObj(pdfio_array_t *a, size_t n) PDFIO_PUBLIC;
extern size_t pdfioArrayGetSize(pdfio_array_t *a) PDFIO_PUBLIC;
extern const char *pdfioArrayGetString(pdfio_array_t *a, size_t n) PDFIO_PUBLIC;
extern pdfio_valtype_t pdfioArrayGetType(pdfio_array_t *a, size_t n) PDFIO_PUBLIC;
@ -130,7 +130,7 @@ extern bool pdfioDictGetBoolean(pdfio_dict_t *dict, const char *key) PDFIO_PUBL
extern pdfio_dict_t *pdfioDictGetDict(pdfio_dict_t *dict, const char *key) PDFIO_PUBLIC;
extern const char *pdfioDictGetName(pdfio_dict_t *dict, const char *key) PDFIO_PUBLIC;
extern double pdfioDictGetNumber(pdfio_dict_t *dict, const char *key) PDFIO_PUBLIC;
extern pdfio_obj_t *pdfioDictGetObject(pdfio_dict_t *dict, const char *key) PDFIO_PUBLIC;
extern pdfio_obj_t *pdfioDictGetObj(pdfio_dict_t *dict, const char *key) PDFIO_PUBLIC;
extern pdfio_rect_t *pdfioDictGetRect(pdfio_dict_t *dict, const char *key, pdfio_rect_t *rect) PDFIO_PUBLIC;
extern const char *pdfioDictGetString(pdfio_dict_t *dict, const char *key) PDFIO_PUBLIC;
extern pdfio_valtype_t pdfioDictGetType(pdfio_dict_t *dict, const char *key) PDFIO_PUBLIC;
@ -141,22 +141,22 @@ extern bool pdfioDictSetDict(pdfio_dict_t *dict, const char *key, pdfio_dict_t
extern bool pdfioDictSetName(pdfio_dict_t *dict, const char *key, const char *value) PDFIO_PUBLIC;
extern bool pdfioDictSetNull(pdfio_dict_t *dict, const char *key) PDFIO_PUBLIC;
extern bool pdfioDictSetNumber(pdfio_dict_t *dict, const char *key, double value) PDFIO_PUBLIC;
extern bool pdfioDictSetObject(pdfio_dict_t *dict, const char *key, pdfio_obj_t *value) PDFIO_PUBLIC;
extern bool pdfioDictSetObj(pdfio_dict_t *dict, const char *key, pdfio_obj_t *value) PDFIO_PUBLIC;
extern bool pdfioDictSetRect(pdfio_dict_t *dict, const char *key, pdfio_rect_t *value) PDFIO_PUBLIC;
extern bool pdfioDictSetString(pdfio_dict_t *dict, const char *key, const char *value) PDFIO_PUBLIC;
extern bool pdfioDictSetStringf(pdfio_dict_t *dict, const char *key, const char *format, ...) PDFIO_PUBLIC PDFIO_FORMAT(3,4);
extern bool pdfioFileClose(pdfio_file_t *pdf) PDFIO_PUBLIC;
extern pdfio_file_t *pdfioFileCreate(const char *filename, const char *version, pdfio_rect_t *media_box, pdfio_rect_t *crop_box, pdfio_error_cb_t error_cb, void *error_data) PDFIO_PUBLIC;
extern pdfio_obj_t *pdfioFileCreateObject(pdfio_file_t *pdf, pdfio_dict_t *dict) PDFIO_PUBLIC;
extern pdfio_obj_t *pdfioFileCreateObj(pdfio_file_t *pdf, pdfio_dict_t *dict) PDFIO_PUBLIC;
// TODO: Add number, array, string, etc. versions of pdfioFileCreateObject?
extern pdfio_stream_t *pdfioFileCreatePage(pdfio_file_t *pdf, pdfio_dict_t *dict) PDFIO_PUBLIC;
extern pdfio_obj_t *pdfioFileFindObject(pdfio_file_t *pdf, size_t number) PDFIO_PUBLIC;
extern pdfio_obj_t *pdfioFileFindObj(pdfio_file_t *pdf, size_t number) PDFIO_PUBLIC;
extern pdfio_array_t *pdfioFileGetID(pdfio_file_t *pdf) PDFIO_PUBLIC;
extern const char *pdfioFileGetName(pdfio_file_t *pdf) PDFIO_PUBLIC;
extern size_t pdfioFileGetNumObjects(pdfio_file_t *pdf) PDFIO_PUBLIC;
extern size_t pdfioFileGetNumObjs(pdfio_file_t *pdf) PDFIO_PUBLIC;
extern size_t pdfioFileGetNumPages(pdfio_file_t *pdf) PDFIO_PUBLIC;
extern pdfio_obj_t *pdfioFileGetObject(pdfio_file_t *pdf, size_t n) PDFIO_PUBLIC;
extern pdfio_obj_t *pdfioFileGetObj(pdfio_file_t *pdf, size_t n) PDFIO_PUBLIC;
extern pdfio_obj_t *pdfioFileGetPage(pdfio_file_t *pdf, size_t n) PDFIO_PUBLIC;
extern const char *pdfioFileGetVersion(pdfio_file_t *pdf) PDFIO_PUBLIC;
extern pdfio_file_t *pdfioFileOpen(const char *filename, pdfio_error_cb_t error_cb, void *error_data) PDFIO_PUBLIC;

View File

@ -77,7 +77,6 @@ do_test_file(const char *filename) // I - PDF filename
num_pages; // Number of pages
pdfio_obj_t *obj; // Object
pdfio_dict_t *dict; // Object dictionary
const char *type; // Object type
// Try opening the file...
@ -87,7 +86,7 @@ do_test_file(const char *filename) // I - PDF filename
puts("PASS");
// Show basic stats...
num_objs = pdfioFileGetNumObjects(pdf);
num_objs = pdfioFileGetNumObjs(pdf);
num_pages = pdfioFileGetNumPages(pdf);
printf(" PDF %s, %d pages, %d objects.\n", pdfioFileGetVersion(pdf), (int)num_pages, (int)num_objs);
@ -108,7 +107,7 @@ do_test_file(const char *filename) // I - PDF filename
if (!pdfioDictGetRect(dict, "MediaBox", &media_box))
{
if ((obj = pdfioDictGetObject(dict, "Parent")) != NULL)
if ((obj = pdfioDictGetObj(dict, "Parent")) != NULL)
{
dict = pdfioObjGetDict(obj);
pdfioDictGetRect(dict, "MediaBox", &media_box);
@ -122,7 +121,7 @@ do_test_file(const char *filename) // I - PDF filename
// Show the associated value with each object...
for (n = 0; n < num_objs; n ++)
{
if ((obj = pdfioFileGetObject(pdf, n)) == NULL)
if ((obj = pdfioFileGetObj(pdf, n)) == NULL)
{
printf(" Unable to get object #%d.\n", (int)n);
}
@ -157,7 +156,6 @@ static int // O - Exit status
do_unit_tests(void)
{
int i; // Looping var
char filename[256]; // PDF filename
pdfio_file_t *pdf, // Test PDF file
*outpdf; // Output PDF file
bool error = false; // Error callback data
@ -214,21 +212,21 @@ do_unit_tests(void)
return (1);
// Create some image objects...
fputs("pdfioFileCreateImageObject(\"testfiles/color.jpg\"): ", stdout);
if ((color_jpg = pdfioFileCreateImageObject(outpdf, "testfiles/color.jpg", true)) != NULL)
fputs("pdfioFileCreateImageObj(\"testfiles/color.jpg\"): ", stdout);
if ((color_jpg = pdfioFileCreateImageObj(outpdf, "testfiles/color.jpg", true)) != NULL)
puts("PASS");
else
return (1);
fputs("pdfioFileCreateImageObject(\"testfiles/gray.jpg\"): ", stdout);
if ((gray_jpg = pdfioFileCreateImageObject(outpdf, "testfiles/gray.jpg", true)) != NULL)
fputs("pdfioFileCreateImageObj(\"testfiles/gray.jpg\"): ", stdout);
if ((gray_jpg = pdfioFileCreateImageObj(outpdf, "testfiles/gray.jpg", true)) != NULL)
puts("PASS");
else
return (1);
// Create fonts...
fputs("pdfioFileCreateBaseFontObject(\"Helvetica\"): ", stdout);
if ((helvetica = pdfioFileCreateBaseFontObject(outpdf, "Helvetica")) != NULL)
fputs("pdfioFileCreateBaseFontObj(\"Helvetica\"): ", stdout);
if ((helvetica = pdfioFileCreateBaseFontObj(outpdf, "Helvetica")) != NULL)
puts("PASS");
else
return (1);
@ -276,7 +274,7 @@ do_unit_tests(void)
return (1);
// Write a page with test images...
first_image = pdfioFileGetNumObjects(outpdf);
first_image = pdfioFileGetNumObjs(outpdf);
if (write_images(outpdf, 7, helvetica))
return (1);
@ -330,7 +328,7 @@ do_unit_tests(void)
// Verify the images
for (i = 0; i < 7; i ++)
verify_image(pdf, (size_t)(first_image + i));
verify_image(pdf, first_image + (size_t)i);
// Close the new PDF file...
fputs("pdfioFileClose(\"testpdfio-out.pdf\"): ", stdout);
@ -489,8 +487,8 @@ verify_image(pdfio_file_t *pdf, // I - PDF file
ssize_t bytes; // Bytes read from stream
printf("pdfioFileFindObject(%lu): ", (unsigned long)number);
if ((obj = pdfioFileFindObject(pdf, number)) != NULL)
printf("pdfioFileFindObj(%lu): ", (unsigned long)number);
if ((obj = pdfioFileFindObj(pdf, number)) != NULL)
puts("PASS");
else
return (1);
@ -550,9 +548,9 @@ verify_image(pdfio_file_t *pdf, // I - PDF file
{
for (x = 0, bufptr = buffer; x < 256; x ++, bufptr += 3)
{
bufptr[0] = y;
bufptr[1] = y + x;
bufptr[2] = y - x;
bufptr[0] = (unsigned char)y;
bufptr[1] = (unsigned char)(y + x);
bufptr[2] = (unsigned char)(y - x);
}
if ((bytes = pdfioStreamRead(st, line, sizeof(line))) != (ssize_t)sizeof(line))
@ -1040,7 +1038,7 @@ write_image_object(
pdfioDictSetDict(dict, "DecodeParms", decode);
// Create the image object...
if ((obj = pdfioFileCreateObject(pdf, dict)) == NULL)
if ((obj = pdfioFileCreateObj(pdf, dict)) == NULL)
return (NULL);
// Create the image stream and write the image...
@ -1051,9 +1049,9 @@ write_image_object(
{
for (x = 0, bufptr = buffer; x < 256; x ++, bufptr += 3)
{
bufptr[0] = y;
bufptr[1] = y + x;
bufptr[2] = y - x;
bufptr[0] = (unsigned char)y;
bufptr[1] = (unsigned char)(y + x);
bufptr[2] = (unsigned char)(y - x);
}
if (!pdfioStreamWrite(st, buffer, sizeof(buffer)))
@ -1182,7 +1180,7 @@ write_images(pdfio_file_t *pdf, // I - PDF file
for (p = _PDFIO_PREDICTOR_PNG_NONE; p <= _PDFIO_PREDICTOR_PNG_AUTO; p ++)
{
int i = p - _PDFIO_PREDICTOR_PNG_NONE;
int i = (int)p - _PDFIO_PREDICTOR_PNG_NONE;
snprintf(pname, sizeof(pname), "IM%d", p);
snprintf(plabel, sizeof(plabel), "PNG Predictor %d", p);
@ -1371,20 +1369,20 @@ write_png(pdfio_file_t *pdf, // I - PDF file
// Import the PNG test images
fputs("pdfioFileCreateImageObject(\"testfiles/pdfio-color.png\"): ", stdout);
if ((color = pdfioFileCreateImageObject(pdf, "testfiles/pdfio-color.png", false)) != NULL)
fputs("pdfioFileCreateImageObj(\"testfiles/pdfio-color.png\"): ", stdout);
if ((color = pdfioFileCreateImageObj(pdf, "testfiles/pdfio-color.png", false)) != NULL)
puts("PASS");
else
return (1);
fputs("pdfioFileCreateImageObject(\"testfiles/pdfio-gray.png\"): ", stdout);
if ((gray = pdfioFileCreateImageObject(pdf, "testfiles/pdfio-gray.png", false)) != NULL)
fputs("pdfioFileCreateImageObj(\"testfiles/pdfio-gray.png\"): ", stdout);
if ((gray = pdfioFileCreateImageObj(pdf, "testfiles/pdfio-gray.png", false)) != NULL)
puts("PASS");
else
return (1);
fputs("pdfioFileCreateImageObject(\"testfiles/pdfio-indexed.png\"): ", stdout);
if ((indexed = pdfioFileCreateImageObject(pdf, "testfiles/pdfio-indexed.png", false)) != NULL)
fputs("pdfioFileCreateImageObj(\"testfiles/pdfio-indexed.png\"): ", stdout);
if ((indexed = pdfioFileCreateImageObj(pdf, "testfiles/pdfio-indexed.png", false)) != NULL)
puts("PASS");
else
return (1);
@ -1572,8 +1570,8 @@ write_text(pdfio_file_t *pdf, // I - PDF file
// Create text font...
fputs("pdfioFileCreateBaseFontObject(\"Courier\"): ", stdout);
if ((courier = pdfioFileCreateBaseFontObject(pdf, "Courier")) != NULL)
fputs("pdfioFileCreateBaseFontObj(\"Courier\"): ", stdout);
if ((courier = pdfioFileCreateBaseFontObj(pdf, "Courier")) != NULL)
puts("PASS");
else
return (1);