# PDFio Programming Manual v1.3.2

Michael R Sweet

Copyright © 2021-2024 by Michael R Sweet

## Contents

- Introduction
  - Requirements
  - Installing pdfio
  - Visual Studio Project
  - Xcode Project
  - Detecting PDFio
  - Header Files
- API Overview
  - Reading PDF Files
  - Writing PDF Files
  - PDF Objects
  - PDF Streams
  - PDF Content Helper Functions
- Examples
  - Read PDF Metadata
  - Create PDF File With Text and Image
- Functions
  - pdfioArrayAppendArray
  - pdfioArrayAppendBinary
  - pdfioArrayAppendBoolean
  - pdfioArrayAppendDate
  - pdfioArrayAppendDict
  - pdfioArrayAppendName
  - pdfioArrayAppendNumber
  - pdfioArrayAppendObj
  - pdfioArrayAppendString
  - pdfioArrayCopy
  - pdfioArrayCreate
  - pdfioArrayCreateColorFromICCObj
  - pdfioArrayCreateColorFromMatrix
  - pdfioArrayCreateColorFromPalette
  - pdfioArrayCreateColorFromPrimaries
  - pdfioArrayCreateColorFromStandard
  - pdfioArrayGetArray
  - pdfioArrayGetBinary
  - pdfioArrayGetBoolean
  - pdfioArrayGetDate
  - pdfioArrayGetDict
  - pdfioArrayGetName
  - pdfioArrayGetNumber
  - pdfioArrayGetObj
  - pdfioArrayGetSize
  - pdfioArrayGetString
  - pdfioArrayGetType
  - pdfioContentClip
  - pdfioContentDrawImage
  - pdfioContentFill
  - pdfioContentFillAndStroke
  - pdfioContentMatrixConcat
  - pdfioContentMatrixRotate
  - pdfioContentMatrixScale
  - pdfioContentMatrixTranslate
  - pdfioContentPathClose
  - pdfioContentPathCurve
  - pdfioContentPathCurve13
  - pdfioContentPathCurve23
  - pdfioContentPathEnd
  - pdfioContentPathLineTo
  - pdfioContentPathMoveTo
  - pdfioContentPathRect
  - pdfioContentRestore
  - pdfioContentSave
  - pdfioContentSetDashPattern
  - pdfioContentSetFillColorDeviceCMYK
  - pdfioContentSetFillColorDeviceGray
  - pdfioContentSetFillColorDeviceRGB
  - pdfioContentSetFillColorGray
  - pdfioContentSetFillColorRGB
  - pdfioContentSetFillColorSpace
  - pdfioContentSetFlatness
  - pdfioContentSetLineCap
  - pdfioContentSetLineJoin
  - pdfioContentSetLineWidth
  - pdfioContentSetMiterLimit
  - pdfioContentSetStrokeColorDeviceCMYK
  - pdfioContentSetStrokeColorDeviceGray
  - pdfioContentSetStrokeColorDeviceRGB
  - pdfioContentSetStrokeColorGray
  - pdfioContentSetStrokeColorRGB
  - pdfioContentSetStrokeColorSpace
  - pdfioContentSetTextCharacterSpacing
  - pdfioContentSetTextFont
  - pdfioContentSetTextLeading
  - pdfioContentSetTextMatrix
  - pdfioContentSetTextRenderingMode
  - pdfioContentSetTextRise
  - pdfioContentSetTextWordSpacing
  - pdfioContentSetTextXScaling
  - pdfioContentStroke
  - pdfioContentTextBegin
  - pdfioContentTextEnd
  - pdfioContentTextMeasure
  - pdfioContentTextMoveLine
  - pdfioContentTextMoveTo
  - pdfioContentTextNewLine
  - pdfioContentTextNewLineShow
  - pdfioContentTextNewLineShowf
  - pdfioContentTextShow
  - pdfioContentTextShowJustified
  - pdfioContentTextShowf
  - pdfioDictCopy
  - pdfioDictCreate
  - pdfioDictGetArray
  - pdfioDictGetBinary
  - pdfioDictGetBoolean
  - pdfioDictGetDate
  - pdfioDictGetDict
  - pdfioDictGetName
  - pdfioDictGetNumber
  - pdfioDictGetObj
  - pdfioDictGetRect
  - pdfioDictGetString
  - pdfioDictGetType
  - pdfioDictIterateKeys
  - pdfioDictSetArray
  - pdfioDictSetBinary
  - pdfioDictSetBoolean
  - pdfioDictSetDate
  - pdfioDictSetDict
  - pdfioDictSetName
  - pdfioDictSetNull
  - pdfioDictSetNumber
  - pdfioDictSetObj
  - pdfioDictSetRect
  - pdfioDictSetString
  - pdfioDictSetStringf
  - pdfioFileClose
  - pdfioFileCreate
  - pdfioFileCreateArrayObj
  - pdfioFileCreateFontObjFromBase
  - pdfioFileCreateFontObjFromFile
  - pdfioFileCreateICCObjFromFile
  - pdfioFileCreateImageObjFromData
  - pdfioFileCreateImageObjFromFile
  - pdfioFileCreateNumberObj
  - pdfioFileCreateObj
  - pdfioFileCreateOutput
  - pdfioFileCreatePage
  - pdfioFileCreateStringObj
  - pdfioFileCreateTemporary
  - pdfioFileFindObj
  - pdfioFileGetAuthor
  - pdfioFileGetCatalog
  - pdfioFileGetCreationDate
  - pdfioFileGetCreator
  - pdfioFileGetID
  - pdfioFileGetKeywords
  - pdfioFileGetName
  - pdfioFileGetNumObjs
  - pdfioFileGetNumPages
  - pdfioFileGetObj
  - pdfioFileGetPage
  - pdfioFileGetPermissions
  - pdfioFileGetProducer
  - pdfioFileGetSubject
  - pdfioFileGetTitle
  - pdfioFileGetVersion
  - pdfioFileOpen
  - pdfioFileSetAuthor
  - pdfioFileSetCreationDate
  - pdfioFileSetCreator
  - pdfioFileSetKeywords
  - pdfioFileSetPermissions
  - pdfioFileSetSubject
  - pdfioFileSetTitle
  - pdfioImageGetBytesPerLine
  - pdfioImageGetHeight
  - pdfioImageGetWidth
  - pdfioObjClose
  - pdfioObjCopy
  - pdfioObjCreateStream
  - pdfioObjGetArray
  - pdfioObjGetDict
  - pdfioObjGetGeneration
  - pdfioObjGetLength
  - pdfioObjGetNumber
  - pdfioObjGetSubtype
  - pdfioObjGetType
  - pdfioObjOpenStream
  - pdfioPageCopy
  - pdfioPageDictAddColorSpace
  - pdfioPageDictAddFont
  - pdfioPageDictAddImage
  - pdfioPageGetNumStreams
  - pdfioPageOpenStream
  - pdfioStreamClose
  - pdfioStreamConsume
  - pdfioStreamGetToken
  - pdfioStreamPeek
  - pdfioStreamPrintf
  - pdfioStreamPutChar
  - pdfioStreamPuts
  - pdfioStreamRead
  - pdfioStreamWrite
  - pdfioStringCreate
  - pdfioStringCreatef
- Data Types
  - pdfio_array_t
  - pdfio_cs_t
  - pdfio_dict_cb_t
  - pdfio_dict_t
  - pdfio_encryption_t
  - pdfio_error_cb_t
  - pdfio_file_t
  - pdfio_filter_t
  - pdfio_linecap_t
  - pdfio_linejoin_t
  - pdfio_matrix_t[3][2]
  - pdfio_obj_t
  - pdfio_output_cb_t
  - pdfio_password_cb_t
  - pdfio_permission_t
  - pdfio_rect_t
  - pdfio_stream_t
  - pdfio_textrendering_t
  - pdfio_valtype_t
- Structures
  - pdfio_rect_s
- Enumerations
  - pdfio_cs_e
  - pdfio_encryption_e
  - pdfio_filter_e
  - pdfio_linecap_e
  - pdfio_linejoin_e
  - pdfio_permission_e
  - pdfio_textrendering_e
  - pdfio_valtype_e

## Introduction

PDFio is a simple C library for reading and writing PDF files. The primary goals of pdfio are:

- Read and write any version of PDF file

- Provide access to pages, objects, and streams within a PDF file

- Support reading and writing of encrypted PDF files

- Extract or embed useful metadata (author, creator, page information, etc.)

- "Filter" PDF files, for example to extract a range of pages or to embed fonts that are missing from a PDF

- Provide access to objects used for each page

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-2024 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

- A POSIX-compliant `sh` 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 configure script that creates a portable makefile that will work on any POSIX-compliant system with ZLIB installed. To make it, run:

    ./configure
    make

To test it, run:

    make test

To install it, run:

    sudo make install

If you want a shared library, run:

    ./configure --enable-shared
    make
    sudo make install

The default installation location is "/usr/local". Pass the `--prefix` option to make to install it to another location:

    ./configure --prefix=/some/other/directory

Other configure options can be found using the `--help` option:

    ./configure --help

### Visual Studio Project

The Visual Studio solution ("pdfio.sln") is provided for Windows developers and 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

### 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:

    CFLAGS  +=      `pkg-config --cflags pdfio`
    LIBS    +=      `pkg-config --libs pdfio`

On Windows, you need to link to the `PDFIO1.LIB` (DLL) library and include the `zlib_native` NuGet package dependency. You can also use the published `pdfio_native` NuGet package.

### Header Files

PDFio provides a primary header file that is always used:

    #include <pdfio.h>

PDFio also provides PDF content helper functions for producing PDF content that are defined in a separate header file:

    #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

### Reading PDF Files

You open an existing PDF file using the `pdfioFileOpen` function:

    pdfio_file_t *pdf = pdfioFileOpen("myinputfile.pdf", password_cb, password_data,
                                      error_cb, error_data);

where the five arguments to the function are the filename ("myinputfile.pdf"), an optional password callback function (`password_cb`) and data pointer value (`password_data`), and an optional error callback function (`error_cb`) and data pointer value (`error_data`). The password callback is called for encrypted PDF files that are not using the default password, for example:

    const char *
    password_cb(void *data, const char *filename)
    {
      (void)data;     // This callback doesn't use the data pointer
      (void)filename; // This callback doesn't use the filename

      // Return a password string for the file...
      return ("Password42");
    }

The error callback is called for both errors and warnings and accepts the `pdfio_file_t` pointer, a message string, and the callback pointer value, for example:

    bool
    error_cb(pdfio_file_t *pdf, const char *message, void *data)
    {
      (void)data; // This callback does not use the data pointer

      fprintf(stderr, "%s: %s\n", pdfioFileGetName(pdf), message);

      // Return false to treat warnings as errors
      return (false);
    }

The default error callback (`NULL`) does the equivalent of the above.

Each PDF file contains one or more pages. The `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
    size_t       count;  // Number of pages
    pdfio_obj_t  *page;  // Current page

    // Iterate the pages in the PDF file
    for (i = 0, count = pdfioFileGetNumPages(pdf); i < count; i ++)
    {
      page = pdfioFileGetPage(pdf, i);
      // do something with page
    }

Each page is represented by a "page tree" object (what `pdfioFileGetPage` returns) that specifies information about the page and one or more "content" objects that contain the images, fonts, text, and graphics that appear on the page. Use the `pdfioPageGetNumStreams` and `pdfioPageOpenStream` functions to access the content streams for each page, and `pdfioObjGetDict` to get the associated page object dictionary. For example, if you want to display the media and crop boxes for a given page:

    pdfio_file_t  *pdf;             // PDF file
    size_t        i;                // Looping var
    size_t        count;            // Number of pages
    pdfio_obj_t   *page;            // Current page
    pdfio_dict_t  *dict;            // Current page dictionary
    pdfio_array_t *media_box;       // MediaBox array
    double        media_values[4];  // MediaBox values
    pdfio_array_t *crop_box;        // CropBox array
    double        crop_values[4];   // CropBox values

    // Iterate the pages in the PDF file
    for (i = 0, count = pdfioFileGetNumPages(pdf); i < count; i ++)
    {
      page = pdfioFileGetPage(pdf, i);
      dict = pdfioObjGetDict(page);

      media_box       = pdfioDictGetArray(dict, "MediaBox");
      media_values[0] = pdfioArrayGetNumber(media_box, 0);
      media_values[1] = pdfioArrayGetNumber(media_box, 1);
      media_values[2] = pdfioArrayGetNumber(media_box, 2);
      media_values[3] = pdfioArrayGetNumber(media_box, 3);

      crop_box       = pdfioDictGetArray(dict, "CropBox");
      crop_values[0] = pdfioArrayGetNumber(crop_box, 0);
      crop_values[1] = pdfioArrayGetNumber(crop_box, 1);
      crop_values[2] = pdfioArrayGetNumber(crop_box, 2);
      crop_values[3] = pdfioArrayGetNumber(crop_box, 3);

      printf("Page %u: MediaBox=[%g %g %g %g], CropBox=[%g %g %g %g]\n",
             (unsigned)(i + 1),
             media_values[0], media_values[1], media_values[2], media_values[3],
             crop_values[0], crop_values[1], crop_values[2], crop_values[3]);
    }

Page object dictionaries have several (mostly optional) key/value pairs, including:

- "Annots": An array of annotation dictionaries for the page; use `pdfioDictGetArray` to get the array

- "CropBox": The crop box as an array of four numbers for the left, bottom, right, and top coordinates of the target media; use `pdfioDictGetArray` to get a pointer to the array of numbers

- "Dur": The number of seconds the page should be displayed; use `pdfioDictGetNumber` to get the page duration value

- "Group": The dictionary of transparency group values for the page; use `pdfioDictGetDict` to get a pointer to the resources dictionary

- "LastModified": The date and time when this page was last modified; use `pdfioDictGetDate` to get the Unix `time_t` value

- "Parent": The parent page tree node object for this page; use `pdfioDictGetObj` to get a pointer to the object

- "MediaBox": The media box as an array of four numbers for the left, bottom, right, and top coordinates of the target media; use `pdfioDictGetArray` to get a pointer to the array of numbers

- "Resources": The dictionary of resources for the page; use `pdfioDictGetDict` to get a pointer to the resources dictionary

- "Rotate": A number indicating the number of degrees of counter-clockwise rotation to apply to the page when viewing; use `pdfioDictGetNumber` to get the rotation angle

- "Thumb": A thumbnail image object for the page; use `pdfioDictGetObj` to get a pointer to the thumbnail image object

- "Trans": The page transition dictionary; use `pdfioDictGetDict` to get a pointer to the dictionary

The `pdfioFileClose` function closes a PDF file and frees all memory that was used for it:

    pdfioFileClose(pdf);

### Writing PDF Files

You create a new PDF file using the `pdfioFileCreate` function:

    pdfio_rect_t media_box = { 0.0, 0.0, 612.0, 792.0 };  // US Letter
    pdfio_rect_t crop_box = { 36.0, 36.0, 576.0, 756.0 }; // w/0.5" margins

    pdfio_file_t *pdf = pdfioFileCreate("myoutputfile.pdf", "2.0", &media_box, &crop_box, error_cb, error_data);

where the six arguments to the function are the filename ("myoutputfile.pdf"), PDF version ("2.0"), media box (`media_box`), crop box (`crop_box`), an optional error callback function (`error_cb`), and an optional pointer value for the error callback function (`error_data`). The units for the media and crop boxes are points (1/72nd of an inch).

Alternately you can stream a PDF file using the `pdfioFileCreateOutput` function:

    pdfio_rect_t media_box = { 0.0, 0.0, 612.0, 792.0 };  // US Letter
    pdfio_rect_t crop_box = { 36.0, 36.0, 576.0, 756.0 }; // w/0.5" margins

    pdfio_file_t *pdf = pdfioFileCreateOutput(output_cb, output_ctx, "2.0", &media_box, &crop_box, error_cb, error_data);

Once the file is created, use the `pdfioFileCreateObj`, `pdfioFileCreatePage`, and `pdfioPageCopy` functions to create objects and pages in the file.

Finally, the `pdfioFileClose` function writes the PDF cross-reference and "trailer" information, closes the file, and frees all memory that was used for it.

### PDF Objects

PDF objects are identified using two numbers - the object number (1 to N) and the object generation (0 to 65535) that specifies a particular version of an object. An object's numbers are returned by the `pdfioObjGetNumber` and `pdfioObjGetGeneration` functions. You can find a numbered object using the `pdfioFileFindObj` function.

Objects contain values (typically dictionaries) and usually an associated data stream containing images, fonts, ICC profiles, and page content. PDFio provides several accessor functions to get the value(s) associated with an object:

- `pdfioObjGetArray` returns an object's array value, if any

- `pdfioObjGetDict` returns an object's dictionary value, if any

- `pdfioObjGetLength` returns the length of the data stream, if any

- `pdfioObjGetSubtype` returns the sub-type name of the object, for example "Image" for an image object.

- `pdfioObjGetType` returns the type name of the object, for example "XObject" for an image object.

### PDF Streams

Some PDF objects have an associated data stream, such as for pages, images, ICC color profiles, and fonts. You access the stream for an existing object using the `pdfioObjOpenStream` function:

    pdfio_file_t *pdf = pdfioFileOpen(...);
    pdfio_obj_t *obj = pdfioFileFindObj(pdf, number);
    pdfio_stream_t *st = pdfioObjOpenStream(obj, true);

The first argument is the object pointer. The second argument is a boolean value that specifies whether you want to decode (typically decompress) the stream data or return it as-is.

When reading a page stream you'll use the `pdfioPageOpenStream` function instead:

    pdfio_file_t *pdf = pdfioFileOpen(...);
    pdfio_obj_t *obj = pdfioFileGetPage(pdf, number);
    pdfio_stream_t *st = pdfioPageOpenStream(obj, 0, true);

Once you have the stream open, you can use one of several functions to read from it:

- `pdfioStreamConsume` reads and discards a number of bytes in the stream

- `pdfioStreamGetToken` reads a PDF token from the stream

- `pdfioStreamPeek` peeks at the next stream data without advancing or "consuming" it

- `pdfioStreamRead` reads a buffer of data

When you are done reading from the stream, call the `pdfioStreamClose` function:

    pdfioStreamClose(st);

To create a stream for a new object, call the `pdfioObjCreateStream` function:

    pdfio_file_t *pdf = pdfioFileCreate(...);
    pdfio_obj_t *obj = pdfioFileCreateObj(pdf, ...);
    pdfio_stream_t *st = pdfioObjCreateStream(obj, PDFIO_FILTER_FLATE);

The first argument is the newly created object. The second argument is either `PDFIO_FILTER_NONE` to specify that any encoding is done by your program or `PDFIO_FILTER_FLATE` to specify that PDFio should Flate compress the stream.

To create a page content stream call the `pdfioFileCreatePage` function:

    pdfio_file_t *pdf = pdfioFileCreate(...);
    pdfio_dict_t *dict = pdfioDictCreate(pdf);
    ... set page dictionary keys and values ...
    pdfio_stream_t *st = pdfioFileCreatePage(pdf, dict);

Once you have created the stream, use any of the following functions to write to the stream:

- `pdfioStreamPrintf` writes a formatted string to the stream

- `pdfioStreamPutChar` writes a single character to the stream

- `pdfioStreamPuts` writes a C string to the stream

- `pdfioStreamWrite` writes a buffer of data to the stream

The PDF content helper functions provide additional functions for writing specific PDF page stream commands.

When you are done writing the stream, call `pdfioStreamClose` to close both the stream and the object.

### PDF Content Helper Functions

PDFio includes many helper functions for embedding or writing specific kinds of content to a PDF file. These functions can be roughly grouped into five categories:

- Color Space Functions

- Font Object Functions

- Image Object Functions

- Page Stream Functions

- Page Dictionary Functions

#### Color Space Functions

PDF color spaces are specified using well-known names like "DeviceCMYK", "DeviceGray", and "DeviceRGB" or using arrays that define so-called calibrated color spaces. PDFio provides several functions for embedding ICC profiles and creating color space arrays:

- `pdfioArrayCreateColorFromICCObj` creates a color array for an ICC color profile object

- `pdfioArrayCreateColorFromMatrix` creates a color array using a CIE XYZ color transform matrix, a gamma value, and a CIE XYZ white point

- `pdfioArrayCreateColorFromPalette` creates an indexed color array from an array of sRGB values

- `pdfioArrayCreateColorFromPrimaries` creates a color array using CIE XYZ primaries and a gamma value

- `pdfioArrayCreateColorFromStandard` creates a color array for a standard color space

You can embed an ICC color profile using the `pdfioFileCreateICCObjFromFile` function:

    pdfio_file_t *pdf = pdfioFileCreate(...);
    pdfio_obj_t *icc = pdfioFileCreateICCObjFromFile(pdf, "filename.icc");

where the first argument is the PDF file and the second argument is the filename of the ICC color profile.

PDFio also includes predefined constants for creating a few standard color spaces:

    pdfio_file_t *pdf = pdfioFileCreate(...);

    // Create an AdobeRGB color array
    pdfio_array_t *adobe_rgb = pdfioArrayCreateColorFromStandard(pdf, 3, PDFIO_CS_ADOBE);

    // Create an Display P3 color array
    pdfio_array_t *display_p3 = pdfioArrayCreateColorFromStandard(pdf, 3, PDFIO_CS_P3_D65);

    // Create an sRGB color array
    pdfio_array_t *srgb = pdfioArrayCreateColorFromStandard(pdf, 3, PDFIO_CS_SRGB);

#### Font Object Functions

PDF supports many kinds of fonts, including PostScript Type1, PDF Type3, TrueType/OpenType, and CID. PDFio provides two functions for creating font objects. The first is `pdfioFileCreateFontObjFromBase` which creates a font object for one of the base PDF fonts:

- "Courier"

- "Courier-Bold"

- "Courier-BoldItalic"

- "Courier-Italic"

- "Helvetica"

- "Helvetica-Bold"

- "Helvetica-BoldOblique"

- "Helvetica-Oblique"

- "Symbol"

- "Times-Bold"

- "Times-BoldItalic"

- "Times-Italic"

- "Times-Roman"

- "ZapfDingbats"

PDFio always uses the Windows CP1252 subset of Unicode for these fonts.

The second function is `pdfioFileCreateFontObjFromFile` which creates a font object from a TrueType/OpenType font file, for example:

    pdfio_file_t *pdf = pdfioFileCreate(...);
    pdfio_obj_t *arial = pdfioFileCreateFontObjFromFile(pdf, "OpenSans-Regular.ttf", false);

will embed an OpenSans Regular TrueType font using the Windows CP1252 subset of Unicode. Pass `true` for the third argument to embed it as a Unicode CID font instead, for example:

    pdfio_file_t *pdf = pdfioFileCreate(...);
    pdfio_obj_t *arial = pdfioFileCreateFontObjFromFile(pdf, "NotoSansJP-Regular.otf", true);

will embed the NotoSansJP Regular OpenType font with full support for Unicode.

> Note: Not all fonts support Unicode.

#### Image Object Functions

PDF supports images with many different color spaces and bit depths with optional transparency. PDFio provides two helper functions for creating image objects that can be referenced in page streams. The first function is `pdfioFileCreateImageObjFromData` which creates an image object from data in memory, for example:

    pdfio_file_t *pdf = pdfioFileCreate(...);
    unsigned char data[1024 * 1024 * 4]; // 1024x1024 RGBA image data
    pdfio_obj_t *img = pdfioFileCreateImageObjFromData(pdf, data, /*width*/1024, /*height*/1024, /*num_colors*/3, /*color_data*/NULL, /*alpha*/true, /*interpolate*/false);

will create an object for a 1024x1024 RGBA image in memory, using the default color space for 3 colors ("DeviceRGB"). We can use one of the color space functions to use a specific color space for this image, for example:

    pdfio_file_t *pdf = pdfioFileCreate(...);

    // Create an AdobeRGB color array
    pdfio_array_t *adobe_rgb = pdfioArrayCreateColorFromMatrix(pdf, 3, pdfioAdobeRGBGamma, pdfioAdobeRGBMatrix, pdfioAdobeRGBWhitePoint);

    // Create a 1024x1024 RGBA image using AdobeRGB
    unsigned char data[1024 * 1024 * 4]; // 1024x1024 RGBA image data
    pdfio_obj_t *img = pdfioFileCreateImageObjFromData(pdf, data, /*width*/1024, /*height*/1024, /*num_colors*/3, /*color_data*/adobe_rgb, /*alpha*/true, /*interpolate*/false);

The "interpolate" argument specifies whether the colors in the image should be smoothed/interpolated when scaling. This is most useful for photographs but should be `false` for screenshot and barcode images.

If you have a JPEG or PNG file, use the `pdfioFileCreateImageObjFromFile` function to copy the image into a PDF image object, for example:

    pdfio_file_t *pdf = pdfioFileCreate(...);
    pdfio_obj_t *img = pdfioFileCreateImageObjFromFile(pdf, "myphoto.jpg", /*interpolate*/true);

#### Page Dictionary Functions

PDF pages each have an associated dictionary to specify the images, fonts, and color spaces used by the page. PDFio provides functions to add these resources to the dictionary:

- `pdfioPageDictAddColorSpace` adds a named color space to the page dictionary

- `pdfioPageDictAddFont` adds a named font to the page dictionary

- `pdfioPageDictAddImage` adds a named image to the page dictionary

#### Page Stream Functions

PDF page streams contain textual commands for drawing on the page. PDFio provides many functions for writing these commands with the correct format and escaping, as needed:

- `pdfioContentClip` clips future drawing to the current path

- `pdfioContentDrawImage` draws an image object

- `pdfioContentFill` fills the current path

- `pdfioContentFillAndStroke` fills and strokes the current path

- `pdfioContentMatrixConcat` concatenates a matrix with the current transform matrix

- `pdfioContentMatrixRotate` concatenates a rotation matrix with the current transform matrix

- `pdfioContentMatrixScale` concatenates a scaling matrix with the current transform matrix

- `pdfioContentMatrixTranslate` concatenates a translation matrix with the current transform matrix

- `pdfioContentPathClose` closes the current path

- `pdfioContentPathCurve` appends a Bezier curve to the current path

- `pdfioContentPathCurve13` appends a Bezier curve with 2 control points to the current path

- `pdfioContentPathCurve23` appends a Bezier curve with 2 control points to the current path

- `pdfioContentPathLineTo` appends a line to the current path

- `pdfioContentPathMoveTo` moves the current point in the current path

- `pdfioContentPathRect` appends a rectangle to the current path

- `pdfioContentRestore` restores a previous graphics state

- `pdfioContentSave` saves the current graphics state

- `pdfioContentSetDashPattern` sets the line dash pattern

- `pdfioContentSetFillColorDeviceCMYK` sets the current fill color using a device CMYK color

- `pdfioContentSetFillColorDeviceGray` sets the current fill color using a device gray color

- `pdfioContentSetFillColorDeviceRGB` sets the current fill color using a device RGB color

- `pdfioContentSetFillColorGray` sets the current fill color using a calibrated gray color

- `pdfioContentSetFillColorRGB` sets the current fill color using a calibrated RGB color

- `pdfioContentSetFillColorSpace` sets the current fill color space

- `pdfioContentSetFlatness` sets the flatness for curves

- `pdfioContentSetLineCap` sets how the ends of lines are stroked

- `pdfioContentSetLineJoin` sets how connections between lines are stroked

- `pdfioContentSetLineWidth` sets the width of stroked lines

- `pdfioContentSetMiterLimit` sets the miter limit for stroked lines

- `pdfioContentSetStrokeColorDeviceCMYK` sets the current stroke color using a device CMYK color

- `pdfioContentSetStrokeColorDeviceGray` sets the current stroke color using a device gray color

- `pdfioContentSetStrokeColorDeviceRGB` sets the current stroke color using a device RGB color

- `pdfioContentSetStrokeColorGray` sets the current stroke color using a calibrated gray color

- `pdfioContentSetStrokeColorRGB` sets the current stroke color using a calibrated RGB color

- `pdfioContentSetStrokeColorSpace` sets the current stroke color space

- `pdfioContentSetTextCharacterSpacing` sets the spacing between characters for text

- `pdfioContentSetTextFont` sets the font and size for text

- `pdfioContentSetTextLeading` sets the line height for text

- `pdfioContentSetTextMatrix` concatenates a matrix with the current text matrix

- `pdfioContentSetTextRenderingMode` sets the text rendering mode

- `pdfioContentSetTextRise` adjusts the baseline for text

- `pdfioContentSetTextWordSpacing` sets the spacing between words for text

- `pdfioContentSetTextXScaling` sets the horizontal scaling for text

- `pdfioContentStroke` strokes the current path

- `pdfioContentTextBegin` begins a block of text

- `pdfioContentTextEnd` ends a block of text

- `pdfioContentTextMoveLine` moves to the next line with an offset in a text block

- `pdfioContentTextMoveTo` moves within the current line in a text block

- `pdfioContentTextNewLine` moves to the beginning of the next line in a text block

- `pdfioContentTextNewLineShow` moves to the beginning of the next line in a text block and shows literal text with optional word and character spacing

- `pdfioContentTextNewLineShowf` moves to the beginning of the next line in a text block and shows formatted text with optional word and character spacing

- `pdfioContentTextShow` draws a literal string in a text block

- `pdfioContentTextShowf` draws a formatted string in a text block

- `pdfioContentTextShowJustified` draws an array of literal strings with offsets between them

## Examples

### Read PDF Metadata

The following example function will open a PDF file and print the title, author, creation date, and number of pages:

    #include <pdfio.h>
    #include <time.h>

    void
    show_pdf_info(const char *filename)
    {
      pdfio_file_t *pdf;
      time_t       creation_date;
      struct tm    *creation_tm;
      char         creation_text[256];

      // Open the PDF file with the default callbacks...
      pdf = pdfioFileOpen(filename, /*password_cb*/NULL, /*password_cbdata*/NULL, /*error_cb*/NULL, /*error_cbdata*/NULL);
      if (pdf == NULL)
        return;

      // Get the creation date and convert to a string...
      creation_date = pdfioFileGetCreationDate(pdf);
      creation_tm   = localtime(&creation_date);
      strftime(creation_text, sizeof(creation_text), "%c", &creation_tm);

      // Print file information to stdout...
      printf("%s:\n", filename);
      printf("         Title: %s\n", pdfioFileGetTitle(pdf));
      printf("        Author: %s\n", pdfioFileGetAuthor(pdf));
      printf("    Created On: %s\n", creation_text);
      printf("  Number Pages: %u\n", (unsigned)pdfioFileGetNumPages(pdf));

      // Close the PDF file...
      pdfioFileClose(pdf);
    }

### Create PDF File With Text and Image

The following example function will create a PDF file, embed a base font and the named JPEG or PNG image file, and then creates a page with the image centered on the page with the text centered below:

    #include <pdfio.h>
    #include <pdfio-content.h>
    #include <string.h>

    void
    create_pdf_image_file(const char *pdfname, const char *imagename, const char *caption)
    {
      pdfio_file_t   *pdf;
      pdfio_obj_t    *font;
      pdfio_obj_t    *image;
      pdfio_dict_t   *dict;
      pdfio_stream_t *page;
      double         width, height;
      double         swidth, sheight;
      double         tx, ty;

      // Create the PDF file...
      pdf = pdfioFileCreate(pdfname, /*version*/NULL, /*media_box*/NULL, /*crop_box*/NULL, /*error_cb*/NULL, /*error_cbdata*/NULL);

      // Create a Courier base font for the caption
      font = pdfioFileCreateFontObjFromBase(pdf, "Courier");

      // Create an image object from the JPEG/PNG image file...
      image = pdfioFileCreateImageObjFromFile(pdf, imagename, true);

      // Create a page dictionary with the font and image...
      dict = pdfioDictCreate(pdf);
      pdfioPageDictAddFont(dict, "F1", font);
      pdfioPageDictAddImage(dict, "IM1", image);

      // Create the page and its content stream...
      page = pdfioFileCreatePage(pdf, dict);

      // Position and scale the image on the page...
      width  = pdfioImageGetWidth(image);
      height = pdfioImageGetHeight(image);

      // Default media_box is "universal" 595.28x792 points (8.27x11in or 210x279mm)
      // Use margins of 36 points (0.5in or 12.7mm) with another 36 points for the
      // caption underneath...
      swidth  = 595.28 - 72.0;
      sheight = swidth * height / width;
      if (sheight > (792.0 - 36.0 - 72.0))
      {
        sheight = 792.0 - 36.0 - 72.0;
        swidth  = sheight * width / height;
      }

      tx = 0.5 * (595.28 - swidth);
      ty = 0.5 * (792 - 36 - sheight);

      pdfioContentDrawImage(page, "IM1", tx, ty + 36.0, swidth, sheight);

      // Draw the caption in black...
      pdfioContentSetFillColorDeviceGray(page, 0.0);

      // Compute the starting point for the text - Courier is monospaced with a
      // nominal width of 0.6 times the text height...
      tx = 0.5 * (595.28 - 18.0 * 0.6 * strlen(caption));

      // Position and draw the caption underneath...
      pdfioContentTextBegin(page);
      pdfioContentSetTextFont(page, "F1", 18.0);
      pdfioContentTextMoveTo(page, tx, ty);
      pdfioContentTextShow(page, /*unicode*/false, caption);
      pdfioContentTextEnd(page);

      // Close the page stream and the PDF file...
      pdfioStreamClose(page);
      pdfioFileClose(pdf);
    }

## Functions

### pdfioArrayAppendArray

Add an array value to an array.

bool pdfioArrayAppendArray(pdfio_array_t *a, pdfio_array_t *value);

#### Parameters

a | Array
value | Value

#### Return Value

`true` on success, `false` on failure

### pdfioArrayAppendBinary

Add a binary string value to an array.

bool pdfioArrayAppendBinary(pdfio_array_t *a, const unsigned char *value, size_t valuelen);

#### Parameters

a | Array
value | Value
valuelen | Length of value

#### Return Value

`true` on success, `false` on failure

### pdfioArrayAppendBoolean

Add a boolean value to an array.

bool pdfioArrayAppendBoolean(pdfio_array_t *a, bool value);

#### Parameters

a | Array
value | Value

#### Return Value

`true` on success, `false` on failure

### pdfioArrayAppendDate

Add a date value to an array.

bool pdfioArrayAppendDate(pdfio_array_t *a, time_t value);

#### Parameters

a | Array
value | Value

#### Return Value

`true` on success, `false` on failure

### pdfioArrayAppendDict

Add a dictionary to an array.

bool pdfioArrayAppendDict(pdfio_array_t *a, pdfio_dict_t *value);

#### Parameters

a | Array
value | Value

#### Return Value

`true` on success, `false` on failure

### pdfioArrayAppendName

Add a name to an array.

bool pdfioArrayAppendName(pdfio_array_t *a, const char *value);

#### Parameters

a | Array
value | Value

#### Return Value

`true` on success, `false` on failure

### pdfioArrayAppendNumber

Add a number to an array.

bool pdfioArrayAppendNumber(pdfio_array_t *a, double value);

#### Parameters

a | Array
value | Value

#### Return Value

`true` on success, `false` on failure

### pdfioArrayAppendObj

Add an indirect object reference to an array.

bool pdfioArrayAppendObj(pdfio_array_t *a, pdfio_obj_t *value);

#### Parameters

a | Array
value | Value

#### Return Value

`true` on success, `false` on failure

### pdfioArrayAppendString

Add a string to an array.

bool pdfioArrayAppendString(pdfio_array_t *a, const char *value);

#### Parameters

a | Array
value | Value

#### Return Value

`true` on success, `false` on failure

### pdfioArrayCopy

Copy an array.

pdfio_array_t *pdfioArrayCopy(pdfio_file_t *pdf, pdfio_array_t *a);

#### Parameters

pdf | PDF file
a | Original array

#### Return Value

New array or `NULL` on error

### pdfioArrayCreate

Create an empty array.

pdfio_array_t *pdfioArrayCreate(pdfio_file_t *pdf);

#### Parameters

pdf | PDF file

#### Return Value

New array or `NULL` on error

### pdfioArrayCreateColorFromICCObj

Create an ICC-based color space array.

pdfio_array_t *pdfioArrayCreateColorFromICCObj(pdfio_file_t *pdf, pdfio_obj_t *icc_object);

#### Parameters

pdf | PDF file
icc_object | ICC profile object

#### Return Value

Color array

### pdfioArrayCreateColorFromMatrix

Create a calibrated color space array using a CIE XYZ transform matrix.

pdfio_array_t *pdfioArrayCreateColorFromMatrix(pdfio_file_t *pdf, size_t num_colors, double gamma, const double matrix[3][3], const double white_point[3]);

#### Parameters

pdf | PDF file
num_colors | Number of colors (1 or 3)
gamma | Gamma value
matrix[3][3] | XYZ transform
white_point[3] | White point

#### Return Value

Color space array

### pdfioArrayCreateColorFromPalette

Create an indexed color space array.

pdfio_array_t *pdfioArrayCreateColorFromPalette(pdfio_file_t *pdf, size_t num_colors, const unsigned char *colors);

#### Parameters

pdf | PDF file
num_colors | Number of colors
colors | RGB values for colors

#### Return Value

Color array

### pdfioArrayCreateColorFromPrimaries

Create a calibrated color sapce array using CIE xy primary chromacities.

pdfio_array_t *pdfioArrayCreateColorFromPrimaries(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);

#### Parameters

pdf | PDF file
num_colors | Number of colors (1 or 3)
gamma | Gama value
wx | White point X chromacity
wy | White point Y chromacity
rx | Red X chromacity
ry | Red Y chromacity
gx | Green X chromacity
gy | Green Y chromacity
bx | Blue X chromacity
by | Blue Y chromacity

#### Return Value

Color space array

### pdfioArrayCreateColorFromStandard

Create a color array for a standard color space.

pdfio_array_t *pdfioArrayCreateColorFromStandard(pdfio_file_t *pdf, size_t num_colors, pdfio_cs_t cs);

#### Parameters

pdf | PDF file
num_colors | Number of colors (1 or 3)
cs | Color space enumeration

#### Return Value

Color array

#### Discussion

This function creates a color array for a standard `PDFIO_CS_` enumerated color space. The "num_colors" argument must be `1` for grayscale and `3` for RGB color.

### pdfioArrayGetArray

Get an array value from an array.

pdfio_array_t *pdfioArrayGetArray(pdfio_array_t *a, size_t n);

#### Parameters

a | Array
n | Index

#### Return Value

Value

### pdfioArrayGetBinary

Get a binary string value from an array.

unsigned char *pdfioArrayGetBinary(pdfio_array_t *a, size_t n, size_t *length);

#### Parameters

a | Array
n | Index
length | Length of string

#### Return Value

Value

### pdfioArrayGetBoolean

Get a boolean value from an array.

bool pdfioArrayGetBoolean(pdfio_array_t *a, size_t n);

#### Parameters

a | Array
n | Index

#### Return Value

Value

### pdfioArrayGetDate

Get a date value from an array.

time_t pdfioArrayGetDate(pdfio_array_t *a, size_t n);

#### Parameters

a | Array
n | Index

#### Return Value

Value

### pdfioArrayGetDict

Get a dictionary value from an array.

pdfio_dict_t *pdfioArrayGetDict(pdfio_array_t *a, size_t n);

#### Parameters

a | Array
n | Index

#### Return Value

Value

### pdfioArrayGetName

Get a name value from an array.

const char *pdfioArrayGetName(pdfio_array_t *a, size_t n);

#### Parameters

a | Array
n | Index

#### Return Value

Value

### pdfioArrayGetNumber

Get a number from an array.

double pdfioArrayGetNumber(pdfio_array_t *a, size_t n);

#### Parameters

a | Array
n | Index

#### Return Value

Value

### pdfioArrayGetObj

Get an indirect object reference from an array.

pdfio_obj_t *pdfioArrayGetObj(pdfio_array_t *a, size_t n);

#### Parameters

a | Array
n | Index

#### Return Value

Value

### pdfioArrayGetSize

Get the length of an array.

size_t pdfioArrayGetSize(pdfio_array_t *a);

#### Parameters

a | Array

#### Return Value

Length of array

### pdfioArrayGetString

Get a string value from an array.

const char *pdfioArrayGetString(pdfio_array_t *a, size_t n);

#### Parameters

a | Array
n | Index

#### Return Value

Value

### pdfioArrayGetType

Get a value type from an array.

pdfio_valtype_t pdfioArrayGetType(pdfio_array_t *a, size_t n);

#### Parameters

a | Array
n | Index

#### Return Value

Value type

### pdfioContentClip

Clip output to the current path.

bool pdfioContentClip(pdfio_stream_t *st, bool even_odd);

#### Parameters

st | Stream
even_odd | Even/odd fill vs. non-zero winding rule

#### Return Value

`true` on success, `false` on failure

### pdfioContentDrawImage

Draw an image object.

bool pdfioContentDrawImage(pdfio_stream_t *st, const char *name, double x, double y, double width, double height);

#### Parameters

st | Stream
name | Image name
x | X offset of image
y | Y offset of image
width | Width of image
height | Height of image

#### Return Value

`true` on success, `false` on failure

#### Discussion

The object name must be part of the page dictionary resources, typically using the `pdfioPageDictAddImage` function.

### pdfioContentFill

Fill the current path.

bool pdfioContentFill(pdfio_stream_t *st, bool even_odd);

#### Parameters

st | Stream
even_odd | Even/odd fill vs. non-zero winding rule

#### Return Value

`true` on success, `false` on failure

### pdfioContentFillAndStroke

Fill and stroke the current path.

bool pdfioContentFillAndStroke(pdfio_stream_t *st, bool even_odd);

#### Parameters

st | Stream
even_odd | Even/odd fill vs. non-zero winding

#### Return Value

`true` on success, `false` on failure

### pdfioContentMatrixConcat

Concatenate a matrix to the current graphics state.

bool pdfioContentMatrixConcat(pdfio_stream_t *st, pdfio_matrix_t m);

#### Parameters

st | Stream
m | Transform matrix

#### Return Value

`true` on success, `false` on failure

### pdfioContentMatrixRotate

Rotate the current transform matrix.

bool pdfioContentMatrixRotate(pdfio_stream_t *st, double degrees);

#### Parameters

st | Stream
degrees | Rotation angle in degrees counter-clockwise

#### Return Value

`true` on success, `false` on failure

### pdfioContentMatrixScale

Scale the current transform matrix.

bool pdfioContentMatrixScale(pdfio_stream_t *st, double sx, double sy);

#### Parameters

st | Stream
sx | X scale
sy | Y scale

#### Return Value

`true` on success, `false` on failure

### pdfioContentMatrixTranslate

Translate the current transform matrix.

bool pdfioContentMatrixTranslate(pdfio_stream_t *st, double tx, double ty);

#### Parameters

st | Stream
tx | X offset
ty | Y offset

#### Return Value

`true` on success, `false` on failure

### pdfioContentPathClose

Close the current path.

bool pdfioContentPathClose(pdfio_stream_t *st);

#### Parameters

st | Stream

#### Return Value

`true` on success, `false` on failure

### pdfioContentPathCurve

Add a Bezier curve with two control points.

bool pdfioContentPathCurve(pdfio_stream_t *st, double x1, double y1, double x2, double y2, double x3, double y3);

#### Parameters

st | Stream
x1 | X position 1
y1 | Y position 1
x2 | X position 2
y2 | Y position 2
x3 | X position 3
y3 | Y position 3

#### Return Value

`true` on success, `false` on failure

### pdfioContentPathCurve13

Add a Bezier curve with an initial control point.

bool pdfioContentPathCurve13(pdfio_stream_t *st, double x1, double y1, double x3, double y3);

#### Parameters

st | Stream
x1 | X position 1
y1 | Y position 1
x3 | X position 3
y3 | Y position 3

#### Return Value

`true` on success, `false` on failure

### pdfioContentPathCurve23

Add a Bezier curve with a trailing control point.

bool pdfioContentPathCurve23(pdfio_stream_t *st, double x2, double y2, double x3, double y3);

#### Parameters

st | Stream
x2 | X position 2
y2 | Y position 2
x3 | X position 3
y3 | Y position 3

#### Return Value

`true` on success, `false` on failure

### pdfioContentPathEnd

Clear the current path.

bool pdfioContentPathEnd(pdfio_stream_t *st);

#### Parameters

st | Stream

#### Return Value

`true` on success, `false` on failure

### pdfioContentPathLineTo

Add a straight line to the current path.

bool pdfioContentPathLineTo(pdfio_stream_t *st, double x, double y);

#### Parameters

st | Stream
x | X position
y | Y position

#### Return Value

`true` on success, `false` on failure

### pdfioContentPathMoveTo

Start a new subpath.

bool pdfioContentPathMoveTo(pdfio_stream_t *st, double x, double y);

#### Parameters

st | Stream
x | X position
y | Y position

#### Return Value

`true` on success, `false` on failure

### pdfioContentPathRect

Add a rectangle to the current path.

bool pdfioContentPathRect(pdfio_stream_t *st, double x, double y, double width, double height);

#### Parameters

st | Stream
x | X offset
y | Y offset
width | Width
height | Height

#### Return Value

`true` on success, `false` on failure

### pdfioContentRestore

Restore a previous graphics state.

bool pdfioContentRestore(pdfio_stream_t *st);

#### Parameters

st | Stream

#### Return Value

`true` on success, `false` on failure

### pdfioContentSave

Save the current graphics state.

bool pdfioContentSave(pdfio_stream_t *st);

#### Parameters

st | Stream

#### Return Value

`true` on success, `false` on failure

### pdfioContentSetDashPattern

Set the stroke pattern.

bool pdfioContentSetDashPattern(pdfio_stream_t *st, double phase, double on, double off);

#### Parameters

st | Stream
phase | Phase (offset within pattern)
on | On length
off | Off length

#### Return Value

`true` on success, `false` on failure

#### Discussion

This function sets the stroke pattern when drawing lines. If "on" and "off" are 0, a solid line is drawn.

### pdfioContentSetFillColorDeviceCMYK

Set device CMYK fill color.

bool pdfioContentSetFillColorDeviceCMYK(pdfio_stream_t *st, double c, double m, double y, double k);

#### Parameters

st | Stream
c | Cyan value (0.0 to 1.0)
m | Magenta value (0.0 to 1.0)
y | Yellow value (0.0 to 1.0)
k | Black value (0.0 to 1.0)

#### Return Value

`true` on success, `false` on failure

### pdfioContentSetFillColorDeviceGray

Set the device gray fill color.

bool pdfioContentSetFillColorDeviceGray(pdfio_stream_t *st, double g);

#### Parameters

st | Stream
g | Gray value (0.0 to 1.0)

#### Return Value

`true` on success, `false` on failure

### pdfioContentSetFillColorDeviceRGB

Set the device RGB fill color.

bool pdfioContentSetFillColorDeviceRGB(pdfio_stream_t *st, double r, double g, double b);

#### Parameters

st | Stream
r | Red value (0.0 to 1.0)
g | Green value (0.0 to 1.0)
b | Blue value (0.0 to 1.0)

#### Return Value

`true` on success, `false` on failure

### pdfioContentSetFillColorGray

Set the calibrated gray fill color.

bool pdfioContentSetFillColorGray(pdfio_stream_t *st, double g);

#### Parameters

st | Stream
g | Gray value (0.0 to 1.0)

#### Return Value

`true` on success, `false` on failure

### pdfioContentSetFillColorRGB

Set the calibrated RGB fill color.

bool pdfioContentSetFillColorRGB(pdfio_stream_t *st, double r, double g, double b);

#### Parameters

st | Stream
r | Red value (0.0 to 1.0)
g | Green value (0.0 to 1.0)
b | Blue value (0.0 to 1.0)

#### Return Value

`true` on success, `false` on failure

### pdfioContentSetFillColorSpace

Set the fill colorspace.

bool pdfioContentSetFillColorSpace(pdfio_stream_t *st, const char *name);

#### Parameters

st | Stream
name | Color space name

#### Return Value

`true` on success, `false` on failure

### pdfioContentSetFlatness

Set the flatness tolerance.

bool pdfioContentSetFlatness(pdfio_stream_t *st, double flatness);

#### Parameters

st | Stream
flatness | Flatness value (0.0 to 100.0)

#### Return Value

`true` on success, `false` on failure

### pdfioContentSetLineCap

Set the line ends style.

bool pdfioContentSetLineCap(pdfio_stream_t *st, pdfio_linecap_t lc);

#### Parameters

st | Stream
lc | Line cap value

#### Return Value

`true` on success, `false` on failure

### pdfioContentSetLineJoin

Set the line joining style.

bool pdfioContentSetLineJoin(pdfio_stream_t *st, pdfio_linejoin_t lj);

#### Parameters

st | Stream
lj | Line join value

#### Return Value

`true` on success, `false` on failure

### pdfioContentSetLineWidth

Set the line width.

bool pdfioContentSetLineWidth(pdfio_stream_t *st, double width);

#### Parameters

st | Stream
width | Line width value

#### Return Value

`true` on success, `false` on failure

### pdfioContentSetMiterLimit

Set the miter limit.

bool pdfioContentSetMiterLimit(pdfio_stream_t *st, double limit);

#### Parameters

st | Stream
limit | Miter limit value

#### Return Value

`true` on success, `false` on failure

### pdfioContentSetStrokeColorDeviceCMYK

Set the device CMYK stroke color.

bool pdfioContentSetStrokeColorDeviceCMYK(pdfio_stream_t *st, double c, double m, double y, double k);

#### Parameters

st | Stream
c | Cyan value (0.0 to 1.0)
m | Magenta value (0.0 to 1.0)
y | Yellow value (0.0 to 1.0)
k | Black value (0.0 to 1.0)

#### Return Value

`true` on success, `false` on failure

### pdfioContentSetStrokeColorDeviceGray

Set the device gray stroke color.

bool pdfioContentSetStrokeColorDeviceGray(pdfio_stream_t *st, double g);

#### Parameters

st | Stream
g | Gray value (0.0 to 1.0)

#### Return Value

`true` on success, `false` on failure

### pdfioContentSetStrokeColorDeviceRGB

Set the device RGB stroke color.

bool pdfioContentSetStrokeColorDeviceRGB(pdfio_stream_t *st, double r, double g, double b);

#### Parameters

st | Stream
r | Red value (0.0 to 1.0)
g | Green value (0.0 to 1.0)
b | Blue value (0.0 to 1.0)

#### Return Value

`true` on success, `false` on failure

### pdfioContentSetStrokeColorGray

Set the calibrated gray stroke color.

bool pdfioContentSetStrokeColorGray(pdfio_stream_t *st, double g);

#### Parameters

st | Stream
g | Gray value (0.0 to 1.0)

#### Return Value

`true` on success, `false` on failure

### pdfioContentSetStrokeColorRGB

Set the calibrated RGB stroke color.

bool pdfioContentSetStrokeColorRGB(pdfio_stream_t *st, double r, double g, double b);

#### Parameters

st | Stream
r | Red value (0.0 to 1.0)
g | Green value (0.0 to 1.0)
b | Blue value (0.0 to 1.0)

#### Return Value

`true` on success, `false` on failure

### pdfioContentSetStrokeColorSpace

Set the stroke color space.

bool pdfioContentSetStrokeColorSpace(pdfio_stream_t *st, const char *name);

#### Parameters

st | Stream
name | Color space name

#### Return Value

`true` on success, `false` on failure

### pdfioContentSetTextCharacterSpacing

Set the spacing between characters.

bool pdfioContentSetTextCharacterSpacing(pdfio_stream_t *st, double spacing);

#### Parameters

st | Stream
spacing | Character spacing

#### Return Value

`true` on success, `false` on failure

### pdfioContentSetTextFont

Set the text font and size.

bool pdfioContentSetTextFont(pdfio_stream_t *st, const char *name, double size);

#### Parameters

st | Stream
name | Font name
size | Font size

#### Return Value

`true` on success, `false` on failure

### pdfioContentSetTextLeading

Set text leading (line height) value.

bool pdfioContentSetTextLeading(pdfio_stream_t *st, double leading);

#### Parameters

st | Stream
leading | Leading (line height) value

#### Return Value

`true` on success, `false` on failure

### pdfioContentSetTextMatrix

Set the text transform matrix.

bool pdfioContentSetTextMatrix(pdfio_stream_t *st, pdfio_matrix_t m);

#### Parameters

st | Stream
m | Transform matrix

#### Return Value

`true` on success, `false` on failure

### pdfioContentSetTextRenderingMode

Set the text rendering mode.

bool pdfioContentSetTextRenderingMode(pdfio_stream_t *st, pdfio_textrendering_t mode);

#### Parameters

st | Stream
mode | Text rendering mode

#### Return Value

`true` on success, `false` on failure

### pdfioContentSetTextRise

Set the text baseline offset.

bool pdfioContentSetTextRise(pdfio_stream_t *st, double rise);

#### Parameters

st | Stream
rise | Y offset

#### Return Value

`true` on success, `false` on failure

### pdfioContentSetTextWordSpacing

Set the inter-word spacing.

bool pdfioContentSetTextWordSpacing(pdfio_stream_t *st, double spacing);

#### Parameters

st | Stream
spacing | Spacing between words

#### Return Value

`true` on success, `false` on failure

### pdfioContentSetTextXScaling

Set the horizontal scaling value.

bool pdfioContentSetTextXScaling(pdfio_stream_t *st, double percent);

#### Parameters

st | Stream
percent | Horizontal scaling in percent

#### Return Value

`true` on success, `false` on failure

### pdfioContentStroke

Stroke the current path.

bool pdfioContentStroke(pdfio_stream_t *st);

#### Parameters

st | Stream

#### Return Value

`true` on success, `false` on failure

### pdfioContentTextBegin

Begin a text block.

bool pdfioContentTextBegin(pdfio_stream_t *st);

#### Parameters

st | Stream

#### Return Value

`true` on success, `false` on failure

### pdfioContentTextEnd

End a text block.

bool pdfioContentTextEnd(pdfio_stream_t *st);

#### Parameters

st | Stream

#### Return Value

`true` on success, `false` on failure

### pdfioContentTextMeasure

Measure a text string and return its width.

double pdfioContentTextMeasure(pdfio_obj_t *font, const char *s, double size);

#### Parameters

font | Font object created by `pdfioFileCreateFontObjFromFile`
s | UTF-8 string
size | Font size/height

#### Return Value

Width

#### Discussion

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.

### pdfioContentTextMoveLine

Move to the next line and offset.

bool pdfioContentTextMoveLine(pdfio_stream_t *st, double tx, double ty);

#### Parameters

st | Stream
tx | X offset
ty | Y offset

#### Return Value

`true` on success, `false` on failure

### pdfioContentTextMoveTo

Offset within the current line.

bool pdfioContentTextMoveTo(pdfio_stream_t *st, double tx, double ty);

#### Parameters

st | Stream
tx | X offset
ty | Y offset

#### Return Value

`true` on success, `false` on failure

### pdfioContentTextNewLine

Move to the next line.

bool pdfioContentTextNewLine(pdfio_stream_t *st);

#### Parameters

st | Stream

#### Return Value

`true` on success, `false` on failure

### pdfioContentTextNewLineShow

Move to the next line and show text.

bool pdfioContentTextNewLineShow(pdfio_stream_t *st, double ws, double cs, bool unicode, const char *s);

#### Parameters

st | Stream
ws | Word spacing or `0.0` for none
cs | Character spacing or `0.0` for none
unicode | Unicode text?
s | String to show

#### Return Value

`true` on success, `false` on failure

#### Discussion

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.

### pdfioContentTextNewLineShowf

Show formatted text.

bool pdfioContentTextNewLineShowf(pdfio_stream_t *st, double ws, double cs, bool unicode, const char *format, ...);

#### Parameters

st | Stream
ws | Word spacing or `0.0` for none
cs | Character spacing or `0.0` for none
unicode | Unicode text?
format | `printf`-style format string
... | Additional arguments as needed

#### Return Value

`true` on success, `false` on failure

#### Discussion

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.

### pdfioContentTextShow

Show text.

bool pdfioContentTextShow(pdfio_stream_t *st, bool unicode, const char *s);

#### Parameters

st | Stream
unicode | Unicode text?
s | String to show

#### Return Value

`true` on success, `false` on failure

#### Discussion

This function shows some text 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.

### pdfioContentTextShowJustified

Show justified text.

bool pdfioContentTextShowJustified(pdfio_stream_t *st, bool unicode, size_t num_fragments, const double *offsets, const char *const *fragments);

#### Parameters

st | Stream
unicode | Unicode text?
num_fragments | Number of text fragments
offsets | Text offsets before fragments
fragments | Text fragments

#### Return Value

`true` on success, `false` on failure

#### Discussion

This function shows some text in a PDF content stream. The "unicode" argument specifies that the current font maps to full Unicode. The "fragments" argument specifies an array of UTF-8 encoded strings.

### pdfioContentTextShowf

bool pdfioContentTextShowf(pdfio_stream_t *st, bool unicode, const char *format, ...);

#### Parameters

st | Stream
unicode | Unicode text?
format | `printf`-style format string
... | Additional arguments as needed

#### Return Value

Show formatted text.

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.

### pdfioDictCopy

Copy a dictionary to a PDF file.

pdfio_dict_t *pdfioDictCopy(pdfio_file_t *pdf, pdfio_dict_t *dict);

#### Parameters

pdf | PDF file
dict | Original dictionary

#### Return Value

New dictionary

### pdfioDictCreate

Create a dictionary to hold key/value pairs.

pdfio_dict_t *pdfioDictCreate(pdfio_file_t *pdf);

#### Parameters

pdf | PDF file

#### Return Value

New dictionary

### pdfioDictGetArray

Get a key array value from a dictionary.

pdfio_array_t *pdfioDictGetArray(pdfio_dict_t *dict, const char *key);

#### Parameters

dict | Dictionary
key | Key

#### Return Value

Value

### pdfioDictGetBinary

Get a key binary string value from a dictionary.

unsigned char *pdfioDictGetBinary(pdfio_dict_t *dict, const char *key, size_t *length);

#### Parameters

dict | Dictionary
key | Key
length | Length of value

#### Return Value

Value

### pdfioDictGetBoolean

Get a key boolean value from a dictionary.

bool pdfioDictGetBoolean(pdfio_dict_t *dict, const char *key);

#### Parameters

dict | Dictionary
key | Key

#### Return Value

Value

### pdfioDictGetDate

Get a date value from a dictionary.

time_t pdfioDictGetDate(pdfio_dict_t *dict, const char *key);

#### Parameters

dict | Dictionary
key | Key

#### Return Value

Value

### pdfioDictGetDict

Get a key dictionary value from a dictionary.

pdfio_dict_t *pdfioDictGetDict(pdfio_dict_t *dict, const char *key);

#### Parameters

dict | Dictionary
key | Key

#### Return Value

Value

### pdfioDictGetName

Get a key name value from a dictionary.

const char *pdfioDictGetName(pdfio_dict_t *dict, const char *key);

#### Parameters

dict | Dictionary
key | Key

#### Return Value

Value

### pdfioDictGetNumber

Get a key number value from a dictionary.

double pdfioDictGetNumber(pdfio_dict_t *dict, const char *key);

#### Parameters

dict | Dictionary
key | Key

#### Return Value

Value

### pdfioDictGetObj

Get a key indirect object value from a dictionary.

pdfio_obj_t *pdfioDictGetObj(pdfio_dict_t *dict, const char *key);

#### Parameters

dict | Dictionary
key | Key

#### Return Value

Value

### pdfioDictGetRect

Get a key rectangle value from a dictionary.

pdfio_rect_t *pdfioDictGetRect(pdfio_dict_t *dict, const char *key, pdfio_rect_t *rect);

#### Parameters

dict | Dictionary
key | Key
rect | Rectangle

#### Return Value

Rectangle

### pdfioDictGetString

Get a key string value from a dictionary.

const char *pdfioDictGetString(pdfio_dict_t *dict, const char *key);

#### Parameters

dict | Dictionary
key | Key

#### Return Value

Value

### pdfioDictGetType

Get a key value type from a dictionary.

pdfio_valtype_t pdfioDictGetType(pdfio_dict_t *dict, const char *key);

#### Parameters

dict | Dictionary
key | Key

#### Return Value

Value type

### pdfioDictIterateKeys

Iterate the keys in a dictionary.

void pdfioDictIterateKeys(pdfio_dict_t *dict, pdfio_dict_cb_t cb, void *cb_data);

#### Parameters

dict | Dictionary
cb | Callback function
cb_data | Callback data

#### Discussion

This function iterates the keys in a dictionary, calling the supplied function "cb":

    bool
    my_dict_cb(pdfio_dict_t *dict, const char *key, void *cb_data)
    {
    ... "key" contains the dictionary key ...
    ... return true to continue or false to stop ...
    }

The iteration continues as long as the callback returns `true` or all keys have been iterated.

### pdfioDictSetArray

Set a key array in a dictionary.

bool pdfioDictSetArray(pdfio_dict_t *dict, const char *key, pdfio_array_t *value);

#### Parameters

dict | Dictionary
key | Key
value | Value

#### Return Value

`true` on success, `false` on failure

### pdfioDictSetBinary

Set a key binary string in a dictionary.

bool pdfioDictSetBinary(pdfio_dict_t *dict, const char *key, const unsigned char *value, size_t valuelen);

#### Parameters

dict | Dictionary
key | Key
value | Value
valuelen | Length of value

#### Return Value

`true` on success, `false` on failure

### pdfioDictSetBoolean

Set a key boolean in a dictionary.

bool pdfioDictSetBoolean(pdfio_dict_t *dict, const char *key, bool value);

#### Parameters

dict | Dictionary
key | Key
value | Value

#### Return Value

`true` on success, `false` on failure

### pdfioDictSetDate

Set a date value in a dictionary.

bool pdfioDictSetDate(pdfio_dict_t *dict, const char *key, time_t value);

#### Parameters

dict | Dictionary
key | Key
value | Value

#### Return Value

`true` on success, `false` on failure

### pdfioDictSetDict

Set a key dictionary in a dictionary.

bool pdfioDictSetDict(pdfio_dict_t *dict, const char *key, pdfio_dict_t *value);

#### Parameters

dict | Dictionary
key | Key
value | Value

#### Return Value

`true` on success, `false` on failure

### pdfioDictSetName

Set a key name in a dictionary.

bool pdfioDictSetName(pdfio_dict_t *dict, const char *key, const char *value);

#### Parameters

dict | Dictionary
key | Key
value | Value

#### Return Value

`true` on success, `false` on failure

### pdfioDictSetNull

Set a key null in a dictionary.

bool pdfioDictSetNull(pdfio_dict_t *dict, const char *key);

#### Parameters

dict | Dictionary
key | Key

#### Return Value

`true` on success, `false` on failure

### pdfioDictSetNumber

Set a key number in a dictionary.

bool pdfioDictSetNumber(pdfio_dict_t *dict, const char *key, double value);

#### Parameters

dict | Dictionary
key | Key
value | Value

#### Return Value

`true` on success, `false` on failure

### pdfioDictSetObj

Set a key indirect object reference in a dictionary.

bool pdfioDictSetObj(pdfio_dict_t *dict, const char *key, pdfio_obj_t *value);

#### Parameters

dict | Dictionary
key | Key
value | Value

#### Return Value

`true` on success, `false` on failure

### pdfioDictSetRect

Set a key rectangle in a dictionary.

bool pdfioDictSetRect(pdfio_dict_t *dict, const char *key, pdfio_rect_t *value);

#### Parameters

dict | Dictionary
key | Key
value | Value

#### Return Value

`true` on success, `false` on failure

### pdfioDictSetString

Set a key literal string in a dictionary.

bool pdfioDictSetString(pdfio_dict_t *dict, const char *key, const char *value);

#### Parameters

dict | Dictionary
key | Key
value | Value

#### Return Value

`true` on success, `false` on failure

### pdfioDictSetStringf

Set a key formatted string in a dictionary.

bool pdfioDictSetStringf(pdfio_dict_t *dict, const char *key, const char *format, ...);

#### Parameters

dict | Dictionary
key | Key
format | `printf`-style format string
... | Additional arguments as needed

#### Return Value

`true` on success, `false` on failure

### pdfioFileClose

Close a PDF file and free all memory used for it.

bool pdfioFileClose(pdfio_file_t *pdf);

#### Parameters

pdf | PDF file

#### Return Value

`true` on success and `false` on failure

### pdfioFileCreate

Create a PDF file.

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_cbdata);

#### Parameters

filename | Filename
version | PDF version number or `NULL` for default (2.0)
media_box | Default MediaBox for pages
crop_box | Default CropBox for pages
error_cb | Error callback or `NULL` for default
error_cbdata | Error callback data, if any

#### Return Value

PDF file or `NULL` on error

#### Discussion

This function creates a new PDF file. The "filename" argument specifies the name of the PDF file to create.
The "version" argument specifies the PDF version number for the file or `NULL` for the default ("2.0").
The "media_box" and "crop_box" arguments specify the default MediaBox and CropBox for pages in the PDF file - if `NULL` then a default "Universal" size 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`.

### pdfioFileCreateArrayObj

Create a new object in a PDF file containing an array.

pdfio_obj_t *pdfioFileCreateArrayObj(pdfio_file_t *pdf, pdfio_array_t *array);

#### Parameters

pdf | PDF file
array | Object array

#### Return Value

New object

#### Discussion

This function creates a new object with an array value in a PDF file. You must call `pdfioObjClose` to write the object to the file.

### pdfioFileCreateFontObjFromBase

Create one of the base 14 PDF fonts.

pdfio_obj_t *pdfioFileCreateFontObjFromBase(pdfio_file_t *pdf, const char *name);

#### Parameters

pdf | PDF file
name | Font name

#### Return Value

Font object

#### Discussion

This function creates one of the base 14 PDF fonts. The "name" parameter specifies the font nane:

- "Courier"
- "Courier-Bold"
- "Courier-BoldItalic"
- "Courier-Italic"
- "Helvetica"
- "Helvetica-Bold"
- "Helvetica-BoldOblique"
- "Helvetica-Oblique"
- "Symbol"
- "Times-Bold"
- "Times-BoldItalic"
- "Times-Italic"
- "Times-Roman"
- "ZapfDingbats"

Base fonts always use the Windows CP1252 (ISO-8859-1 with additional characters such as the Euro symbol) subset of Unicode.

### pdfioFileCreateFontObjFromFile

Add a font object to a PDF file.

pdfio_obj_t *pdfioFileCreateFontObjFromFile(pdfio_file_t *pdf, const char *filename, bool unicode);

#### Parameters

pdf | PDF file
filename | Filename
unicode | Force Unicode

#### Return Value

Font object

#### Discussion

This function embeds a TrueType/OpenType font into a PDF file. The "unicode" parameter controls whether the font is encoded for two-byte characters (potentially full Unicode, but more typically a subset) or to only support the Windows CP1252 (ISO-8859-1 with additional characters such as the Euro symbol) subset of Unicode.

### pdfioFileCreateICCObjFromFile

Add an ICC profile object to a PDF file.

pdfio_obj_t *pdfioFileCreateICCObjFromFile(pdfio_file_t *pdf, const char *filename, size_t num_colors);

#### Parameters

pdf | PDF file
filename | Filename
num_colors | Number of color components (1, 3, or 4)

#### Return Value

Object

### pdfioFileCreateImageObjFromData

Add image object(s) to a PDF file from memory.

pdfio_obj_t *pdfioFileCreateImageObjFromData(pdfio_file_t *pdf, const unsigned char *data, size_t width, size_t height, size_t num_colors, pdfio_array_t *color_data, bool alpha, bool interpolate);

#### Parameters

pdf | PDF file
data | Pointer to image data
width | Width of image
height | Height of image
num_colors | Number of colors
color_data | Colorspace data or `NULL` for default
alpha | `true` if data contains an alpha channel
interpolate | Interpolate image data?

#### Return Value

Object

#### Discussion

This function creates image object(s) in a PDF file from a data buffer in memory. The "data" parameter points to the image data as 8-bit color values. The "width" and "height" parameters specify the image dimensions. The "num_colors" parameter specifies the number of color components (`1` for grayscale, `3` for RGB, and `4` for CMYK) and the "alpha" parameter specifies whether each color tuple is followed by an alpha value. The "color_data" parameter specifies an optional color space array for the image - if `NULL`, the image is encoded in the corresponding device color space. The "interpolate" parameter specifies whether to interpolate when scaling the image on the page.
Note: When creating an image object with alpha, a second image object is created to hold the "soft mask" data for the primary image.

### pdfioFileCreateImageObjFromFile

Add an image object to a PDF file from a file.

pdfio_obj_t *pdfioFileCreateImageObjFromFile(pdfio_file_t *pdf, const char *filename, bool interpolate);

#### Parameters

pdf | PDF file
filename | Filename
interpolate | Interpolate image data?

#### Return Value

Object

#### Discussion

This function creates an image object in a PDF file from a JPEG or PNG file. The "filename" parameter specifies the name of the JPEG or PNG file, while the "interpolate" parameter specifies whether to interpolate when scaling the 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.

### pdfioFileCreateNumberObj

Create a new object in a PDF file containing a number.

pdfio_obj_t *pdfioFileCreateNumberObj(pdfio_file_t *pdf, double number);

#### Parameters

pdf | PDF file
number | Number value

#### Return Value

New object

#### Discussion

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.

### pdfioFileCreateObj

Create a new object in a PDF file.

pdfio_obj_t *pdfioFileCreateObj(pdfio_file_t *pdf, pdfio_dict_t *dict);

#### Parameters

pdf | PDF file
dict | Object dictionary

#### Return Value

New object

### pdfioFileCreateOutput

Create a PDF file through an output callback.

pdfio_file_t *pdfioFileCreateOutput(pdfio_output_cb_t output_cb, void *output_cbdata, const char *version, pdfio_rect_t *media_box, pdfio_rect_t *crop_box, pdfio_error_cb_t error_cb, void *error_cbdata);

#### Parameters

output_cb | Output callback function
output_cbdata | Output callback data
version | PDF version number or `NULL` for default (2.0)
media_box | Default MediaBox for pages
crop_box | Default CropBox for pages
error_cb | Error callback or `NULL` for default
error_cbdata | Error callback data, if any

#### Return Value

PDF file or `NULL` on error

#### Discussion

This function creates a new PDF file that is streamed though an output callback. The "output_cb" and "output_cbdata" arguments specify the output callback and its data pointer which is called whenever data needs to be written:

    ssize_t
    output_cb(void *output_cbdata, const void *buffer, size_t bytes)
    {
      // Write buffer to output and return the number of bytes written
    }

The "version" argument specifies the PDF version number for the file or `NULL` for the default ("2.0").
The "media_box" and "crop_box" arguments specify the default MediaBox and CropBox for pages in the PDF file - if `NULL` then a default "Universal" size 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`.

> Note: Files created using this API are slightly larger than those created using the `pdfioFileCreate` function since stream lengths are stored as indirect object references.

### pdfioFileCreatePage

Create a page in a PDF file.

pdfio_stream_t *pdfioFileCreatePage(pdfio_file_t *pdf, pdfio_dict_t *dict);

#### Parameters

pdf | PDF file
dict | Page dictionary

#### Return Value

Contents stream

### pdfioFileCreateStringObj

Create a new object in a PDF file containing a string.

pdfio_obj_t *pdfioFileCreateStringObj(pdfio_file_t *pdf, const char *string);

#### Parameters

pdf | PDF file
string | String

#### Return Value

New object

#### Discussion

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.

### pdfioFileCreateTemporary

pdfio_file_t *pdfioFileCreateTemporary(char *buffer, size_t bufsize, const char *version, pdfio_rect_t *media_box, pdfio_rect_t *crop_box, pdfio_error_cb_t error_cb, void *error_cbdata);

#### Parameters

buffer | Filename buffer
bufsize | Size of filename buffer
version | PDF version number or `NULL` for default (2.0)
media_box | Default MediaBox for pages
crop_box | Default CropBox for pages
error_cb | Error callback or `NULL` for default
error_cbdata | Error callback data, if any

#### Return Value

Create a temporary PDF file.

This function creates a PDF file with a unique filename in the current temporary directory. The temporary file is stored in the string "buffer" an will have a ".pdf" extension. Otherwise, this function works the same as the `pdfioFileCreate` function.

### pdfioFileFindObj

Find an object using its object number.

pdfio_obj_t *pdfioFileFindObj(pdfio_file_t *pdf, size_t number);

#### Parameters

pdf | PDF file
number | Object number (1 to N)

#### Return Value

Object or `NULL` if not found

#### Discussion

This differs from `pdfioFileGetObj` which takes an index into the list of objects while this function takes the object number.

### pdfioFileGetAuthor

Get the author for a PDF file.

const char *pdfioFileGetAuthor(pdfio_file_t *pdf);

#### Parameters

pdf | PDF file

#### Return Value

Author or `NULL` for none

### PDFio 1.3 pdfioFileGetCatalog

Get the document catalog dictionary.

pdfio_dict_t *pdfioFileGetCatalog(pdfio_file_t *pdf);

#### Parameters

pdf | PDF file

#### Return Value

Catalog dictionary

### pdfioFileGetCreationDate

Get the creation date for a PDF file.

time_t pdfioFileGetCreationDate(pdfio_file_t *pdf);

#### Parameters

pdf | PDF file

#### Return Value

Creation date or `0` for none

### pdfioFileGetCreator

Get the creator string for a PDF file.

const char *pdfioFileGetCreator(pdfio_file_t *pdf);

#### Parameters

pdf | PDF file

#### Return Value

Creator string or `NULL` for none

### pdfioFileGetID

Get the PDF file's ID strings.

pdfio_array_t *pdfioFileGetID(pdfio_file_t *pdf);

#### Parameters

pdf | PDF file

#### Return Value

Array with binary strings

### pdfioFileGetKeywords

Get the keywords for a PDF file.

const char *pdfioFileGetKeywords(pdfio_file_t *pdf);

#### Parameters

pdf | PDF file

#### Return Value

Keywords string or `NULL` for none

### pdfioFileGetName

Get a PDF's filename.

const char *pdfioFileGetName(pdfio_file_t *pdf);

#### Parameters

pdf | PDF file

#### Return Value

Filename

### pdfioFileGetNumObjs

Get the number of objects in a PDF file.

size_t pdfioFileGetNumObjs(pdfio_file_t *pdf);

#### Parameters

pdf | PDF file

#### Return Value

Number of objects

### pdfioFileGetNumPages

Get the number of pages in a PDF file.

size_t pdfioFileGetNumPages(pdfio_file_t *pdf);

#### Parameters

pdf | PDF file

#### Return Value

Number of pages

### pdfioFileGetObj

Get an object from a PDF file.

pdfio_obj_t *pdfioFileGetObj(pdfio_file_t *pdf, size_t n);

#### Parameters

pdf | PDF file
n | Object index (starting at 0)

#### Return Value

Object

### pdfioFileGetPage

Get a page object from a PDF file.

pdfio_obj_t *pdfioFileGetPage(pdfio_file_t *pdf, size_t n);

#### Parameters

pdf | PDF file
n | Page index (starting at 0)

#### Return Value

Object

### pdfioFileGetPermissions

Get the access permissions of a PDF file.

pdfio_permission_t pdfioFileGetPermissions(pdfio_file_t *pdf, pdfio_encryption_t *encryption);

#### Parameters

pdf | PDF file
encryption | Type of encryption used or `NULL` to ignore

#### Return Value

Permission bits

#### Discussion

This function returns the access permissions of a PDF file and (optionally) the type of encryption that has been used.

### pdfioFileGetProducer

Get the producer string for a PDF file.

const char *pdfioFileGetProducer(pdfio_file_t *pdf);

#### Parameters

pdf | PDF file

#### Return Value

Producer string or `NULL` for none

### pdfioFileGetSubject

Get the subject for a PDF file.

const char *pdfioFileGetSubject(pdfio_file_t *pdf);

#### Parameters

pdf | PDF file

#### Return Value

Subject or `NULL` for none

### pdfioFileGetTitle

Get the title for a PDF file.

const char *pdfioFileGetTitle(pdfio_file_t *pdf);

#### Parameters

pdf | PDF file

#### Return Value

Title or `NULL` for none

### pdfioFileGetVersion

Get the PDF version number for a PDF file.

const char *pdfioFileGetVersion(pdfio_file_t *pdf);

#### Parameters

pdf | PDF file

#### Return Value

Version number or `NULL`

### pdfioFileOpen

Open a PDF file for reading.

pdfio_file_t *pdfioFileOpen(const char *filename, pdfio_password_cb_t password_cb, void *password_cbdata, pdfio_error_cb_t error_cb, void *error_cbdata);

#### Parameters

filename | Filename
password_cb | Password callback or `NULL` for none
password_cbdata | Password callback data, if any
error_cb | Error callback or `NULL` for default
error_cbdata | Error callback data, if any

#### Return Value

PDF file

#### Discussion

This function opens an existing PDF file. The "filename" argument specifies the name of the PDF file to create.
The "password_cb" and "password_cbdata" arguments specify a password callback and its data pointer for PDF files that use one of the standard Adobe "security" handlers. The callback returns a password string or `NULL` to cancel the open. If `NULL` is specified for the callback function and the 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`.

### pdfioFileSetAuthor

Set the author for a PDF file.

void pdfioFileSetAuthor(pdfio_file_t *pdf, const char *value);

#### Parameters

pdf | PDF file
value | Value

### pdfioFileSetCreationDate

Set the creation date for a PDF file.

void pdfioFileSetCreationDate(pdfio_file_t *pdf, time_t value);

#### Parameters

pdf | PDF file
value | Value

### pdfioFileSetCreator

Set the creator string for a PDF file.

void pdfioFileSetCreator(pdfio_file_t *pdf, const char *value);

#### Parameters

pdf | PDF file
value | Value

### pdfioFileSetKeywords

Set the keywords string for a PDF file.

void pdfioFileSetKeywords(pdfio_file_t *pdf, const char *value);

#### Parameters

pdf | PDF file
value | Value

### pdfioFileSetPermissions

Set the PDF permissions, encryption mode, and passwords.

bool pdfioFileSetPermissions(pdfio_file_t *pdf, pdfio_permission_t permissions, pdfio_encryption_t encryption, const char *owner_password, const char *user_password);

#### Parameters

pdf | PDF file
permissions | Use permissions
encryption | Type of encryption to use
owner_password | Owner password, if any
user_password | User password, if any

#### Return Value

`true` on success, `false` otherwise

#### Discussion

This function sets the PDF usage permissions, encryption mode, and passwords.

> Note: This function must be called before creating or copying any objects. Due to fundamental limitations in the PDF format, PDF encryption offers little protection from disclosure. Permissions are not enforced in any meaningful way.

### pdfioFileSetSubject

Set the subject for a PDF file.

void pdfioFileSetSubject(pdfio_file_t *pdf, const char *value);

#### Parameters

pdf | PDF file
value | Value

### pdfioFileSetTitle

Set the title for a PDF file.

void pdfioFileSetTitle(pdfio_file_t *pdf, const char *value);

#### Parameters

pdf | PDF file
value | Value

### pdfioImageGetBytesPerLine

Get the number of bytes to read for each line.

size_t pdfioImageGetBytesPerLine(pdfio_obj_t *obj);

#### Parameters

obj | Image object

#### Return Value

Number of bytes per line

### pdfioImageGetHeight

Get the height of an image object.

double pdfioImageGetHeight(pdfio_obj_t *obj);

#### Parameters

obj | Image object

#### Return Value

Height in lines

### pdfioImageGetWidth

Get the width of an image object.

double pdfioImageGetWidth(pdfio_obj_t *obj);

#### Parameters

obj | Image object

#### Return Value

Width in columns

### pdfioObjClose

Close an object, writing any data as needed to the PDF file.

bool pdfioObjClose(pdfio_obj_t *obj);

#### Parameters

obj | Object

#### Return Value

`true` on success, `false` on failure

### pdfioObjCopy

Copy an object to another PDF file.

pdfio_obj_t *pdfioObjCopy(pdfio_file_t *pdf, pdfio_obj_t *srcobj);

#### Parameters

pdf | PDF file
srcobj | Object to copy

#### Return Value

New object or `NULL` on error

### pdfioObjCreateStream

Create an object (data) stream for writing.

pdfio_stream_t *pdfioObjCreateStream(pdfio_obj_t *obj, pdfio_filter_t filter);

#### Parameters

obj | Object
filter | Type of compression to apply

#### Return Value

Stream or `NULL` on error

### pdfioObjGetArray

Get the array associated with an object.

pdfio_array_t *pdfioObjGetArray(pdfio_obj_t *obj);

#### Parameters

obj | Object

#### Return Value

Array or `NULL` on error

### pdfioObjGetDict

Get the dictionary associated with an object.

pdfio_dict_t *pdfioObjGetDict(pdfio_obj_t *obj);

#### Parameters

obj | Object

#### Return Value

Dictionary or `NULL` on error

### pdfioObjGetGeneration

Get the object's generation number.

unsigned short pdfioObjGetGeneration(pdfio_obj_t *obj);

#### Parameters

obj | Object

#### Return Value

Generation number (0 to 65535)

### pdfioObjGetLength

Get the length of the object's (data) stream.

size_t pdfioObjGetLength(pdfio_obj_t *obj);

#### Parameters

obj | Object

#### Return Value

Length in bytes or `0` for none

### pdfioObjGetNumber

Get the object's number.

size_t pdfioObjGetNumber(pdfio_obj_t *obj);

#### Parameters

obj | Object

#### Return Value

Object number (1 to 9999999999)

### pdfioObjGetSubtype

Get an object's subtype.

const char *pdfioObjGetSubtype(pdfio_obj_t *obj);

#### Parameters

obj | Object

#### Return Value

Object subtype name or `NULL` for none

#### Discussion

This function returns an object's PDF subtype name, if any. Common subtype names include:

- "CIDFontType0": A CID Type0 font
- "CIDFontType2": A CID TrueType font
- "Image": An image or image mask
- "Form": A fillable form
- "OpenType": An OpenType font
- "Type0": A composite font
- "Type1": A PostScript Type1 font
- "Type3": A PDF Type3 font
- "TrueType": A TrueType font

### pdfioObjGetType

Get an object's type.

const char *pdfioObjGetType(pdfio_obj_t *obj);

#### Parameters

obj | Object

#### Return Value

Object type name or `NULL` for none

#### Discussion

This function returns an object's PDF type name, if any. Common type names include:

- "CMap": A character map for composite fonts
- "Font": An embedded font (`pdfioObjGetSubtype` will tell you the font format)
- "FontDescriptor": A font descriptor
- "Page": A (visible) page
- "Pages": A page tree node
- "Template": An invisible template page
- "XObject": An image, image mask, or form (`pdfioObjGetSubtype` will tell you which)

### pdfioObjOpenStream

Open an object's (data) stream for reading.

pdfio_stream_t *pdfioObjOpenStream(pdfio_obj_t *obj, bool decode);

#### Parameters

obj | Object
decode | Decode/decompress data?

#### Return Value

Stream or `NULL` on error

### pdfioPageCopy

Copy a page to a PDF file.

bool pdfioPageCopy(pdfio_file_t *pdf, pdfio_obj_t *srcpage);

#### Parameters

pdf | PDF file
srcpage | Source page

#### Return Value

`true` on success, `false` on failure

### pdfioPageDictAddColorSpace

Add a color space to the page dictionary.

bool pdfioPageDictAddColorSpace(pdfio_dict_t *dict, const char *name, pdfio_array_t *data);

#### Parameters

dict | Page dictionary
name | Color space name
data | Color space array

#### Return Value

`true` on success, `false` on failure

#### Discussion

This function adds a named color space to the page dictionary.
The names "DefaultCMYK", "DefaultGray", and "DefaultRGB" specify the default device color space used for the page.
The "data" array contains a calibrated, indexed, or ICC-based color space array that was created using the `pdfioArrayCreateCalibratedColorFromMatrix`, `pdfioArrayCreateCalibratedColorFromPrimaries`, `pdfioArrayCreateICCBasedColor`, or `pdfioArrayCreateIndexedColor` functions.

### pdfioPageDictAddFont

Add a font object to the page dictionary.

bool pdfioPageDictAddFont(pdfio_dict_t *dict, const char *name, pdfio_obj_t *obj);

#### Parameters

dict | Page dictionary
name | Font name; must not contain spaces
obj | Font object

#### Return Value

`true` on success, `false` on failure

### pdfioPageDictAddImage

Add an image object to the page dictionary.

bool pdfioPageDictAddImage(pdfio_dict_t *dict, const char *name, pdfio_obj_t *obj);

#### Parameters

dict | Page dictionary
name | Image name
obj | Image object

#### Return Value

`true` on success, `false` on failure

### pdfioPageGetNumStreams

Get the number of content streams for a page object.

size_t pdfioPageGetNumStreams(pdfio_obj_t *page);

#### Parameters

page | Page object

#### Return Value

Number of streams

### pdfioPageOpenStream

Open a content stream for a page.

pdfio_stream_t *pdfioPageOpenStream(pdfio_obj_t *page, size_t n, bool decode);

#### Parameters

page | Page object
n | Stream index (0-based)
decode | `true` to decode/decompress stream

#### Return Value

Stream

### pdfioStreamClose

Close a (data) stream in a PDF file.

bool pdfioStreamClose(pdfio_stream_t *st);

#### Parameters

st | Stream

#### Return Value

`true` on success, `false` on failure

### pdfioStreamConsume

Consume bytes from the stream.

bool pdfioStreamConsume(pdfio_stream_t *st, size_t bytes);

#### Parameters

st | Stream
bytes | Number of bytes to consume

#### Return Value

`true` on success, `false` on EOF

### pdfioStreamGetToken

Read a single PDF token from a stream.

bool pdfioStreamGetToken(pdfio_stream_t *st, char *buffer, size_t bufsize);

#### Parameters

st | Stream
buffer | String buffer
bufsize | Size of string buffer

#### Return Value

`true` on success, `false` on EOF

#### Discussion

This function reads a single PDF token from a stream. Operator tokens, boolean values, and numbers are returned as-is in the provided string buffer. String values start with the opening parenthesis ('(') but have all escaping resolved and the terminating parenthesis removed. Hexadecimal string values start with the opening angle bracket ('<') and have all whitespace and the terminating angle bracket removed.

### pdfioStreamPeek

Peek at data in a stream.

ssize_t pdfioStreamPeek(pdfio_stream_t *st, void *buffer, size_t bytes);

#### Parameters

st | Stream
buffer | Buffer
bytes | Size of buffer

#### Return Value

Bytes returned or `-1` on error

### pdfioStreamPrintf

Write a formatted string to a stream.

bool pdfioStreamPrintf(pdfio_stream_t *st, const char *format, ...);

#### Parameters

st | Stream
format | `printf`-style format string
... | Additional arguments as needed

#### Return Value

`true` on success, `false` on failure

### pdfioStreamPutChar

Write a single character to a stream.

bool pdfioStreamPutChar(pdfio_stream_t *st, int ch);

#### Parameters

st | Stream
ch | Character

#### Return Value

`true` on success, `false` on failure

### pdfioStreamPuts

Write a literal string to a stream.

bool pdfioStreamPuts(pdfio_stream_t *st, const char *s);

#### Parameters

st | Stream
s | Literal string

#### Return Value

`true` on success, `false` on failure

### pdfioStreamRead

Read data from a stream.

ssize_t pdfioStreamRead(pdfio_stream_t *st, void *buffer, size_t bytes);

#### Parameters

st | Stream
buffer | Buffer
bytes | Bytes to read

#### Return Value

Number of bytes read or `-1` on error

#### Discussion

This function reads data from a stream. When reading decoded image data from a stream, you must read whole scanlines. The `pdfioImageGetBytesPerLine` function can be used to determine the proper read length.

### pdfioStreamWrite

Write data to a stream.

bool pdfioStreamWrite(pdfio_stream_t *st, const void *buffer, size_t bytes);

#### Parameters

st | Stream
buffer | Data to write
bytes | Number of bytes to write

#### Return Value

`true` on success or `false` on failure

### pdfioStringCreate

Create a durable literal string.

char *pdfioStringCreate(pdfio_file_t *pdf, const char *s);

#### Parameters

pdf | PDF file
s | Nul-terminated string

#### Return Value

Durable string pointer or `NULL` on error

#### Discussion

This function creates a literal string associated with the PDF file "pdf". The "s" string points to a nul-terminated C string.
`NULL` is returned on error, otherwise a `char *` that is valid until `pdfioFileClose` is called.

### pdfioStringCreatef

Create a durable formatted string.

char *pdfioStringCreatef(pdfio_file_t *pdf, const char *format, ...);

#### Parameters

pdf | PDF file
format | `printf`-style format string
... | Additional args as needed

#### Return Value

Durable string pointer or `NULL` on error

#### Discussion

This function creates a formatted string associated with the PDF file "pdf". The "format" string contains `printf`-style format characters.
`NULL` is returned on error, otherwise a `char *` that is valid until `pdfioFileClose` is called.

## Data Types

### pdfio_array_t

Array of PDF values

typedef struct _pdfio_array_s pdfio_array_t;

### pdfio_cs_t

Standard color spaces

typedef enum pdfio_cs_e pdfio_cs_t;

### pdfio_dict_cb_t

Dictionary iterator callback

typedef bool (*pdfio_dict_cb_t)(pdfio_dict_t *dict, const char *key, void *cb_data);

### pdfio_dict_t

Key/value dictionary

typedef struct _pdfio_dict_s pdfio_dict_t;

### pdfio_encryption_t

PDF encryption modes

typedef enum pdfio_encryption_e pdfio_encryption_t;

### pdfio_error_cb_t

Error callback

typedef bool (*pdfio_error_cb_t)(pdfio_file_t *pdf, const char *message, void *data);

### pdfio_file_t

PDF file

typedef struct _pdfio_file_s pdfio_file_t;

### pdfio_filter_t

Compression/decompression filters for streams

typedef enum pdfio_filter_e pdfio_filter_t;

### pdfio_linecap_t

Line capping modes

typedef enum pdfio_linecap_e pdfio_linecap_t;

### pdfio_linejoin_t

Line joining modes

typedef enum pdfio_linejoin_e pdfio_linejoin_t;

### pdfio_matrix_t[3][2]

Transform matrix

typedef double pdfio_matrix_t[3][2];

### pdfio_obj_t

Numbered object in PDF file

typedef struct _pdfio_obj_s pdfio_obj_t;

### pdfio_output_cb_t

Output callback for pdfioFileCreateOutput

typedef ssize_t (*pdfio_output_cb_t)(void *ctx const void *data size_t datalen);

### pdfio_password_cb_t

Password callback for pdfioFileOpen

typedef const char *(*pdfio_password_cb_t)(void *data const char *filename);

### pdfio_permission_t

PDF permission bitfield

typedef int pdfio_permission_t;

### pdfio_rect_t

PDF rectangle

typedef struct pdfio_rect_s pdfio_rect_t;

### pdfio_stream_t

Object data stream in PDF file

typedef struct _pdfio_stream_s pdfio_stream_t;

### pdfio_textrendering_t

Text rendering modes

typedef enum pdfio_textrendering_e pdfio_textrendering_t;

### pdfio_valtype_t

PDF value types

typedef enum pdfio_valtype_e pdfio_valtype_t;

## Structures

### pdfio_rect_s

PDF rectangle

struct pdfio_rect_s {
double x1;
double x2;
double y1;
double y2;
};

#### Members

x1 | Lower-left X coordinate
x2 | Upper-right X coordinate
y1 | Lower-left Y coordinate
y2 | Upper-right Y coordinate

## Constants

### pdfio_cs_e

Standard color spaces

#### Constants

PDFIO_CS_ADOBE | AdobeRGB 1998
PDFIO_CS_P3_D65 | Display P3
PDFIO_CS_SRGB | sRGB

### pdfio_encryption_e

PDF encryption modes

#### Constants

PDFIO_ENCRYPTION_AES_128 | 128-bit AES encryption (PDF 1.6)
PDFIO_ENCRYPTION_NONE | No encryption
PDFIO_ENCRYPTION_RC4_128 | 128-bit RC4 encryption (PDF 1.4)
PDFIO_ENCRYPTION_RC4_40 | 40-bit RC4 encryption (PDF 1.3)

### pdfio_filter_e

Compression/decompression filters for streams

#### Constants

PDFIO_FILTER_ASCII85 | ASCII85Decode filter (reading only)
PDFIO_FILTER_ASCIIHEX | ASCIIHexDecode filter (reading only)
PDFIO_FILTER_CCITTFAX | CCITTFaxDecode filter
PDFIO_FILTER_CRYPT | Encryption filter
PDFIO_FILTER_DCT | DCTDecode (JPEG) filter
PDFIO_FILTER_FLATE | FlateDecode filter
PDFIO_FILTER_JBIG2 | JBIG2Decode filter
PDFIO_FILTER_JPX | JPXDecode filter (reading only)
PDFIO_FILTER_LZW | LZWDecode filter (reading only)
PDFIO_FILTER_NONE | No filter
PDFIO_FILTER_RUNLENGTH | RunLengthDecode filter (reading only)

### pdfio_linecap_e

Line capping modes

#### Constants

PDFIO_LINECAP_BUTT | Butt ends
PDFIO_LINECAP_ROUND | Round ends
PDFIO_LINECAP_SQUARE | Square ends

### pdfio_linejoin_e

Line joining modes

#### Constants

PDFIO_LINEJOIN_BEVEL | Bevel joint
PDFIO_LINEJOIN_MITER | Miter joint
PDFIO_LINEJOIN_ROUND | Round joint

### pdfio_permission_e

PDF permission bits

#### Constants

PDFIO_PERMISSION_ANNOTATE | PDF allows annotation
PDFIO_PERMISSION_ASSEMBLE | PDF allows assembly (insert, delete, or rotate pages, add document outlines and thumbnails)
PDFIO_PERMISSION_COPY | PDF allows copying
PDFIO_PERMISSION_FORMS | PDF allows filling in forms
PDFIO_PERMISSION_MODIFY | PDF allows modification
PDFIO_PERMISSION_NONE | No permissions
PDFIO_PERMISSION_PRINT | PDF allows printing
PDFIO_PERMISSION_PRINT_HIGH | PDF allows high quality printing
PDFIO_PERMISSION_READING | PDF allows screen reading/accessibility (deprecated in PDF 2.0)
~0 | All permissions

### pdfio_textrendering_e

Text rendering modes

#### Constants

PDFIO_TEXTRENDERING_FILL | Fill text
PDFIO_TEXTRENDERING_FILL_AND_STROKE | Fill then stroke text
PDFIO_TEXTRENDERING_FILL_AND_STROKE_PATH | Fill then stroke text and add to path
PDFIO_TEXTRENDERING_FILL_PATH | Fill text and add to path
PDFIO_TEXTRENDERING_INVISIBLE | Don't fill or stroke (invisible)
PDFIO_TEXTRENDERING_STROKE | Stroke text
PDFIO_TEXTRENDERING_STROKE_PATH | Stroke text and add to path
PDFIO_TEXTRENDERING_TEXT_PATH | Add text to path (invisible)

### pdfio_valtype_e

PDF value types

#### Constants

PDFIO_VALTYPE_ARRAY | Array
PDFIO_VALTYPE_BINARY | Binary data
PDFIO_VALTYPE_BOOLEAN | Boolean
PDFIO_VALTYPE_DATE | Date/time
PDFIO_VALTYPE_DICT | Dictionary
PDFIO_VALTYPE_INDIRECT | Indirect object (N G obj)
PDFIO_VALTYPE_NAME | Name
PDFIO_VALTYPE_NONE | No value, not set
PDFIO_VALTYPE_NULL | Null object
PDFIO_VALTYPE_NUMBER | Number (integer or real)
PDFIO_VALTYPE_STRING | String