GNU PDF Library Reference

first Edition, Updated for version trunk.

Free Software Foundation

This is the first edition of the GNU PDF Library Reference, updated for libgnupdf version trunk. Copyright c 2007, 2008, 2009 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled “GNU Free Documentation License”.

i

Table of Contents
1 2 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Base Layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2.1 2.2 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 Error Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 2.2.1 Status types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 2.2.2 Error Reporting procedures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 2.2.3 Debugging procedures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 2.3 Memory Allocation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 2.4 Basic Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 2.4.1 Boolean Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 2.4.2 Numeric Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 2.4.3 Big Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 2.4.4 Memory Buffers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 2.4.5 Progress Monitors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 2.4.6 Universal Unique Identifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 2.5 Hash Tables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 2.5.1 Hash Table Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 2.5.2 Creating and Destroying Hash Tables . . . . . . . . . . . . . . . . . . . . . 28 2.5.3 Hash Table properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 2.5.4 Working with keys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 2.5.5 Adding and removing elements . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 2.5.6 Searching elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 2.5.7 Working with iterators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 2.5.8 Basic dispose functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 2.5.9 Hash helper functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 2.6 Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 2.6.1 List Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 2.6.2 Creating and Destroying Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 2.6.3 Managing List Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 2.6.4 Searching for List Elements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 2.6.5 Setting and Getting List Elements . . . . . . . . . . . . . . . . . . . . . . . . 56 2.6.6 Adding and Removing List Elements . . . . . . . . . . . . . . . . . . . . . 59 2.6.7 Working with sorted lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 2.6.8 Working with Iterators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 2.7 Filtered Streams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 2.7.1 Stream Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 2.7.2 Creating and Destroying Streams . . . . . . . . . . . . . . . . . . . . . . . . . 69 2.7.3 Getting and Setting Stream Properties . . . . . . . . . . . . . . . . . . . 70 2.7.4 Managing the Filter Chain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 2.7.5 Reading and Writing Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 2.7.6 Stream Positioning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 2.8 Floating Point Maths . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74

ii 2.8.1 Floating Point Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 2.8.2 Floating Point Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 2.8.3 Rounding Routines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 2.8.4 Exponential and Logarithmic Routines . . . . . . . . . . . . . . . . . . . 77 2.8.5 Number Conversion Routines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 2.8.6 Trigonometric Routines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 2.8.7 Geometry Routines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 2.8.8 Other Maths Routines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 2.8.9 Creation and Destruction of Functions . . . . . . . . . . . . . . . . . . . . 82 2.8.10 Evaluation of Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 2.9 Encoded Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 2.9.1 Text Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 2.9.2 Creating and Destroying Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 2.9.3 Managing Text Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94 2.9.4 Managing Text Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 2.9.5 Comparing Text Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102 2.9.6 Managing Host Encodings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 2.10 Time Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 2.10.1 Time Related Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 2.10.2 Time Creation and Destruction . . . . . . . . . . . . . . . . . . . . . . . . 106 2.10.3 Managing Time Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 2.10.4 Getting Time Intervals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 2.10.5 Time Comparison . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 2.10.6 Time Printing and Parsing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115 2.10.7 Getting the Current Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117 2.10.8 Time Span Creation and Destruction . . . . . . . . . . . . . . . . . . . 117 2.10.9 Managing Time Span Values . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 2.10.10 Time Span Comparison . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121 2.10.11 Calendar Spans Management. . . . . . . . . . . . . . . . . . . . . . . . . . 122 2.10.12 Platform-specific functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125 2.11 The Filesystem Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125 2.11.1 Filesystem Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125 2.11.2 Filesystem Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126 2.11.3 The Filesystem Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126 2.11.3.1 Filesystem Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127 2.11.3.2 Getting File System Properties . . . . . . . . . . . . . . . . . . . . 127 2.11.3.3 Folder Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128 2.11.3.4 Getting File System Item Properties . . . . . . . . . . . . . . . 130 2.11.4 The File Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133 2.11.4.1 File Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134 2.11.4.2 Opening Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134 2.11.4.3 File Properties Management . . . . . . . . . . . . . . . . . . . . . . . 136 2.11.4.4 Comparing Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 2.11.4.5 Managing File Positions . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 2.11.4.6 Changing the Size of a File . . . . . . . . . . . . . . . . . . . . . . . . 140 2.11.4.7 Synchronous Input/Output . . . . . . . . . . . . . . . . . . . . . . . . 140 2.11.4.8 Read in Advance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142 2.11.4.9 Closing and Reopening Files. . . . . . . . . . . . . . . . . . . . . . . 143

iii 2.11.5 The Filesystem Implementation Interface . . . . . . . . . . . . . . . 2.11.5.1 File System Interface Implementation. . . . . . . . . . . . . . 2.11.5.2 File Interface Implementation . . . . . . . . . . . . . . . . . . . . . 2.11.6 The Filesystem Definition Interface . . . . . . . . . . . . . . . . . . . . . 2.11.6.1 File System Definition Data Types . . . . . . . . . . . . . . . . 2.11.6.2 File System Definition Functions . . . . . . . . . . . . . . . . . . 2.12 The Tokeniser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.12.1 Tokeniser data types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.12.2 Creation and destruction of tokenisers . . . . . . . . . . . . . . . . . . 2.12.3 Reading tokens . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.12.4 Writing tokens . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.12.5 Creating and destroying tokens . . . . . . . . . . . . . . . . . . . . . . . . . 2.12.6 Accessing token attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.13 Encryption . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.13.1 Creating and destroying Ciphers . . . . . . . . . . . . . . . . . . . . . . . 2.13.2 Encryption and decryption . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.13.3 Message digest functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.13.4 Utilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144 144 146 148 149 149 150 150 151 154 155 156 159 161 162 163 165 168

3

Object Layer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
3.1 3.2 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . PDF Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.2.1 Object Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.2.2 Generic Functions to Manipulate Objects . . . . . . . . . . . . . . . . 3.2.3 Object Strong References. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.2.4 Compressibility of Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.2.5 Object Collections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.2.6 Real Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.2.7 Integer Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.2.8 Boolean Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.2.9 Name Objects. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.2.10 String Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.2.11 Array Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.2.12 Dictionary Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.2.13 Stream Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.2.14 Null Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.3 Object Documents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.3.1 Object Document Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.3.2 Opening and Closing Object Documents . . . . . . . . . . . . . . . . . 3.3.3 Managing Object Document Properties . . . . . . . . . . . . . . . . . . 3.3.4 Retrieving and Storing Objects . . . . . . . . . . . . . . . . . . . . . . . . . . 3.3.5 Garbage collection in object documents . . . . . . . . . . . . . . . . . . 169 171 171 173 179 181 182 187 189 190 192 195 198 204 213 217 218 218 218 222 225 228

4 5

Document Layer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229 Page Contents Layer . . . . . . . . . . . . . . . . . . . . . . . . . 230

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240 Function index . . . . . . . . . . . . . . . . . . . .2 Architectural limits . .iv 6 Implementation Limits . . . . . . . . . . . . . . . . . . . . . . . . 231 Memory limits . . . . . . . . . . . 231 6. . . 231 Appendix A GNU Free Documentation License . . . . . . . . . . . . . 232 Global variable index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1 6. . . . . . . . . . . . 239 Data type index . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Chapter 1: Overview 1 1 Overview .

The implemented facilities are organized into modules.Chapter 2: Base Layer 2 2 Base Layer 2. 2. Each module exports an API to be used by the client application or other layers of the library.1 Overview The base layer of the GNU PDF Library provides system-independent access to several facilities. Here we also define status types returned by most procedures (there are exceptions though).2.1 Status types pdf_status_t [Data Type] A status variable. This type of variable is returned by many library functions in order to communicate the status of the performed operation.2 Error Management The Error module provides procedures for error reporting to the client as well as for error tracing (via debug messages) to developers. 2. The following constants define the valid values to be held in a pdf_status_t variable: PDF_OK Success [Constant] [Constant] [Constant] [Constant] [Constant] [Constant] [Constant] [Constant] [Constant] PDF_ERROR A serious error PDF_EBADDATA Invalid or bad arguments PDF_ENOMEM Insufficient memory PDF_EEOF End of file PDF_EDIVBYZERO Divison by zero PDF_ENONODE No node found PDF_EINVRANGE Invalid range PDF_ETEXTENC Error in text encoding . Some modules make use of the facilities implemented in other modules (such as allocation or error functions).

const char *format. Returns nothing pdf_status_t st.2. Parameters status fd format . . pdf_i64_add (dest.. addend_1. addend_1. FILE *fd. "Couldn’t do i64 addition"). .)’. pdf_i64_add (dest. also prints the corresponding message. &st). ) [Function] Prints a message with ‘fprintf (fd.. } status code file descriptor open for writing string format for the message format’s arguments Usage example . const char *str ) Prints the message corresponding to status to stderr followed by str. Parameters status str Returns nothing pdf_status_t st. addend_2. addend_2. if status is nonzero. if (st != PDF_OK) { pdf_error (st. &st). if (st != PDF_OK) { pdf_perror (st. format. [Constant] 2. } status code a user-defined message [Function] Usage example void pdf_error (const pdf status t status.... logfd. "couldn’t do i64 addition").Chapter 2: Base Layer 3 PDF_ENOMATCH No matching found This list will grow as we get closer to a mature state of development..2 Error Reporting procedures void pdf_perror (const pdf status t status.

GNU PDF:***DEBUG <layer>***:<file-name>:<line-number>: <message>.. .. In addition. . void* pdf_alloc (const pdf size t size ) Allocates heap memory.Chapter 2: Base Layer 4 2. GNU PDF:***DEBUG BASE***:pdf-fp-func. 10. For example.1). If this value is 0 then no memory is allocated and NULL is returned. PDF_ASSERT_BASE (condition) PDF_ASSERT_OBJECT (condition) PDF_ASSERT_DOCUMENT (condition) PDF_ASSERT_PAGE (condition) Parameters condition Usage example PDF_ASSERT_BASE (1 == 1)..) Parameters message ..3 Memory Allocation The memory allocation module provides system-independent heap memory allocation and deallocation.) PDF_DEBUG_DOCUMENT (message. The usual malloc/free/realloc schema is used to provide this service. [Macro] [Macro] [Macro] [Macro] Output format The output format for these macros is. "string".c:344: division by zero.3 Debugging procedures For each layer there is a macro procedure defined...2. . this module provides a assert macro for each layer. Returns nothing a ’const char*’ string message’s arguments [Macro] [Macro] [Macro] [Macro] Usage example PDF_DEBUG_BASE("Testing macro ’%s’ ’%d’ ’%lf’". . a C expression. . Parameters size [Function] The requested number of octects to allocate.) PDF_DEBUG_PAGE (message... 2. PDF_DEBUG_BASE (message. 7. The file name and the line number at which the error ocurred is printed to stderr followed by message.) PDF_DEBUG_OBJECT (message...

The contents of newly allocated memory are undetermined. If the requested size is larger or equal than the original size of the allocated memory then the previous contents of the allocated memory remains. The memory to deallocate should have been previously allocated using pdf_alloc. Parameters pointer [Function] A pointer pointing to the memory we want to deallocate.Chapter 2: Base Layer 5 Returns A pointer to the newly allocated memory. p = (char *) pdf_alloc (21). char *p. Returns None. The memory to reallocate should have been allocated using pdf_alloc or pdf_realloc. If there is not enough available memory to satisfy the petition then NULL is returned. int *p. Parameters pointer [Function] A pointer to previously allocated memory. The new size of the allocated memory chunk. p = (int *) pdf_alloc (sizeof(int)). size Returns A pointer to the reallocated memory. char *p. Usage example void pdf_dealloc (const void *pointer ) Deallocates heap memory. then a fatal error is signaled killing the current process. If the requested size is shorter than the original size of the allocated memory then it is truncated. Any previous contents in the memory will be lost. *p = 666. An error status is returned to the operating system. Usage Example void* pdf_realloc (const void *pointer. pdf_dealloc (p). If there is not enough available memory to satisfy the request. const pdf size t size ) Reallocates memory. Usage Example .

1 Boolean Types pdf_bool_t A boolean value. /* p now points to "abcd" */ p = (char *) pdf_realloc (5). [Constant] [Constant] [Constant] PDF_I32_MIN Minimum value able to be stored in a pdf_i32_t variable.4 Basic Types 2. The following constants specify the valid ranges for these data types: PDF_I32_MAX Maximum value able to be stored in a pdf_i32_t variable. .4. 4).2 Numeric Types pdf_i32_t Signed 32 bits integer. strncpy (p.Chapter 2: Base Layer 6 p = (char *) pdf_alloc (4). [Data Type] [Data Type] pdf_u32_t Unsigned 32 bits integer.4. [Constant] [Constant] PDF_FALSE Logical false. 2. /* p now points to "abcde" */ p = (char *) pdf_realloc (4). 2. p[4] = ’e’. /* p now points to "abcd" */ pdf_dealloc (p). "abcd". The following constants define the valid values to be held in a pdf_bool_t variable: [Data Type] PDF_TRUE Logical true. PDF_U32_MAX Maximum value able to be stored in a pdf_u32_t variable.

const pdf u32 t low. The low (unsigned) part of the 64 bit integer. const pdf i32 t high. pdf_i64_t bignum. pdf_i64_t pdf_i64_new (const pdf i32 t high. The low (unsigned) part of the 64 bit integer. pdf_i64_t result. Usage example pdf_i64_t *bignum.Chapter 2: Base Layer 7 PDF_U32_MIN Minimum value able to be stored in a pdf_u32_t variable. pdf_status_t *p_status.4. Pointer to a pdf status t variable to hold the status of the operation.3 Big Numbers An implementation of big numbers (64 bit) is also provided. /*bignum is now -10*/ Usage example void pdf_i64_assign (pdf i64 t *bignum. pdf status t *p_status ) [Function] Assign a value based on a 32 bit signed integer and a 32 bit unsigned integer to a 64 bit integer. bignum = pdf_i64_new((1 << 31). A pdf status value: PDF_OK Operation successful PDF_EBADDATA NULL value in bignum. Parameters high low Returns The high (signed) part of the 64 bit integer. result = pdf_i64_new(0.10). This data type can be used in machines not providing true 64 bit integers. Parameters bignum high low p status Returns Variable that stores a 64 bit integer The high (signed) part of the 64 bit integer. [Function] Create a new i64 variable from one 32 bit signed integer and a 32 bit unsigned integer. bignum = &result. 0). . const pdf u32 t low ) The newly created i64 object. [Constant] 2. pdf_i64_t [Data Type] A variable of type pdf i64 t is capable of representing a 64 bit signed integer. If it is NULL then this parameter is ignored.

pdf status t *p_status ) [Function] Assign a value coming from one 32 bit signed integer to a 64 bit signed integer. pdf i64 t *copy. pdf_i64_t result. const pdf i32 t value. [Function] Pointer to a pdf status t variable to hold the status of the operation. -10. If it is NULL then this parameter is ignored. Parameters value bignum p status Returns A signed 32 bit integer Variable that stores 64 bit integer Pointer to a pdf status t variable to hold the status of the operation. pdf_i64_assign_quick(bignum. Note that if the client is in a system supporting true 64 bit scalar types. Parameters orig copy p status Returns Original variable whose data is to be copied. pdf_status_t *p_status.Chapter 2: Base Layer 8 pdf_i64_assign(bignum. A pdf status value: PDF_OK Operation successful PDF_EBADDATA NULL value in bignum. pdf status t *p_status ) Copies the data from orig to copy. if (*p_status != PDF_OK) /*bignum is now -10*/ { /* Error code */ } void pdf_i64_copy (const pdf i64 t orig. 0). if (*p_status != PDF_OK) /*bignum is now -10*/ { /* Error code */ } void pdf_i64_assign_quick (pdf i64 t *bignum. 10. Variable where data is copied to. result = pdf_i64_new(0. p_status). Usage example pdf_i64_t *bignum. (1 << 31). A pdf status value: PDF_OK Operation successful . pdf_i64_ assign_quick will be a macro that will also accept a 64 bit value. If it is NULL then this parameter is ignored. bignum = &result. p_status).

const pdf i32 t addend2. &p_status). addend_2 = pdf_i64_new(0. pdf_i64_copy(orig. pdf_i64_t result. Operation successful A pdf status value: PDF_OK PDF_EBADDATA NULL value in bignum. orig = pdf_i64_new(0. if (*p_status != PDF_OK) /* Now dest is 60 */ { /* Error code */ } void pdf_i64_add_i32 (pdf i64 t *dest. 25).Chapter 2: Base Layer 9 PDF_EBADDATA NULL value in bignum. result = pdf_i64_new(0. addend_1 = pdf_i64_new(0. const pdf i64 t addend2. dest = &result. 35). pdf_i64_t addend_2. [Function] . copy. addend_1. pdf_status_t *p_status. pdf status t *p_status ) Adds a 64bit number and a 32bit number. pdf_status_t *p_status. Usage example pdf_i64_t *dest. pdf_i64_t *copy. Usage example pdf_i64_t orig. pdf_i64_t addend_1. If it is NULL then this parameter is ignored. p_status) if ( *p_status != PDF_OK) /*Now copy is also 10*/ { /* Error code */ } void pdf_i64_add (pdf i64 t *dest. pdf_i64_add (dest. const pdf i64 t addend1. const pdf i64 t addend1. addend_2. 10). pdf status t *p_status ) Adds two 64 bit numbers Parameters addend1 addend2 dest p status Returns First addend of the sum Second addend of the sum Where 64 bit result is stored [Function] Pointer to a pdf status t variable to hold the status of the operation. 0).

Chapter 2: Base Layer 10 Parameters addend1 addend2 dest p status Returns First addend of the sum (64bit type) Second addend of the sum (32 bit) Where 64 bit result is stored Pointer to a pdf status t variable to hold the status of the operation. addend_1 = pdf_i64_new(0. A pdf status value: PDF_OK Operation successful PDF_EBADDATA NULL value in dest. pdf status t *p_status ) Finds the difference between two 64 bit numbers Parameters minuend subtrahend The subtrahend of the subtraction dest p status Returns Where 64 bit result is stored The minuend of the subtraction [Function] Pointer to a pdf status t variable to hold the status of the operation. If it is NULL then this parameter is ignored. . 35. If it is NULL then this parameter is ignored. result = pdf_i64_new(0. dest = &result.p_status) if (*p_status != PDF_OK) /* Now dest is 60 */ { /* Error code */ } void pdf_i64_subtraction (pdf i64 t *dest. addend_1. 25). A pdf status value: PDF_OK Operation successful PDF_EBADDATA NULL value in bignum. pdf_i64_t addend_1. 0). Usage example pdf_i64_t *dest. const pdf i64 t subtrahend. const pdf i64 t minuend. pdf_i64_t result. Usage example pdf_i64_t *dest. pdf_i64_add (dest. pdf_status_t *p_status.

minuend. 0).p_status) if (*p_status != PDF_OK) /* Now dest is -10 */ { /* Error code */ } void pdf_i64_subtraction_i32_min (pdf i64 t *dest. pdf_i64_t subtrahend. p_status) if (*p_status != PDF_OK) /* Now dest is -10 */ { /* Error code */ } void pdf_i64_subtraction_i32_sub (pdf i64 t *dest. If it is NULL then this parameter is ignored. subtrahend = pdf_i64_new(0. const pdf i64 t subtrahend. pdf_i64_t minuend. 35). pdf status t *p_status ) Finds the difference between a 64 bit number and a 32 bit number . 35). result = pdf_i64_new(0. subtrahend = pdf_i64_new(0. minuend = pdf_i64_new(0. const pdf i32 t subtrahend. 25). pdf_i64_t result. const [Function] pdf i64 t minuend. Usage example pdf_i64_t *dest. pdf_status_t *p_status. subtrahend. Operation successful The minuend of the subtraction (32 bits) A pdf status value: PDF_OK PDF_EBADDATA NULL value in dest. result = pdf_i64_new(0. dest = &result. pdf_i64_subtraction (dest. 0). pdf_i64_t subtrahend. subtrahend. dest = &result. pdf_i64_subtraction (dest. pdf_status_t *p_status. 25.Chapter 2: Base Layer 11 pdf_i64_t result. const [Function] pdf i32 t minuend. pdf status t *p_status ) Finds the difference between a 32 bit number and a 64 bit number Parameters minuend subtrahend The subtrahend of the subtraction (64 bits type) dest p status Returns Where 64 bit result is stored Pointer to a pdf status t variable to hold the status of the operation.

result = pdf_i64_new(0. Usage example pdf_i64_t *dest.Chapter 2: Base Layer 12 Parameters minuend subtrahend The subtrahend of the subtraction (32 bits) dest p status Returns Where 64 bit result is stored Pointer to a pdf status t variable to hold the status of the operation. Usage example pdf_i64_t *dest. pdf_i64_t minuend. . If it is NULL then this parameter is ignored. 35. 25). minuend = pdf_i64_new(0. if ( != PDF_OK) /* Now dest is -10 */ { /* Error code */ } void pdf_i64_mult (pdf i64 t *dest. const pdf i64 t factor_2. 0). A pdf status value: PDF_OK Operation successful PDF_EBADDATA NULL value in bignum. const pdf i64 t factor_1. The minuend of the subtraction (64 bits type) A pdf status value: PDF_OK Operation successful PDF_EBADDATA NULL value in dest. pdf status t *p_status ) Multiplication of two 64 bit numbers Parameters factor 1 factor 2 dest p status Returns First factor in the multiplication Second factor in the multiplication Where 64 bit result is stored [Function] Pointer to a pdf status t variable to hold the status of the operation. p_status). minuend. pdf_status_t *p_status. pdf_i64_t result. pdf_i64_subtraction (dest. If it is NULL then this parameter is ignored. dest = &result.

0). factor_1 = pdf_i64_new (0. factor_1. pdf_i64_t factor_1. factor_2. const pdf i64 t factor_1. pdf_status_t *p_status.Chapter 2: Base Layer 13 pdf_i64_t result. pdf_i64_t factor_1. dest = &result. 10). pdf status t *p_status ) Division of two 64 bit numbers [Function] . 10). A pdf status value: PDF_OK Operation successful PDF_EBADDATA NULL value in dest. const pdf i64 t divisor. factor_2 = pdf_i64_new (0. factor_1. factor_1 = pdf_i64_new (0. 100. pdf_i64_mult (dest. 0). const pdf i32 t factor_2. result = pdf_i64_new (0. pdf_i64_mult (dest. result = pdf_i64_new (0. pdf_i64_t result. dest = &result. if ( *p_status != PDF_OK) /* Now dest is 1000 */ { /* Error code */ } void pdf_i64_mult_i32 (pdf i64 t *dest. pdf status t *p_status ) Multiplication of a 64 bit number and a 32 bit number Parameters factor 1 factor 2 dest p status Returns First factor in the multiplication (64 bits) Second factor in the multiplication (32bits) Where 64 bit result is stored [Function] Pointer to a pdf status t variable to hold the status of the operation. If it is NULL then this parameter is ignored. Usage example pdf_i64_t *dest.p_status).p_status) if (*p_status != PDF_OK) /* Now dest is 1000 */ { /* Error code */ } void pdf_i64_div (pdf i64 t *dest. 100). const pdf i64 t dividend. pdf_i64_t factor_2.

. Usage example pdf_i64_t *dest. result. A PDF status value: PDF_OK Operation successful PDF_EBADDATA NULL value in dest.p_status). Usage example pdf_i64_t pdf_i64_t pdf_i64_t pdf_i64_t *dest. divisor. dividend. dividend = pdf_i64_new(0. pdf_i64_div (dest. dest = &result. If it is NULL then this parameter is ignored. const pdf i64 t divisor. divisor = pdf_i64_new(0. result = pdf_i64_new(0. 200). PDF EBADDATA NULL value in dest. 0). const pdf i32 t dividend. divisor.Chapter 2: Base Layer 14 Parameters dividend divisor dest Returns The dividend in the division The divisor in the division Where 64 bit result is stored PDF OK Operation successful PDF EDIVBYZERO Division by zero. pdf status t *p_status ) Division of a 32bit number and a 64bit number Parameters dividend divisor dest p status Returns The dividend in the division (64 bits) The divisor in the division (32 bits) Where 64 bit result is stored [Function] Pointer to a pdf status t variable to hold the status of the operation. if(*p_status != PDF_OK) /* Now dest is 20 */ { /* Error code */ } void pdf_i64_div_i32_dividend (pdf i64 t *dest. pdf_i64_t result. dividend. 10).

If it is NULL then this parameter is ignored. 0). result = pdf_i64_new(0. result = pdf_i64_new(0. pdf_i64_t result. 10) != PDF_OK) /* Now dest is 20 */ { /* Error code */ } void pdf_i64_mod (pdf i64 t *dest. dest = &result. if (pdf_i64_div (dest. divisor = pdf_i64_new(0. pdf_i64_t dividend. 10). if (pdf_i64_div (dest. 200). A PDF status value: PDF_OK Operation successful. const pdf i64 t divisor. const pdf i64 t dividend. Usage example pdf_i64_t *dest. PDF_EBADDATA NULL value in dest. 0). const pdf i32 t divisor. pdf status t *p_status ) Division of a 64bit number and a 32bit number Parameters dividend divisor dest p status Returns The dividend in the division (64 bits) The divisor in the division (32 bits) Where 64 bit result is stored [Function] Pointer to a pdf status t variable to hold the status of the operation. dividend.Chapter 2: Base Layer 15 pdf_i64_t divisor. divisor) != PDF_OK) /* Now dest is 20 */ { /* Error code */ } void pdf_i64_div_i32_divisor (pdf i64 t *dest. const pdf i64 t dividend. pdf status t *p_status ) Returns the remainder of the division between two 64 bit numbers Parameters dividend The dividend in the division [Function] . 200. dest = &result. dividend = pdf_i64_new(0.

pdf_i64_t divisor. A pdf status value: PDF_OK Operation successful PDF_EBADDATA dest is null Usage example pdf_i64_t *dest. 10). pdf_status_t *p_status. dest = &result. if ( *p_status != PDF_OK) /* Now dest is 5 */ { /* Error code */ } void pdf_i64_mod_i32_dividend (pdf i64 t *dest. dividend. pdf_i64_t result. const pdf i64 t divisor. . 105).Chapter 2: Base Layer 16 divisor dest p status Returns The divisor in the division Where 64 bit result is stored Pointer to a pdf status t variable to hold the status of the operation. divisor = pdf_i64_new(0. A pdf status value: PDF_OK Operation successful PDF_EBADDATA NULL value in dest. pdf_i64_t result. pdf_i64_mod (dest. const pdf i32 t dividend. 0). dividend = pdf_i64_new(0. Usage example pdf_i64_t *dest. If it is NULL then this parameter is ignored. pdf_i64_t divisor.p_status). divisor. pdf status t *p_status ) Parameters dividend divisor dest p status Returns The dividend in the division (32bits) The divisor in the division (64bits) Where 64 bit result is stored [Function] Returns the remainder of the division between a 32 bit number and a 64 bit number Pointer to a pdf status t variable to hold the status of the operation. result = pdf_i64_new(0. pdf_i64_t dividend. If it is NULL then this parameter is ignored.

if (pdf_i64_mod (dest. 10) != PDF_OK) /* Now dest is 5 */ { /* Error code */ } void pdf_i64_abs (pdf i64 t *dest. pdf status t *p_status ) Parameters dividend divisor dest p status Returns The dividend in the division (64 bits) The divisor in the division (32 bits) Where 64 bit result is stored [Function] Returns the remainder of the division between a 64 bit number and a 32 bit number Pointer to a pdf status t variable to hold the status of the operation. 10). dividend. 0). divisor) != PDF_OK) /* Now dest is 5 */ { /* Error code */ } void pdf_i64_mod_i32_divisor (pdf i64 t *dest. const pdf i64 t dividend. 105. result = pdf_i64_new(0. A pdf status value: PDF_OK Operation successful PDF_EBADDATA NULL value in dest. 0). pdf_i64_t result. dest = &result. pdf status t *p_status ) Returns the absolute value Parameters number dest pdf i64 t type variable Where 64 bit result is stored [Function] . const pdf i64 t number. if (pdf_i64_mod (dest. Usage example pdf_i64_t *dest. dividend = pdf_i64_new(0. 105). If it is NULL then this parameter is ignored. result = pdf_i64_new(0. pdf_i64_t dividend. const pdf i32 t divisor. dest = &result.Chapter 2: Base Layer 17 divisor = pdf_i64_new(0.

105). /*number is -105*/ result = pdf_i64_new (0. Operation successful A pdf status value: PDF_OK PDF_EBADDATA NULL value in dest.p_status) if ( *p_status != PDF_OK) /* now dest stores 105 */ { /* Error code */ } int pdf_i64_cmp (const pdf i64 t number_1. const pdf i32 t number_2 ) Compares a 64 bit number and a 32 bit number Parameters number 1 pdf i64 t type variable [Function] . number_2). pdf_i64_t result. /* number_2 is 10 */ result = pdf_i64_cmp (number_1. const pdf i64 t number_2 ) Compares two 64 bit integers Parameters number 1 number 2 Returns An integer: 0 1 -1 Usage example pdf_i64_t number_1. If numbers are equal If number 1 is greater than number 2 If number 2 is greater than number 1 pdf i64 t type variable pdf i64 t type variable [Function] number_1 = pdf_i64_new ((1 << 31). 10). pdf_status_t *p_status. number = pdf_i64_new ((1 << 31). 0). int result. /* number_1 is -10 */ number_2 = pdf_i64_new (0. number. If it is NULL then this parameter is ignored.Chapter 2: Base Layer 18 p status Returns Pointer to a pdf status t variable to hold the status of the operation. dest = &result. pdf_i64_t number_2. pdf_i64_t number. Usage example pdf_i64_t *dest. /* Now result is -1 */ int pdf_i64_cmp_i32 (const pdf i64 t number_1. pdf_i64_abs (dest. 10).

If number can’t be represented in 32 bits the result is undefined.p_status) if ( *p_status != PDF_OK) /* now dest stores -10 */ { /* Error code */ } pdf_i32_t pdf_i64_to_i32 (const pdf i64 t bignum ) [Function] Converts a pdf i64 t to a 32 bit value. const pdf i64 t number. 0).Chapter 2: Base Layer 19 number 2 Returns An integer: 0 1 -1 Usage example pdf i32 t type variable If numbers are equal If number 1 is greater than number 2 If number 2 is greater than number 1 pdf_i64_t number_1. so should be used with caution. Parameters bignum pdf i64 t type variable . 10). pdf status t *p_status ) Changes sign of 64 bit integer Parameters number p status Returns pdf i64 t type variable [Function] Pointer to a pdf status t variable to hold the status of the operation. number = pdf_i64_new (0. pdf_i64_t result. Usage example pdf_i64_t *dest. 10). number. dest = &result. If it is NULL then this parameter is ignored. result = pdf_i64_new (0. /* number_1 is -10 */ result = pdf_i64_cmp (number_1. pdf_i64_neg (dest. /* Now result is -1 */ void pdf_i64_neg (pdf i64 t *dest. number_1 = pdf_i64_new ((1 << 31). pdf_i64_t number. 10). int result. A pdf status value: PDF_OK Operation successful PDF_EBADDATA NULL value in dest. pdf_status_t *p_status.

2. if (my_buffer == NULL) { /* Not enough memory */ } Usage example pdf_status_t pdf_buffer_destroy (pdf buffer t buffer ) Destroy a memory buffer.Chapter 2: Base Layer 20 Returns A pdf status value: PDF_OK Operation successful Usage example pdf_i32_t num. in octects. Current write pointer.4. Parameters buffer Returns A pointer to the buffer that will be destroyed. Parameters size Returns The size of the new buffer. pdf_buffer_t my_buffer. bignum = pdf_i64_new (0. Number of octects allocated in data. or NULL if there is not enough memory to serve the petition. data size rp wp Pointer to the buffer contents. pdf_i64_t bignum. num = pdf_i64_to_i32(bignum). 10). my_buffer = pdf_buffer_new (1024). A PDF status value: [Function] . [Data Type] [Function] [Data Type] pdf_buffer_t Pointer to a pdf_buffer_s structure. Current read pointer.4 Memory Buffers struct pdf_buffer_s This structure contains the data associated to a simple memory buffer. pdf_buffer_t pdf_buffer_new (pdf size t size ) Create a new memory buffer. A pointer to a pdf_buffer_s structure.

The buffer is full. my_buffer = pdf_buffer_new (1024). pdf_buffer_t my_buffer. pdf_bool_t pdf_buffer_full_p (pdf buffer t buffer ) Determine whether a memory buffer is full. } /* The buffer should be full now */ if (pdf_buffer_full_p (my_buffer)) { /* Buffer full */ } pdf_buffer_destroy (my_buffer). Usage example int i. Parameters buffer Returns A pointer to a memory buffer. [Function] . A PDF boolean value: PDF_OK PDF_FALSE The buffer is not full. A PDF boolean value: PDF_TRUE The buffer is in an end-of-buffer state. /* Fill the entire buffer */ for (i = 0. [Function] pdf_bool_t pdf_buffer_eob_p (pdf buffer t buffer ) Determine whether a memory buffer is in an end-of-buffer state. i++) { my_buffer->data[my_buffer->wp++] = ’a’. Parameters buffer Returns A pointer to a buffer. /* Create a new buffer */ my_buffer = pdf_buffer_new (1024). pdf_buffer_t my_buffer. i < 1024. pdf_buffer_destroy (my_buffer).Chapter 2: Base Layer 21 PDF_OK Usage example The operation suceeded.

strncpy (my_string. /* Copy some contents into the buffer. /* Create a new buffer */ my_buffer = pdf_buffer_new (3).Chapter 2: Base Layer 22 PDF_FALSE The buffer is not in an end-of-buffer state. [Function] A PDF status variable: PDF_OK PDF_ENOMEM Not enough memory to perform the operation. "abc". filling it entirely */ strncpy (my_buffer->data. pdf_char_t my_char. The operation succeeded. pdf size t newsize ) Resize a memory buffer. /* Create a new buffer */ my_buffer = pdf_buffer_new (4). my_buffer->wp += 3. "0123456789". Usage example pdf_buffer_t my_buffer. /* Read data from the buffer until an eob condition */ while (!pdf_buffer_eob_p (my_buffer)) { my_char = my_buffer->data[my_buffer->rp++]. } pdf_status_t pdf_buffer_resize (pdf buffer t buffer. my_string = pdf_alloc (my_string_size). Parameters buffer newsize Returns A pointer to a memory buffer. 10). my_string[10] = 0. /* Create a string */ my_string_size = 10. pdf_size_t written_bytes. Usage example pdf_buffer_t my_buffer. The new size (in octects) for the buffer. 3). . pdf_char_t *my_string. pdf_size_t my_string_size. pdf_char_t my_char.

"abc". The struct pdf_pm_s structure provides a way for the client application to specify callbacks implemented by a progress monitor. [Function] /* Create a new buffer and initialize its contents */ my_buffer = pdf_buffer_new (3). A PDF status value: PDF_OK Usage example pdf_buffer_t my_buffer. 2. my_buffer->wp += 3. 3). strncpy (my_buffer->data. Parameters buffer Returns A pointer to a memory buffer.Chapter 2: Base Layer 23 /* Copy the contents of my_string into my_buffer making it larger in chunks of 4 bytes */ written_bytes = 0. . while (written_bytes < my_string_size) { if (pdf_buffer_full_p (my_buffer)) { /* Grow the buffer */ pdf_buffer_resize (my_buffer. struct pdf_pm_s [Data Type] Structure containing several callbacks to be called as an operation progress.5 Progress Monitors The client application of the library may want to monitor the progress of some operations. The operation succeeded. /* Replace the contents */ pdf_buffer_rewind (my_buffer). } my_buffer->data[my_buffer->wp] = my_string[my_buffer->wp]. "ABC". my_buffer->wp++.4. pdf_status_t pdf_buffer_rewind (pdf buffer t buffer ) Rewind a memory buffer. my_buffer->wp + 5). } /* Adjust the buffer size */ pdf_buffer_resize (my_buffer. such as the saving of a document. strncpy (my_buffer->data. my_string_size). 3). my_buffer->wp += 3.

[Data Type] pdf_status_t (*pdf_pm_set_duration_fn_t) (void *client_data. void *duration ) Callback implemented by a progress monitor. Parameters client data User supplied data. This callback is called at the end of the operation. Returns This callback should return PDF_OK to the caller. This callback is called to get the current value of the progress monitor duration. Returns This callback should return PDF_OK to the caller. pdf_status_t (*pdf_pm_begin_operation_fn_t) (void *client_data ) [Data Type] Callback implemented by a progress monitor that initializes it to a current value of 0.Chapter 2: Base Layer 24 pdf_pm_begin_operation_fn_t begin_operation_fn pdf_pm_end_operation_fn_t end_operation_fn pdf_pm_get_duration_fn_t get_duration_fn pdf_pm_set_duration_fn_t set_duration_fn pdf_pm_get_current_value_fn_t get_current_value_fn_t pdf_pm_set_current_value_fn_t set_current_value_fn_t pdf_pm_set_text_fn_t set_text_fn The type definitions for the callbacks follows. duration Returns A pointer to a pdf time span t variable to store the current duration of the progress monitor. . void *duration ) Callback implemented by a progress monitor. Parameters client data User supplied data. This callback is called to set the current value of the progress monitor duration. Parameters client data User supplied data. This callback should return PDF_OK to the caller. [Data Type] pdf_status_t (*pdf_pm_end_operation_fn_t) (void *client_data ) Callback implemented by a progress monitor. [Data Type] pdf_status_t (*pdf_pm_get_duration_fn_t) (void *client_data.

This callback should return PDF_OK to the caller. This callback is called to set the description of the current status of the operation to the progress monitor. Parameters client data User supplied data. duration Returns A time span variable containing the new duration for the progress monitor. This callback is called to get the current value of the progress monitor duration. Parameters client data User supplied data. [Data Type] pdf_status_t (*pdf_pm_set_text_fn_t) (void *client_data. This callback is called to set the current value of the progress monitor duration.Chapter 2: Base Layer 25 Parameters client data User supplied data. . This callback should return PDF_OK to the caller. This callback should return PDF_OK to the caller. Parameters client data User supplied data. This callback should return PDF_OK to the caller. void *duration ) Callback implemented by a progress monitor. void *text ) Callback implemented by a progress monitor. void *duration ) Callback implemented by a progress monitor. duration Returns A pointer to a time span variable containing the new duration for the progress monitor. duration Returns A pointer to a pdf time span t variable to store the current duration of the progress monitor. text Returns A text variable containing the new description. [Data Type] pdf_status_t (*pdf_pm_get_current_value_fn_t) (void *client_data. [Data Type] pdf_status_t (*pdf_pm_set_current_value_fn_t) (void *client_data.

separated by the ascii hyphen-minus. PDF_UUID_NAME Name-based UUID as defined by ITU X. also known as Globally Unique Identifiers or GUIDs. [Function] .667. PDF_UUID_RANDOM Random-based UUID as defined by ITU X. On the other hand. If the library is running in a system where no such information is available then a standardized alternative random method is used. pdf_uuid_t pdf_uuid_generate (enum pdf uuid type e type ) Generate a new UUID of the specified type. according to the ITU recommendation.667 Recommendation for the generation of Universal Unique Identifiers. uuid generators should produce lowercase letters in hexadecimal encoding.667. 45 character.Chapter 2: Base Layer 26 2. it is recommended for uuid consumers to be case-insensitive regarding alphabetic characters in hexadecimal strings. [Data Type] [Data Type] enum pdf_uuid_type_e Type of an UUID: PDF_UUID_TIME Time-based UUID as defined by ITU X. Note also that the time-based method makes use of the MAC address of the primary network card installed in the system. pdf_uuid_t Opaque type representing an Universally Unique Identifier. This implementation follows both recommendations. Each UUID is a hexadecimal-coded ascii sequence composed by the following fields.667. except between the VariantAndClockSeqHigh and ClockSeqLow: − TimeLow (4 bytes => 8 hexadecimal digits) − TimeMid (2 bytes => 4 hexadecimal digits) − VersionAndTimeHigh (2 bytes => 4 hexadecimal digits) − VariantAndClockSeqHigh (1 byte => 2 hexadecimal digits) − ClockSeqLow (1 octect => 2 hexadecimal digits) − Node (6 octects => 12 hexadecimal digits) An example of an UUID would be: 00000000-0000-0000-0000-000000000000 There are three standardized ways to generate the values of those fields: − time-based − random-based − name-based Note that.4.6 Universal Unique Identifiers The basic types module provides an implementation of the ITU X.

printf ("The generated UUID: %s\n".5 Hash Tables 2. if (pdf_uuid_equal_p (uuid1. */ uuid = uuid_generate (PDF_UUID_NAME). Parameters uuid Returns A previously generated UUID.Chapter 2: Base Layer 27 Parameters type Returns Usage example pdf_uuid_t uuid. uuid1 = pdf_uuid_generate (PDF_TIME). The generated UUID. pdf uuid t uuid2 ) Determine if two given UUIDs are equal. /* Generate a name-based UUID. [Function] A PDF boolean indicating whether both UUIDs are equal.5. Parameters uuid1 uuid2 Returns Usage example pdf_uuid_t uuid1. uuid2)) { /* Extremely unlikely! */ } The first UUID to compare. . 2. Usage example pdf uuid t uuid. A key may be any NULL-terminated string. const char * pdf_uuid_string (pdf uuid t uuid ) Return an ASCII string with the printed representation of uuid. pdf_uuid_t uuid2. uuid2 = pdf_uuid_generate (PDF_TIME). The second UUID to compare. The type of UUID to generate. pdf uuid string (uuid)). uuid = pdf uuid generate (PDF UUID TIME).1 Hash Table Types pdf_hash_t [Data Type] A Hash Table able to store key/value pairs. [Function] A null-terminated buffer containing the printed representation of uuid. pdf_bool_t pdf_uuid_equal_p (pdf uuid t uuid1.

[Data Type] void (*pdf hash key dispose fn t) (const void *key) A function type for disposing hash keys. [Data Type] 2. . [Data Type] void (*pdf hash element dispose fn t) (const void *elt) A function type for disposing hash elements.5. pdf hash t *table ) [Function] Create a new empty hash table.2 Creating and Destroying Hash Tables pdf_status_t pdf_hash_new (pdf hash key dispose fn t dispose_key_fn. PDF_EBADDATA Invalid table pointer. When some element is removed dispose key fn are called. /* Create an instance of a hash without a disposal function */ if (pdf_hash_new (NULL. &hash) != PDF_OK) { /* Error creating the hash table */ } pdf_status_t pdf_hash_destroy (pdf hash t table ) Destroy a hash table. Parameters table Returns A hash table. A pdf status value: PDF_OK PDF_ENOMEM Not enough memory. The elements of the table are disposed first. Usage example pdf_hash_t hash. can be NULL. [Function] A pdf status value: PDF_OK The operation succeeded. The operation succeeded.Chapter 2: Base Layer 28 pdf_hash_iterator_t An iterator over the keys of a Hash Table. Parameters dispose key fn A pointer to a hash table element key dispose function or NULL. table Returns A pointer to a hash table.

pdf_hash_add (hash. [Function] Returns a boolean value indicating whether an element with key key exists in table.3 Hash Table properties pdf_size_t pdf_hash_size (const pdf hash t table ) Returns the number of entries in table. &hash) == PDF_OK) { /* Destroy the hash */ pdf_hash_destroy (hash). NULL).5. "third-key". } [Function] Usage example 2. "first-key". /* This call should return 3 */ pdf_hash_size (hash). "second-value". pdf_hash_add (hash. } else { /* Error creating the hash table */ } 2. The number of entries. pdf_hash_t hash. "third-key". if (pdf_hash_new (NULL. "first-value". NULL). "second-key". /* Create a new hash */ if (pdf_hash_new (NULL. &hash) == PDF_OK) { /* Add some elements to the hash */ pdf_hash_add (hash. Parameters table Returns A hash table.5. NULL). A valid key string. A pdf boolean value: .Chapter 2: Base Layer 29 Usage example pdf_hash_t hash.4 Working with keys pdf_bool_t pdf_hash_key_p (const pdf hash t table. const char *key ) Parameters table key Returns A hash table.

/* Create a new hash */ if (pdf_hash_new (NULL. There is no element associated with key. const char *new_key ) Renames the key key to new key in table. Usage example pdf_hash_t hash. The operation succeded. PDF_ENOMEM Not enough memory to perform the operation. [Function] A pdf status value: PDF_OK PDF_ERROR The key is not associated with any element in table. PDF_EBADDATA Either table or a key string is invalid or NULL. "a-key")) { /* The program enters here */ } if (pdf_hash_key_p (hash. "x-key")) { /* The program doesnt reach this */ } } pdf_status_t pdf_hash_rename (pdf hash t table. Usage example pdf_hash_t hash. NULL). if (pdf_hash_key_p (hash. A valid key string. /* Create a new hash */ if (pdf_hash_new (NULL. "a-key". "a-value". &hash) == PDF_OK) . Parameters table key new key Returns A hash table. A valid key string.Chapter 2: Base Layer 30 PDF_TRUE PDF_FALSE An element associated with key exists. &hash) == PDF_OK) { /* Add some elements to the hash */ pdf_hash_add (hash. const char *key.

if (pdf_hash_key_p (hash. const char *key. pdf hash element dispose fn t disp_fn ) [Function] Adds the element element with the associated key key to table. if (pdf_hash_key_p (hash. Parameters table key element disp fn Returns A hash table. . "a-key")) { /* The program doesnt enter here */ } if (pdf_hash_key_p (hash. A function called when element is removed. The operation succeeded. If NULL is given nothing is done. "b-key")) { /* The program enters here */ } } 2. A pointer to the element being added. "a-value". PDF_EBADDATA Either table.Chapter 2: Base Layer 31 { /* Add an element to the hash */ pdf_hash_add (hash. A pdf status value: PDF_OK PDF_ENOMEM Not enough memory.5 Adding and removing elements pdf_status_t pdf_hash_add (pdf hash t table. If key already exists nothing is done. "b-key"). const void *element. "a-key")) { /* The program enters here */ } /* Rename the key */ pdf_hash_rename (hash. Usage example pdf_hash_t hash. A valid key string. "a-key". NULL). key or element is invalid.5. "a-key".

NULL). "third-key". A valid key string. } pdf_status_t pdf_hash_remove (pdf hash t table. NULL). The element is disposed first. &hash) == PDF_OK) { /* Add an element to the hash.. /* Create a new hash */ if (pdf_hash_new (NULL.5. . Parameters table key A hash table. "a-key". "second-value". /* And remove it */ pdf_hash_remove (hash. PDF_EBADDATA Invalid table or key. const void **elem_pointer ) [Function] Searches for the element associated with the given key in table and store it in elem pointer. "a-key"). &hash) == PDF_OK) { /* Add some elements to the hash */ pdf_hash_add (hash. "first-value". } 2. pdf_hash_add (hash. A valid null-terminated string key. [Function] Removes the element associated with key from table.6 Searching elements pdf_status_t pdf_hash_get (const pdf hash t table. NULL). A pdf status value: PDF_OK The operation succeeded. const char *key. "third-key". "first-key". pdf_hash_add (hash.Chapter 2: Base Layer 32 /* Create a new hash */ if (pdf_hash_new (NULL. PDF_ERROR The key wasn’t found. NULL).. "a-value". "second-key". */ pdf_hash_add (hash. const char *key ) Parameters table key Returns A hash table. Usage example pdf_hash_t hash.

Chapter 2: Base Layer

33

elem pointer A pointer where to store the element. Returns A pdf status value: PDF_OK The operation succeeded.

PDF_EBADDATA Either elem pointer is NULL, key or the table is invalid. PDF_ERROR The key wasn’t found. Usage example pdf_hash_t hash; char *elem; /* Create a new hash */ if (pdf_hash_new (NULL, &hash) == PDF_OK) { /* Add an element to the hash... */ pdf_hash_add (hash, "a-key", "a-value", NULL); /* Get the element from the hash */ pdf_hash_search (hash, "a-key", (void **) &elem); }

2.5.7 Working with iterators
pdf_status_t pdf_hash_iterator_new (const pdf hash t table, pdf hash iterator t *iterator )
[Function]

Creates an iterator over the keys of table and saves it in iterator. Keys composed only by numbers are returned first followed by keys in the order imposed by the “strcmp()” function. Parameters table iterator Returns A hash table. A pointer to an iterator.

A pdf status value: PDF_OK The operation succeeded.

PDF_EBADDATA Either iterator is NULL or table is invalid. Usage example pdf_hash_t hash; pdf_hash_iterator_t hash_iter; /* Create a new hash */ if (pdf_hash_new (NULL, &hash) == PDF_OK)

Chapter 2: Base Layer

34

{ /* Add some elements to the hash */ pdf_hash_add (hash, "first-key", "first-value", NULL); pdf_hash_add (hash, "second-key", "second-value", NULL); pdf_hash_add (hash, "third-key", "third-key", NULL); /* Get an iterator to the first element of the hash */ pdf_hash_iterator_new (hash, &hash_iter); }

pdf_status_t pdf_hash_iterator_next (pdf hash iterator t iterator, const char **key )
Retrieves the next key from iterator. Parameters iterator key Returns A Hash Table iterator pointer. A pointer where to save the key.

[Function]

A pdf status value: PDF_OK The operation succeeded.

PDF_EBADDATA Either iterator is invalid or key is NULL. PDF_ERROR There are no more keys to traverse over. Usage example pdf_hash_t hash; pdf_hash_iterator_t hash_iter; pdf_char_t *key; /* Create a new hash */ if (pdf_hash_new (NULL, &hash) == PDF_OK) { /* Add some elements to the hash */ pdf_hash_add (hash, "first-key", "first-value", NULL); pdf_hash_add (hash, "second-key", "second-value", NULL); pdf_hash_add (hash, "third-key", "third-key", NULL); /* Traverse all the values of the hash with an iterator */ pdf_hash_iterator_new (hash, &hash_iter); while (pdf_hash_iterator_next (hash_iter, &key) != PDF_ERROR) { /* key contains the next key */ } }

Chapter 2: Base Layer

35

pdf_status_t pdf_hash_iterator_destroy (pdf hash iterator t iterator )
Free all resources used by iterator. Parameters iterator Returns A Hash Table iterator pointer. A pdf status value: PDF_OK Usage example pdf_hash_t hash; pdf_hash_iterator_t hash_iter; The operation succeeded.

[Function]

/* Create a new hash */ if (pdf_hash_new (NULL, &hash) == PDF_OK) { /* Add some elements to the hash */ pdf_hash_add (hash, "first-key", "first-value", NULL); pdf_hash_add (hash, "second-key", "second-value", NULL); pdf_hash_add (hash, "third-key", "third-key", NULL); /* Get an iterator to the first element of the hash */ pdf_hash_iterator_new (hash, &hash_iter); /* Destroy the iterator */ pdf_hash_iterator_destroy (hash_iter); }

2.5.8 Basic dispose functions
These are the basic function implementations to free elements and keys. They should only be used if you allocated elements/keys with pdf alloc() and don’t need to free any other resource.

void pdf_hash_element_dealloc_fn (const void * elt )
Deallocates elt with pdf dealloc(). Parameters elt Returns Nothing. pdf_hash_t hash; pdf_char_t *elem; /* Create a new hash */ if (pdf_hash_new (NULL, &hash) == PDF_OK) { A pointer to the element being freed.

[Function]

Usage example

Chapter 2: Base Layer

36

/* Allocate memory for a value to be inserted into the hash */ elem = pdf_alloc (sizeof(pdf_char_t) * 4); strcpy ((char *) elem, "abc"); /* Add an element to the hash, specifying pdf_hash_element_dealloc_fn as its disposal function */ pdf_hash_add (hash, "a-key", (void *) elem, pdf_hash_element_dealloc_fn); /* Destroy the hash (the disposal function invokes pdf_dealloc in the allocated string */ pdf_hash_destroy (hash); }

void pdf_hash_key_dealloc_fn (const void * elt )
Deallocates elt with pdf dealloc(). Parameters elt Returns Nothing. pdf_hash_t hash; pdf_char_t *key; A pointer to the element being freed.

[Function]

Usage example

/* Create a new hash */ if (pdf_hash_new (pdf_hash_key_dealloc_fn, &hash) == PDF_OK) { /* Allocate memory for a key to be used into the hash */ key = pdf_alloc (sizeof(pdf_char_t) * 4); strcpy ((char *) elem, "abc"); /* Add an element to the hash, using the key */ pdf_hash_add (hash, key, "abc", NULL);

/* Destroy the hash (the key disposal function invokes pdf_dealloc in the allocated string */ pdf_hash_destroy (hash); }

2.5.9 Hash helper functions
These are specific functions for adding and getting different types of elements (types defined by the library). They guarantee that when an element of one of these types is removed from a hash table the correct disposal function is called.

Chapter 2: Base Layer

37

NOTE: If you are going to use the element after the table containing the element is destroyed, in that case don’t use these functions.

pdf_status_t pdf_hash_add_text (pdf hash t table, const char *key, const pdf text t *elt )

[Function]

Adds the text elt with the associated key key to table. If key already exists nothing is done. Parameters table key elt Returns A hash table. A valid key string. A pointer to the element being added.

A pdf status value: PDF_OK PDF_ENOMEM Not enough memory. PDF_EBADDATA Either table, key or elt is invalid. The operation succeeded.

Usage example pdf_hash_t hash; pdf_text_t elem; /* Create a new hash */ if (pdf_hash_new (NULL, &hash) == PDF_OK) { /* Create the element for the hash */ pdf_text_new_from_unicode ("abc", 3, PDF_TEXT_UTF8, &hash); /* Add an element to the hash, specifying pdf_hash_element_dealloc_fn as its disposal function */ pdf_hash_add_text (hash, "a-key", &elem); /* Destroy the hash */ pdf_hash_destroy (hash); }

pdf_status_t pdf_hash_get_text (pdf hash t table, const char *key, pdf text t *elt )
Get a text variable from a hash table. Parameters table The hash table to get the value from.

[Function]

PDF_EBADDATA Either table. Usage example pdf_text_t text.Chapter 2: Base Layer 38 key elt Returns The key associated with the desired value. const pdf time t *elt ) [Function] Adds the time elt with the associated key key to table.. Usage example pdf_hash_t hash. A valid key string. A pointer to the text variable to hold the value. pdf_hash_t table. insert a text variable into the hash . const char *key. &hash) == PDF_OK) { /* Create the element for the hash */ pdf_time_new (&elem). key or elt is invalid.. Parameters table key elt Returns A hash table. pdf_time_t elem. A PDF status variable: PDF_OK The value was successfully stored into elt. A pointer to the element being added. If key already exists nothing is done. &text) != PDF_OK) { /* Error */ } pdf_status_t pdf_hash_add_time (pdf hash t table. The operation succeeded. . /* Create a new hash */ if (pdf_hash_new (NULL.. A pdf status value: PDF_OK PDF_ENOMEM Not enough memory. */ if (pdf_hash_get_text (table. key or the table is invalid. PDF_ERROR The key wasn’t found. PDF_EBADDATA Either elt is NULL. "a text". /* ..

[Function] A PDF status variable: PDF_OK The value was successfully stored into elt.. The key associated with the desired value. Parameters table key elt Returns A hash table. insert a time variable into the hash . PDF_ERROR The key wasn’t found. If key already exists nothing is done. const char *key. Parameters table key elt Returns The hash table to get the value from.Chapter 2: Base Layer 39 /* Add an element to the hash */ pdf_hash_add_time (hash. A valid key string. } pdf_status_t pdf_hash_get_time (pdf hash t table. &elem). pdf time t *elt ) Get a time variable from a hash table. const pdf list t *elt ) [Function] Adds the list elt with the associated key key to table. const char *key. A pointer to the time variable to hold the value.. . pdf_hash_t table. "a-key". "a time". key or the table is invalid.. /* Destroy the hash */ pdf_hash_destroy (hash). A pdf status value: PDF_OK The operation succeeded. A pointer to the element being added. Usage example pdf_time_t time. */ if (pdf_hash_get_time (table. &time) != PDF_OK) { /* Error */ } pdf_status_t pdf_hash_add_list (pdf hash t table.. /* . PDF_EBADDATA Either elt is NULL.

.. key or the table is invalid. "a-key".. &list) != PDF_OK) { /* Error */ } . The key associated with the desired value. pdf_list_t elem. /* Create a new hash */ if (pdf_hash_new (NULL. Usage example pdf_list_t list. } pdf_status_t pdf_hash_get_list (pdf hash t table. Parameters table key elt Returns The hash table to get the value from. /* . PDF_ERROR The key wasn’t found. Usage example pdf_hash_t hash. insert a list variable into the hash . const char *key. /* Add an element to the hash */ pdf_hash_add_list (hash.. pdf_hash_t table. [Function] A PDF status variable: PDF_OK The value was successfully stored into elt. */ if (pdf_hash_get_list (table. PDF_EBADDATA Either elt is NULL. &hash) == PDF_OK) { /* Create the element for the hash */ pdf_list_new (&elem). &elem). "a list". key or elt is invalid.Chapter 2: Base Layer 40 PDF_ENOMEM Not enough memory. A pointer to the list variable to hold the value. pdf list t *elt ) Get a list variable from a hash table. PDF_EBADDATA Either table. /* Destroy the hash */ pdf_hash_destroy (hash).

A valid key string. . /* Create a new hash */ if (pdf_hash_new (NULL. key or elt is invalid. A pointer to the element being added. A pdf status value: PDF_OK PDF_ENOMEM Not enough memory. pdf hash t *elt ) Get a hash variable from a hash table. &hash) == PDF_OK) { /* Create the element for the hash */ pdf_hash_new (&elem). const char *key. const pdf hash t *elt ) [Function] Adds the hash table elt with the associated key key to table. Parameters table key elt Returns A hash table.Chapter 2: Base Layer 41 pdf_status_t pdf_hash_add_hash (pdf hash t table. The operation succeeded. Parameters table key elt Returns The hash table to get the value from. const char *key. /* Add an element to the hash */ pdf_hash_add_hash (hash. A pointer to the hash variable to hold the value. /* Destroy the hash */ pdf_hash_destroy (hash). &elem). PDF_EBADDATA Either table. If key already exists nothing is done. } pdf_status_t pdf_hash_get_hash (pdf hash t table. pdf_hash_t elem. The key associated with the desired value. [Function] A PDF status variable: PDF_OK The value was successfully stored into elt. "a-key". Usage example pdf_hash_t hash.

/* Create a new hash */ if (pdf_hash_new (NULL. . /* Use default cache size */ PDF_STM_READ. &stm). "a hash".Chapter 2: Base Layer 42 PDF_EBADDATA Either elt is NULL. /* . pdf_stm_t elem. Parameters table key elt Returns A hash table. PDF_ERROR The key wasn’t found.. key or elt is invalid. pdf_hash_t table. &hash) != PDF_OK) { /* Error */ } pdf_status_t pdf_hash_add_stm (pdf hash t table. Usage example pdf_hash_t hash. &hash) == PDF_OK) { /* Create the element for the hash */ buf = pdf_alloc (10). pdf_stm_mem_new (buf. insert a hash variable into the hash . PDF_EBADDATA Either table. const pdf stm t *elt ) [Function] Adds the stream elt with the associated key key to table. */ if (pdf_hash_get_hash (table.. Usage example pdf_hash_t hash. A pdf status value: PDF_OK PDF_ENOMEM Not enough memory. A pointer to the element being added. key or the table is invalid. A valid key string.. pdf_char_t *buf. 0. If key already exists nothing is done. 10.. The operation succeeded. const char *key.

. const char *key. PDF_ERROR The key wasn’t found. */ if (pdf_hash_get_stm (table. pdf stm t *elt ) Get a stm variable from a hash table.Chapter 2: Base Layer 43 /* Add the element to the hash */ pdf_hash_add_hash (hash. If key already exists nothing is done. Parameters table key elt A hash table. insert a stm variable into the hash . A pointer to the stm variable to hold the value. "a-key". pdf_hash_t table. A valid key string. &elem). The key associated with the desired value.. "a stm". const pdf size t elt ) [Function] Adds the pdf_size_t value elt with the associated key key to table. /* . key or the table is invalid. Usage example pdf_stm_t stm. /* Destroy the hash */ pdf_hash_destroy (hash). A pdf_size_t value. } pdf_status_t pdf_hash_get_stm (pdf hash t table. PDF_EBADDATA Either elt is NULL. &stm) != PDF_OK) { /* Error */ } pdf_status_t pdf_hash_add_size (pdf hash t table. Parameters table key elt Returns The hash table to get the value from. /* Destroy the memory buffer */ pdf_dealloc (buf). const char *key.. .. [Function] A PDF status variable: PDF_OK The value was successfully stored into elt.

pdf_size_t elem. /* Destroy the memory buffer */ pdf_dealloc (buf). pdf size t *elt ) Get a size variable from a hash table. } pdf_status_t pdf_hash_get_size (pdf hash t table. /* Destroy the hash */ pdf_hash_destroy (hash). The operation succeeded. Usage example pdf_hash_t hash. PDF_ERROR The key wasn’t found. elem). Parameters table key elt Returns The hash table to get the value from. . pdf_hash_t table. const char *key. key or elt is invalid. A pointer to the size variable to hold the value. "a-key". key or the table is invalid. PDF_EBADDATA Either elt is NULL.Chapter 2: Base Layer 44 Returns A pdf status value: PDF_OK PDF_ENOMEM Not enough memory. /* Add the element to the hash */ pdf_hash_add_size (hash. &hash) == PDF_OK) { /* Create the element for the hash */ elem = 10. PDF_EBADDATA Either table. The key associated with the desired value. Usage example pdf_size_t size. [Function] A PDF status variable: PDF_OK The value was successfully stored into elt. /* Create a new hash */ if (pdf_hash_new (NULL.

A valid key string. The operation succeeded. /* Destroy the hash */ pdf_hash_destroy (hash). pdf char t **elt ) Get a string variable from a hash table. strncpy (elem.. */ if (pdf_hash_get_size (table. PDF_EBADDATA Either table. "a-key". pdf_char_t *elem. A pdf status value: pdf_status_t pdf_hash_get_string (pdf hash t table. /* Destroy the memory buffer */ pdf_dealloc (buf). A * pdf_char_t value. /* Create a new hash */ if (pdf_hash_new (NULL. If key already exists nothing is done. &hash) == PDF_OK) { /* Create the element for the hash */ elem = pdf_alloc(4).. &size) != PDF_OK) { /* Error */ } pdf_status_t pdf_hash_add_string (pdf hash t table.. Usage example pdf_hash_t hash. /* Add the element to the hash */ pdf_hash_add_size (hash. 4). "a size". elem). key or elt is invalid. } A hash table. [Function] . "abc".. Parameters table key elt Returns PDF_OK PDF_ENOMEM Not enough memory. const pdf char t *elt ) [Function] Adds the *pdf_char_t value elt with the associated key key to table.Chapter 2: Base Layer 45 /* . const char *key. const char *key. insert a size variable into the hash .

[Data Type] pdf_list_iterator_t A list iterator.1 List Data Types pdf_list_t A list composed by zero or more nodes. you should use the sorted version of each function if it’s available. */ if (pdf_hash_get_string (table. pdf_bool_t (*pdf list element equals fn t) (const void *elt1. insert a string variable into the hash . In case you’re going to work with a sorted list.6. pdf_hash_t table. PDF_ERROR The key wasn’t found. A pointer to the string variable to hold the value. [Data Type] . page 63. 2. PDF_EBADDATA Either elt is NULL. &string) != PDF_OK) { /* Error */ } 2. const void [Data Type] *elt2) A function type for comparing list elements equality. "a string"..6 Lists This section describes how to work with unsorted and sorted lists. key or the table is invalid.. Each node is able to contain a data structure via a void npointer.6..Chapter 2: Base Layer 46 Parameters table key elt Returns The hash table to get the value from. The key associated with the desired value. See Section 2. /* . A PDF status variable: PDF_OK The value was successfully stored into elt. Should return PDF TRUE in case they are equal and PDF FALSE otherwise.7 [Working with sorted lists]. Usage example pdf_char_t *string. [Data Type] pdf_list_node_t [Data Type] A list node. void (*pdf list element dispose fn t) (const void *elt) A function type for disposing list elements..

Parameters equals fn A function to compare list elements. list contains a new empty list. [Function] Destroy a list freeing all used resources. [Function] dispose fn A function to dispose list elements. PDF_ENOMEM Not enough memory to create the list. const void *elt2) [Data Type] A function type for comparing list elements. list_element_destroy. or greater than zero corresponding to whether the first element is considered less than. allow duplicates This parameter indicate if the list is allowed to contain duplicate elements (elements for which equals fn evaluate to PDF_TRUE).2 Creating and Destroying Lists pdf_status_t pdf_list_new (pdf list element equals fn t equals_fn. equal to. The elements of the list are disposed first. Should return the corresponding hash code. equal to. 2. or greater than the second element. A status variable: PDF_OK PDF_EBADDATA list points to NULL. pdf_size_t (*pdf list element hashcode fn t) (const void *elt) [Data Type] A function type for calculating a Hash code given a list element. pdf list element dispose fn t dispose_fn. list Returns A pointer to a list where the new one will be saved. It is used when destroying list elements.Chapter 2: Base Layer 47 int (*pdf list element compar fn t) (const void *elt1... */ } PDF_FALSE pdf_status_t pdf_list_destroy (pdf list t list ) Parameters list The list to be destroyed. pdf list t *list ) Create a new list containing no elements. const pdf bool t allow_duplicates.6. It is used in sort operations. Should return an integer less than. if (pdf_list_new (list_element_equal_p. Usage example pdf_list_t mylist. . &mylist) != PDF_OK) { /* manage the error.

create ‘mylist’. pdf_size_t num_elm. .6. The number of elements inside list... [Function] Usage example 2. */ num_elm = pdf_list_size (mylist).. pdf_list_t mylist.4 Searching for List Elements pdf_status_t pdf_list_search (const pdf list t list. Usage example pdf_list_t list.. Parameters list Returns A list. pdf list node t *node ) Search whether an element is already in the list.. */ pdf_list_destroy (mylist). [Function] A pdf status value: PDF_OK The operation succeeded. /* . PDF_ENONODE element not found.6.insert some elements into ‘mylist’.. const void* element. Usage example pdf_list_t mylist. /* .Chapter 2: Base Layer 48 Returns A pdf status value: PDF_OK The operation succeeded. The searched node if it was found. pdf_list_node_t node.. PDF_EBADDATA Invalid node pointer. The element to search for. Parameters list element node Returns A list..3 Managing List Properties pdf_size_t pdf_list_size (const pdf list t list ) Get the number of elements contained into a given list. 2.

Parameters list start index Index indicating the begin of the search. NULL). PDF_FALSE. PDF_ENONODE element not found. pdf_list_node_t node. /* Create the list */ if (pdf_list_new (list_element_equal_p. /* Allow duplicates */ &list) == PDF_OK) { /* Insert an element into the list */ pdf_list_add_first (list. int elem1. Usage example pdf_list_t list.Chapter 2: Base Layer 49 int elem. const [Function] pdf size t start_index. &node) == PDF_OK) { /* The program should reach this place */ } } pdf_status_t pdf_list_search_from (const pdf list t list. PDF_EINVRANGE start index is greater than the list size or less than 0. node Returns The searched node if it was found. at a position >= start index. (void *) &elem. const void* element. if (pdf_list_new (list_element_equal_p. . int elem3. (void *) &elem. list_element_destroy. list_element_destroy. A pdf status value: PDF_OK The operation succeeded. int elem2. /* Search for that element into the list */ if (pdf_list_search (list. A list. PDF_EBADDATA Invalid node pointer. pdf list node t *node ) Search whether an element is already in the list.

NULL). (list. (list. PDF_ENONODE element not found. (void *) &elem1. &node) == PDF_OK) { /* The program should never reach this place. Parameters list start index Index to the first list position to be searched. 1. [Function] const pdf size t start_index. PDF_EBADDATA Invalid node pointer. /* Search for an element into the list */ if (pdf_list_search_from (list. NULL). (void *) &elem1. pdf list node t *node ) Search whether an element is already in the list. /* Allow duplicates */ &list) == PDF_OK) { /* Insert several pdf_list_add_last pdf_list_add_last pdf_list_add_last elements into the list */ (list. at a position >= start index and < end index.Chapter 2: Base Layer 50 PDF_FALSE. since elem1 occupies the first position (0) in the list */ } } pdf_status_t pdf_list_search_from_to (const pdf list t list. PDF_EINVRANGE start index or end index is greater than the list size or less than 0. const pdf size t end_index. The seached node if it was found. (void *) &elem2. end index Index to the last list position to be searched. A list. element node Returns The element to search for. A pdf status value: PDF_OK The operation succeeded. . NULL). const void* element. (void *) &elem3.

NULL). pdf_list_add_last (list. Parameters list node prev Returns A list. (void *) &elem3. since elem4 occupies the last position (3) in the list */ } } pdf_status_t pdf_list_next_node (const pdf list t list. int elem4. int elem3. (void *) &elem4. A pointer where the next node will be saved. pdf_list_add_last (list. (void *) &elem4. A node contained in list.Chapter 2: Base Layer 51 Usage example pdf_list_t list. . pdf list node t *next ) Return the node immediately after the given node in the list. pdf_list_node_t node. (void *) &elem1. pdf_list_add_last (list. 3. &node) == PDF_OK) { /* The program should never reach this place. list_element_destroy. int elem2. PDF_ENONODE Next node not found. PDF_EBADDATA Invalid next pointer. 1. NULL). NULL). const pdf list node t node. /* Allow duplicates */ &list) == PDF_OK) { /* Insert several elements into the list */ pdf_list_add_last (list. NULL). [Function] A pdf status value: PDF_OK The operation succeeded. int elem1. /* Search for an element into the list */ if (pdf_list_search_from_to (list. PDF_FALSE. (void *) &elem2. if (pdf_list_new (list_element_equal_p.

if (pdf_list_new (list_element_equal_p. PDF_FALSE. (void *) &elem1. &node_first). pdf_list_node_t node_second. NULL). [Function] A pdf status value: PDF_OK The operation succeeded. Usage example pdf_list_t list. Parameters list node prev Returns A list. /* Allow duplicates */ &list) == PDF_OK) { /* Insert several elements into the list */ pdf_list_add_last (list. /* Get the next node in the list */ pdf_list_next_node (list. /* Get the node containing "elem1" */ pdf_list_search (list. NULL). . pdf_list_node_t node_second. int elem1. int elem1. (void *) &elem2. /* Now node_second is the node containing elem2 */ } pdf_status_t pdf_list_previous_node (const pdf list t list. PDF_ENONODE Previous node not found. pdf_list_add_last (list. const pdf list node t node. int elem2. first_node. PDF_EBADDATA Invalid prev pointer. A pointer where the previous node will be saved. pdf list node t *prev ) Return the node immediately before the given node in the list. pdf_list_node_t node_first. (void *) &elem1. pdf_list_node_t node_first.Chapter 2: Base Layer 52 Usage example pdf_list_t list. &node_second). A node contained in list. list_element_destroy.

/* Allow duplicates */ &list) == PDF_OK) { /* Insert several elements into the list */ pdf_list_add_last (list. PDF_ENONODE element not found. (void *) &elem2. pdf_list_add_last (list. pdf_list_node_t node_second. pdf_list_node_t node_first. (void *) &elem1. A pointer to user data. pdf_size_t index_of_elem2.Chapter 2: Base Layer 53 int elem2. A pdf status value: PDF_OK The operation succeeded. &node_first). Parameters list element position Returns A list. . NULL). [Function] A pointer where the element position will be saved. NULL). list_element_destroy. PDF_EBADDATA Invalid or NULL pointers. /* Get the previous node in the list */ pdf_list_previous_node (list. Usage Example pdf_list_t list. &node_second). /* Now node_first is the node containing elem2 */ } pdf_status_t pdf_list_indexof (const pdf list t list. int elem2. const void* element. /* Get the node containing "elem2" */ pdf_list_search (list. pdf size t *position ) Search whether an element is already in the list. if (pdf_list_new (list_element_equal_p. list_element_destroy. int elem1. second_node. (void *) &elem2. if (pdf_list_new (list_element_equal_p. PDF_FALSE.

int elem4. PDF_ENONODE element not found. const void* element. PDF_EBADDATA Invalid or NULL pointers. A pointer where the element position will be saved. pdf_list_node_t node_first. int elem3. . /* Get the index of elem2 */ pdf_list_indexof (list. pdf_list_node_t node_second.Chapter 2: Base Layer 54 PDF_FALSE. if (pdf_list_new (list_element_equal_p. at a position >= start index. (void *) &elem2. pdf_list_add_last (list. (void *) &elem2. A pdf status value: PDF_OK The operation succeeded. pdf size t *position ) Search whether an element is already in the list. NULL). (void *) &elem1. const [Function] pdf size t start_index. A list. Parameters list start index An index to a position in list. list_element_destroy. NULL). pdf_size_t index_of_elem1. Usage example pdf_list_t list. /* Now size_of_elem2 contains 1 */ } pdf_status_t pdf_list_indexof_from (const pdf list t list. &size_of_elem2). int elem2. /* Allow duplicates */ &list) == PDF_OK) { /* Insert several elements into the list */ pdf_list_add_last (list. element position Returns The element to search for. int elem1. PDF_EINVRANGE start index or end index is greater than the list size or less than 0.

at a position >= start index and < end index. &size_of_elem1) == PDF_ENONODE) { /* The program reaches this point. PDF_ENONODE element not found. NULL). (void *) &elem1. /* Get the index of elem1 */ if (pdf_list_indexof_from (list. Parameters list start index A position in list. const pdf size t end_index. (void *) &elem1. A list. (void *) &elem4. const void* element. (void *) &elem2. (list. NULL). since elem1 occupies the first position into the list */ } } pdf_status_t pdf_list_indexof_from_to (const pdf list t list.Chapter 2: Base Layer 55 PDF_FALSE. pdf size t *position ) Search whether an element is already in the list. PDF_EBADDATA Invalid or NULL pointers. NULL). . /* Allow duplicates */ &list) == PDF_OK) { /* Insert several pdf_list_add_last pdf_list_add_last pdf_list_add_last pdf_list_add_last elements into the list */ (list. A pdf status value: PDF_OK The operation succeeded. [Function] const pdf size t start_index. (void *) &elem3. PDF_EINVRANGE start index or end index is greater than the list size or less than 0. NULL). element position Returns A pointer to some user data. (list. (list. A pointer where the element position will be saved. 1. end index A position in list.

pdf_list_node_t node_first. Usage example . A node of list.5 Setting and Getting List Elements void * pdf_list_node_value (const pdf list t list. NULL). pdf_list_add_last (list. [Function] The element value represented by node. (void *) &elem2. pdf_list_add_last (list. Parameters list node Returns A list. (void *) &elem1. NULL). int elem1. &size_of_elem4) == PDF_ENONODE) { /* The program reaches this point. NULL). list_element_destroy. if (pdf_list_new (list_element_equal_p. PDF_FALSE. (void *) &elem1. since elem4 occupies the last position (3) into the list */ } } 2. pdf_size_t index_of_elem4. /* Allow duplicates */ &list) == PDF_OK) { /* Insert several elements into the list */ pdf_list_add_last (list. NULL).6. (void *) &elem3. pdf_list_add_last (list. int elem3. int elem1. int elem2. 1. const pdf list node t node ) Get the element value represented by a list node. pdf_list_node_t node_second. pdf_list_t list. (void *) &elem4. pdf_list_node_t node.Chapter 2: Base Layer 56 Usage example pdf_list_t list. /* Get the index of elem4 */ if (pdf_list_indexof_from_to (list. 3. int elem4.

if (pdf_list_new (list_element_equal_p. } pdf_status_t pdf_list_get_at (const pdf list t list. /* Allow duplicates */ &list) == PDF_OK) { /* Insert an element into the list */ pdf_list_add_last (list. Parameters list position value Returns A list. A pdf status value: PDF_OK The operation succeeded. Usage example pdf_list_t list. A position in list. (void *) &elem1. (void *) &elem1. PDF_FALSE. &node). int elem1. (void *) &elem1. NULL). /* Get the node of the element of the list */ pdf_list_search (list. (list). NULL). /* Allow duplicates */ &list) == PDF_OK) { /* Insert an element into the list */ pdf_list_add_last (list. /* Get the value out of the node */ pointer_to_elem1 = (int *) pdf_list_node_value (list. list_element_destroy. PDF_EINVRANGE Invalid position PDF_EBADDATA Invalid value pointer. list_element_destroy. node). PDF_FALSE.Chapter 2: Base Layer 57 int *pointer_to_elem1. if (pdf_list_new (list_element_equal_p. int *pointer_to_elem1. . const void **value ) Get the element at a given position in the list. [Function] Must be >= 0 and < pdf_list_size A pointer to which the element will be saved. const pdf size t position.

[Function] Must be >= 0 and < pdf_list_size A pointer to save the node containing the replaced element or NULL. const void* element. pdf list node t *node ) Replace the element at a given position in a list. (void *) &c. PDF_FALSE. A position in list. NULL). &pointer_to_elem_1). PDF_BADDATA The list does not allow duplicated values and already contain element. PDF_EINVRANGE Invalid position range. (list). NULL). pdf_list_add_last (list. /* Now the list contains abc */ . PDF_ENOMEM Not enough memory to perform the operation. pdf_u32_t a. pdf_u32_t c. The new element. const pdf size t position. NULL). (void *) &a.Chapter 2: Base Layer 58 /* Get the first element of the list */ pdf_list_get_at (list. /* Allow duplicates */ &list) == PDF_OK) { /* Insert the elements into the list */ pdf_list_add_last (list. /* Create a list of integers */ if (pdf_list_new (NULL. A pdf status value: PDF_OK The operation succeeded. (void *) &b. NULL. pdf_u32_t x. Usage example pdf_list_t list. pdf_list_add_last (list. Parameters list position element node Returns A list. } pdf_status_t pdf_list_set_at (pdf list t list. pdf_u32_t b. 0.

NULL. const void* element. If non NULL. /* Now the list contains axc */ } 2. */ } pdf_status_t pdf_list_add_last (pdf list t list.6 Adding and Removing List Elements pdf_status_t pdf_list_add_first (pdf list t list. 1. a list node variable used to contain the added element. PDF_EBADDATA The list does not allow duplicated values and already contain element. &sublist). /* Create empty lists. pdf_list_new (NULL. (void *) &sublist.Chapter 2: Base Layer 59 pdf_list_set_at (list. A pointer to the user data to be stored as a list element. PDF_FALSE. . (void *) &x. NULL) != PDF_OK) { /* Error adding the element to the list. pdf list node t *node ) [Function] Add an element as the first element of the list. */ if (pdf_list_add_first (list.6. */ pdf_list_new (NULL. pdf_list_t sublist. A PDF status value: PDF_OK The element was inserted successfully. If node is not NULL then a reference to the newly created node is copied to it. PDF_FALSE. PDF_ENOMEM Not enough memory to perform the operation. If node is not NULL then a reference to the newly created node is copied to it. Parameters list element node Returns A list. Usage example pdf_list_t list. const void* element. NULL. /* Set the sublist as the first element of the list. NULL). pdf list node t *node ) [Function] Add an element as the last element of the list. &list).

NULL) != PDF_OK) { /* Error appending the element to the list. A pointer to the node where the given element was stored or NULL. A pdf status value: PDF_OK The operation succeeded.Chapter 2: Base Layer 60 Parameters list element node Returns A list. PDF_ENOMEM Not enough memory to perform the operation. /* Append my_var to ’list’. PDF_EINVRANGE Invalid range of given position. [Function] A position in the list. PDF_EBADDATA The list does not allow duplicated values and already contain element. my_t my_var. Should be >= 0 and <= pdf_list_size (list). A pointer to the user data to be stored as a list element. A pointer to the user data to be stored as a list element. Parameters list position element node Returns A list. const pdf size t position. PDF_BADDATA The list does not allow duplicated values and already contain element. If non NULL. A PDF status value: PDF_OK The element was inserted successfully. const void* element. */ } pdf_status_t pdf_list_add_at (pdf list t list. (void *) &my_var. . Usage example pdf_list_t list. a list node variable used to contain the added element. */ if (pdf_list_add_last (list. pdf list node t *node ) Add an element at a given position in the list.

Chapter 2: Base Layer 61 PDF_ENOMEM Not enough memory to perform the operation. /* (a c) */ pdf_list_add_at (list. PDF_FALSE. /* Create the list and add some elements to it. (void *) &elem1. */ &list) == PDF_OK) { /* Add some elements to the list. pdf_list_search (list. Usage example pdf_list_t list. /* Allow duplicates. int elem1. NULL. NULL). if (pdf_list_new (NULL. /* (a b c) */ pdf_status_t pdf_list_remove_node (pdf list t list. /* (a) */ pdf_list_add_at (list. 0. int elem3. (void *) &c). 1. (void *) &a). int elem2. /* Remove the element containing ’elem2’ from ’list’. b. &list). (void *) &b). (void *) &elem3. Parameters list node Returns A list. PDF_FALSE. pdf_list_add_last (list. (void *) &elem2. pdf_list_add_last (list. NULL). c. NULL. &node). The node to be removed. */ } } */ . */ pdf_list_add_last (list. int a. NULL). node) != PDF_OK) { /* Error removing the node from the list. (void *) &elem2. if (pdf_list_remove_node (list. 1. pdf_list_new (NULL. [Function] A pdf status value: PDF_OK Usage example pdf_list_t list. */ pdf_list_add_at (list... const pdf list node t node ) Remove an element from the list. pdf_list_node_t node.

*/ &list) == PDF_OK) { /* Add some elements to the list. (list). if (pdf_list_new (NULL. NULL). pdf_list_add_last (list. /* Allow duplicates. (void *) &elem1. */ pdf_list_add_last (list. */ } } */ pdf_status_t pdf_list_remove (pdf list t list. [Function] A pdf status value: PDF_EBADDATA element was not found in the list. [Function] Must be >= 0 and < pdf_list_size A pdf status value: PDF_OK The operation succeeded. (void *) &elem3. element was found in the list and was removed. Parameters list element Returns PDF_OK A list. pdf_list_add_last (list. The element to be removed. 1) != PDF_OK) { /* Error removing the node from the list. A position in list. int elem1. NULL). if (pdf_list_remove_at (list. NULL). /* Remove the element containing ’elem2’ from ’list’.Chapter 2: Base Layer 62 pdf_status_t pdf_list_remove_at (pdf list t list. (void *) &elem2. const void * element ) Search and remove an element from the lsit. const pdf size t position ) Remove an element at a given position from the list. Usage example pdf_list_t list. NULL. int elem3. . PDF_FALSE. Parameters list position Returns A list. PDF_EINVRANGE Invalid position range. int elem2.

pdf list node t * element_node ) Add an element to the list. pdf list element compar fn t compar_fn. NULL). PDF_FALSE. PDF_ENOMEM Not enough memory to perform the operation. NULL). compar fn A comparision function. (void *) &elem1. Usage example XXX . Returns A pdf status value: PDF_OK The operation succeeded. (void *) &elem2) != PDF_OK) { /* Error removing the node from the list.Chapter 2: Base Layer 63 Usage example pdf_list_t list. Can be NULL. NULL. int elem1. int elem3. (void *) &elem3. */ &list) == PDF_OK) { /* Add some elements to the list.6. NULL). /* Allow duplicates. if (pdf_list_new (NULL. int elem2. Parameters list A list. PDF_EBADDATA Invalid compar fn pointer. [Function] element node A pointer where the added element node will be saved. /* Remove the element containing ’elem2’ from ’list’.7 Working with sorted lists pdf_status_t pdf_list_sorted_add (pdf list t list. element A pointer to the user data to be stored as a list element. */ if (pdf_list_remove (list. */ pdf_list_add_last (list. pdf_list_add_last (list. */ } } 2. pdf_list_add_last (list. (void *) &elem2. const void* element.

at a position >= start index and < end index. Usage example XXX pdf_status_t pdf_list_sorted_search_from_to (const pdf list t [Function] list. compar fn A comparision function. PDF_ENONODE element was not found in the list. PDF_ENONODE element not found. [Function] A pdf status value: PDF_OK element was found in the list and was removed. Usage example XXX pdf_status_t pdf_list_sorted_search (const pdf list t list.Chapter 2: Base Layer 64 pdf_status_t pdf_list_sorted_remove (pdf list t list. pdf list element compar fn t compar_fn. const void * element ) Search and remove an element from the list. [Function] A pdf status value: PDF_OK The operation succeeded. Parameters list A list. const pdf size t end_index. const pdf size t start_index. pdf list node t *node ) Search whether an element is already in the list. pdf list element compar fn t compar_fn. element Returns The element to be removed. . PDF_EBADDATA Invalid compar fn. const void* element. The searched node if it was found. element node Returns The element to search for. pdf list node t *node ) Search whether an element is already in the list. const void* element. compar fn A comparision function. Parameters list A list. pdf list element compar fn t compar_fn. PDF_EBADDATA Invalid node pointer or compar fn.

Chapter 2: Base Layer 65 Parameters list A list. compar fn A comparision function. [Function] pdf list element compar fn t compar_fn. element node Returns The element to search for. PDF_EBADDATA Invalid node pointer or compar fn. A pdf status value: PDF_OK The operation succeeded. compar fn A comparision function. const void* element. element position Returns A pointer to user data. A pdf status value: PDF_OK The operation succeeded. pdf size t *position ) Search whether an element is already in the list. PDF_ENONODE element not found. The seached node if it was found. Usage Example XXX . A pointer where the element position will be saved. Usage example XXX pdf_status_t pdf_list_sorted_indexof (const pdf list t list. PDF_ENONODE element not found. start index Index to the first list position to be searched. end index Index to the last list position to be searched. Parameters list A list. PDF_EINVRANGE start index or end index is greater than the list size or less than 0. PDF_EBADDATA Invalid or NULL pointers.

Parameters list itr Returns A list. The list contents must not be modified while the iterator is in use. pdf list iterator t *itr ) [Function] Create an iterator traversing a list. The operation succeeded. const pdf size t start_index. pdf size t *position ) Search whether an element is already in the list. except for replacing or removing the last returned element. PDF_EINVRANGE start index or end index is greater than the list size or less than 0.8 Working with Iterators pdf_status_t pdf_list_iterator (const pdf list t list. A list. element position Returns A pointer to some user data.6. const void* element. A pointer where the element position will be saved. end index A position in list. at a position >= start index and < end index. A status variable: PDF_OK PDF_EBADDATA itr points to NULL. A pointer to where the new iterator will be saved. pdf list element compar fn t compar_fn. const pdf size t end_index. compar fn A comparision function. PDF_EBADDATA Invalid or NULL pointers. Parameters list start index A position in list.Chapter 2: Base Layer 66 pdf_status_t pdf_list_sorted_indexof_from_to (const pdf list t [Function] list. itr contains a new iterator for list. . Usage example XXX 2. A pdf status value: PDF_OK PDF_ENONODE element not found.

. store its node in *node pointer if it is non-NULL. There is a next element. A status variable: PDF_OK itr contains a new iterator for list pointing to start index. node pointer A pointer to a list node. const pdf size t end_index. Usage example XXX pdf_status_t pdf_list_iterator_next (pdf list iterator t *iterator. end index A position in list. pdf list iterator t *itr ) Create an iterator traversing the element with indices i. itr Returns A pointer to an iterator where the new one will be saved. except for replacing or removing the last returned element. pdf list node t *node_pointer ) [Function] If there is a next element. Parameters iterator A list iterator. [Function] const pdf size t start_index.Chapter 2: Base Layer 67 Usage example XXX pdf_status_t pdf_list_iterator_from_to (const pdf list t list. element pointer A pointer to a pointer to user data. Returns A pdf status value: PDF_OK PDF_ERROR There is not a next element. const void **element_pointer. The list contents must not be modified while the iterator is in use. start_index <= i < end_ index. PDF_EINVRANGE start index or end index is greater than the list size or less than 0. of a list. store the next element in *element pointer. A list. PDF_EBADDATA itr points to NULL. and advance the iterator. Parameters list start index A position in list.

Chapter 2: Base Layer 68 Usage example XXX pdf_status_t pdf_list_iterator_free (pdf list iterator t *iterator ) Free an iterator releasing any used resource.1 Stream Types pdf_stm_t A stm variable. PDF_STM_WRITE The stm will be used to write data into the open file or memory buffer. for example. Parameters iterator Returns A list iterator.7 Filtered Streams This module provides read/write streams of data to memory buffers and open files adding the following functionality: − Filtering. This provides a convenient access to files with several parts requiring different filters to read or write its contents. [Data Type] [Data Type] enum pdf_stm_mode_e The operation mode of a stm object. to provide efficient character-based I/O. PDF_STM_READ The stm will be used to read data from the open file or memory buffer. A pdf status value: PDF_OK Usage example XXX [Function] 2. The size of the buffer is specified by the client in creation time. Filters (such as the PDF standard ones) are supported for both reading and writing. Many filters may be used in a single stream (those filters are applied in an order when writing and in the inverse order when reading). This is used. 2. − Buffering. Several streams can be created to operate in the same open file. Note that the streams operating in memory buffers do not provide buffering. enum pdf_stm_filter_type_e The several types of supported stream filters. [Data Type] . The file streams maintain a buffer for both reading and writing.7.

Position into the file. measured in octects.2 Creating and Destroying Streams pdf_status_t pdf_stm_file_new (pdf fsys file t file. mode stm Returns The operation mode for the stream. cache size The desired size for the stream cache. A PDF status value: . PDF_STM_FILTER_AESV2_ENC AESV2 encoder. Parameters file offset An open file.7. PDF_STM_FILTER_MD5_ENC MD5 encoder. A pointer to the stm to be created. PDF_STM_FILTER_RL_ENC Run-Length encoder. PDF_STM_FILTER_FLATE_ENC Flate (zlib) encoder. PDF_STM_FILTER_AHEX_DEC ASCII Hex decoder. PDF_STM_FILTER_FLATE_DEC Flate (zlib) decoder. PDF_STM_FILTER_V2_ENC V2 encoder. enum pdf stm mode e mode. If it is 0 then the default size (4kb) is used. pdf size t cache_size. pdf stm t *stm ) Create a new stream operating in a given open file. PDF_STM_FILTER_V2_ENC V2 decoder.Chapter 2: Base Layer 69 PDF_STM_FILTER_AHEX_ENC ASCII Hex encoder. PDF_STM_FILTER_RL_DEC Run-Length decoder. 2. pdf off t [Function] offset. PDF_STM_FILTER_JBIG2_DEC JBIG2 decoder. PDF_STM_FILTER_AESV2_DEC AESV2 decoder.

measured in octects. [Function] A PDF status value. pdf size t [Function] size. The stream was successfully created. Parameters stm Returns A stream. Parameters buffer size Memory buffer where the information will be written-to or readed-from.7.3 Getting and Setting Stream Properties pdf_stm_get_mode (pdf_stm_t stm ) Return the mode of a given stream stm. In that case the return code of pdf_stm_flush is returned. A PDF status value: PDF_OK PDF_ERROR There was an error and the stream was not created. [Function] . The mode of the stream.Chapter 2: Base Layer 70 PDF_OK PDF_ERROR The stream object was successfully created. The desired size for the memory buffer. measured in octects. Usage example XXX pdf_status_t pdf_stm_destroy (pdf stm t stm ) Destroy a stream freeing all the used resources. cache size The desired size for the stream cache. This is PDF_OK unless the closed stream is a writing stream. Parameters stm Returns A stream. If it is 0 then the default size (4kb) is used. pdf stm t *stm ) Create a new stream operating in a memory buffer. A pointer to the stm to be created. There was an error and the stream was not created. Usage example XXX pdf_status_t pdf_stm_mem_new (pdf char t *buffer. XXX Usage example 2. mode stm Returns The operation mode for the stream. pdf size t cache_size. enum pdf stm mode e mode.

/* Returns PDF_STM_WRITE */ 2. /* Use the default cache size */ PDF_STM_WRITE. 2048. A stream.Chapter 2: Base Layer 71 Usage example pdf_stm_t stm. pdf hash t filter_params ) Install a fiter in the filter chain of a stream. pdf_status_t pdf_stm_install_filter (pdf stm t stm. enum [Function] pdf stm filter type e filter_type.7. filter type The type of the filter to be installed. pdf_stm_get_mode (stm). filter params Hash table containing a set of key-value pairs with the parameters for the filter.5 Reading and Writing Data pdf_status_t pdf_stm_read (pdf stm t stm.7. The number of octects to read. 2. 0. &stm). pdf_stm_mem_new (buffer. pdf size t bytes. pdf char t *buf. Usage example XXX The filter was successfully installed in the stream. Returns A PDF status value: PDF_OK PDF_ERROR There was an error and the filter was not installed in the stream. The buffer to hold the read data. Parameters stm A stream.4 Managing the Filter Chain The following functions can be used to build the filter chain of a given stream. [Function] . If this value is less than bytes then an end of file condition occurred. pdf size t *read_bytes ) Read a chunk of data from a given stream. Parameters stm buf bytes read bytes The number of octects actually read.

All the requested bytes were successfully read into buf. Parameters stm buf bytes A stream. Returns A PDF status value: PDF_OK PDF_EEOF PDF_EINVOP Writting was requested in a read stream. const pdf char t *buf. Parameters stm c Returns A stream. The number of bytes to write into the stream. . Usage example XXX pdf_status_t pdf_stm_write (pdf stm t stm. [Function] A PDF status value: PDF_OK A character was successfully read into c. pdf char t *c ) Read a character from a given stream. Usage example XXX All the requested bytes were successfully written into stm. pdf size t *written_bytes ) Write a chunk of data into a given stream. PDF_ERROR An error prevented to read the bytes. The buffer containing the written information. PDF_ERROR An error prevented to write the bytes. [Function] written bytes A pointer to a PDF size containing the number of octects actually written. If the returned value is less than bytes then a disk full condition has occured. An end of file condition occurred. pdf_status_t pdf_stm_read_char (pdf stm t stm. The address of a character. A disk full condition occurred. pdf size t bytes.Chapter 2: Base Layer 72 Returns A PDF status value: PDF_OK PDF_EEOF PDF_EINVOP Reading was requested in a writing stream.

Reading was requested in a writing stream. The address of a character. Usage example XXX pdf_status_t pdf_stm_peek_char (pdf stm t stm.Chapter 2: Base Layer 73 PDF_EEOF PDF_EINVOP End of file. A disk full condition occurred. PDF_ERROR An error prevented to read the character. pdf char t *c ) Peek a character from a given stream. Parameters stm finish p A stream. A boolean value indicating whether to finalize the filter chain. Usage example XXX pdf_status_t pdf_stm_flush (pdf stm t stm. May be 0. . A character was successfully peek into c. All the requested bytes were successfully written into stm. flushed bytes A pointer to a pdf_size_t variable to hold the number of flushed bytes. PDF_ERROR An error prevented to peek the character. pdf size t *flushed_bytes ) [Function] Flush any pending writing data in a given stream. Parameters stm c Returns A stream. Returns A PDF status value: PDF_OK PDF_EEOF PDF_EINVOP Writting was requested in a read stream. End of file. pdf bool t finish_p. [Function] A PDF status value: PDF_OK PDF_EEOF PDF_EINVOP Peeking was requested in a writing stream. If finish p equals to PDF_TRUE then the filters in the stream’s filter chain are tell to generate any remaining output.

XXX Usage example pdf_off_t pdf_stm_btell (pdf stm t stm ) Parameters stm Returns A stream.6 Stream Positioning pdf_off_t pdf_stm_bseek (pdf stm t stm. if no bseek was made. pdf off t pos ) Seek into the backend of a given stream.Chapter 2: Base Layer 74 PDF_ERROR An error prevented to write the bytes. XXX Usage example 2. Usage example XXX 2.8 Floating Point Maths . [Function] The new position of the stream read/write pointer. Parameters stm pos Returns A stream. [Function] Get the current position of the read/write pointer of the backend of a stream. The current position (measured in octets) of the read/write pointer. If it is equal to the current position then there was an error. The current position (measured in octets from the beginning of the backend media) of the read/write pointer. The position to seek. Parameters stm Returns A stream.7. XXX Usage example pdf_off_t pdf_stm_tell (pdf stm t stm ) [Function] Get the number of octects read/written from/to the stream since either the last pdf_ stm_bseek operation or the creation of the stream. measured in octects from the beginning of the backend media.

pdf_real_t h Horizontal coordinate. . pdf_matrix_t A pointer to a pdf_matrix_s structure. pdf_point_t A pointer to a pdf_point_s structure.8. The coordinates of the point are made using floating point numbers.8. pdf_real_t a pdf_real_t b The first row of the matrix is a b 0.Chapter 2: Base Layer 75 2. [Data Type] struct pdf_matrix_s [Data Type] This structure represents a 3x3 matrix representing an affine transformation. pdf_real_t c pdf_real_t d The second row of the matrix is c d 0. The following constants specify the valid ranges for this data type: [Data Type] struct pdf_point_s [Data Type] This structure represents a single point.1 Floating Point Constants PDF_PI The value of PI. PDF_REAL_MIN Minimum value able to be stored in a pdf_real_t variable. pdf_real_t v Vertical coordinate. pdf_real_t h pdf_real_t v The third row of the matrix is h v 1. 2.2 Floating Point Types pdf_real_t An opaque type representing a floating-point number. [Data Type] struct pdf_rect_s [Data Type] This structure represents a rectangle. It is composed by the coordinates for its four sides. The rectangle sides should be horizontal and vertical and opposite sides should be parallel. [Constant] [Constant] [Constant] PDF_REAL_MAX Maximum value able to be stored in a pdf_real_t variable.

3 Rounding Routines pdf_real_t pdf_fp_floor (pdf real t op ) Round op down to the nearest integer.Chapter 2: Base Layer 76 pdf_real_t left x coordinate for the left points. pdf_real_t top y coordinate for the upper points. pdf_rect_t A pointer to a pdf_rect_s structure.8. Parameters op Returns A real operand. It is composed by four corners (floatingpoint points). The rounded integer value. number = 1. 2. If op is integral or infinite. [Data Type] struct pdf_quad_s [Data Type] This structure represents a quadrilateral. pdf_real_t bottom y coordinate for the bottom points. pdf_real_t right x coordinate for the right points.2. [Function] Usage example . rounded = pdf_fp_floor (number). pdf_u32_t rounded. [Data Type] [Data Type] pdf_fp_func_t Opaque type representing a Floating Point function. pdf_point_t br Bottom-right point. op itself is returned. pdf_quad_t A pointer to a pdf_quad_t structure. pdf_point_t tr Top-right point. pdf_point_t tl Top-left point. pdf_real_t number. pdf_point_t bl Bottom-left point.

Parameters op Returns A real operand.Chapter 2: Base Layer 77 /* rounded equals 1 */ number = 1. op itself is returned. The value of e raised to the power of op. /* rounded equals 2 */ pdf_real_t pdf_fp_ceil (pdf real t op ) Round op up to the nearest integer. [Function] The rounded integer value. rounded = pdf_fp_ceil (number).2.6. /* rounded equals 2 */ Usage example 2. XXX [Function] Return the value of e (the base of natural logarithms) raised to the power of op. pdf_real_t number. rounded = pdf_fp_floor (number). /* rounded equals 2 */ number = 1.8. If op is integral or infinite.4 Exponential and Logarithmic Routines pdf_real_t pdf_fp_exp (pdf real t op ) Parameters op Returns A real operand. number = 1.6. /* rounded equals 1 */ number = 2. rounded = pdf_fp_ceil (number). rounded = pdf_fp_floor (number). /* rounded equals 2 */ number = 2. Usage example pdf_real_t pdf_fp_log (pdf real t op ) Return the natural logarithm of op. rounded = pdf_fp_ceil (number). [Function] . pdf_u32_t rounded.

0"). /* real now contains 1.8. pdf_fp_string_to_real (str. str[1] = 0. &real). XXX Usage example pdf_real_t pdf_fp_log10 (pdf real t op ) Return the base 10 logarithm of op. The conversion was successful. The base 10 logarithm of op. Parameters string result Returns A NULL terminated string. Parameters op Returns A real operand. "1. strcpy (str. A PDF status value: PDF_OK PDF_ERROR No recognizable real value was found in the string. Usage example pdf_real_t real. pdf real t *result ) [Function] Convert a numeric string representation to a pdf_real_t value. XXX [Function] Usage example 2. /* real now contains 1. pdf_char_t str[5]. The real variable where the result is stored.0 */ . taking into account the data before the first invalid character. The string is scanned from left to right.0 */ strcpy (str. "1"). str[3] = 0. pdf_fp_string_to_real (str.5 Number Conversion Routines pdf_status_t pdf_fp_string_to_real (const pdf char t *string.Chapter 2: Base Layer 78 Parameters op Returns A real operand. The natural logarithm of op. &real).

123" */ if (pdf_fp_real_to_string (real. 9. A textual representation of real was successfully written in s.0 */ strcpy (str. 3). "foo"). 6). /* s contains "1. &real). pdf size t size.123456" */ pdf_fp_real_to_string (real.123456. The number of decimal digits to include in the textual representation. pdf_fp_real_to_string (real. str[3] = 0.0X"). Usage example pdf_real_t real. s. 9. s. Parameters real buffer The number to convert. size precision Returns A PDF status value: PDF_OK PDF_ERROR An error prevented to perform the conversion. /* s contains "1. 4. If it is 0 then the maximum precision is used. "1. /* real now contains 1. pdf_char_t s[9]. The maximum number of characteres that may be stored in buffer. if (pdf_fp_string_to_real (str. pdf u32 t precision ) Get a textual representation of a pdf_real_t value. pdf_fp_string_to_real (str. real = 1. str[4] = 0.Chapter 2: Base Layer 79 strcpy (str. pdf char t *buffer. s. Note that this function adds a ’\0’ to the end of the textual representation. 3) == PDF_ERROR) { /* The code reach this point: not enough space in the string . &real) == PDF_ERROR) { /* The code reach this point */ } pdf_status_t pdf_fp_real_to_string (pdf real t real. [Function] The buffer where to store the textual representation of real.

[Function] . XXX Usage example 2.Chapter 2: Base Layer 80 to hold the textual representation of the number with the specified precision */ } 2. The second matrix to multiply. It is similar to calculating the arc tangent of op1 / op2 except that the signs of both arguments are used to determine the quadrant of the result.6 Trigonometric Routines pdf_real_t pdf_fp_sin (pdf real t op ) Return the sine of op. XXX [Function] Usage example pdf_real_t pdf_fp_cos (pdf real t op ) Return the cosine of op. matrix 1 matrix 2 The first matrix to multiply. where op is given in radians. Parameters op Returns A real operand. pdf real t op2 ) [Function] Return the arc tangent of the two values op1 and op2. A real value between -1 and 1. XXX [Function] Usage example pdf_real_t pdf_fp_atan2 (pdf real t op1. pdf matrix t matrix_1. Returns The result in radians. where op is given in radians. pdf matrix t matrix_2 ) Multiplies two matrices. It may be a copy of matrix 1 or matrix 2. Parameters op Returns A real operand. wichi is between -PDF_PI and PDF_PI (inclusive). A real value between -1 and 1.8. Parameters op A real operand.8. Parameters result Pointer to the matrix that will be filled with the result.7 Geometry Routines pdf_status_t pdf_fp_matrix_concat (pdf matrix t result.

Parameters result matrix Returns [Function] A pointer to a matrix that will store the inverted matrix. const pdf matrix t matrix. [Function] . A pointer to the point to transform. Usage example XXX pdf_status_t pdf_fp_matrix_invert (pdf matrix t result. pdf matrix t matrix ) Calculate the inverse of a matrix. The operation suceeded. A PDF status value: PDF_OK PDF_ERROR An error prevented the operation to finish. const pdf matrix t matrix. The operation succeeded. This parameters can be a copy of matrix. const pdf point t point ) Transform a point through a matrix. A PDF status value: PDF_OK PDF_ERROR An error prevented the operation to finish. The operation succeeded. Usage example XXX pdf_status_t pdf_fp_matrix_transform (pdf point t result. A pointer to a matrix used to calculate the inverse. Parameters result matrix point Returns [Function] A pointer to a point to hold the result. This can be a copy of point. A pointer to the matrix used to perform the transformation.Chapter 2: Base Layer 81 Returns A PDF status code: PDF_OK PDF_ERROR There was an error performing the execution. Usage example XXX pdf_status_t pdf_fp_matrix_transform_rect (pdf rect t result. const pdf rect t rect ) Transform a rectangle through a matrix.

pdf char t *samples. const [Function] pdf real t domain []. const pdf real t encode []. The absolute value of the operand. Parameters op Returns A real operand. . const pdf real t range [].9 Creation and Destruction of Functions pdf_status_t pdf_fp_func_0_new (pdf u32 t m. pdf fp func t *function ) Create a new type 0 (sampled) function. A pointer to the rectangle to transform. A PDF status value: PDF_OK PDF_ERROR An error prevented the operation to finish.8 Other Maths Routines pdf_fp_abs (pdf_real_t op ) Return the absolute value of the real number op. pdf u32 t bps. pdf u32 t n. const pdf real t decode []. A pointer to the matrix used to perform the transformation. The square root of op. Parameters op Returns A real operand. XXX [Function] Usage example pdf_fp_sqrt (pdf_real_t op ) Return the non-negative square root of op. The operation suceeded. pdf size t samples_size.Chapter 2: Base Layer 82 Parameters result matrix point Returns A pointer to a rectangle to hold the result. Parameters m n Number of input values. XXX [Function] Usage example 2. This can be a copy of rect. pdf u32 t size [].8. Usage example XXX 2. Number of output values.8. pdf u32 t order.

Array of 2 * n numbers specifying the linear mapping of sample values into the range appropriate for the function’s output values. 12. function Returns A pointer to the variable holding the new function. 8. The number of bits used to represent a sample in the samples table. The function was successfully created. size bps order encode decode samples samples size Size of the samples table. Valid values shall be 1. pdf real t c1 []. Each pair of consecutive numbers defines the domain of an input variable. Output values outside these ranges will be clipped to the appropriate range. Usage example XXX pdf_status_t pdf_fp_func_2_new (pdf u32 t m. . pdf u32 t n.Chapter 2: Base Layer 83 domain range Array of 2 * m numbers. Array of 2 * n numbers. Order of interpolation between samples. 4. Valid values shall be 1 and 3. Output values outside these ranges will be clipped to the appropriate range. pdf fp func t *function ) Create a new type 2 (exponential interpolation) function. 16. Parameters m n domain range Number of input values. const pdf real t range []. Array of m positive integers containing the number of samples in each input dimension in the samples table. Array of 2 * n numbers. Each pair of consecutive numbers defines the range of an output variable. Array of 2 * m numbers specifying the linear mapping of input values into the domain of the function’s sample table. pdf real t c0 []. Array of 2 * m numbers. A PDF status value: PDF_OK PDF_ERROR Error while creating the function. 24 and 32. Each pair of consecutive numbers defines the range of an output variable. Number of output values. const [Function] pdf real t domain []. pdf real t N. 2. Each pair of consecutive numbers defines the domain of an input variable. Buffer containing the samples table for the function.

An array of n numbers that shall define the function return when x = 1. An array of k 1-input functions that shall make up the stitching function. const [Function] pdf real t domain []. A PDF status value: PDF_OK PDF_ERROR Error while creating the function. pdf u32 t k. Each pair of consecutive numbers defines the range of an output variable. k functions bounds encode function Returns A PDF status value: . An array of 2 * k numbers that. Output values outside these ranges will be clipped to the appropriate range. An array of n numbers that shall define the function result when x = 0. pdf fp func t *functions. pdf real t bounds []. Parameters m n domain range Number of input values.0. taken in pairs. pdf fp func t *function ) Create a new type 3 (stitching) function. The function was successfully created. Array of 2 * m numbers. pdf u32 t n.Chapter 2: Base Layer 84 N c0 c1 function Returns The interpolation exponent.0. The output dimensionality of all functions shall be the same. An array of k .1 numbers that. Usage example XXX pdf_status_t pdf_fp_func_3_new (pdf u32 t m. A pointer to a variable holding the new function. Pointer to a variable holding the new function. Each pair of consecutive numbers defines the domain of an input variable. and each value shall be within the domain defined by domain. in combination with domain. shall define the intervals to which each function from the functions parameter shall apply. Array of 2 * n numbers. and compatible with the value of range. bounds elements shall be in order of increasing value. const pdf u32 t encode []. shall map each subset of the domain defined by domain and the bounds parameter to the domain of the corresponding function. Number of stitching functions. Number of output values. const pdf real t range [].

[Function] pdf real t domain []. Number of output values. Pointer to a variable where it will put the current offset on error. Array of 2 * n numbers. pdf u32 t n. Each pair of consecutive numbers defines the range of an output variable. A PDF status variable: PDF_OK Usage example XXX The function was successfully destroyed. pdf real t range []. pdf fp func t *function ) Create a new type 4 (postscript calculator) function. pdf char t *code. The function was successfully created. Usage example XXX pdf_status_t pdf_fp_func_4_new (pdf u32 t m. Error while creating the function. pdf size t code_size. Size of code. pdf size t *error_at. Memory buffer containing the postscript code to execute. Parameters function Returns A pointer to an initialized function. Parameters m n domain range Number of input values. code code size error at function Returns A PDF status value: PDF_OK PDF_ERROR Error while creating the function. Output values outside these ranges will be clipped to the appropriate range.Chapter 2: Base Layer 85 PDF_OK PDF_ERROR The function was successfully created. Each pair of consecutive numbers defines the domain of an input variable. Array of 2 * m numbers. Pointer to a variable holding the new function. Usage example XXX pdf_status_t pdf_fp_func_destroy (pdf fp func t function ) Destroy a function. [Function] .

pdf_fp_func_debug_t type0 type2 type3 type4 [Data Type] This structure contains debugging data associated to the evaluation of a function. in dimensions Variable to hold the input dimensions of function. status A PDF status value: PDF_ERROR An unknown error ocurred. Returns A PDF status value: PDF_OK Usage example XXX The operation was successfully performed.10 Evaluation of Functions pdf_status_t pdf_fp_func_get_bounds (const pdf fp func t [Function] function. PDF_EMATH Math error. . pdf i32 t *in_dimensions. pdf i32 t *out_dimensions ) Return the bounds of a given function. PDF_EOVERFLOW Overflow of stack. No information for type2 functions.8. PDF_FP_FUNC_TYPE4_TRUE Stand for true value in the debugging information structure. PDF_EINVRANGE Invalid range operand for the current operator. No information for type0 functions. PDF_EBADTYPE Invalid type data for the current operator.. out dimensions Variable to hold the output dimensions of function. PDF_EUNDERFLOW Try to fetch an element from an empty stack. No information for type3 functions. Parameters function An initialized function. [Constant] [Constant] PDF_FP_FUNC_TYPE4_FALSE Stand for false value in the debugging information structure.Chapter 2: Base Layer 86 2.

PDF_TYPE3 Error in a type3 function. The evaluation was successfully performed. The debug structure will contain more information.9 Encoded Text . PDF_TYPE0 Error in a type0 function. pdf fp func debug t *debug ) Evaluate a function. Usage example XXX 2. Array containing the output values from the function evaluation. Parameters function in out debug Returns The function to evaluate. Size of the stack. The debug structure will contain more information. Each element is a double value or a boolean one. PDF_TYPE4 Error in a type4 function. The debug structure will contain more information. PDF_TYPE2 Error in a type2 function. A pointer to the structure will contain debug information. Array containing the input values for the function.Chapter 2: Base Layer 87 op stack_size Offset in the source code in which the error ocurred. const pdf real t in []. pdf real t out []. [Function] pdf_status_t pdf_fp_func_eval (pdf fp func t function. The first element is the last pushed one. The debug structure will contain more information. A PDF status value: PDF_OK PDF_ERROR Error while evaluating the function. stack Array of elements in the stack when the error ocurred.

PDF_TEXT_UNICODE_NO_OPTION (= 0) No specific option PDF_TEXT_UNICODE_WITH_BOM Prepend Byte Order Marker to the UNICODE string.Chapter 2: Base Layer 88 2. PDF_TEXT_UTF8 UTF-8 encoding. 2-byte NUL for UTF-16 and 4-byte NUL for UTF-32). PDF_TEXT_UTF16BE_WITH_LANGCODE Insert language/country code information between the BOM (if required) and the data. enum pdf_text_filter_type_e Enumeration of ‘pdf text filter’). [Data Type] pdf_text_unicode_options_e [Data Type] Enumeration of extra options to get the contents of a pdf text t in a given UNICODE encoding (see function ‘pdf text get unicode’). PDF_TEXT_UTF16_HE Host Endian UTF-16 encoding (may be little-endian or big-endian). PDF_TEXT_FILTER_LINE_ENDINGS Normalize line endings. PDF_TEXT_UTF32_BE Big Endian UTF-32 encoding. .9. PDF_TEXT_UTF16_BE Big Endian UTF-16 encoding. PDF_TEXT_UTF16_LE Little Endian UTF-16 encoding.1 Text Data Types enum pdf_text_unicode_encoding_e Enumeration of supported Unicode encodings. PDF_TEXT_UTF32_LE Little Endian UTF-32 encoding. PDF_TEXT_UNICODE_WITH_NUL_SUFFIX Append a NUL suffix to the Unicode string (1-byte NUL for UTF-8. It is a no-op. If specified in any other encoding. This option is ONLY applicable to UTF16BE. supported filters in encoded text objects [Data Type] (see function PDF_TEXT_FILTER_IDENTITY Do not perform any transformation in the encoded text. PDF_TEXT_UTF32_HE Host Endian UTF-32 encoding (may be little-endian or big-endian). the function will fail.

Chapter 2: Base Layer

89

PDF_TEXT_FILTER_UPPER_CASE Makes all text upper case. PDF_TEXT_FILTER_LOWER_CASE Makes all text lower case. PDF_TEXT_FILTER_TITLE_CASE Makes all text title case. PDF_TEXT_FILTER_REMOVE_AMP Remove all single ampersands. This filter transform && into &. PDF_TEXT_FILTER_NORM_WITH_FULL_WIDTH Normalize with full width ASCII variants filter. PDF_TEXT_FILTER_REMOVE_LINE_ENDINGS Replace line endings with space characters.

pdf_text_t

[Data Type] A Unicode string, which must be considered as an opaque type. It contains the data in UTF-32BE encoding, as well as any ‘ISO-639-1’ country code and/or ‘ISO-3166-1 alpha-2’ language code applied. It also contains an internal list of word boundaries. This data type must be initialized before being used, and destroyed afterwards.

pdf_text_host_encoding_t

[Data Type] This data type identifies an encoding used in a host (all the possible values are hostdependent). There is no initialization/destruction requirement for this data type.

2.9.2 Creating and Destroying Text
pdf_status_t pdf_text_new (pdf text t *text)
Create a new text object containing no text. Parameters text Returns A pointer to the new instance of text object. A pdf status value: PDF_OK PDF_ENOMEM Not enough memory to create the text object. PDF_EBADCONTEXT The global context of the text module was not initialized. PDF_ERROR Other error. Usage Example pdf_text_t mytext; pdf_text_new (&mytext); The text object was successfully created. [Function]

Chapter 2: Base Layer

90

pdf_status_t pdf_text_destroy (pdf text t text)
Destroy a text object and its contents. Parameters text Returns A properly created text object. The status of the destruction pdf_text_t mytext; mytext = pdf_text_new (); pdf_text_destroy(mytext);

[Function]

Usage Example

pdf_text_t pdf_text_dup (const pdf text t text )
Dup a new text object from a existing one. Parameters text Returns A properly created text object. A pointer to the newly created text object. pdf_text_t text1; pdf_text_t text2; text1 = pdf_text_new (); text2 = pdf_text_dup (text1);

[Function]

Usage Example

pdf_status_t pdf_text_new_from_host (const pdf char t *str, [Function] const pdf size t size, const pdf text host encoding t enc, pdf text t *text )
Create a new text object and initialize it with a given host encoded string. Parameters str size enc text Returns A multybyte string in some host encoding. The length of str, in bytes. The host encoding with which str is encoded. A pointer to the output text object

A pdf status value: PDF_OK PDF_ENOMEM Out of memory condition. PDF_EBADCONTEXT The global context for the text module is not initialized. PDF_ETEXTENC Invalid data in the input string (encoding error). The operation succeeded.

Chapter 2: Base Layer

91

PDF_EBADDATA Invalid parameters. Usage Example pdf_text_t text; pdf_char_t *he_string; pdf_size_t he_string_size; pdf_text_host_encoding_t encoding; pdf_status_t ret_code; /* Obtain host encoding and text... */ /* And create text object with those contents */ ret_code = pdf_text_new_from_host(he_string, he_string_size, encoding, &text); if(ret_code != PDF_OK) { /* Something bad happened */ }

pdf_status_t pdf_text_new_from_pdf_string (const pdf char t [Function] *str, const pdf size t size, pdf char t **remaining_str, pdf size t *remaining_length, pdf text t *text )
Create a new text object and initialize it with a given ‘PDF string’ text representation. This ‘PDF string’ can be either encoded in UTF-16BE, with BOM and optional Country/Language code information, or in PDF Doc Encoding. The Country/Language code marker is treated as end-of-text marker, so that a text object handles only a given pair of country and language codes. This function must be used inside a loop, so that the input string of data is splitted in chunks if more than one language/code is available in the text (only if PDF string is encoded in UTF-16BE). Parameters str size A text representation of a PDF string. The length of str in bytes

remaining str Returned pointer to the next chunk of data to process, if any. remaining length Length of remaining str in bytes text Returns A pointer to the newly created text object.

A pdf status value: PDF_OK The operation succeeded.

Chapter 2: Base Layer

92

PDF_ENOMEM Out of memory condition. PDF_EBADCONTEXT The global context for the text module is not initialized. PDF_ETEXTENC Invalid data in the input string (encoding error). PDF_EBADDATA Invalid parameters. Usage Example pdf_text_t text; pdf_char_t *pdf_string; pdf_size_t pdf_string_size; pdf_char_t *remaining_str; pdf_size_t remaining_size; pdf_status_t ret_code; /* Obtain PDF string... */ /* And create text object with those contents */ remaining_str = pdf_string; remaining_length = pdf_string_size; do { ret_code = pdf_text_new_from_host(remaining_str, remaining_length, &remaining_str, &remaining_length, &text); /* Do something with the chunk of string */ pdf_text_destroy(text); } while((ret_code == PDF_OK) && (remaining_length > 0));

pdf_status_t pdf_text_new_from_unicode (const pdf char t *str, [Function] const pdf size t size, const enum pdf text unicode encoding e enc, pdf text t *text )
Create a new text object from a string of Unicode characters in a given unicode encoding. The Unicode string can be given with or without BOM, and there mustn’t be any language/code information embedded in the string. Note that for UTF-16BE strings two options are possible to create the pdf text t object: treating it as a PDF string (so BOM is mandatory and Language/Country code are optional) or treating it as a general Unicode string (so BOM is optional and Language/Country code is not allowed).

Chapter 2: Base Layer

93

Parameters str size enc text Returns PDF OK A Unicode string. The length of str in bytes. The Unicode encoding used by str. A pointer to the newly created text object.

A pdf status value: The operation succeeded.

PDF ENOMEM Out of memory condition. PDF EBADCONTEXT The global context for the text module is not initialized. PDF ETEXTENC Invalid data in the input string (encoding error). PDF EBADDATA Invalid parameters. Usage Example pdf_text_t text; pdf_char_t *unicode_string; pdf_size_t unicode_string_size; pdf_status_t ret_code; /* Obtain unicode text... */

/* And create text object with those contents */ ret_code = pdf_text_new_from_unicode(unicode_string, unicode_string_size PDF_TEXT_UTF16_BE, &text); if(ret_code != PDF_OK) { /* Something bad happened */ }

pdf_status_t pdf_text_new_from_u32 (const pdf u32 t number,

[Function] pdf text t *text) Create a new text variable containing the textual representation of a given integer. Parameters number text An unsigned 32 bit number. A pointer to the newly created text object.

Returns

A pdf status value:

A text variable.. as it is managed by the ‘pdf text t’ data type.9. PDF_ETEXTENC Invalid data in the input string (encoding error). number = 24. as it is managed by the ‘pdf text t’ data type. PDF_EBADDATA Invalid parameters. if(ret_code != PDF_OK) { /* Something bad happened */ } 2.Chapter 2: Base Layer 94 PDF_OK PDF_ENOMEM The operation succeeded. text Returns Usage Example pdf_text_t text. The returned string should not be modified. &text).create and manipulate ‘text’ */ code = pdf_text_get_country (text). as a NUL-terminated string.3 Managing Text Properties const pdf_char_t * pdf_text_get_country (const pdf text t text ) [Function] Return the ‘ISO-3166-1 alpha-2’ country code associated with a text variable. /* . ret_code = pdf_text_new_from_u32 (number. pdf_u32_t number. Parameters The code of the country associated with text. Usage Example pdf_text_t text. Out of memory condition.. PDF_EBADCONTEXT The global context for the text module is not initialized. pdf_status_t ret_code. pdf_char_t *code. as a NULterminated string. . The returned string should not be modified. const pdf_char_t * pdf_text_get_language (const pdf text t text ) [Function] Return the ‘ISO-639-1’ language code associated with a text variable.

pdf_text_t text.create and manipulate ‘text’ */ code = pdf_text_get_language (text). pdf_status_t ret_code. /* .. [Function] The status of the assignment. /* .. Usage Example .. Usage Example pdf_status_t pdf_text_set_country (pdf text t text.. Parameters text code Returns A text variable. A country code.Chapter 2: Base Layer 95 Parameters text Returns A text variable. [Function] The status of the assignment. pdf_char_t *code. A language code. pdf_text_t text. "27").create and manipulate ‘text’ */ ret_code = pdf_text_set_country (text.. "10"). pdf_text_t text. const pdf char t *code ) Associate a text variable with a ‘ISO-639-1’ language code.. const pdf char t *code ) Associate a text variable with a ‘ISO-3166-1 alpha-2’ country code.create and manipulate ‘text’ */ ret_code = pdf_text_set_language (text. Parameters text code Returns A text variable. /* . pdf_status_t ret_code. The code of the language associated with text. Usage Example pdf_status_t pdf_text_set_language (pdf text t text.

pdf_dealloc(str). encoding).initialize and manipulate ‘text’.9. Must be freed afterwards.... Output array of bytes (May contain NUL bytes). The text variable contain no text. pdf size t [Function] *length. */ ret_code = pdf_text_get_host (&str. &str_length. text. const pdf text t text. Usage Example pdf_text_t text.. Parameters contents length text enc Returns Usage Example pdf_text_t text. /* . pdf_size_t str_length. const pdf text host encoding t enc ) Get the contents of a text variable encoded in a given host encoding.initialize and manipulate ‘text’.4 Managing Text Contents pdf_status_t pdf_text_get_host (pdf char t **contents. Parameters text Returns A text variable.. The status of the conversion.. pdf_text_host_encoding_t encoding. pdf_char_t *str. A host encoding supported by the host.Chapter 2: Base Layer 96 pdf_bool_t pdf_text_empty_p (const pdf text t text ) Determine if a given text variable is empty (contains no text).. . /* . pdf_status_t ret_code. Output length of contents A text variable. The text variable contain some text.. */ if (pdf_text_empty_p (text)) { /* ‘text’ contains no text */ } A boolean value: PDF_TRUE PDF_FALSE [Function] 2.

Must be freed afterwards. text). */ ret_code = pdf_text_get_pdfdocenc (&str.. /* . pdf_text_t text. pdf_dealloc(str). const pdf u32 t options ) [Function] Get the contents of a text variable encoded in the specified Unicode encoding. Additional options can be set in the request.. pdf size t *length. Parameters contents length text enc options Output array of bytes (May contain NUL bytes). const enum pdf text unicode encoding e enc. Usage Example . pdf_status_t ret_code. in the way: OPTION 1 | OPTION 2 | OPTION 3. and NUL-terminated. Must be freed afterwards. pdf_char_t *str. const pdf text t text. (see pdf_text_unicode_ options_e data type) Returns The status of the conversion. Usage Example pdf_status_t pdf_text_get_unicode (pdf char t **contents. pdf_status_t ret_code.Chapter 2: Base Layer 97 pdf_status_t pdf_text_get_pdfdocenc (pdf char t **contents. A given UNICODE encoding. Additional options that can be set. A text variable. pdf_char_t *str.initialize and manipulate ‘text’. The status of the conversion. Parameters contents text Returns Output array of bytes (Can’t contain NUL bytes). specifying requested endianness. pdf_text_t text... Output length of contents A text variable. pdf_size_t str_length. const pdf text t text ) [Function] Get the contents of a text variable encoded in PDF Doc Encoding.

(PDF_TEXT_UNICODE_WITH_BOM | PDF_TEXT_U pdf_dealloc(str).str). in bytes. Parameters text delimiter Returns A text variable A single ASCII char used as delimiter A NUL-terminated string with the contents of the text object in hexadecimal representation. PDF_TEXT_UTF16_BE.. A string encoded with some host encoding. const pdf char t *str. The status of the conversion. */ str = pdf_text_get_hex (text. pdf_dealloc(str).. */ ret_code = pdf_text_get_unicode (&str. ’:’). The host encoding used to encode str. The length of str... const pdf text host encoding t enc ) Parameters text str enc enc Returns A text variable. pdf_status_t ret_code. . PDF_DEBUG_BASE("Internal representation of the string is: ’%s’".initialize and manipulate ‘text’.. separated by the character given in delimiter (usually ’:’). text.Chapter 2: Base Layer 98 /* . pdf_char_t * pdf_text_get_hex (const pdf text t text. &str_length. pdf_char_t *str. const pdf size t size..initialize and manipulate ‘text’... [Function] Set a string encoded with some host encoding as the value of a text variable. /* . The string must be deallocated by the caller. Usage Example pdf_status_t pdf_text_set_host (pdf text t text. pdf_text_t text. const pdf char t delimiter ) [Function] Get the contents of a text variable encoded in ASCII format and represented in Hexadecimal format.

str. The length of str. const pdf char t *str ) Set a PDF Doc Encoding encoded string as the value of a text variable. */ if (pdf_text_set_host (text. pdf_size_t length.. length. str) != PDF_OK) { /* ‘str’ contains bad data */ } Usage Example pdf_status_t pdf_text_set_unicode (pdf text t text. ‘encoding’ and ‘str’. NUL terminated. /* . pdf_text_t text. Usage Example . in bytes.. Parameters text str size enc Returns A text variable. const enum pdf text unicode encoding e enc ) Set a Unicode encoded string as the value of a text variable.. pdf_size_t length. pdf_char_t *str.Chapter 2: Base Layer 99 Usage Example pdf_text_t text. const pdf size t size..initialize and manipulate ‘text’. The status of the conversion.... pdf_char_t *str. [Function] A string encoded with PDF Doc Encoding. The status of the conversion. pdf_text_host_encoding_t encoding. pdf_char_t *str. [Function] A Unicode string without country/language data embedded.. const pdf char t *str. Parameters text str Returns A text variable. /* . The used Unicode encoding in str. */ if (pdf_text_set_pdfdocenc (text.initialize and manipulate ‘text’ and ‘str’. pdf_text_t text. enc) != PDF_OK) { /* ‘str’ contains bad data */ } pdf_status_t pdf_text_set_pdfdocenc (pdf text t text.

. The ascii string to concatenate. enc) != PDF_OK) { /* ‘str’ contains bad data */ } pdf_status_t pdf_text_concat (pdf text t text1. pdf_text_t text1. The contents of this variable are left unchanged.. The second text variable to concatenate. const pdf char t * ascii_str ) [Function] Concatenate the contents of text variable text1 with ASCII string ascii str.Chapter 2: Base Layer 100 enum pdf_text_unicode_encoding_e enc. text2..initialize and manipulate ‘text’. The contents of this variable are left unchanged.. the country and language information is not checked. str. Parameters text1 ascii str Returns The first text variable to concatenate. The status of the operation. */ if (pdf_text_set_unicode (text. and store the result in text1. length. const pdf bool t override_langinfo ) [Function] Concatenate the contents of two text variables (text1 first. pdf_text_t text2... The contents of this variable are modified with the output of the concatenation. override langinfo Flag to indicate if the language and country information must be checked before performing the concatenation. const pdf text t text2. /* . then text2) and store the result in text. Returns The status of the operation. The contents of this variable are modified with the output of the concatenation. */ if (pdf_text_concat (text1. /* . ‘str’ and ‘enc’. . If override langinfo is set. Warning! override langinfo is not set and different country/language codes are found within the text variables an error will be returned (concatenation not possible). PDF_FALSE) != PDF_OK) { /* Manage the error */ } Usage Example pdf_status_t pdf_text_concat_ascii (pdf text t text1.initialize ‘text1’ and ‘text2’... Parameters text1 text2 The first text variable to concatenate.

. */ if (pdf_text_concat_ascii (text1.. old pattern [Function] The text to be replaced. const pdf text t new_pattern. Any occurrence of this text is replaced with new pattern. Any occurrence of this text is replaced with new pattern.. pdf_text_t new_pattern.initialize ‘text’. const pdf char t *old_pattern ) Replace a fixed ASCII pattern in the content of a given text variable. /* . Returns The status of the operation . pdf_text_t old_pattern. Parameters text A text variable. new pattern The replacement text. const pdf text t old_pattern ) Replace a fixed pattern in the content of a given text variable.initialize ‘text1’ and ‘str. pdf_char_t * str. new_pattern. */ if (pdf_text_replace (text.. new_pattern) != PDF_OK) { /* Manage the error */ } Usage Example pdf_status_t pdf_text_replace_ascii (pdf text t text. str) != PDF_OK) { /* Manage the error */ } pdf_status_t pdf_text_replace (pdf text t text. Returns The status of the operation pdf_text_t text. ‘new_pattern’ and ‘old_pattern’. new pattern The replacement ASCII string. old pattern [Function] The text to be replaced.Chapter 2: Base Layer 101 Usage Example pdf_text_t text1. Parameters text A text variable.... /* .. const pdf char t *new_pattern.

Warning!! At most one case-related filter can be applied at a time... Parameters text filter A text variable. old_pattern) != PDF_OK) { /* Manage the error */ } pdf_status_t pdf_text_filter (pdf text t text. [Function] Filter to be run in text.. . */ Usage Example if (pdf_text_filter (text. /* . new_pattern.Chapter 2: Base Layer 102 Usage Example pdf_text_t text. */ if (pdf_text_replace_ascii (text. const pdf text t [Function] text2.5 Comparing Text Variables pdf_i32_t pdf_text_cmp (const pdf text t text1.initialize ‘text’. Returns The status of the operation pdf_text_t text. case sensitive A boolean value indicating if the comparison is case-sensitive: PDF_TRUE PDF_FALSE Case insensitive. const pdf bool t case_sensitive. const pdf_char_t *old_pattern = "Linux"... (see pdf_text_filter_type_e data type). Parameters text1 text2 A text variable... /* . Case sensitive. pdf status t *p_ret_code ) Compare the contents of two text variables. in the way: FILTER 1 | FILTER 2 | FILTER 3.initialize ‘text’. const pdf_char_t *new_pattern = "GNU/Linux". A text variable..9. (PDF_TEXT_FILTER_LOWER_CASE | PDF_TEXT_FILTER { /* Manage error */ } 2. const pdf u32 t filter ) Filter the contents of a text variable.

so that the return status is not considered. Usage Example [Function] .. enc = pdf_text_get_host_encoding(). Returns An integer: -1 0 +1 Usage Example pdf_text_t text1.6 Managing Host Encodings pdf_text_host_encoding_t pdf_text_get_host_encoding (void) Return the host encoding configured by the user/system in the locale.. text2. pdf_text_t text2. pdf_text_host_encoding enc.. /* . } case +1: { /* XXX */ break. NULL can be passed. } case 0: { /* XXX */ break. PDF_FALSE)) { case -1: { /* XXX */ break.9.. Parameters None Returns The host encoding configured in the user’s locale. */ switch (pdf_text_cmp (text1. } } If text1 < text2 If text1 = text2 If text1 > text2 2.initialize ‘text1’ and ‘text2’.Chapter 2: Base Layer 103 p ret code Pointer to store the status of the comparison (an internal error could happen).

so the function will check for Unicode encodings supported in the system. p encoding Pointer to a pdf text host encoding t variable. pdf_text_host_encoding enc. it will return PDF OK and will fill in the pdf text host encoding t variable passed by reference. Usage Example . Parameters encoding name Name of the encoding to check for. pdf_text_host_encoding enc. If available. Usage Example if(pdf_text_check_host_encoding((pdf_char_t *)"ascii-us". const pdf text host encoding t preferred_encoding ) Return the best available host encoding to encode the contents of a given text variable.Chapter 2: Base Layer 104 pdf_status_t pdf_text_check_host_encoding (const pdf char t *encoding_name. pdf_text_t text. The “best” encoding is an encoding able to encode the bigger number of characters of the unicode content of the given text variable. pdf_text_host_encoding pref.. pref).. /* .create and manipulate ‘text’. Returns The best host encoding available to encode the contents of text. preferred encoding A text encoding supported by the host. Returns Returns PDF OK if the encoding is available in the system as a hostencoding. pdf text host encoding t *p_encoding ) [Function] Check if a given encoding is available in the system as a host-encoding.. A specified preferred encoding is selected if there is no clear best encoding.&enc) == PDF_OK { /* XXX */ } pdf_text_host_encoding_t pdf_text_get_best_encoding (const [Function] pdf text t text. Parameters text A text variable. */ enc = pdf_text_get_best_encoding (text..

. day of week. The valid range is 1. pdf_u32_t sec A second. in seconds west of GMT.31..59.10 Time Management 2. hours.. pdf_i32_t year A year number. pdf_u32_t month A month number. months. pdf_u32_t minute A minute. pdf_u32_t hour An hour.. The calendar can be represented in both UTC and local time. The valid range is 1. struct pdf time cal span s [Data Type] This structure holds information about a time span represented in calendar items: years. the calendar fields come in a given local time. The valid range is 0.12.1 Time Related Data Types pdf_time_t [Data Type] A variable of type pdf_time_t contains information about a particular date and time. pdf_u32_t dow Day of the week. minutes. minutes and seconds. The valid range is 1. pdf_u32_t day A day number. hours. pdf_i32_t gmt_offset A GMT offset.. [Data Type] A variable of type pdf_time_span_t represents a span of time. the calendar fields come in UTC. seconds and the relative offset with GMT. pdf_u32_t pdf_u32_t pdf_u32_t pdf_u32_t pdf_u32_t pdf_u32_t years months days hours minutes seconds . months. If the given GMT offset is zero. The valid range is 0.. if not zero. days.23. The valid range is 0.59. pdf_time_span_t struct pdf time cal s [Data Type] This structure holds information about a specific time represented in calendar items: years.10.Chapter 2: Base Layer 105 2. Negative values may be supported in some systems.7 (Monday to Sunday). days. Note that leap seconds are not considered.

PDF_TIME_FORMAT_PDF PDF date strings. allocating memory. Should be a properly created time variable.10. orig = pdf_time_new (). Usage example .2 Time Creation and Destruction pdf_status_t pdf_time_new (pdf time t *time ) Parameters time Returns The time object that will contain the newly created instance. A pdf status value: PDF_OK PDF_ENOMEM Not enough memory to perform the requested operation. PDF_TIME_FORMAT_GENERALIZED_ASN1 Generalized ASN1 date. NULL if there is an error. 2. PDF_TIME_FORMAT_ISO_8601 ISO 8601 date and time strings. Parameters orig Returns [Function] The time variable to be dupped. pdf_time_t orig.Chapter 2: Base Layer 106 enum pdf_time_format_e [Data Type] Enumeration containing the several supported time formats used to convert a time to a string representation or to parse a time from a string representation. [Function] Create a new time and set it to the Epoch: Jan 1 1970-01-01 00:00:00 UTC pdf_time_t pdf_time_dup (const pdf time t orig ) Dup a new time variable from a given one. A new time variable containing a copy of orig values. if (pdf_time_new (&mytime) != PDF_OK) { /* Error */ } The time object was successfully instantiated. Usage example pdf_time_t mytime. pdf_time_t new_time. PDF_TIME_FORMAT_UTC_ASN1 UTC ASN1 date.

Chapter 2: Base Layer

107

new_time = pdf_time_dup (orig); if (new_time == NULL) { /* Error */ }

pdf_status_t pdf_time_destroy (pdf time t time_var )
Destroy time var and free all used memory. Parameters time var Returns

[Function]

The time variable to be destroyed. Should be a properly created time variable. The operation succeeded.

A status value: PDF_OK

Usage example pdf_time_t mytime; mytime = pdf_time_new (); pdf_time_destroy (mytime);

2.10.3 Managing Time Values
pdf_status_t pdf_time_copy (const pdf time t orig, pdf time t copy )
Copies the data from orig to copy. Parameters orig copy The time whose data is to be copied. Should be a properly created time variable. The time to receive the data from orig. Should be a properly created time variable. Note that any previous data is destroyed. The operation succeeded. [Function]

Returns

A status value: PDF_OK

Usage example pdf_time_t orig; pdf_time_t copy; orig = pdf_time_new (); copy = pdf_time_new (); if (!pdf_time_copy (orig, copy)) { /* Error */ }

Chapter 2: Base Layer

108

pdf_status_t pdf_time_clear (pdf time t time_var )

[Function] Reset time var to the newly created state. After this call time var will contain the same date as if returned by pdf_time_new. time var Returns The time variable to clear. Should be a properly create time variable.

Parameters

A status value: PDF_OK The operation succeeded.

Usage example pdf_time_t mytime; mytime = pdf_time_new (); /* ...manipulate ‘mytime’... */ pdf_time_clear (mytime);

pdf_status_t pdf_time_set_from_u32 (pdf time t time_var, pdf u32 t seconds )

[Function]

This function will initialize time var to the given Unix time (seconds since January 1st 1970) in UTC timescale. The time is represented as a 32-bit unsigned integer. Parameters time var seconds Returns The time variable to set. Should be a properly create time variable. Seconds since January 1st 1970, 32-bit unsigned value.

A status value: PDF_OK The operation succeeded.

Usage example pdf_time_t mytime; mytime = pdf_time_new (); pdf_time_set_from_u32(mytime, 1217009657);

pdf_status_t pdf_time_set_from_i64 (pdf time t time_var, pdf i64 t seconds )

[Function]

This function will initialize time var to the given Unix time (seconds since January 1st 1970) in UTC timescale. The time is represented as a pdf i64 t integer. Parameters time var The time variable to set. Should be a properly create time variable.

Chapter 2: Base Layer

109

seconds Returns PDF_OK Usage example

Seconds since January 1st 1970, pdf i64 t variable. The operation succeeded.

A status value:

pdf_time_t mytime; pdf_i64_t epoch = pdf_i64_new(0,1217009657); mytime = pdf_time_new (); pdf_time_set_from_i64(mytime, epoch);

pdf_status_t pdf_time_add_cal_span (pdf time t time_var, const struct pdf time cal span s *p_cal_span )

[Function]

Add the time span represented by the calendar span under the address in p cal span to time var. Parameters time var p cal span A pointer to a calendar span with valid values. Returns A status value: PDF_OK The operation successfully finished. PDF_EBADDATA The data in *p cal span is invalid. Usage example pdf_time_t mytime; struct pdf_time_cal_span_s cal_span; A properly created time variable.

mytime = pdf_time_new (); /* Initialized to Jan 1 1970-01-01 00:00:00 */ cal_span.year = 30; cal_span.month = 7; cal_span.day = 20; cal_span.hour = 21; cal_span.minute = 0; cal_span.second = 0; if (pdf_time_add_cal_span (mytime, &cal_span) == PDF_EBADDATA) { /* Bad data in ‘cal_span’ */ } else { /* ‘time’ now contains Aug 21 2000-08-21 21:00:00 */ }

Chapter 2: Base Layer

110

pdf_status_t pdf_time_sub_cal_span (pdf time t time_var, const struct pdf time cal span s *p_cal_span )

[Function]

Subtract the time span represented by the calendar span under the address in p cal span to time var. Parameters time var p cal span A pointer to a calendar span with valid values. Returns A status value: PDF_OK The operation successfully finished. A properly created time variable.

PDF_EBADDATA The data in cal span is invalid. Usage example pdf_time_t mytime; struct pdf_time_cal_span_s cal_span;

mytime = pdf_time_new (); /* Initialized to Jan 1 1970-01-01 00:00:00 */ cal_span.year = 30; cal_span.month = 7; cal_span.day = 20; cal_span.hour = 21; cal_span.minute = 0; cal_span.second = 0; if (pdf_time_add_cal_span (mytime, &cal_span) == PDF_EBADDATA) { /* Bad data in ‘cal_span’ */ } else { /* ‘time’ now contains Aug 21 2000-08-21 21:00:00 */ } if (pdf_time_sub_cal_span (mytime, cal_span) == PDF_EBADDATA) { /* Bad data in ‘cal_span’ */ } else { /* ‘time’ now contains Jan 1 1970-01-01 00:00:00 */ }

Chapter 2: Base Layer

111

pdf_status_t pdf_time_add_span (pdf time t time_var, const pdf time span t time_span )
Add the time span contained in time span to time var. Parameters time var A properly created time variable. time span A properly created time span. Returns A status value: PDF_OK Usage example pdf_time_t mytime; pdf_time_span_t myspan; mytime = pdf_time_new (); /* ...create and initialize ‘myspan’... */ pdf_time_add_span (mytime, myspan); The operation successfully finished.

[Function]

pdf_status_t pdf_time_sub_span (pdf time t time_var, const pdf time span t time_span )
Subtract the time span contained in time span to time var. Parameters time var A properly created time variable. time span A properly created time span. Returns A status value: PDF_OK Usage example pdf_time_t mytime; pdf_time_span_t myspan; mytime = pdf_time_new (); /* ...create and initialize ‘myspan’... */ pdf_time_sub_span (mytime, myspan); The operation successfully finished.

[Function]

pdf_status_t pdf_time_get_local_cal (const pdf time t time_var, struct pdf time cal s *p_local_cal )
Fill p local cal with the local calendar time of time var. Parameters time var A properly created time variable.

[Function]

The operation successfully finished. &cal). .Chapter 2: Base Layer 112 p local cal A pointer to the time calendar structure that will hold the local time of time var. Parameters time var p cal time A properly created time variable.create and manipulate ‘mytime’.create and manipulate ‘mytime’. &cal_time). Returns A status value: PDF_OK Usage example pdf_time_t mytime.. Returns A status value: PDF_OK Usage example pdf_time_t mytime.. /* . [Function] A pointer to the calendar time structure that will hold the UTC time of time var. struct pdf_time_cal_s cal.. /* . The operation successfully finished.. const struct pdf time cal s *p_cal_time ) Set the value of a time variable to a given calendar time. pdf_status_t pdf_time_from_cal (pdf time t time_var. A properl created time variable. */ pdf_time_get_utc_cal (mytime.. Parameters time var p cal time A pointer to a calendar time structure. Returns A status value: PDF_OK The operation successfully finished. pdf_status_t pdf_time_get_utc_cal (const pdf time t time_var.. sruct pdf_time_cal_s cal_time. */ pdf_time_get_local_cal (mytime... struct pdf time cal s *p_utc_cal ) Get the UTC calendar time of a given time variable. [Function] PDF_EBADDATA There is invalid data in the calendar structure cal time.

[Function] Set the local time offset of time var to the one used by the operating system.dow = 0.year = 2000. struct pdf time cal span s *p_cal_span ) [Function] Calculate the time span that goes from time1 to time2 and store it in p cal span. . if (pdf_time_from_cal (mytime. mycaltime. mytime = pdf_time_new ().hour = 0. struct pdf_time_cal_s mycaltime. pdf_time_set_local_offset (time). 2.Chapter 2: Base Layer 113 Usage example pdf_time_t mytime. mycaltime. mycaltime. The end of the time interval (exclusive).10. Parameters time1 time2 p cal span Pointer to the calendar time span structure that will hold the time span that goes between time1 and time2. mycaltime. mycaltime.day = 10.minute = 0. The beginning of the time interval (inclusive). A status value: PDF_OK Usage example pdf_time_t mytime.month = 8.sec = 0. The operation successfully finished. mycaltime. /* This field is ignored by ‘pdf_time_from_cal’ */ mycaltime. const pdf time t time2.gmt_offset = 1.4 Getting Time Intervals pdf_status_t pdf_time_diff_cal (const pdf time t time1. mytime = pdf_time_new (). mycaltime. Note that the highest possible distribution inside p cal span is used. &mycaltime) == PDF_EBADDATA) { /* Bad data in ‘mycaltime’ */ } pdf_status_t pdf_time_set_local_offset (pdf time t time_var ) Parameters time Returns A properly created time variable.

create and manipulate ‘time_begin’ and ‘time_end’ */ pdf_time_diff (time_begin. pdf_time_span_t time_span. Should be a properly created time variable.. Parameters time1 time2 [Function] The beginning time. pdf_time_t time2.5 Time Comparison pdf_i32_t pdf_time_cmp (const pdf time t time1. 2.. &time_span). Should be a properly created time variable.. const pdf time t time2. Should be a properly created time. Usage example pdf_time_t time_begin.. [Function] . The ending time. Any previous content of *p time span will be destroyed. const pdf time t time2 ) Compares two times. ‘time2’ and ‘time_span’. Should be a properly created time. pdf_status_t pdf_time_diff (const pdf time t time1. p time span The pointer to the time span variable that will hold the difference between time1 and time2. pdf_time_t time_end. /* . Should be a properly created time span. time_end.. &cal_span). time2. struct pdf_time_cal_span_s cal_span. Parameters time1 time2 The first time to compare. Returns A status value: PDF_OK Usage example pdf_time_t time1. pdf time span t *p_time_span ) Calculate the time span between two dates.Chapter 2: Base Layer 114 Returns A status value: PDF_OK The operation successfully finished. The operation successfully finished. /* .create and manipulate ‘time1’. */ pdf_time_diff (time1.. The second time to compare.10.

If time1 and time2 contain the same time. time2)) { case -1: { /* ‘time1’ precedes ‘time2’ */ break. If time2 precedes time1..Chapter 2: Base Layer 115 Returns A status value: -1 0 1 If time1 precedes time2. Parameters time var A properly created time variable. const enum pdf time format e time_format. pdf_time_t time2. time2 = pdf_time_new (). } case 0: { /* ‘time1’ contain the same time than ‘time2’ */ break.. } case 1: { /* ‘time2’ precedes ‘time1’ */ break. pdf bool t include_trailing_apostrophe ) Create a string representation of a given time.. } } Usage example 2. /* . pdf_time_t time1. .6 Time Printing and Parsing pdf_char_t* pdf_time_to_string (const pdf time t time_var.10.. time1 = pdf_time_new (). */ switch (pdf_time_cmp (time1.manipulate ‘time1’ and ‘time2’. [Function] time format The format to use when creating the string representation of time.

NULL if there is an error. pdf_dealloc(mytime_str). Note that this parameter is ignored if time format is not PDF_TIME_FORMAT_PDF. Must be deallocated by the caller of the function explicitly with pdf dealloc(). If time format is not PDF_TIME_FORMAT_PDF then this argument is ignored. Returns A status value: PDF_OK The operation succeeded. Usage example pdf_time_t mytime. require trailing apostrophe If this argument is PDF_TRUE a PDF date specification containing minutes should be followed by an APOSTROPHE character (’). Usage example pdf_status_t pdf_time_from_string (pdf time t time_var.create and manipulate ‘mytime’.Chapter 2: Base Layer 116 include trailing apostrophe Append an apostrophe after the GMT offset minutes field. pdf_time_t mytime.. Returns The string representation of time. char time_str[] = "D:20090813210000+00’00". pdf_char_t *mytime_str. */ mytime_str = pdf_time_to_string (mytime.. Parameters time var time str A properly created time variable. 21:00 GMT 0 */ mytime = pdf_time_new (). pdf bool t require_trailing_apostrophe ) Get a string containing a time specification in some format and fill a time variable with the parsed values. PDF_TIME_FORMAT_PDF). PDF_EBADDATA Error while parsing time str according to time format. . if present. A null-terminated string representation of a time. /* 13-August-2009.. time format The format indicating how to parse time str. /* . const [Function] pdf char t *time_str. const enum pdf time format e time_format..

The operation successfully finished.Chapter 2: Base Layer 117 if (pdf_time_from_string (mytime. 2. A status value: PDF_OK Usage example pdf_time_t mytime. time_str. pdf_time_set_to_current_utc_time (mytime). PDF_TIME_FORMAT_PDF) == PDF_EBADDATA) { /* Error while parsing ‘time_str’ according to ‘PDF_TIME_FORMAT_PDF’ * } 2. pdf_status_t pdf_time_set_to_current_utc_time (pdf time t time_var ) Parameters time var Returns A properly created time variable. The time span is initialized with a zero value (zero seconds). .10. [Function] Set the value of time var to the current UTC time used by the operating system. pdf_time_set_to_current_local_time (mytime).7 Getting the Current Time pdf_status_t pdf_time_set_to_current_local_time (pdf time t time_var ) Parameters time var Returns A properly created time variable. The operation successfully finished. mytime = pdf_time_new (). Parameters None.8 Time Span Creation and Destruction pdf_time_span_t pdf_time_span_new (void) [Function] Allocate and return a new time span variable. [Function] Set the value of time var to the current local time used by the operating system.10. mytime = pdf_time_new (). A status value: PDF_OK Usage example pdf_time_t mytime.

Parameters span A properly created time span variable. A status value: PDF_OK The operation successfully finished. /* . /* . Parameters p span Returns [Function] The pointer to the time span variable to be destroyed. Usage example pdf_time_span_t pdf_time_span_dup (const pdf time span t span ) [Function] Allocate and dup a new time span from an existing one. pdf_time_span_t new_span...9 Managing Time Span Values pdf_status_t pdf_time_span_set (pdf time span t *p_span.. span = pdf_time_span_new ().. 2. Usage example pdf_status_t pdf_time_span_destroy (pdf time span t *p_span ) Destroy a time span variable freeing all used memory. Parameters p span high value The high (signed) part of the time span value. Returns The newly created time span variable. const pdf i32 t high_value. pdf_time_span_t span.create and manipulate ‘span’.10.Chapter 2: Base Layer 118 Returns The newly created time span variable or NULL if there is an error... A pointer to a properly created time span variable. */ pdf_time_span_destroy (span).. .. Usage example pdf_time_span_t span. The internal representation of the time span is 64 bits long (signed). pdf_time_span_t span. const pdf u32 t low_value ) [Function] Set the value of a time span. The new time span has the same value as the base time span. */ new_span = pdf_time_span_dup (span).create and manipulate ‘span’.

const pdf i32 t seconds ) Set the value of a time span from a 32 bits signed number. /* The span is -10 seconds lon pdf_status_t pdf_time_span_set_from_i32 (pdf time span t *p_span. /* . Parameters span A pointer to a properly created time span variable.. Usage exaple pdf_time_span_t span.Chapter 2: Base Layer 119 low value Returns The low (unsigned) part of the time span value. span = pdf_time_span_new (). Parameters p span seconds Returns [Function] A pointer to a properly created time span variable.create and manipulate ‘span’. [Function] . (1 << 31).. span = pdf_time_span_create (). A signed 32 bits number. /* The span is -10 seconds long pdf_status_t pdf_time_span_negate (pdf time span t *p_span ) [Function] Make a positive time span into a negative one or make a negative time span into a positive one.. pdf_time_span_set (&span.. Usage example pdf_time_span_t span. const pdf time span t span2. 10). A status value: PDF_OK The operation successfully finished. Usage example pdf_time_span_t span. pdf_time_span_set_from_i32 (&span. A status value: PDF_OK The operation successfully finished. Parameters span1 The first time span to add. pdf_status_t pdf_time_span_add (const pdf time span t span1. pdf time span t *p_result ) Add two time spans and store the result in another time span. -10). */ pdf_time_span_negate (span). Returns A status value: PDF_OK The operation successfully finished.

. A status value: PDF_OK The operation successfully finished. span_dest). Usage example pdf_time_span_t span_orig.Chapter 2: Base Layer 120 span2 p result Returns The second time span to add. const pdf time span t span2... &result). Any previous content is lost. . pdf_time_span_t span2. pdf_time_span_t span_dest. pdf_status_t pdf_time_span_copy (const pdf time span t orig. [Function] The pointer to the time span variable that will hold the value of orig. PDF_EBADDATA p dest is not a valid pointer. pdf_status_t pdf_time_span_diff (const pdf time span t span1. span2. */ pdf_time_span_add (span1.create and manipulate ‘span1’. Parameters span1 span2 The first time span to diff.. The second time span to diff. Usage example pdf_time_span_t span1. The pointer to the time span holding the result of the add operation. PDF_EBADDATA p result is not a valid pointer. pdf time span t *p_dest ) Copy the value of a time span into another time span.create and manipulate ‘span_orig’ and ‘span_dest’... Parameters orig p dest Returns The origin time span.. A status value: PDF_OK The operation successfully finished. /* . */ pdf_time_span_copy (span_orig. ‘span2’ and ‘result’. pdf_time_span_t result. pdf time span t *p_result ) [Function] Difference two time spans and store the result (maybe negative) into another time span. Any previous value is lost.. /* .

Usage example pdf_time_span_t span1.. [Function] A status value: -1 0 +1 The length of span1 is shorter than the length of span2.. pdf_time_span_t span2. PDF_EBADDATA p result is not a valid pointer..10. Parameters span Returns A properly created time span variable. pdf_time_span_t span. */ num_seconds = pdf_time_span_to_secs (span). Usage example 2. Parameters span1 span2 Returns The first time span to compare. A status value: PDF_OK The operation successfully finished. span_diff). span2. A negative value is returned if the time span is negative.. Any previous value of the time span is lost. /* . [Function] The value of the time span in seconds.. const pdf time span t span2 ) Compare the length two time spans. The lengts of span1 and span2 are equal.10 Time Span Comparison pdf_i32_t pdf_time_span_cmp (const pdf time span t span1. pdf_time_span_t span_diff.. /* . . pdf_i32_t num_seconds. The length of span1 is greater than the length of span2. The second time span to compare.create and manipulate ‘span’.create and manipulate ‘span1’. ‘span2’ and ‘span3’ */ pdf_time_span_diff (span1.Chapter 2: Base Layer 121 p result Returns The result of the diff operation. pdf_i64_t pdf_time_span_to_secs (const pdf time span t span ) Get the value of a time span in seconds.

A status value: PDF_OK The operation successfully finished. PDF_EBADDATA There is invalid data in span1 or span2. struct pdf time cal span s *p_result ) Add two calendar spans. struct pdf_time_cal_span_s cal_span1. pdf_time_span_t span2.create and manipulate ‘span1’ and ‘span2’. The pointer to the second calendar span to add.. Pointer to the calendar span to store the result of the add operation. */ switch (pdf_time_span_cmp (span1. .Chapter 2: Base Layer 122 Usage example pdf_time_span_t span1.. Parameters p span1 p span2 base time p result Returns The pointer to the first calendar span to add. } case 1: { /* The length of ‘span1’ is greater than the length of ‘span2’ */ break.10. Since the calendar spans are relative (some years has more days than another) the calendar spans are first resolved from a base time..11 Calendar Spans Management pdf_status_t pdf_time_add_cal_span_with_base (const struct [Function] pdf time cal span s *p_span1. } } 2.. span2)) { case -1: { /* The length of ‘span1’ is shorter than the length of ‘span2’ */ break. Usage example pdf_time_t mytime. const struct pdf time cal span s *p_span2. The base time to use. } case 0: { /* The length of ‘span1’ is equal to the length of ‘span2’ */ break. const pdf time t base_time. /* .

pdf status t *p ret code) Compare two calendar spans previously resolved with a given base time. the time interval defined by p span1 is greater in length than the time interval defined by p span2. &cal_span2. the time inveral defined by p span1 is equal in length than the time interval defined by p span2.. Should be a correctly created time variable. &cal_result) == PDF_EBADDATA) { /* Invalid data in ‘cal_span1’ or ‘cal_span2’ */ } pdf_i32_t pdf_time_cal_span_cmp (const struct pdf time cal span s [Function] *p_span1. */ if (pdf_time_add_cal_span_with_base (&cal_span1.Chapter 2: Base Layer 123 struct pdf_time_cal_span_s cal_span2. struct pdf_time_cal_span_s span2. struct pdf_time_cal_span_s span1.. ‘span1’ and ‘span2’. Given the base time.. const struct pdf time cal span s *p_span2. Parameters p span1 p span2 base time p ret code Pointer to a status variable to store any error happened in the function. Returns -1 0 +1 Usage example pdf_time_t mytime. mytime)) { Given the base time... mytime. The pointer to the first calendar span to be compared. . */ switch (pdf_time_cal_span_cmp (&span1.create and manipulate ‘mytime’. &span2.. the time interval defined by p span2 is greater in length than the time interval defined by p span1. ‘cal_span1’ * and ‘cal_span2’.. Given the base time. The pointer to the second calendar span to be compared.create and initialize ‘mytime’. /* . /* . const pdf time t base_time. The used base time. struct pdf_time_cal_span_s cal_result..

Pointer to the calendar structure holding the result of the difference. */ if (pdf_time_cal_span_diff (&span1.. } case 1: { /* The length of ‘span1’ is greater than the length of ‘span2’ */ break. /* . Should be a correctly created time variable. } case 0: { /* The length of ‘span1’ is equal than the length of ‘span2’ */ break. struct pdf_time_cal_span_s result. . const pdf time t base_time.create and manipulate ‘span1’. struct pdf_time_cal_span_s span2. } } pdf_status_t pdf_time_cal_span_diff (const struct [Function] pdf time cal span s *p_span1. const struct pdf time cal span s *p_span2. Usage example pdf_time_t mytime. PDF_EBADDATA There is invalid data in span1 or span2. The base time... ‘span2’ and * ‘result’.Chapter 2: Base Layer 124 case -1: { /* The length of ‘span1’ is shorter than the length of ‘span2’ */ break. The pointer to the second calendar span to diff. Parameters p span1 p span2 base time p result Returns The pointer to the first calendar span to diff. struct pdf time cal span s *p_result ) Compute the difference between two calendar spans relative to a given base time and store it in a given calendar span. struct pdf_time_cal_span_s span1. A status value: PDF_OK The operation successfully finished..

FILETIME filetime. In this way a high level of abstraction is achieved in the library code that uses the filesystem services: the library is able to read . By implementing the functions defined in the Filesystem Implementation Interface the client can define and use its own filesystems. /* do stuff to get the FILETIME */ pdf_time_w32_set_from_filetime(mytime. mytime. &result) == PDF_EBADDATA) { /* Invalid data in ‘span1’ or ‘span2’ */ } 2. Usage example pdf_time_t mytime. In the GNU PDF Library a filesystem object (of type pdf_fsys_t) is an implementation of the file system services for a specific class of devices.1 Filesystem Concepts Filesystem objects provides access to file system services in an abstract way.10. rename files. Should be a properly create time variable. mytime = pdf_time_new (). manage file and folder permissions.11.11 The Filesystem Module 2. letting the library client to define filesystems for other classes of devices. Path names are named locations identifying files or folders. &filetime). containing A status value: PDF_OK The operation succeeded.Chapter 2: Base Layer 125 &span2.12 Platform-specific functions pdf_status_t pdf_time_w32_set_from_filetime (pdf time t time_var. read and write data from/to open files. Pointer to a valid FILETIME structure. Parameters time var p filetime Returns The time variable to set. create and delete folders. The filesystem object provides the functionality to open files. 2. etc. Open files are readable or writeable file items in a filesystem. const FILETIME *p_filetime ) [Function] This function will initialize time var to the given Filetime epoch in UTC timescale. 100-nanosecond intervals since 1 January 1601. This function is only available in Windows OS.

that provides functionalities related to open files. Each time has a type and several properties. and the File Interface. Conceptually speaking a filesystem contain a tree (or several trees in some filesystem implementations supporting several volumes) of filesystem items. 2. Open files are associated with a given filesystem and any filesystem can maintain an arbitrary number of open files (this may depend on the specific filesystem implementation).11. Several path names can refer to the same file or folder. delete and rename folders.3 The Filesystem Interface The Filesystem Interface is implemented by the Filesystem module and provides access to some filesystem functionalities in a filesystem implementation independent way. such as reading and writing information. Instead. from a network webdav based filesystem. Path names are implemented using PDF strings. an http server or a compressed image. folders are referred using path names. See XXX for more information about the disk filesystem path names.2 Filesystem Interfaces This section describes several interfaces that can be found in the Filesystem module. used to manage several filesystem aspects. An open file object (of type pdf_fsys_file_t) represent a readable and/or writable file in a filesystem. There is an internal interface filesystem implementors can implement to define a new filesystem. The interpretation of those path names depend in the specific plattform where the library is running. Both the encoding and the format of the contents of a path name depends on the specific filesystem implementation. The Filesystem Interface provides functions to create. The GNU PDF Library provides the default disk filesystem implementation for each supported plattform. There are also two interfaces implemented by the Filesystem module allowing clients to access the module functionality: the Filesystem Interface. The client can ask the filesystem for the properties of a given item identified by a path name. The implementation of the open files then call to the appropriate functionality of the filesystem managing the file. The client should close any opened file calling the appropriate function on the underlying filesystem.10).11. The client can read and write data from/to an open file using the pdf_fsys_file_* functions. It is called the Filesystem Implementation Interface. There is not an explicit data type for an open folder in the GNU PDF Library. . A Filesystem Definition Interface allow users to register the implementation functions into a filesystem variable. The functionality covered by the Filesystem Interface includes: • Folder management. Both files and folders in a filesystem can be referred using a string locator: a path name. 2.Chapter 2: Base Layer 126 the contents of a PDF file from a file stored in the local filesystem. The default disk filesystem provided by the GNU PDF Library uses the textual device idependent file specifications described in the PDF Reference (section 3.

flags. pdf_fsys_t An opaque type representing a filesystem. Read In Advance capabilities.1 Filesystem Data Types The following data types are defined and provided to the client by the Filesystem Module.2 Getting File System Properties pdf_i64_t pdf_fsys_get_free_space (pdf fsys t filesystem. • Read In Advance (RIA) capabilities. [Data Type] struct pdf fsys item props s [Data Type] This structure holds information about a filesystem item (a file or a directory). path name A path name. • Storage properties management (free space. If NULL then the default filesystem is used. are usually implemented in slow file system devices such as network filesystems. Parameters file system A filesystem. When a specific filesystem implementation does not support a functionality in the Filesystem Interface then the specific call becomes a no-op. remove. pdf_bool_t is_hidden pdf_bool_t is_readable pdf_bool_t is_writable pdf_time_t creation_date pdf_time_t modification_date pdf_u32_t file_size_high pdf_u32_t file_size_low pdf_u32_t folder_size 2. Note that not all the filesystem implementations support these operations.11. • Volume-level flush operations. etc).Chapter 2: Base Layer 127 • Folder contents management. 2. Returns A 64-bit value containing the remaining free space in the volume containing path name. etc).3. for example. pdf text t path_name ) Get the free storage space in the volume containing path name.3. • Management of filesystem items (rename. XXX [Function] Usage example .11.

3 Folder Management pdf_status_t pdf_fsys_create_folder (const pdf fsys t filesystem. pdf list t item_list ) Get a list with the path names of the items contained in a given folder. Usage example XXX pdf_status_t pdf_fsys_get_folder_contents (const pdf fsys t [Function] filesystem. A filesystem. A filesystem. [Function] PDF_EBADNAME The specified path name is incorrect. PDF_EBADPERMS The client does not have permissions to create the folder.11. Usage example XXX . const pdf text t path_name ) Create a folder named path name. item list Returns An output list variable to hold the path names of the items contained in the folder. If NULL the default filesystem is used. PDF_ERROR Any other error condition. PDF_EBADPERMS The client does not have permissions to read the contents of the folder. PDF_EBADNAME path name does not name a folder in the filesystem.Chapter 2: Base Layer 128 2. Parameters filesystem path name The path name of a folder. Returns A PDF status value: PDF_OK The folder was successfully created.3. const pdf text t path_name. Parameters filesystem path name The path name of the folder to be created. If NULL the default filesystem is used. PDF_ERROR Any other error condition. A PDF status value: PDF_OK The operation was successfully performed.

Usage example XXX . Usage example XXX pdf_status_t pdf_fsys_remove_folder (const pdf fsys t filesystem. PDF_EBADNAME path name does not name a valid item in the filesystem. If path name is the root directory then NULL is returned in parent path. If NULL the default filesystem is used. PDF_EBADNAME path name does not name a folder in the filesystem. PDF_EBADPERMS The client does not have permissions to remove the folder. PDF_ERROR Any other error. parent path [Function] A filesystem. const pdf text t path_name ) Remove an empty folder from the filesystem. If NULL the default filesystem is used. Parameters filesystem path name A path name of an empty folder in the filesystem. PDF_EBADPERMS The client does not have permissions to get the parent of the specified item.Chapter 2: Base Layer 129 pdf_status_t pdf_fsys_get_parent (const pdf fsys t filesystem. Output text variable to hold the path of the parent of the item identified by path name. [Function] A filesystem. pdf text t parent_path ) Get the path name of the father of a given item in the filesystem. Parameters filesystem path name The path name of an item in the filesystem. Returns A PDF status value: PDF_OK The path name of the parent of the item was successfully stored in parent path. const pdf text t path_name. Returns A PDF status value: PDF_OK The folder was successfully removed.

item props The address of a structure to hold the properties of the filesystem item. A filesystem. The key-value pairs returned in the hash variable are the following: isHidden isReadable Boolean value. pdf_status_t pdf_fsys_get_item_props (pdf fsys t filesystem. pdf_text_t path. isWritable Boolean value.4 Getting File System Item Properties The following functions provides access to generic properties of filesystem items (both files and directories). [Function] pdf text t path_name. PDF_EBADPERMS The client does not have enough permissions to read the requested item. /* Get the properties for the item */ pdf_status_t ret = pdf_fsys_get_item_props (NULL. Parameters filesystem path name A pdf string containing the path name of the filesystem item. PDF_EBADDATA Invalid path name. ret = pdf_status_t pdf_fsys_item_props_to_hash (const struct pdf fsys item props s item_props.Chapter 2: Base Layer 130 2. struct pdf fsys item props s *item_props ) Get the properties of a filesystem item identified by a path name. Returns A PDF status value: PDF_OK The operation succeeded.11. pdf_status_t ret. Boolean value. If NULL the default filesystem is used. pdf_text_new_from_unicode ("/path/to/foo". [Function] . Usage example struct pdf_fsys_item_props_s item_props. path.3. PDF_TEXT_UTF8. &item_props). 12. &path). pdf hash t props_hash ) Get a PDF hash variable containing the properties of a filesystem item.

If NULL the default filesystem is used. pdf_bool_t pdf_fsys_item_p (pdf fsys t filesystem. Parameters item props A filesystem item properties structure. modDate Text value containing a PDF style date string. Returns A PDF boolean value: [Function] Determine if a given item. path name A path name. It will be filled with the properties of the item. . Returns A PDF status value: PDF_OK Usage example XXX The operation succeeded and the properties were stored in the hash variable. versionMajor 32bit unsigned integer value. isPublished Boolean value. fileSizeHigh 32bit unsigned integer value. identified by a path name. props hash A PDF hash variable. isCheckedOut Boolean value.Chapter 2: Base Layer 131 creationDate Text value containing a PDF style date string. creatorCode 32bit unsigned integer value. fileSizeLow 32bit unsigned integer value. pdf text t path_name ) Parameters filesystem A filesystem. versionMinor 32bit unsigned integer value. folderSize 32bit unsigned integer value. exists in a given filesystem.

PDF_TEXT_UTF8. &path). Returns A PDF boolean value: PDF_TRUE PDF_FALSE The filesystem item is not readable. Usage example pdf_status_t status. [Function] Determine if a given filesystem item. path). Usage example pdf_bool_t ret. PDF_TEXT_UTF8. pdf_bool_t pdf_fsys_item_writable_p (pdf fsys t filesystem. 12. status = pdf_text_new_from_unicode ("/path/to/foo". pdf_bool_t pdf_fsys_item_readable_p (pdf fsys t filesystem. 12. pdf_text_t path. [Function] Determine if a given filesystem item. The filesystem item is readable. is writable. . If NULL the default filesystem is used.Chapter 2: Base Layer 132 PDF_TRUE PDF_FALSE The specified item exists in the filesystem. /* Determine if the item is readable */ pdf_bool_t ret = pdf_fsys_item_readable_p (NULL. pdf text t path_name ) Parameters filesystem path name A valid path name of an existing filesytem item. The specified item does not exist in the filesystem or the client does not have enough permissions to be able to read it. A filesystem. If NULL the default filesystem is used. status = pdf_text_new_from_unicode ("/path/to/foo". identified by a path name. pdf text t path_name ) Parameters filesystem path name A valid path name of an existing filesystem item. A filesystem. &path). path). is readable. identified by a path name. pdf_text_t path. pdf_status_t status. /* Test whether the path to /path/to/foo is a valid path to foo */ pdf_bool_t ret = pdf_fsys_item_p (NULL.

.Chapter 2: Base Layer 133 Returns A PDF boolean value: PDF_TRUE PDF_FALSE The filesystem item is not writable. pdf_text_t filename = NULL. /* Determine if the item is writable */ pdf_bool_t ret = pdf_fsys_item_writable_p (NULL. store resulting path in output.txt"). Variable-length pdf text t object list.. pdf_text_t parent_path = get_current_dir_as_text (). . &filename). pdf_text_t path.. Usage example pdf_status_t status. PDF_TEXT_UTF8... The filesystem item is writable. pdf_status_t st. if (st != PDF_OK) { /* . Returns Returns PDF OK if operation succeeded and output points to built path. first name First text path component. . . PDF_TEXT_UTF8. &full_path.. If NULL the default filesystem is used. pdf text t first_name.11. strlen ("filename. st = pdf_fsys_build_path (NULL. &path). filename). last element must be NULL. pdf_status_t pdf_fsys_build_path (pdf fsys t filesystem. such as writing and reading data to/from a specific file.) [Function] Build a file path by concatenating first name with the following variable-length list of pdf_text_t objects. A pdf text t pointer where the resulting path name will be stored. pdf text t *output. /* example */ Usage example pdf_text_new_from_from_unicode ("filename. */ } 2. status = pdf_text_new_from_unicode ("/path/to/foo". 12. Parameters filesystem output A filesystem.4 The File Interface The File Interface is implemented by the filesystem module and provides access to filesystem functionality related with open files. path). pdf_text_t full_path = NULL. parent_dir.txt".

pdf_fsys_file_t [Data Type] An opaque type representing an open file. Parameters filesystem A filesystem. so the client should only provide a correctly initialized (opened) file variable to the pdf_fsys_file_* functions. const enum pdf fsys file mode e mode. • Asynchronoous Input/Output (not to be confused with RIA. • File positioning management. 2. See above). . The available modes are described in the following list. • File size management. The file should exist in the filesystem. enum pdf_fsys_file_mode_e 2. PDF_FSYS_OPEN_MODE_WRITE The file is opened in write-only mode. The functionality covered by the File Interface includes: • Synchronous Input/Output. If NULL the default filesystem is used. pdf fsys file t *file ) Open a file in filesystem identified by path name using the specified mode and store a new open file variable in file.11. • File flags (status) management. The file should exist in the filesystem.Chapter 2: Base Layer 134 Note that open file variables (pdf_fsys_file_t) contain a reference to its underlying filesystem implementation. • File-level flush operations.11.2 Opening Files pdf_status_t pdf_fsys_file_open (const pdf fsys t filesystem. PDF_FSYS_OPEN_MODE_READ The file is opened in read-only mode. [Function] const pdf text t path_name. PDF_FSYS_OPEN_MODE_RW The file is opened in read/write mode.4.4. The file is truncated to 0 size (any previous contents are lost) if the file exists and it is created if it does not exist.1 File Data Types The following file-related data types are defined and provided to the client by the Filesystem Module. The client can perform several operations in the file using the pdf_fsys_file_t as a reference. [Data Type] The mode used when opening a file in a filesystem.

Not enough memory. pdf fsys file t *file ) Create a temporary file in filesystem and open it. [Function] The temporary file is opened with mode PDF_FSYS_OPEN_MODE_RW and stored in file. If NULL the default filesystem is used. PDF_ENOMEM Not enough memory. PDF_EBADNAME The path name specified in path name does not identify an existing file in the filesystem. PDF_ENOMEM . PDF_ERROR It was not possible to create the temporary file. it is not guaranteed. A PDF status value: PDF_OK The file was successfully opened and stored in the file variable. mode file Returns The open mode to use to open the file. The output file variable. A PDF status value: PDF_OK The file was successfully opened and stored in the file variable. The format and encoding of this text variable depends on the underlying filesystem implementation.Chapter 2: Base Layer 135 path name A path name that identifies the file to be opened. Usage example XXX pdf_status_t pdf_fsys_file_open_tmp (const pdf fsys t filesystem. Note that while the filesystem implementation may also delete the file when the client application exits. The file will be automatically deleted with it is closed. The output file variable. Parameters filesystem file Returns A filesystem. PDF_EBADPERMS The client does not have permission to open the specified file using the specified mode. If the filesystem implementation does not support this functionality then NULL is stored in file.

"Temporary data". This deletes it from the filesystem. pdf_size_t written. Parameters file Returns An open file.4. /* Close the file. pdf_fsys_file_close (tmpfile). 14. Parameters file Returns An open file. pdf_status_t status.Chapter 2: Base Layer 136 Usage example pdf_fsys_file_t tmpfile. */ 2. [Function] Usage example pdf_status_t ret. XXX [Function] Usage example pdf_fsys_t pdf_fsys_file_get_filesystem (pdf fsys file t file ) Get the filesystem associated with a given open file. pdf_fsys_file_write (tmpfile. The size of the file in octects. */ pdf_fsys_file_open_tmp (NULL. pdf_text_t path. pdf_fsys_file_t file = pdf_alloc(sizeof(pdf_fsys_file_s)). A mode value if successful. XXX [Function] Usage example enum pdf_fsys_file_mode_e pdf_fsys_file_get_mode (pdf fsys file t file ) Return the access mode used to open a given file.11. &tmpfile). The filesystem associated with file.3 File Properties Management The following functions provides access to several properties of open files. &written). status = pdf_text_new_from_unicode ("/path/to/foo". . /* Open a temporary file and write some contents to it. Parameters file Returns An open fiile. pdf_size_t pdf_fsys_file_get_size (pdf fsys file t file ) Get the size (in number of octects) of a given open file. otherwise returns -1.

If the filesystem does not support URLs then an empty string is returned. path. pdf_text_t path. Usage example pdf_status_t ret. Note that for some filesystems could be not possible to build a valid URL. [Function] Returns PDF OK if the mode is set to the new mode. PDF_FSYS_OPEN_MODE_WRITE. Parameters file An open file. pdf_text_t pdf_fsys_file_get_url (pdf fsys file t file ) [Function] Get a text variable containing a valid URL to refer to a given open file. otherwise returns an appropriate pdf status t error. PDF_TEXT_UTF8. PDF_EBADDATA The mode provided was invalid. enum pdf fsys file mode e new_mode ) Update the mode of a given open file. enum pdf_fsys_file_mode_e mode. A PDF status value: PDF_OK The operation succeeded. new mode The new mode to set for the file. file). &path). enum pdf_fsys_file_mode_e mode = PDF_FSYS_OPEN_MODE_READ. 12. PDF_ERROR General failure. PDF_FSYS_OPEN_MODE_READ. file). mode). pdf_fsys_file_t file = pdf_alloc(sizeof(pdf_fsys_file_s)). path. most applicable to Win32. ret = pdf_fsys_file_open (NULL. pdf_status_t status. XXX Usage example pdf_status_t pdf_fsys_file_set_mode (pdf fsys file t file.Chapter 2: Base Layer 137 12. Returns A PDF text variable containing a valid URL that can be used to refer to the open file. ret = pdf_fsys_file_set_mode(file. status = pdf_text_new_from_unicode ("/path/to/foo". mode = pdf_fsys_file_get_mode(file). Parameters file Returns An open file. . PDF_TEXT_UTF8. ret = pdf_fsys_file_open (NULL. &path).

Parameters file pos Returns An open file.5 Managing File Positions The following functions allow to move the input/output pointer of a buffer file (its “current position”). [Function] A PDF status variable: PDF_OK PDF_ERROR The function call failed due to an error.4. A PDF boolean value: PDF_TRUE PDF_FALSE The files are not the same file. or the given pathname does not identify a file in the underlying filesystem.4 Comparing Files The following functions allow to compare files.11. pdf_text_t other_path. pdf_fsys_file_t file. Parameters file path Returns An open file. Both files are the same file. pdf size t *pos ) Get the current position (in octects) in a given open file. /* some pre-initialized file variable */ pdf_status_t status. &other_path). Usage example pdf_bool_t ret. . PDF_TEXT_UTF8. A file path. The address of a pdf_size_t variable. 2.Chapter 2: Base Layer 138 2. pdf_bool_t pdf_fsys_file_same_p (pdf fsys file t file. 12. status = pdf_text_new_from_unicode ("/path/to/baz". The operation was successfully performed. ret = pdf_fsys_file_same_p (file. pdf text t path ) [Function] Determine whether a given open file is the same file as a given file identified by a file path.4. other_path). pdf_status_t pdf_fsys_file_get_pos (pdf fsys file t file.11.

Chapter 2: Base Layer 139 Usage example pdf_status_t ret. pdf_status_t status. pdf_text_t path. pos). status = pdf_text_new_from_unicode ("/path/to/foo". pos). [Function] A PDF status value: PDF_OK The operation succeeded. ret = pdf_fsys_file_open (NULL. ret = pdf_fsys_file_get_pos(file. 12. &path). pdf_fsys_file_t file = pdf_alloc(sizeof(pdf_fsys_file_s)). PDF_FSYS_OPEN_MODE_WRITE. ret = pdf_fsys_file_open (NULL. &path). PDF_TEXT_UTF8. PDF_EBADPERMS The client does not have enough permissions to change the current file position. path. pdf_fsys_file_t file = pdf_alloc(sizeof(pdf_fsys_file_s)). PDF_EBADDATA Invalid new position. 12. path. Usage example pdf_status_t ret. file). PDF_FSYS_OPEN_MODE_WRITE. PDF_TEXT_UTF8. . pdf_size_t pos = 20. ret = pdf_fsys_file_set_pos(file. Parameters file new pos Returns An open file. pdf_status_t pdf_fsys_file_set_pos (pdf fsys file t file. The new position of the file. pdf_text_t path. pdf size t new_pos ) Set the current position in a given open file. pdf_size_t pos = 20. status = pdf_text_new_from_unicode ("/path/to/foo". pdf_status_t status. file).

[Function] . pdf size t bytes.6 Changing the Size of a File pdf_bool_t pdf_fsys_file_can_set_size_p (pdf fsys file t file. or is 0 if there is an error. If it is bigger than the previous size then the file is augmented to that size. pdf char t *buf. Usage example XXX pdf_status_t pdf_fsys_file_set_size (pdf fsys file t file.4. Parameters file new size An open file. pdf size t *read_bytes ) Synchronously read data from an open file item. XXX Usage example 2. Returns A PDF size value indicating the new size of the file. pdf_status_t pdf_fsys_file_read (pdf fsys file t file. If it is shorter than the previous size then the file gets truncated.11. The file can be resized to the given size.11. Parameters file buf bytes read bytes The number of octects actually read. Parameters file size Returns An open file. It should match the requested new size.7 Synchronous Input/Output The following functions provides synchronous input/output for open files. pdf size t size ) Resize a given file to a given new size measured in octects.Chapter 2: Base Layer 140 2. The number of octects to read. An open file. [Function] The new size for the file.4. The new size for the file in octects. The buffer to hold the read data. [Function] A PDF boolean value: PDF_TRUE PDF_FALSE The file cannot be resized to the given size. pdf size t size ) Determine if a given open file is resizeable to a given size.

Usage example XXX An end of file condition occurred. pdf size t *written_bytes ) Synchronously write data to an open file item. A PDF status value: PDF_OK The open file was flushed successfully. PDF_EBADDATA The file element or a given pointer is invalid. PDF_EBADDATA The file element or a given pointer is invalid. The number of octects to write. Parameters file buf bytes An open file. PDF_ENOMEM A disk full condition ocurred. [Function] PDF_EBADDATA Bad function parameters to underlying write(). pdf_status_t pdf_fsys_file_write (pdf fsys file t file. Parameters file Returns An open file variable. [Function] A pointer to memory containing the data to write into the file. . Usage example XXX pdf_status_t pdf_fsys_file_flush (pdf fsys file t file ) Flush all the written data for the specified file. PDF_ERROR An error prevented to write the bytes.Chapter 2: Base Layer 141 Returns A PDF status value: PDF_OK All the requested bytes were successfully read into buf. written bytes The number of octects actually written. Returns A PDF status value: PDF_OK All the requested bytes were successfully written to file. pdf size t bytes. pdf char t *buf. PDF_EEOF PDF_ERROR An error prevented to read the bytes.

pdf size t count ) [Function] Request a Read-In-Advance operation in a given open file. If the filesystem does not implement RIA capabilities then this function is a no-op. The beginning of the requested block.11. The size (in octects) of the requested block. pdf size t offset. Usage example XXX 2. Note that it is up to the underlying filesystem to honour the operation. Parameters file An open file. Note that it is up to the underlying filesystem to honour the operation. Parameters file offset count Returns An open file. Usage example XXX pdf_bool_t pdf_fsys_file_has_ria (pdf fsys file t file ) [Function] Determine whether the filesystem is performing some RIA operation for the given open file.8 Read in Advance When working with slow filesystems (such as network filesystems) it is useful to be able to request parts of the file in advance. pdf_status_t pdf_fsys_file_request_ria (pdf fsys file t file. PDF_ERROR There was an error flushing the open file. The filesystem is performing some RIA operation in the given file. The operation succeeded. Returns A PDF boolean value: PDF_TRUE PDF_FALSE There is not an outstanding RIA operation in the given file.Chapter 2: Base Layer 142 PDF_EAGAIN Try again. A PDF status value: PDF_OK PDF_ERROR An error occurred.4. Usage example XXX . If the filesystem does not implement RIA capabilities then this function always return PDF_FALSE.

Any pending output data is flushed before to close the file. A PDF status value: PDF_OK PDF_ERROR There was an error closing the file.9 Closing and Reopening Files The following functions allow to close an open file or to reopen it using another file mode. If the filesystem does not implement RIA capabilities then this function is a no-op.11. 2. PDF_EBADPERMS The client does not have enough permissions to open the file using the specified mode. [Function] A PDF status value: PDF_OK The file was successfully reopened using the new mode.Chapter 2: Base Layer 143 pdf_status_t pdf_fsys_file_cancel_ria (pdf fsys file t file ) Cancel any pending RIA operation in a given open file. [Function] Note that it is up to the underlying filesystem to honour the operation. Usage example XXX The file was successfully closed. enum pdf fsys file mode e mode ) Reopen a given open file with a given mode. Parameters file Returns An open file. pdf_status_t pdf_fsys_file_close (pdf fsys file t file ) Parameters file Returns An open file.4. The open file is now closed. A file mode. [Function] Close a given open file. A PDF status value: PDF_OK Usage example XXX Any pending RIA operation was cancelled. pdf_status_t pdf_fsys_file_reopen (pdf fsys file t file. Parameters file mode Returns An open file. Usage example XXX .

This callback is called by the pdf_fsys_create function. to open it in read/write mode and to store it in file.11. 2. This callback is called by the pdf_file_fsys_open filesystem interface function.1 File System Interface Implementation pdf_status_t (*pdf_fsys_init_fn_t) (void **data ) [Data Type] Filesystem callback called to initialize the filesystem internal state. This callback is called by the pdf_fsys_file_open_tmp filesystem interface function. deletion and modification of folders in the filesystem and retrieval of folder contents. pdf_fsys_file_t *file ) Filesystem callback called to open a file identified by the path path name in the mode specified by mode. The implementation of both interfaces then makes use of the Filesystem Implementation Interface in order to honour the petition. A new pdf_fsys_file_t is created and stored in file. This callback is called by the pdf_fsys_close filesystem interface function. pdf_status_t (*pdf_fsys_file_open_tmp_fn_t) (pdf_fsys_file_t *file ) [Data Type] Filesystem callback called to create a temporary file. Note that the functions conforming the Implementation Interface are not intended to be directly invoked by clients. if any. pdf_status_t (*pdf_fsys_cleanup_fn_t) (void *data ) This callback is called by the pdf_fsys_destroy function. pdf_status_t (*pdf_fsys_file_open_fn_t) (pdf_text_t [Data Type] path_name. if any. The following callbacks are defined to provide folder management: creation.Chapter 2: Base Layer 144 2. • Making calls to the File Interface. enum pdf_fsys_file_mode_e mode. . The output buffers of the file are flushed before to close it.5 The Filesystem Implementation Interface The filesystem implementation interface is a set of functions that are installed in a pdf_ fsys_t variable in order to provide its functionality. [Data Type] Filesystem callback called to cleanup the filesystem internal state. By implementing those functions the client can provide a filesystem for some (physical or logical) storage device: a webdav directory. etc. pdf_status_t (*pdf_fsys_close_fn_t) (pdf_fsys_file_t file ) [Data Type] Filesystem callback used to close a given file identified by the open file variable file.5.11. a read-only http filesystem. Clients can access to the functionality of the filesystem using indirect ways: • Making calls to the Filesystem Interface.

This callback is called by the pdf_fsys_create_folder filesystem interface function. pdf_size_t bytes. The following callbacks are defined to provide synchronous input/output in open files. pdf_status_t (*pdf_fsys_get_parent_fn_t) (pdf_text_t path_name. This callback is called by the pdf_fsys_remove_folder filesystem interface function. pdf_status_t (*pdf_fsys_file_read_fn_t) (pdf_fsys_file_t file. pdf_status_t (*pdf_fsys_get_item_props_fn_t) (pdf_text_t path_name. pdf_size_t*read_bytes ) [Data Type] Filesystem callback used to synchronously read data from an open file item. This callback is called by the pdf_fsys_get_item_props filesystem interface function. The file system items are addressed using path names. . struct pdf_fsys_item_props_s *props ) [Data Type] Filesystem callback used to get the properties of a named filesystem item. pdf_size_t*written_bytes ) Filesystem callback used to synchronously write data to an open file item. The following callbacks are defined to provide access to several filesystem item properties. This callback is called by the pdf_fsys_get_parent filesystem interface function. pdf_size_t bytes. pdf_list_t item_list ) [Data Type] Filesystem callback used to get the contents of a specified folder as a list of path names. pdf_status_t (*pdf_fsys_file_write_fn_t) [Data Type] (pdf_fsys_file_t file. This callback is called by the pdf_fsys_file_write file interface function.Chapter 2: Base Layer 145 pdf_status_t (*pdf_fsys_create_folder_fn_t) (pdf_text_t path_name ) [Data Type] Filesystem callback used to create a folder identified by the path name path name. pdf_status_t (*pdf_fsys_get_folder_contents_fn_t) (pdf_text_t path_name. pdf_text_t parent_path ) [Data Type] Filesystem callback used to get the path name of the father of a given item in a filesystem. This callback is called by the pdf_fsys_file_read file interface function. pdf_status_t (*pdf_fsys_file_flush_fn_t) (pdf_fsys_file_t file ) [Data Type] Filesystem callback used to flush all the written data for the specified file. If path name is the root directory then NULL is returned in parent path. pdf_char_t*buf. pdf_char_t*buf. pdf_status_t (*pdf_fsys_remove_folder_fn_t) (pdf_text_t path_name ) [Data Type] Filesystem callback used to remove an empty folder identified by path name. This callback is called by the pdf_fsys_file_flush file interface function. This callback is called by the pdf_fsys_get_folder_contents filesystem interface function.

The callback should return a PDF bool value specifying if it is possible to perform the operation. . pdf_bool_t (*pdf_fsys_file_can_set_size_fn_t) (pdf_fsys_file_t file. exists in a given filesystem. pdf_bool_t (*pdf_fsys_item_p_fn_t) (pdf_text_t path_name ) [Data Type] Filesystem callback used to determine whether a given item. This callback is called by the pdf_fsys_item_readable_p file system interface function. is writeable. identified by a path name. pdf text t first element. pdf_bool_t (*pdf_fsys_item_readable_p_fn_t) (pdf_text_t path_name ) [Data Type] Filesystem callback used to determine whether a given filesystem item. is readable. pdf_text_t first_name.5. This callback is called by the pdf_fsys_get_free_space file system interface function. pdf_size_t pos ) [Data Type] Filesystem callback used to determine if it is possible to set the size of a given file to an especified value. pdf text t * output. typedef pdf status t (*pdf fsys build path fn t) (void * data. pdf list t rest). 2. identified by a path name.Chapter 2: Base Layer 146 pdf_size_t (*pdf_fsys_get_free_space_fn_t) (pdf_text_t path_name ) [Data Type] Filesystem callback used to get the free storage space in the volume containing path name. This callback is called by the pdf_fsys_item_p file system interface function. This callback is called by the pdf_fsys_item_writeable_p file system interface function. Where rest is a list of pdf text t objects. This callback is called by the pdf_fsys_build_path file system interface function.2 File Interface Implementation The following callbacks are defined to provide access to several file properties. [Data Type] pdf_text_t *output. pdf_status_t (*pdf_fsys_build_path_fn_t) (void * data.11. pdf_list_t rest ) Filesystem callback used to concatenate and build a file path. identified by a path name. pdf_bool_t (*pdf_fsys_item_writable_p_fn_t) (pdf_fsys_t filename. pdf_text_t path_name ) [Data Type] Filesystem callback used to determine whether a given filesystem item.

pdf_size_t pos ) Filesystem callback used to set the logical size of a file (in octects). pdf_size_t *pos ) Filesystem callback used to get the current position in a given file. The callback should return a PDF status variable: PDF_OK [Data Type] The operation was successfully performed and the current position in nfile was set to pos. The callback should return a PDF status value: PDF_OK [Data Type] The operation was successfully performed and the logical size of the file was stored in pos. pdf_status_t (*pdf_fsys_file_set_size_fn_t) (pdf_fsys_file_t file. This callback is called by the pdf_fsys_file_get_pos file interface function. The callback should return a PDF status variable: PDF_OK [Data Type] The operation was successfully performed and the current position in file was stored in pos. pdf_size_t pos ) Filesystem callback used to set the current position in a given file. PDF_BADPERMS The client does not have enough permissions to get the logical size of file. This callback is called by the pdf_fsys_file_get_mode file interface function. pdf_size_t pos ) Filesystem callback used to get the logical size of a file (in octects). enum pdf_fsys_file_mode_e (*pdf_fsys_file_get_mode_fn_t) (pdf_fsys_file_t file ) [Data Type] Filesystem callback used to get the open mode of a given open file. The callback should return a PDF status value: PDF_OK [Data Type] The operation was successfully performed and the logical size of the file was changed.Chapter 2: Base Layer 147 pdf_status_t (*pdf_fsys_file_get_size_fn_t) (pdf_fsys_file_t file. This callback is called by the pdf_fsys_file_set_mode file interface function. This callback is called by the pdf_fsys_file_set_pos file interface function. . pdf_status_t (*pdf_fsys_file_set_pos_fn_t) (pdf_fsys_file_t file. pdf_status_t (*pdf_fsys_file_set_mode_fn_t) [Data Type] (pdf_fsys_file_t file. PDF_BADPERMS The client does not have enough permissions to set the logical size of file. enum pdf_fsys_file_mode_e new_mode ) Filesystem callback used to update the mode of a given open file with a given set of file modes. pdf_status_t (*pdf_fsys_file_get_pos_fn_t) (pdf_fsys_file_t file.

. pdf_size_t count ) Filesystem callback used to request a Read-In-Advance operation in a given open file. This callback is called by the pdf_fsys_file_same_p file interface function. A pdf_fsys_t should be properly defined before to use it.11. pdf_status_t (*pdf_fsys_file_cancel_ria_fn_t) (pdf_fsys_file_t file ) [Data Type] Filesystem callback used to cancel any pending RIA operation in a given open file. [Data Type] This callback is called by the pdf_fsys_file_close file interface function. pdf_status_t (*pdf_fsys_file_request_ria_fn_t) [Data Type] (pdf_fsys_file_t file.6 The Filesystem Definition Interface The Filesystem Definition Interface is implemented by the Filesystem module and provides functionality to provide an implementation of a filesystem.Chapter 2: Base Layer 148 pdf_text_t (*pdf_fsys_file_get_url_fn_t) (pdf_fsys_file_t file ) Filesystem callback used to get a URL pointing to a given open file. pdf_bool_t (*pdf_fsys_file_has_ria_fn_t) (pdf_fsys_file_t file ) [Data Type] Filesystem callback used to determine whether the filesystem is performing some RIA operation for the given open file. This callback is called by the pdf_fsys_file_request_ria file interface function. pdf_size_t offset. This callback is called by the pdf_fsys_file_reopen file interface function. [Data Type] This callback is called by the pdf_fsys_file_get_url file interface function. The Filesystem Definition Interface defines the following elements: • The function types conforming the Filesystem Implementation Interface. pdf_bool_t (*pdf_fsys_file_same_p_fn_t) (pdf_fsys_file_t file. This callback is called by the pdf_fsys_file_cancel_ria file interface function. 2. • Installation functions to register implementation functions into a filesystem variable. pdf_text_t path_name ) [Data Type] Filesystem callback used to determine whether a given open file is the same file as a given file identified by a file path. pdf_status_t (*pdf_fsys_file_close_fn_t) (pdf_fsys_file_t file ) Filesystem callback used to close a given open file. pdf_status_t (*pdf_fsys_file_reopen_fn_t) [Data Type] (pdf_fsys_file_t file. enum pdf_fsys_file_mode_e mode ) Filesystem callback used to reopen a given open file with a given mode. This callback is called by the pdf_fsys_file_has_ria file interface function.

The members of the structure are the following: pdf_fsys_init_fn init_fn pdf_fsys_cleanup_fn cleanup_fn pdf_fsys_open_fn_t open_fn pdf_fsys_close_fn_t c close_fn pdf_fsys_create_folder_fn_t create_folder_fn pdf_fsys_get_folder_contents_fn_t get_folder_contents_fn pdf_fsys_get_parent_fn_t get_parent_fn pdf_fsys_remove_folder_fn_t remove_folder_fn pdf_fsys_file_read_fn_t file_read_fn pdf_fsys_file_write_fn_t file_write_fn pdf_fsys_file_flush_fn_t fiile_flush_fn pdf_fsys_get_item_props_fn_t get_item_props_fn pdf_fsys_get_free_space_fn_t get_free_space_fn pdf_fsys_item_p_fn_t item_p_fn pdf_fsys_item_readable_p_fn_t item_readable_p_fn pdf_fsys_item_writable_p_fn_t item_writable_p_fn pdf_fsys_get_temp_path_name_fn_t get_temp_path_name_fn pdf_fsys_file_can_set_size_fn_t file_can_set_size_fn pdf_fsys_file_get_size_fn_t file_get_size_fn pdf_fsys_file_set_size_fn_t file_set_size_fn pdf_fsys_file_get_pos_fn_t file_get_pos_fn pdf_fsys_file_set_pos_fn_t file_set_pos_fn pdf_fsys_file_get_mode_fn_t file_get_mode_fn pdf_fsys_file_set_mode_fn_t file_set_mode_fn pdf_fsys_file_get_url_fn_t file_get_url_fn pdf_fsys_file_same_p_fn_t file_same_p_fn pdf_fsys_file_request_ria_fn_t file_request_ria_fn pdf_fsys_file_has_ria_fn_t file_has_ria_fn pdf_fsys_file_cancel_ria_fn_t file_cancel_ria_fn pdf_fsys_file_close_fn_t file_close_fn pdf_fsys_file_reopen_fn_t file_reopen_fn 2.11.Chapter 2: Base Layer 149 2.11.2 File System Definition Functions pdf_fsys_t pdf_fsys_create (struct pdf fsys impl s implementation ) Parameters implementation A filesystem implementation. Returns A fileystem variable.1 File System Definition Data Types struct pdf fsys impl s [Data Type] Structure containing the callbacks to a concrete file system implementation. . [Function] Create and return a new filesystem variable that will use a given implementation.6.6.

A PDF status value: PDF_OK Usage example XXX The filesystem was successfully destroyed. which marks the end of a dictionary.Chapter 2: Base Layer 150 Usage example XXX pdf_status_t pdf_fsys_destroy (pdf fsys t filesystem ) Destroy a filesystem freein all used resources. .12 The Tokeniser The tokeniser module provides functions to: − Read PDF lexical tokens from a base layer stream − Write PDF lexical tokens into a base layer stream 2.12. PDF_TOKEN_DICT_END The “>>” operator. [Function] 2. Valid values are: PDF_TOKEN_INTEGER A PDF integer value. PDF_TOKEN_STRING A PDF string. any string of regular characters such as “null” or “R” that is not matched as another type. which marks the beginning of a dictionary. [Data Type] [Data Type] enum pdf_token_type_e The type of a PDF token. PDF_TOKEN_KEYWORD A keyword.e. Parameters filesystem Returns A filesystem variable.. i. PDF_TOKEN_COMMENT A PDF comment. PDF_TOKEN_DICT_START The “<<” operator.1 Tokeniser data types pdf_token_t A PDF token. PDF_TOKEN_NAME A PDF name. PDF_TOKEN_REAL A PDF real value (a floating-point number).

generating the textual representation of a PDF token.12. which marks the end of an array. Usage example pdf_stm_t stream. PDF_EBADDATA stm is not a reading stream. [Data Type] A token writer that operates on a writing base layer stream. pdf token reader t *reader ) Create a new token reader operating a given reading stream.2 Creation and destruction of tokenisers pdf_status_t pdf_token_reader_new (pdf stm t stm. which marks the end of a procedure. [Function] A PDF status value: PDF_OK The reader was successfully created. PDF_ENOMEM Not enough memory to create the reader. PDF_TOKEN_PROC_END The “}” operator. A pointer to a token reader. &reader)) { . pdf_token_reader_t reader. pdf_token_writer_t 2. which marks the beginning of an array. PDF_ERROR An error prevented to perform the operation. PDF_TOKEN_PROC_START The “{” operator.Chapter 2: Base Layer 151 PDF_TOKEN_ARRAY_START The “[” operator. pdf_token_reader_t [Data Type] A token reader that operates on a reading base layer stream and provides a stream of PDF tokens. PDF_TOKEN_ARRAY_END The “]” operator. which marks the beginning of a procedure. /* Open a file stream */ XXX /* Create the token reader */ switch (pdf_token_reader_new (stream. Parameters stm reader Returns A reading stream.

Usage example pdf_stm_t stream. } } pdf_status_t pdf_token_writer_new (pdf stm t stm. } case PDF_ERROR: { /* Some other error prevented the creation of the reader */ break. PDF_EBADDATA stm is not a writing stream. [Function] A PDF status value: PDF_OK The writer was successfully created. /* Open a file stream */ XXX . } default: { /* Success */ break. A pointer to a token writer.Chapter 2: Base Layer 152 case PDF_BADDATA: { /* STREAM is not a valid reading stream */ break. pdf_token_writer_t writer. pdf token writer t *writer ) Create a new token writer operating a given reading stream. Parameters stm writer Returns A writing stream. } case PDF_ENOMEM: { /* Not enough memory to create the reader */ break. PDF_ERROR An error prevented to perform the operation. PDF_ENOMEM Not enough memory to create the writer.

. } case PDF_ENOMEM: { /* Not enough memory to create the writer */ break. [Function] A PDF status value: PDF_OK The token reader was destroyed. } } pdf_status_t pdf_token_reader_destroy (pdf token reader t reader ) Destroy a token reader freeing any used resources. } case PDF_ERROR: { /* Any other error prevented the creation of the writer */ break. PDF_EBADDATA reader was NULL. } default: { /* Success */ break. /* Create a reader */ XXX /* Destroy the reader */ pdf_token_reader_destroy (reader). Parameters reader Returns The reader to destroy. &writer)) { case PDF_BADDATA: { /* STREAM is not a valid writing stream */ break. Usage example pdf_token_reader_t reader.Chapter 2: Base Layer 153 /* Create the token writer */ switch (pdf_token_writer_new (stream.

. Parameters reader flags A token reader. and return PDF EEOF when successful (i.e. [Function] A PDF status value: PDF_OK The operation succeeded. Usage example pdf_token_writer_t writer. A bitmask specifying a combination of these flags: PDF_TOKEN_NO_NAME_ESCAPES Don’t treat “#” as a special character when reading name tokens (this flag should be used when reading PDF 1.1 files).Chapter 2: Base Layer 154 pdf_status_t pdf_token_writer_destroy (pdf token writer t writer ) Destroy a token writer. find the beginning of the corresponding stream. [Function] PDF_EBADDATA writer was NULL. PDF_TOKEN_END_AT_STREAM Assume that a “stream” keyword token was just read. pdf u32 t flags. /* Create a writer */ XXX /* Destroy the writer */ pdf_token_writer_destroy (writer). PDF_TOKEN_RET_COMMENTS Return comments as tokens (rather than ignoring them). freeing any used resources. 2. A PDF status value: PDF_OK The token writer was destroyed. token Returns A pointer to a pdf token t that will hold the read token. Parameters writer Returns The writer to destroy.3 Reading tokens pdf_status_t pdf_token_read (pdf token reader t reader. when the input stream is positioned after the first line feed). pdf token t *token ) Read a token from a token reader.12. .

. pdf u32 t flags. [Function] . PDF_EEOF Reached the end of the input stream (at a valid position). A bitmask specifying a combination of these flags: PDF_TOKEN_NO_NAME_ESCAPES Don’t escape special characters using “#” when writing name tokens (this flag should be used when writing PDF 1.e. the operation should be repeated with the same flags when data becomes available. pdf token t token ) Write a given token using a given token writer.1 files). Usage example XXX pdf_status_t pdf_token_reader_reset (pdf token reader t reader ) Reset the state of the token reader. PDF_TOKEN_READABLE_STRINGS Encode strings in a human-readable way (i. PDF_EBADFILE The stream violates the PDF specifications. PDF_EIMPLLIMIT It’s not possible to read the next token without exceeding an implementation limit (e.. in hexadecimal or with special characters escaped).4 Writing tokens pdf_status_t pdf_token_write (pdf token writer t writer.g. PDF_TOKEN_HEX_STRINGS Write strings in hexadecimal encoding. Parameters writer flags A token writer. [Function] 2. A PDF status value: PDF_OK The operation succeeded. Parameters reader Returns A token reader. Since one may have been partially read. PDF_ERROR An unspecified error occurred.Chapter 2: Base Layer 155 PDF_EAGAIN It’s not possible to read a full token now. token A PDF token.12. the token is too long).

pdf token t *token ) Create an integer token. PDF_EBADDATA One of the arguments is invalid. [Function] A PDF status value: PDF_OK PDF_ENOMEM Not enough memory. Parameters reader Returns A token writer. Parameters value token The numeric value for the token. Usage example XXX pdf_status_t pdf_token_writer_reset (pdf token writer t writer ) Reset the state of the token writer. The operation succeeded.. A pointer to the newly created token. the operation must be repeated with the same arguments when the stream becomes writable. pdf_status_t pdf_token_real_new (pdf real t value. Parameters value token Returns The numeric value for the token. This may be caused by an invalid token (e.12. A PDF status value: PDF_OK The operation succeeded. [Function] . A pointer to the newly created token.5 Creating and destroying tokens pdf_status_t pdf_token_integer_new (pdf i32 t value.g. one that contains unrepresentable characters). PDF_ERROR An unspecified error occurred. [Function] 2. The operation succeeded. Since it may have been partially written. pdf token t *token ) Create a real (floating-point number) token.Chapter 2: Base Layer 156 Returns A PDF status value: PDF_OK PDF_EAGAIN It’s not possible to write a full token now.

PDF_ENOMEM Not enough memory. in octets. pdf size t size. PDF_EBADDATA The given value is invalid. The amount of data to copy. pdf token t *token ) Create a string token containing a copy of the given data. Parameters value size token Returns [Function] A pointer to the binary data that will make up the name. Parameters value size [Function] A pointer to the binary data that will make up the keyword. PDF_ENOMEM Not enough memory. pdf_status_t pdf_token_name_new (const pdf char t *value. pdf token t *token ) Create a keyword token containing a copy of the given data. A pointer to the newly created token. in octets. PDF_EBADDATA The given value is invalid. A PDF status value: PDF_OK PDF_ENOMEM Not enough memory. pdf size t size. pdf_status_t pdf_token_keyword_new (const pdf char t *value. in octets.Chapter 2: Base Layer 157 Returns A PDF status value: PDF_OK The operation succeeded. A PDF status value: PDF_OK The operation succeeded. The operation succeeded. Parameters value size token Returns [Function] A pointer to the binary data that will make up the string. pdf size t size. pdf token t *token ) Create a name token containing a copy of the given data. The amount of data to copy. pdf_status_t pdf_token_string_new (const pdf char t *value. The amount of data to copy. A pointer to the newly created token. .

A pointer to the newly created token. A PDF status value: PDF_OK The operation succeeded. PDF_EBADDATA The given value is invalid. pdf_status_t pdf_token_valueless_new (enum pdf token type e type. The amount of data to copy. PDF_EBADDATA The given type is not valid for this constructor. pdf token t *token ) [Function] Create a token of one of the valueless types (PDF TOKEN DICT START. Parameters value size token Returns [Function] A pointer to the binary data that will make up the keyword.Chapter 2: Base Layer 158 token Returns A pointer to the newly created token. PDF TOKEN DICT END. A PDF status value: PDF_OK PDF_ENOMEM Not enough memory. A PDF status value: PDF_OK The operation succeeded. PDF_EBADDATA The given value is invalid. pdf_status_t pdf_token_comment_new (const pdf char t *value. pdf token t *token ) Create a comment token containing a copy of the given data. PDF TOKEN ARRAY START. [Function] . The operation succeeded. pdf size t size. PDF_ENOMEM Not enough memory. pdf_status_t pdf_token_dup (const pdf token t token. or PDF TOKEN PROC END). PDF_ENOMEM Not enough memory. in octets. PDF TOKEN PROC START. A pointer to the newly created token. Parameters type token Returns The type of token to create. PDF TOKEN ARRAY END. pdf token t *new ) Create a copy of the given token.

*/ /* Read a name */ if (pdf_token_read (reader. pdf_token_t token. [Function] . The type of the given token. pdf_status_t pdf_token_destroy (pdf token t token ) Destroy the given token. 2.. /* . &token) != PDF_OK) { /* Error */ } if (pdf_token_get_type (token) != PDF_TOKEN_NAME) { /* We were expecting a name */ } [Function] Usage example pdf_bool_t pdf_token_equal_p (const pdf token t token1.12. const pdf token t token2 ) Determines whether the given tokens are equivalent. A pointer to the newly created token. A pointer to the newly created token. [Function] A PDF status value: PDF_OK The operation succeeded. freeing any memory it used. Parameters token Returns A token.. A PDF status value: PDF_OK PDF_ENOMEM Not enough memory. The operation succeeded.6 Accessing token attributes enum pdf_token_type_e pdf_token_get_type (const pdf token t token ) Get the type of a given token.Chapter 2: Base Layer 159 Parameters old new Returns The token to copy. Parameters old new Returns The token to copy. pdf_token_reader_t reader.

. The given tokens are equal. Parameters token Returns A token of type PDF TOKEN REAL. which will be valid until the token is destroyed. Parameters token Returns A token of type PDF TOKEN NAME.Chapter 2: Base Layer 160 Parameters token1 token2 Returns A token. [Function] pdf_real_t pdf_token_get_real_value (const pdf token t token ) Returns the value associated with a given real token. Parameters token Returns A token of type PDF TOKEN INTEGER. The string’s size. The token’s value. A boolean value: PDF_TRUE PDF_FALSE The tokens are not equal. Another token. [Function] const pdf_char_t *pdf token get string data (const pdf token t token ) Returns a pointer to the data associated with a given string token. [Function] A pointer to the name data. The data is not null-terminated. The data is null-terminated. The token’s value. [Function] pdf_size_t pdf_token_get_string_size (const pdf token t token ) Returns the amount of data associated with a given string token. [Function] A pointer to the data. const pdf_char_t *pdf token get name data (const pdf token t token ) Returns a pointer to the data associated with a given name token. pdf_i32_t pdf_token_get_integer_value (const pdf token t token ) Returns the value associated with a given integer token. Parameters token Returns A token of type PDF TOKEN STRING. in octets. Parameters token Returns A token of type PDF TOKEN STRING. which will be valid until the token is destroyed.

The keyword’s size.Chapter 2: Base Layer 161 pdf_size_t pdf_token_get_name_size (const pdf token t token ) Returns the amount of data associated with a given name token. Parameters token Returns A token of type PDF TOKEN KEYWORD. [Function] The name’s size. Parameters token Returns A token of type PDF TOKEN COMMENT. Parameters token Returns A token of type PDF TOKEN COMMENT. A pointer to the data. in octets (excluding the terminating null byte). The comment’s size. 2. The data is null-terminated. [Function] pdf_size_t pdf_token_get_comment_size (const pdf token t token ) Returns the amount of data associated with a given comment token. Parameters token Returns A token of type PDF TOKEN NAME. which will be valid until the token is destroyed. The data is not null-terminated. A pointer to the data. [Function] const pdf_char_t *pdf token get comment data (const pdf token t token ) Returns a pointer to the data associated with a given comment token. . [Function] const pdf_char_t *pdf token get keyword data (const pdf token t token ) Returns a pointer to the data associated with a given keyword token.13 Encryption This section describes related to encryption functions. Parameters token Returns A token of type PDF TOKEN KEYWORD. in octets (excluding the terminating null byte). which will be valid until the token is destroyed. in octets. [Function] pdf_size_t pdf_token_get_keyword_size (const pdf token t token ) Returns the amount of data associated with a given keyword token.

PDF_CRYPT_CIPHER_ALGO_V2 Use ARC4 algorithm. It contains data which is required between several calls to functions. PDF_CRYPT_CIPHER_ALGO_AESV2 Use AES algorithm with a key of 128 bits to encrypt the data. [Function] pdf_status_t pdf_crypt_cipher_new (enum pdf crypt cipher algo e algorithm. pdf crypt cipher t *cipher ) Create a new cipher. Parameters algorithm cipher Returns The algorithm the cipher will use in order to encrypt or decrypt data. Parameters cipher Returns [Function] The cipher you want destroy. if (st != PDF_OK) { /* Error */ } pdf_status_t pdf_crypt_cipher_destroy (pdf crypt cipher t cipher ) Destroy a cipher. pdf_crypt_cipher_t cipher. It must have been created with pdf_crypt_cipher_new functions previously. A pointer to pdf_crypt_cipher_t variable where it will put the cipher. pdf_crypt_cipher_t [Data Type] A cipher. &cipher). st = pdf_crypt_cipher_new (PDF_CRYPT_CIPHER_ALG_AESV2. Operation successful Usage example pdf_status_t st.13. A PDF status value: PDF_OK PDF_ERROR A error ocurred when trying to create the cipher.1 Creating and destroying Ciphers enum pdf_crypt_cipher_algo_e [Data Type] An algorithm provided. It contains low level functions of the algorithm implementation.Chapter 2: Base Layer 162 2. .

key. Usage example pdf_crypt_cipher_t cipher.. sizeof(key)). if (st != PDF_OK) { /* Error */ } pdf_status_t pdf_crypt_cipher_encrypt (pdf crypt cipher t [Function] cipher. */ st = pdf_crypt_cipher_setkey (&cipher. [Function] A PDF status value: PDF_OK Operation successful PDF_EBADDATA Invalid argument.2 Encryption and decryption pdf_status_t pdf_crypt_cipher_setkey (pdf crypt cipher t cipher. pdf_crypt_cipher_destroy (cipher). pdf_char_t key[16].. pdf size t size ) Set the key which will be used to encrypt and decrypt data. Operation successful 2. The ciphered text will be put in out.13. Note that some algorithms could require a fixed length of key. pdf char t *out. &cipher). The size parameter is not supported by the cipher. pdf size t *result_size ) Encrypt a buffer. PDF_ERROR A error ocurred while trying to set the key. pdf size t in_size. . pdf size t out_size. Parameters cipher key size Returns A pointer to a cipher created previously. pdf char t *key. A pointer to memory where the key is stored. pdf_crypt_cipher_t cipher. pdf char t *in. Usage example pdf_status_t st. /* . The length of the key in bytes.Chapter 2: Base Layer 163 A PDF status value: PDF_OK PDF_ERROR A error ocurred when trying to destroy the cipher. pdf_crypt_cipher_new (PDF_CRYPT_CIPHER_ALG_AESV2.

pdf char t *in. out_size. pdf size t out_size. in. pdf size t *result_size ) Decrypt a buffer. in_size. . pdf char t *out. in. Usage example pdf_crypt_cipher_t cipher. pdf_size_t out_size. result size A pointer where it will put the real size of the output buffer. out. A pointer to the output buffer. /* . The plain text will be put in out.. Parameters cipher out A cipher. pdf size t in_size. */ out_size = pdf_crypt_cipher_encrypt_size (cipher. A pointer to the output buffer. pdf_size_t in_size. pdf_char_t *in. Size reserved for the output buffer in bytes. in_size). Some algorithms requires than IN SIZE to be multiple of a fixed integer. pdf_status_t st. The length of the input buffer in bytes.. I must be greater than zero. A pointer to input buffer. &out_ if (st != PDF_OK) { /* Error*/ } pdf_status_t pdf_crypt_cipher_decrypt (pdf crypt cipher t [Function] cipher. pdf_char_t *out. Returns PDF_OK PDF_ERROR An error ocurred. This size will be lesser or equal than out size. The function will fail if it is not too large to contain the output. Operation successful st = pdf_crypt_cipher_encrypt (cipher. out = pdf_alloc (out_size).Chapter 2: Base Layer 164 Parameters cipher out out size in in size A cipher.

pdf_size_t in_size. It must be greater than zero. The length of the input buffer in bytes. PDF_CRYPT_MD_MD5 Use the md5 algorithm. in. . /* . in_size).. pdf_char_t *in. pdf crypt md t *md ) Create a message-digest descriptor for an algorithm. */ out_size = pdf_crypt_cipher_decrypt_size (cipher. The function will fail if it is not too large to contain the output. &out_s if (st != PDF_OK) { /* Error*/ } 2. It contains low level functions of the algorithm implementation.3 Message digest functions enum pdf_crypt_md_algo_e [Data Type] An algorithm provided. pdf_status_t st. A pointer to input buffer. Returns PDF_OK PDF_ERROR An error ocurred. pdf_char_t *out. Usage example pdf_crypt_cipher_t cipher. in.Chapter 2: Base Layer 165 out size in in size Size reserved for the output buffer in bytes. pdf_crypt_md_t A message-digest descriptor. in_size. Operation successful st = pdf_crypt_crypt_decrypt (cipher. out_size..13. This size will be lesser or equal than out size. [Data Type] [Function] pdf_status_t pdf_crypt_md_new (enum pdf crypt md algo e algo. out. pdf_size_t out_size. result size A pointer where it will put the real size of the output buffer. out = pdf_alloc (out_size).

st = pdf_crypt_md_new (&md. st = pdf_crypt_md_hash (md. Operation successful Usage example pdf_status_t st. in_size). A PDF status value: PDF_OK Operation successful PDF_EBADDATA Bad parameter.Chapter 2: Base Layer 166 Parameters md algo Returns A pointer to the pdf crypt md t. [Function] Pass a buffer to the message-digest handler in order to compute its digest. /* . The size of the output buffer is wrong. pdf_size_t in_size. A pointer to the input buffer. pdf_char_t *in. pdf_status_t st. Size of the input buffer in bytes.. .Prepare IN and IN_SIZE variables */ pdf_crypt_md_new (&md. A PDF status value: PDF_OK PDF_ERROR An error ocurred. in. if (st != PDF_OK) { /* Error /* } pdf_status_t pdf_crypt_md_write (pdf crypt md t md. Algorithm which be used to hashing. PDF_CRYPT_MD_MD5). Usage example pdf_crypt_md_t md. pdf_crypt_md_t md. pdf size t in_size ) Parameters md in in size Returns A message-digest descriptor. pdf char t *in. PDF_CRYPT_MD_MD5)..

pdf_status_t pdf_crypt_md_destroy (pdf crypt md t md ) Destroy a message-digest descriptor. A PDF status value: PDF_OK Operation successful [Function] PDF_EBADDATA Bad parameter. Operation successful [Function] . pdf size t out_size ) Read the computed digest value from a message-digest descriptor. /* . The size of the output buffer is wrong. pdf_crypt_md_new (&md. Parameters md Returns A message-digest descriptor.Write the buffer into descriptor here. pdf char t *out. */ st = pdf_crypt_md_read (md. out_size).. PDF_CRYPT_MD_MD5).Chapter 2: Base Layer 167 if (st != PDF_OK) { /* Error */ } pdf_crypt_md_destroy (md). A PDF status value: PDF_OK PDF_ERROR An error ocurred. pdf_size_t out_size. if (st != PDF_OK) { /* Error */ } pdf_crypt_md_destroy (md). pdf_char_t *out. pdf_status_t st.. Usage example pdf_crypt_md_t md. out. Parameters md Returns An message-digest descriptor.. pdf_status_t pdf_crypt_md_read (pdf crypt md t md..

PDF_CRYPT_MD_MD5). [Function] A PDF status value: PDF_OK Operation successful Usage example pdf_char_t buffer[16]. . /* . Size of the buffer in bytes. pdf_crypt_md_t md. st = pdf_crypt_md_new (&md. 2. sizeof(buffer))..Chapter 2: Base Layer 168 Usage example pdf_status_t st.13. Parameters buffer size Returns Buffer which be filled. /* pdf_crypt_md_destroy (md).. pdf_crypt_nonce (buffer.4 Utilities pdf_status_t pdf_crypt_nonce (pdf char t *buffer. pdf size t size ) Fill a buffer with random bytes.

A PDF document is a hierarchy of objects arranged following some conventions.Chapter 3: Object Layer 169 3 Object Layer 3. the objects contained in dictionaries are usually accessed using the value of a key. Arrays Arrays are collections of objects that are arranged sequentially. PDF arrays does not need to be homogeneous: the same array can contain objects of several types including other arrays. they are heterogeneous. In particular the null octet (00H) can be part of a string and it is not used to to finalize it like in some programming languages. PDF objects can be of several data types: Scalars Names Scalar values are integer and real numbers and booleans (true. Strings Strings are sequences of octects. Dictionaries Dictionaries are a set of key-value pairs. The descriptor contains information about the stream. Both arrays and dictionaries are containers. Usually the UTF-8 encoding of ISO-16000 is used. The interpretation of the contents of a string depends of the selected encoding and other factors. Like arrays. By using container objects it is possible to build arbitrary structures made out of objects. like its size and how its contents should be filtered when read. They are like the associative arrays of some programming languages. They are finished by a null octet. Name objects are atoms made out of a sequence of printable characters. meaning that they can contain other objects. Streams Streams are like strings. . Unlike the arrays in most programming languages. but they are unrestrained (no limitation on its size) and are accompanied by a descriptor dictionary. Unlike arrays. Note that the octects contained in a PDF string are not restricted to the printable ASCII subset. Indirect References An indirect reference is a way to refer to some indirect object (XXX: xref). The characters of the string making up the name do not contribute to the meaning of the name. false).1 Overview In its more fundamental structure. a PDF document is conformed by a collection of PDF objects organized in a certain way.

. Any other object in the document shall be accessible from the root dictionary. page 229 provides a convenient API to manipulate PDF files while maintaining its structural integrity. author.Chapter 3: Object Layer 170 Figure 3. The client should be careful when using this layer. Note: The use of this layer can lead to non-well conformed PDF documents: not every PDF object document define a document. In contrast the Chapter 4 [Document Layer]. The only exception is the optional information dictionary.1: Hierarchy of objects in a PDF document. etc. The dictionary at the top of the hierarchy is known as the root dictionary. If it exists it contains meta-information about the document: software that made the document.

9 [Name Objects]. names.14 and 1. page 190. It does not have internal structure. booleans. 3.6 [Real Objects].Chapter 3: Object Layer 171 3. Otherwise the variable shall be considered as a “reference”.1 Object Data Types pdf_obj_t [Data Type] Opaque type representing a PDF Object.2.2.10 [String Objects]. . streams and the null object. See Section 3. page 195. PDF_OBJ_STREAM See Section 3.2. See Section 3. while the value is a PDF object of any type.13 [Stream Objects].2. See Section 3.11 [Array Objects].2. page 187. Despite being opaque. Unlike the postscript dictionaries the key should be a Name Object. PDF_OBJ_DICT A dictionary is a collection of key-value pairs. page 189. This section describes data types and functions to create.2. page 198. See Section 3.00000. PDF_OBJ_INTEGER Integer objects denote quantities in the integer domain.8 [Boolean Objects]. strings.2. PDF_OBJ_ARRAY A heterogeneous array of PDF objects. the user shall be aware that a pdf_obj_t variable containing a direct scalar object shall be considered as the object itself (its value). PDF_OBJ_BOOLEAN Possible values are true and false. such as 3 and 1.2.12 [Dictionary Objects]. page 204. page 192.2.7 [Integer Objects]. PDF_OBJ_NAME A PDF name is an atomic symbol uniquely defined by a sequence of regular characters. See Section 3. page 213.2 PDF Objects PDF objects are the fundamental bricks used in PDF documents. See Section 3. destroy and manipulate all kind of PDF objects: numbers. such as 3. PDF_OBJ_STRING A PDF string is a sequence of bytes whose values are in the range 0-255. See Section 3. [Data Type] enum pdf_obj_type_e Enumeration of the supported types of PDF objects: PDF_OBJ_REAL Real objects denote quantities in the real domain.

Parameters obj The meaning of this parameter depends on the type of obj: Array Dictionary A key. PDF_OBJ_STM_OPEN_MODE_UNFILTERED The data wont be filtered nor decrypted. pdf_obj_t value. void *client_data ) Callback used in pdf_obj_enum that is called for every directly contained object in a composite PDF object (array. Stream value The stream’s dictionary. An array element. See Section 3. Stream The Null object. page 217. The meaning of this parameter depends on the type of obj: Array Dictionary A value. [Data Type] A non-negative number representing the generation number of a PDF object. An object ID uniquely represents an object into an object document. pdf_obj_id_t [Data Type] A positive integer representing the identification number of a PDF object. Returns A PDF status value.2.5 [Object Collections]. PDF_OBJ_STM_OPEN_MODE_FILTERED The data will be both decrypted and filtered. [Data Type] . dictionary. [Data Type] pdf_obj_col_t Opaque type representing an object collection into an object document. stream).14 [Null Object]. The Null object. page 182. See Section 3. [Data Type] pdf_obj_gen_t pdf_bool_t (*pdf_obj_enum_fn_t) (pdf_obj_t obj.2. PDF_OBJ_STM_OPEN_MODE_RAW The data will be decrypted but not filtered.Chapter 3: Object Layer 172 PDF_OBJ_NULL The Null object has a type and a value that are unequal to those of any other object. enum pdf_obj_stm_open_mode_e Open modes for PDF stream objects.

dest Returns A PDF object to hold the copied object. Parameters source dest doc The PDF object to copy. doc. Usage example pdf_obj_doc_t doc. The copy was successfully performed. The corresponding entries in source will be missing in dest. /* Make a copy of ’obj1’ in ’obj2’ in the same object document ’doc’ */ if (pdf_obj_copy (obj1. PDF_ERROR Some error prevented the operation to complete. All indirectly referenced objects in source are copied to dest doc. The object document that will hold the copied object.. This operation sets the dirty flag of dest doc if the copied object is not a direct scalar. &obj2) != PDF_ERROR_) { /* ’obj2’ now contains a copy of ’obj1’.2. pdf bool t copy_indirect. PDF_TRUE. pdf_obj_t obj2. The value of dest is undefined. */ } . pdf obj t *dest ) [Function] Copy a PDF object from one document to another. . pdf_status_t pdf_obj_copy (pdf obj t source.2 Generic Functions to Manipulate Objects The following functions can be called on any pdf_obj_t variable regardless its type. pdf_obj_t obj1. copy indirect A boolean value: PDF_TRUE PDF_FALSE The indirectly referenced objects in source are not copied to dest doc. The destination document can be the same than the document associated with source. A PDF status value PDF_OK PDF_ENOMEM Not enough memory to perform the copy.. pdf obj doc t dest_doc. But note that the effects of the call may vary depending on the object type.Chapter 3: Object Layer 173 3.

Parameters obj The PDF object whose elements are going to be enumerated. dictionary. stream) then any directly referenced object is also destroyed. /* Destroy the info dictionary of an object document */ pdf_obj_doc_get_info_dict (doc. The value of obj is now undefined and shall not be used. The value of obj is now undefined and shall not be used. Dictionary enum cb is called for every key-value. A PDF status value: pdf_status_t pdf_obj_enum (pdf obj t obj. The root dictionary of an object document can not be destroyed. &info_dict). The specific semantics of pdf_obj_enum depend on the type of this object: Scalar or a string The function does nothing and returns PDF_OK. Usage example pdf_obj_doc_t doc. Parameters obj Returns PDF_OK PDF_ERROR An error prevented to complete the operation. This function is a nop if obj is a direct scalar type or the Null object. This operation sets the dirty flag of the document containing the object. pdf_obj_t info_dict. PDF_EINVOP The user requested to destroy the root dictionary of the object document. The object was successfully destroyed. The PDF object to destroy. If obj is a composite object (array. pdf_obj_destroy (info_dict). Note that this is a recursive rule: a string directly contained in a dictionary that is in turn directly contained in an array will be destroyed if the top-level array is destroyed. void *client_data ) [Function] Enumerate all the elements of a PDF object by calling a client-provided callback function. The indirectly referenced objects are not destroyed.Chapter 3: Object Layer 174 pdf_status_t pdf_obj_destroy (pdf obj t obj ) [Function] Destroy a PDF object obj. pdf obj enum fn t enum_cb... passing the key as the first argument and the value as the . .

considering PDF_OK as true and <> PDF_OK as false. − If they are scalars. */ } . pdf obj t obj2 ) [Function] Test whether two PDF objects are equal. that is the AND logical value of the values returned by the enumeration procedure. pdf_obj_t value. Array enum cb is called for every element contained in the array. Two PDF objects are equal when all the following conditions are satisfied: − They are both direct objects or indirect objects. /* Perform an enumeration of the elements of some object */ if (pdf_obj_enum (obj.. Stream Returns A PDF status value.Chapter 3: Object Layer 175 second argument. . − They have the same type.. enum cb is called once with the stream dictionary as the first parameter and the Null object as the second parameter. my_enum_callback. they share the same generation number and has the same object number.. they have the same value. passing the value as the first argument and the Null object as the second argument. − If they are indirect. void *client_data) { /* Process the callback. /* Callback function */ pdf_bool_t my_enum_callback (pdf_obj_t obj. NULL)) { /* All the calls to ’my_enum_callback’ returned PDF_OK */ } else { /* Some call to ’my_enum_callback’ returned <> PDF_OK */ } Usage example pdf_bool_t pdf_obj_equal_p (pdf obj t obj1. The enumeration order is ascending with the index of the array.. The enumeration order is undefined.

&obj1). Parameters obj doc Returns A PDF object. A PDF status value: PDF_OK The object document was stored in doc. PDF_ERROR An error prevented the operation to complete. The second PDF object to compare. A pointer to a pdf obj doc t variable.. pdf_obj_t obj1. pdf obj doc t *doc ) [Function] Gets the object document associated with a given PDF object obj. . &obj2). Parameters obj1 obj2 Returns The first PDF object to compare. PDF_EINVOBJ The specified object obj is a scalar object.. /* Compare integers */ pdf_obj_integer_new (doc. This is a nop for direct scalar objects. pdf_obj_destroy (obj2). since they are not associated with an object document.. . pdf_obj_t obj2. Usage example pdf_obj_doc_t doc. pdf_obj_integer_new (doc. /* Returns PDF_FALSE */ pdf_obj_destroy (obj1). pdf_obj_equal_p (obj1.Chapter 3: Object Layer 176 − If they are non-scalar. The PDF objects are equal. The value of doc is now undefined. 20. pdf_obj_t obj. A PDF boolean value: PDF_TRUE PDF_FALSE The PDF objects are not equal.. . Usage example pdf_obj_doc_t doc. PDF_TRUE. 10. PDF_FALSE. obj2). they reference the same value. pdf_status_t pdf_obj_get_doc (pdf obj t obj.

*/ } pdf_status_t pdf_obj_get_id (pdf obj t obj. pdf obj gen t *gen_number ) Get the generation number of a given indirect PDF object obj. PDF_ERROR An error prevented to complete the operation. [Function] A pointer to a pdf_obj_gen_t variable to hold the generation number. &doc) != PDF_ERROR) { /* ’doc’ contains a reference to the object document containing ’obj’. Returns A PDF status value: PDF_OK The generation number was stored in gen number. The value of gen number is invalid and shall not be used.Chapter 3: Object Layer 177 if (pdf_obj_get_doc (obj. &gen_number) == PDF_OK) { /* ’gen_number’ contains the generation number of ’obj’. [Function] A pointer to a pdf_obj_id_t variable to hold the id number. if (pdf_obj_get_generation (obj. Usage example pdf_obj_t obj.. . . pdf_obj_gen_t gen_number. pdf obj id t *id_number ) Get the identification number of a given indirect PDF object obj. Parameters obj id number An indirect PDF object. */ } pdf_status_t pdf_obj_get_generation (pdf obj t obj. Any previous contents of gen number are left untouched.. PDF_EINVOBJ obj is not an indirect object. Parameters obj gen number An indirect PDF object.

PDF_EINVOBJ obj is not an indirect object. Parameters obj Returns Usage example pdf_obj_doc_t doc. /* Get its type */ pdf_obj_get_type (obj).5 [Object Collections]. */ } enum pdf_obj_type_e pdf obj get type (pdf obj t obj ) Get the type of a given PDF object obj. . pdf_obj_id_t id_number. &obj). pdf_obj_t obj. PDF_FALSE. [Function] /* Create an integer object */ pdf_obj_integer_new (doc. &id_number) == PDF_OK) { /* ’id_number’ contains the identification number of ’obj’. PDF_ERROR Some error prevented the operation to complete. page 182.. . Usage example pdf_obj_t obj. Parameters obj A PDF object....e. A PDF object. The type of obj. See Section 3.2. /* Returns PDF_OBJ_INTEGER */ pdf_bool_t pdf_obj_compressed_p (pdf obj t obj ) [Function] Determine if a given PDF object obj is compressed (i. if (pdf_obj_get_id (obj. The previous value of id number remains. 10. it is contained in an object collection).Chapter 3: Object Layer 178 Returns A PDF status value: PDF_OK The identification number of obj was stored in id number. . The value of id number is invalid and shall not be used.

Usage example pdf_obj_doc_t doc. A boolean value: PDF_TRUE PDF_FALSE [Function] /* Create an indirect object */ pdf_obj_integer_new (doc.3 Object Strong References Every PDF object (but direct scalars) contained in an object document features an acquire counter whose value is initially 0. Parameters obj Returns A PDF object. pdf_obj_indirect_p (obj_indirect). &obj_indirect). . The object obj is compressed.2. 10. */ pdf_obj_col_add_obj (objcol. PDF_FALSE. 10. /* Add ’obj’ to an object collection.Chapter 3: Object Layer 179 Returns A boolean value: PDF_TRUE PDF_FALSE The object obj is not compressed. PDF_TRUE.. /* Returns PDF_FALSE */ 3. pdf_obj_indirect_p (obj_direct). pdf_obj_col_t objcol. pdf_obj_t obj_indirect. /* Returns PDF_TRUE */ /* Create a direct object */ pdf_obj_integer_new (doc. &obj_direct). Usage example pdf_obj_t obj.. pdf_obj_t obj_direct. . The garbage collector (see Section 3.. obj).. The object obj is indirect.5 [Garbage collection in object documents]. . /* The following call returns PDF_TRUE */ pdf_obj_compressed_p (obj). The object obj is direct. page 228) never destroys unmarked objects with an acquire counter of 1 or more.3. pdf_bool_t pdf_obj_indirect_p (pdf obj t obj ) Determine if a given PDF object obj is indirect.

A PDF status value: PDF_OK Usage example pdf_obj_doc_t doc. meaning that someone acquired the object via the pdf_obj_ t variable. but B won’t. 0.Chapter 3: Object Layer 180 pdf_status_t pdf_obj_acquire (pdf obj t obj ) [Function] Create a strong reference for obj in its container document by incrementing its acquire counter by one.2: Acquire counters in PDF objects. The acquire counter of B is 1. . /* Get an object from a document */ pdf_obj_doc_get_obj (doc. &obj). Figure 3. /* Create a strong reference for the object in ‘doc’ */ The strong reference was created or the request was ignored. For direct scalars this operation is a nop. Parameters obj Returns A PDF object. If the object A is garbage collected then C will be also collected. pdf_obj_t obj. The above figure shows a container object A containing two objects B and C. 10.

Only compressible objects can be added to an object collection. */ pdf_obj_acquire (obj). */ pdf_obj_release (obj). − It has a generation number of zero. counter is decreased to 0. Parameters obj A PDF object. pdf_bool_t pdf_obj_get_compressibility (pdf obj t obj ) [Function] Test if a given PDF object obj is compressible. − It is not a stream. Usage example pdf_obj_doc_t doc. Its acquire Its acquire 3.5 [Object Collections]. counter is increased to 1. 10. /* Remove a strong reference for the object in ‘doc’.2. /* Create a strong reference for the object in ‘doc’. pdf_obj_t obj. Returns A PDF status value: PDF_OK The strong reference was destroyed or the operation was ignored.Chapter 3: Object Layer 181 pdf_obj_acquire (obj). Parameters obj A PDF object. /* Get an object from a document */ pdf_obj_doc_get_obj (doc. &obj). explicitly marked as incompressible with pdf_obj_set_ A compressible object is suitable to be contained in an object collection. − It has not been compressibility. Returns A PDF boolean value: . 0. pdf_status_t pdf_obj_release (pdf obj t obj ) [Function] Remove a strong reference from the PDF object obj by decreasing its acquire counter by one. For direct scalars this operation is a nop.4 Compressibility of Objects A PDF object is compressible if any of the following conditions are true: − It is an indirect object. page 182. See Section 3.2.

PDF_ERROR Some error prevented the operation to complete. The object is not compressible. Returns A PDF status value: PDF_OK [Function] The compressibility of obj was set according to compressible p.5 Object Collections Sometimes a group of objects are related in a way they acquire “locality”. . meaning that if one of those objects is read it is very likely that the other objects will be read as well. . pdf bool t compressible_p ) Set the compressibility attribute of the PDF object obj. PDF_TRUE). Parameters obj A PDF object. Usage example pdf_obj_t obj. compressible p A boolean value. /* Check the compressibility of a PDF object */ if (pdf_obj_get_compressibility (obj)) { /* The object ’obj’ is compressible.2. Usage example pdf_obj_t obj. .. PDF_FALSE). */ } pdf_bool_t pdf_obj_set_compressibility (pdf obj t obj.. PDF_EINVOBJ obj cannot be compressed. /* Set it back to false */ pdf_obj_set_compressibility (obj.. /* Set the compressibility of ’obj’ to true */ pdf_obj_set_compressibility (obj.Chapter 3: Object Layer 182 PDF_TRUE PDF_FALSE The object is compressible. 3..

An object can be declared as part of one (and just one) object collection. Parameters doc col Returns An object document.Chapter 3: Object Layer 183 An example is the collection of objects containing the contents of a page: you need to read them all to render the page. . pdf_obj_col_t col1. pdf_obj_col_t col2. pdf_obj_col_new (doc. pdf_status_t pdf_obj_col_new (pdf obj doc t doc. Returns An object collection. An error prevented the operation to complete.. Only compressible objects can be added to a collection. The object collection was created and a reference to it was stored in col. &col1). &col2). The value of col is undefined and shall not be used. [Function] A pointer to a pdf obj col t variable that will contain the new object collection. pdf obj col t *col ) Create a new object collection in the specified object document doc. It is possible to pack several PDF objects in a compressed stream in the object document on disk. /* Create some object collections */ pdf_obj_col_new (doc. A PDF status value. . The callback function. An object collection can be translated into one or several of such compressed streams. [Function] Enumerate all the PDF objects contained in the given object collection col. void *client_data ) Parameters col enum cb client data Pointer passed to the callback function. pdf obj enum fn t enum_cb.. pdf_status_t pdf_obj_col_enum (pdf obj col t col. considering PDF_OK as true and <> PDF_OK as false. A PDF status value: PDF_OK PDF_ERROR Usage example pdf_obj_doc_t doc. that is the AND logical value of the values returned by the enumeration procedure.

&col2).Chapter 3: Object Layer 184 Usage example /* Callback function */ pdf_bool_t my_enum_callback (pdf_obj_t obj. The collections are the same. pdf obj col t col2 ) Test whether two PDF object collections are the same collection... /* Create two object collections and compare them */ pdf_obj_col_new (doc. */ } . */ if (pdf_obj_col_enum (col. NULL) == PDF_OK) { /* All the calls to ’my_enum_callback’ returned PDF_OK */ } else { /* Some call to ’my_enum_callback’ returned <> PDF_OK */ } pdf_bool_t pdf_obj_col_equal_p (pdf obj col t col1. &col1).. [Function] A boolean value: PDF_TRUE PDF_FALSE The collections are not the same. pdf_obj_t value.. Usage example pdf_obj_doc_t doc. void *client_data) { /* Process the callback.. Parameters col1 col2 Returns The first collection to compare. . /* Perform an enumeration of the objects contained in some object collection ’col’.. . pdf_obj_col_new (doc. my_enum_callback. pdf_obj_col_t col1. pdf_obj_col_t col2. The second collection to compare.

pdf_obj_t obj.. Usage example pdf_obj_col_t col. PDF_EINVOBJ The object obj is not compressible. The number of objects contained in col. pdf obj t obj ) [Function] Add an object obj to a collection col.Chapter 3: Object Layer 185 pdf_obj_col_equal_p (col1.. obj1). Parameters col obj Returns An object collection. pdf_obj_col_add_obj (objcol. [Function] Usage example /* Create an object collection and put some objects in it. */ pdf_obj_col_new (doc. A PDF status value: PDF_OK The object obj was successfully added into the object collection col. col2). PDF_ERROR An error prevented the operation to complete. pdf_obj_t obj2. col1). obj2). /* Returns PDF_TRUE */ pdf_u32_t pdf_obj_col_size (pdf obj col t col ) Get the number of PDF objects contained in the object collection col. This operation sets the dirty flag of the document containing the object collection. Parameters col Returns An object collection. The given object should be compressible. /* Should return 2 */ pdf_status_t pdf_obj_col_add_obj (pdf obj col t col. pdf_obj_col_t col. . pdf_obj_doc_t doc. . pdf_obj_col_add_obj (objcol. /* Get the number of objects */ pdf_obj_col_size (objcol). &col). A PDF object. /* Returns PDF_FALSE */ pdf_obj_col_equal_p (col1. pdf_obj_t obj1.

Usage example pdf_obj_t obj. . pdf_status_t pdf_obj_col_remove_obj (pdf obj t obj ) [Function] Remove a given PDF object obj from its containing object collection. The object was successfully dissociated from any containing object collection. obj). [Function] A pointer to a pdf_obj_col_t value containing the returned object collection. PDF_EINVOBJ obj is not a compressible object. If the object is not contained in an object collection then this operation is a nop.. pdf_obj_col_t col. was stored in col. The value in col is undefined and shall not be used. or NULL if there is no one. pdf_obj_col_add_obj (col.. /* Add an object into an object collection */ pdf_obj_col_add_obj (col.. This operation sets the dirty flag of the document containing the object collection. Parameters obj A PDF object.Chapter 3: Object Layer 186 . pdf_status_t pdf_obj_get_col (pdf obj t obj. Returns A PDF status value: PDF_OK PDF_ERROR An error prevented the operation to complete. A PDF status value: PDF_OK The object collection containing obj. obj). /* After the next sentence ’obj’ won’t be associated with ’col’ anymore */ pdf_obj_col_remove_obj (obj).. . Parameters obj col Returns A PDF object. pdf obj col t *col ) Get the containing object collection containing a given PDF object obj.

A new object of type real was created in doc and stored in obj. pdf_obj_t real_obj_1. pdf_obj_t real_obj_2.. pdf_status_t pdf_obj_real_new (pdf obj doc t doc. The value in obj shall be considered invalid. /* Returns ’col’ */ pdf_obj_col_remove_obj (obj). &col). pdf_obj_col_t col. pdf_obj_col_add_obj (col. pdf bool t indirect_p. pdf_obj_col_new (doc. pdf_obj_get_col (obj). &real_obj_1) != PDF_OK) { . A pointer to a pdf_obj_t variable to store the newly created object. pdf_obj_t obj. Usually represented in fixed point rather than floating point.. . 3.2. A PDF status value: PDF_OK PDF_ERROR An error prevented the operation to complete. [Function] indirect p A boolean value indicating whether to create an indirect object. value obj Returns The initial value for the object. pdf obj t *obj ) Create a new Real object in the given document doc and store it in obj.6 Real Objects PDF real objects are quantities in the real domain.Chapter 3: Object Layer 187 Usage example pdf_obj_doc_t doc. They are defined by range and precision.14. Usage example pdf_obj_doc_t doc. pdf_obj_get_col (obj). /* Create some real objects */ if (pdf_obj_real_new (doc. obj). /* Returns NULL */ 3. Parameters doc A document object. pdf real t value. PDF_FALSE.

14 */ } } .14. &result) != PDF_OK) { /* Error getting the Real value */ } else { /* result equals to 3. [Function] A pointer to a pdf real t variable to store the result. PDF_ERROR Some error prevented the operation to complete. &real_obj) != PDF_OK) { /* Error creating Real object */ } else { if (pdf_obj_real_value (real_obj. PDF_FALSE. &real_obj_2) != PDF_OK) { /* Error creating real object */ } pdf_status_t pdf_obj_real_value (pdf obj t obj. pdf real t *value ) Get the value of a PDF Real object. pdf_real_t result. A PDF status value: PDF_OK The real value stored in obj was successfully stored in value.Chapter 3: Object Layer 188 /* Error creating real object */ } if (pdf_obj_real_new (doc.7182. if (pdf_obj_real_new (doc. PDF_FALSE. PDF_EINVOBJ The object obj is not a Real object. Usage example pdf_obj_doc_t doc. The value in value shall be considered invalid. Parameters obj value Returns A PDF object. 3. 2. pdf_obj_t real_obj.

pdf_obj_t integer_obj_1. They are limited by an implementation limit (see Chapter 6 [Implementation Limits]. A pointer to a pdf_obj_t variable to store the newly created object. 10.7 Integer Objects The PDF integer objects are quantities in the integer domain. pdf i32 t *value ) Get the value of a PDF Integer object.2. /* Create some integer objects */ if (pdf_obj_integer_new (doc. PDF_FALSE. Usage example pdf_obj_doc_t doc. [Function] Create a new Integer object in the given document doc and store it in obj. pdf_status_t pdf_obj_integer_new (pdf obj doc t doc. The value in obj shall be considered invalid. -10. indirect p A boolean value indicating whether to create an indirect object.Chapter 3: Object Layer 189 3. page 231). value obj Returns The initial value for the object. pdf i32 t value. &integer_obj_1) != PDF_OK) { /* Error creating integer object */ } if (pdf_obj_integer_new (doc. PDF_FALSE. [Function] . pdf bool t indirect_p. pdf_obj_t integer_obj_2. Parameters obj A PDF object. pdf obj t *obj ) Parameters doc A document object. &integer_obj_2) != PDF_OK) { /* Error creating integer object */ } pdf_status_t pdf_obj_integer_value (pdf obj t obj. A PDF status value: PDF_OK PDF_ERROR Some error prevented the operation to complete. A new integer object was successfully created in doc and stored in obj.

. if (pdf_obj_integer_new (doc. A PDF status value: PDF_OK The integer value of obj was stored in value. PDF_ERROR Some error prevented the operation to complete. pdf_i32_t result. [Function] Create a new Boolean object in the given document doc and store it in obj. pdf bool t value.2. values of dictionary entries and as operators in the postscript calculator functions (type 4 functions). 10. The value of value shall be considered invalid. PDF_FALSE. pdf_obj_t integer_obj. pdf bool t indirect_p. &result) != PDF_OK) { /* Error getting the Integer value */ } else { /* result equals to 10 */ } } 3.Chapter 3: Object Layer 190 value Returns A pointer to a pdf i32 t variable to store the result. pdf obj t *obj ) Parameters doc A document object.8 Boolean Objects Boolean objects can hold just two values: − true − false Can be used as values of array elements. Usage example pdf_obj_doc_t doc. PDF_EINVOBJ The object obj is not an Integer object. &integer_obj) != PDF_OK) { /* Error creating Integer object */ } else { if (pdf_obj_integer_value (integer_obj. pdf_status_t pdf_obj_boolean_new (pdf obj doc t doc.

Chapter 3: Object Layer

191

indirect p A boolean value indicating whether to create an indirect object. value obj Returns The initial value for the object. A pointer to a pdf_obj_t variable to store the newly created object.

A PDF status value: PDF_OK PDF_ERROR An error prevented the operation to complete. The value in obj shall be considered invalid. A new boolean object was created in doc and stored in obj.

Usage example pdf_obj_doc_t doc; pdf_obj_t boolean_obj_1; pdf_obj_t boolean_obj_2; /* Create some Boolean objects */ if (pdf_obj_boolean_new (doc, PDF_FALSE, PDF_TRUE, &boolean_obj_1) != PDF_OK) { /* Error creating boolean object */ } if (pdf_obj_boolean_new (doc, PDF_FALSE, PDF_FALSE, &boolean_obj_2) != PDF_OK) { /* Error creating boolean object */ }

pdf_status_t pdf_obj_boolean_value (pdf obj t obj, pdf bool t *value )
Get the value of a PDF boolean object. Parameters obj value Returns A PDF object.

[Function]

A pointer to a pdf bool t variable to store the result.

A PDF status value: PDF_OK The boolean value of obj was successfully stored in value.

PDF_EINVOBJ The object obj is not a boolean object. PDF_ERROR Some error prevented the operation to complete. The value of value shall be considered invalid.

Chapter 3: Object Layer

192

Usage example pdf_obj_doc_t doc; pdf_obj_t boolean_obj; pdf_bool_t result; if (pdf_obj_boolean_new (doc, PDF_FALSE, PDF_TRUE, &boolean_obj) != PDF_OK) { /* Error creating Boolean object */ } else { if (pdf_obj_boolean_value (boolean_obj, &result) != PDF_OK) { /* Error getting the Boolean value */ } else { /* result equals to PDF_TRUE */ } }

3.2.9 Name Objects
A PDF name object is an atomic symbol uniquely defined by a sequence of regular characters. It does not have internal structure.

pdf_status_t pdf_obj_name_new (pdf obj doc t doc, pdf bool t indirect_p, pdf char t *value, pdf obj t *obj )
Create a new Name object in the given document doc and store it in obj. Parameters doc A document object.

[Function]

indirect p A boolean value indicating whether to create an indirect object. value obj Returns The null-terminated string value for the object. A pointer to a pdf_obj_t variable to store the newly created object.

A PDF status value: PDF_OK A new name object was successfully created in doc and stored in obj.

PDF_EBADDATA Invalid value in value.

Chapter 3: Object Layer

193

PDF_ERROR An error prevented the operation to complete. The value in doc shall be considered invalid. Usage example pdf_obj_doc_t doc; pdf_obj_t name_obj_1; pdf_obj_t name_obj_2; /* Create some Name objects */ if (pdf_obj_name_new (doc, PDF_FALSE, "FooBar", &name_obj_1) != PDF_OK) { /* Error creating name object */ } if (pdf_obj_name_new (doc, PDF_FALSE, "BazFoo", &name_obj_2) != PDF_OK) { /* Error creating name object */ }

pdf_status_t pdf_obj_name_size (pdf obj t obj, pdf size t *size )

[Function] Return the size of the PDF name obj (i.e. the number of characters composing it). Note that the initial slash character (/) is not included in the count. The size of the / name (without any character after the slash) is 0. Parameters obj size A PDF name object. A pointer to a pdf size t variable to hold the size of obj in octects.

Returns

A PDF status value: PDF_OK The size of obj was stored in size.

PDF_EINVOBJ obj is not a name object. The value in size is unchenged. PDF_ERROR Some error prevented the operation to complete. The value in size shall be considered invalid. Usage example pdf_obj_doc_t doc; pdf_obj_t name; ...

Chapter 3: Object Layer

194

pdf_obj_name_new (doc, PDF_FALSE, "Foo", &name); pdf_obj_name_size (name); /* Should return 3 */

pdf_status_t pdf_obj_name_value (pdf obj t obj, pdf char t *buf )

[Function] Get the value of a PDF Name object in the buffer pointed by buf. There should be enough space in buf to hold the value (the user can get the size of the name object using pdf_obj_name_size). The value of the name object does not include the “/” prefix. Parameters obj buf Returns A PDF name object. A memory buffer to store the result.

A PDF status value: PDF_OK The string representing the name value of obj was successfully stored in value.

PDF_EINVOBJ The object obj is not a name object. PDF_ERROR Some error prevented the operation to complete. The value in buf shall be considered invalid. Usage example pdf_obj_doc_t doc; pdf_obj_t name_obj; pdf_char_t *name; if (pdf_obj_name_new (doc, PDF_FALSE, "FooBar", &name_obj) != PDF_OK) { /* Error creating Name object */ } else { name = malloc (pdf_obj_name_size (name_obj)); if (pdf_obj_name_value (name_obj, name) != PDF_OK) { /* Error getting the Name value */ } else { /* ’name’ equals to "FooBar" */ } }

Chapter 3: Object Layer

195

3.2.10 String Objects
A PDF string object is a sequence of bytes in the range 0-255. They are not NULLterminated.

pdf_status_t pdf_obj_string_new (pdf obj doc t doc, pdf bool t [Function] indirect_p, pdf char t *str, pdf size t str_size, pdf obj t *obj )
Create a new String object in the given document doc and store it in obj. Parameters doc A document object. indirect p A boolean value indicating whether to create an indirect object. str The string value. Note that this is not a NULL terminated string, since PDF strings can held arbitrary binary data. The data pointed by str is copied internally. The size of str, in bytes. A pointer to a pdf_obj_t variable to store the newly created object.

str size obj Returns

A PDF status value: PDF_OK PDF_ERROR An error prevented the operation to complete. The value in obj shall be considered invalid. A new string object was successfully created in doc and stored in obj.

Usage example pdf_obj_doc_t doc; pdf_obj_t str; /* Create a new String PDF object */ if (pdf_obj_string_new (doc, PDF_FALSE, "f\233o", 3, &str) != PDF_OK) { /* Error creating the String object */ }

pdf_status_t pdf_obj_string_size (pdf obj t obj, pdf size t *size )
Parameters obj size Returns A PDF string object.

[Function]

Return the size of the PDF string obj (i.e. the number of octects composing it).

A pointer to a pdf size t variable to hold the size of obj.

A PDF status value:

Parameters obj buf A PDF string object. "foo". PDF_FALSE. if (pdf_obj_string_new (doc. There should be enough space in buf to hold the value (the user can get the size of the string using pdf_obj_string_size).. "foo bar baz". pdf_obj_t str_obj. pdf char t *buf ) [Function] Get the value of a PDF String object in the buffer pointed by buf. pdf_obj_string_new (doc. . &str_obj).. pdf_char_t *str. A memory buffer to store the result. Returns A PDF status value: PDF_OK The value of the string object was successfully stored in buf. PDF_EINVOBJ obj is not a string object.Chapter 3: Object Layer 196 PDF_OK The size of obj in octects was stored in size. pdf_obj_string_size (str_obj). Usage example pdf_obj_doc_t doc. The value in size is undefined and shall not be used. The value in buf shall be considered invalid. &name_obj) != PDF_OK) { /* Error creating the String object */ } else . 11. PDF_EINVOBJ The object obj is not a String object. Usage example pdf_obj_doc_t doc. PDF_FALSE. pdf_obj_t str_obj. PDF_ERROR Some error prevented the operation to complete. 3. /* Returns 3 */ pdf_status_t pdf_obj_string_value (pdf obj t obj. PDF_ERROR An error prevented the operation to complete.

A String object with the hex flag set to true is saved in an hexadecimal form. A String object with the hex flag set to true is saved in an hexadecimal form. if (pdf_obj_string_hex_p (str)) { /* The hex flag of ’str’ is set */ } else { /* The hex flag of ’str’ is not set */ } pdf_status_t pdf_obj_string_hex_set (pdf obj t obj. If obj is not a string object then PDF_FALSE is returned. The new value of the hex flag for obj. Parameters obj hex p Returns A PDF String object. The string won’t be saved in hexadecimal form. pdf bool t hex_p ) [Function] Set the hex flag of the String object obj. Parameters obj A PDF String object. Returns A PDF boolean value: PDF_TRUE PDF_FALSE Usage example pdf_obj_t str. A PDF status value: . str) != PDF_OK) { /* Error getting the String value */ } else { /* ’str’ contains "foo bar baz" */ } } pdf_bool_t pdf_obj_string_hex_p (pdf obj t obj ) [Function] Return the hex flag of the String object obj. if (pdf_obj_string_value (str_obj. The string will be saved in hexadecimal form.Chapter 3: Object Layer 197 { str = malloc (pdf_obj_string_size (str_obj)).

The objects can be of any type. indirect p A boolean value indicating whether to create an indirect object. . pdf obj t *obj ) Parameters doc A document object. array size The number of elements of the new array. Usage example pdf_obj_t str.2. PDF_ERROR An error prevented the operation to complete.11 Array Objects A PDF array is a one-dimensional collection of objects arranged sequentially. A PDF status value: PDF_OK PDF_ENOMEM Not enough memory. PDF_ERROR Some error prevented the operation to complete.Chapter 3: Object Layer 198 PDF_OK The hex flag of obj was set to hex p. The array object was created and stored into obj. /* Create an indirect array object to initially held 10 elements */ . obj Returns A pointer to a pdf_obj_t variable to store the newly created object. pdf bool t indirect_p. pdf_obj_t array. [Function] Create a new Array object in the given object document doc and store it in obj. Usage example pdf_obj_doc_t doc. PDF_EINVOBJ obj is not a string object.. pdf_status_t pdf_obj_array_new (pdf obj doc t doc. 3. pdf size t array_size. The value of obj shall be considered invalid. The hex flag of the document shall be considered unchanged. /* Reverse the hex flag of ’str’ */ pdf_obj_string_hex_set (!pdf_obj_string_hex_p (str)). The value of obj shall be considered invalid..

pdf size t index. &array) == PDF_OK) { /* The object was successfully created */ } pdf_status_t pdf_obj_array_get (pdf obj t array. PDF_EBADDATA The specified index is invalid. A PDF status value: PDF_OK The indexth object was stored into obj. /* Iterate through the first 5 objects of ’array’ */ for (index = 0. pdf_size_t index. PDF_ERROR Some error prevented the operation to complete. [Function] A pointer to a pdf_obj_t variable to store the result. . index. index++) { if (pdf_obj_array_get (array. pdf size t index. An index into the array. If index equals to the array size then the object is inserted at the end. A non-scalar direct object cannot be inserted in more than one container. Usage example pdf_obj_t array. The value of obj is untouched. index < 5. &elem) == PDF_OK) { /* Use ’elem’ */ } } pdf_status_t pdf_obj_array_set (pdf obj t array. pdf obj t *obj ) Get the indexth element of the given array and store it into obj.Chapter 3: Object Layer 199 if (pdf_obj_array_new (doc.. . pdf obj t obj ) [Function] Set the indexth element of the array to the given object obj. pdf_obj_t elem.. The value of obj shall be considered invalid. PDF_TRUE. 10. The object obj and the array array should be associated with the same object document. Parameters array index obj Returns A PDF array.

An index into the array. pdf_obj_t array. PDF_FALSE. index.Chapter 3: Object Layer 200 The previous object occupying the indexth position is no longer referenced by the array. if (pdf_obj_array_set (array. . pdf size t *size ) Get the number of elements contained in array. A PDF status value: PDF_OK PDF_EINVOBJ The object obj is a non-scalar direct object already contained in another object or the object belongs to other document.. /* Insert numbers as the first 10 elements of the array */ for (index = 0. index++) { pdf_obj_integer_new (doc. */ } } pdf_status_t pdf_obj_array_size (pdf obj t array. PDF_EBADDATA The specified index is invalid. Parameters array size A PDF array. [Function] A pointer to a PDF size variable to hold the number of objects contained in array. index < 10.. pdf_obj_t elem. Parameters array index obj Returns A PDF array. . &elem). A PDF object. elem) == PDF_OK) { /* Element inserted into the array. The element was inserted at the specified position. PDF_ERROR Usage example pdf_obj_doc_t doc. (pdf_u32_t) index. pdf_size_t index.

Chapter 3: Object Layer 201 Returns A PDF status value: PDF_OK The size of array was stored in size.. pdf_size_t array_size. The value in size is left untouched. . Parameters array index Returns A PDF array. pdf_size_t index. The element at index is a weak reference. for (index = 0. . index++) { /* Do something */ } pdf_bool_t pdf_obj_array_weak_p (pdf obj t array. A boolean value: PDF_TRUE PDF_FALSE The element at index is not a weak reference.5 [Garbage collection in object documents]. See Section 3. pdf size t index ) [Function] Determine if the indexth element of array is a weak reference. &array_size). PDF_EINVOBJ array is not an array object.3. /* Iterate through the element of the array */ pdf_obj_array_size (array. The value in size is undefined.. pdf_size_t index. page 228. index < array_size. This function returns PDF_FALSE if array is not an array object and if index is out of bounds. Usage example pdf_obj_t array. A weak reference changes the way the garbage collection works. Usage example pdf_obj_t array. pdf_size_t array_size. PDF_ERROR Some error prevented the operation to complete.. An index into array. ..

.Chapter 3: Object Layer 202 /* Determine if some element of array has a weak reference */ pdf_obj_array_size (array. PDF_EINVOBJ array is not an array object. for (index = 0. index. &array_size). index++) { if (pdf_obj_array_weak_p (array. } . . A boolean value. A PDF status value: PDF_OK The weak reference was (un)set in the element occupying the indexth position into array. PDF_FALSE). In particular it does not set a strong reference to the object occupying the indexth position in the array. index++) { pdf_obj_array_weak_set (array. for (index = 0. index < array_size. Usage example pdf_obj_t array. pdf_size_t array_size.. /* Remove any weak reference in ’array’ */ pdf_obj_array_size (array. index)) { /* The index-th element has a weak reference */ } } pdf_bool_t pdf_obj_array_weak_set (pdf obj t array. Parameters array index weak p Returns A PDF array. pdf_size_t index. &array_size). The effect of this call when weak p is PDF_FALSE is to remove the effect of a previous call with weak p set to PDF_TRUE. PDF_ERROR An error prevented the operation to complete. PDF_EBADDATA The specified index is out of bounds. An index into array. index < array_size. pdf size t index. pdf bool t weak_p ) [Function] Set if the indexth element of array is a weak reference.

if (pdf_obj_array_remove (array. PDF_ERROR Some error prevented to complete the operation. The PDF object to remove from the array. PDF_EBADDATA obj was not contained in the array. A PDF status value: PDF_OK The requested element was found and removed from the array. Parameters array obj Returns A PDF array. .Chapter 3: Object Layer 203 pdf_status_t pdf_obj_array_remove (pdf obj t array. pdf size t index ) Find the indexth element and remove it from the array. elem) == PDF_OK) { /* The element was removed from the array */ } pdf_status_t pdf_obj_array_remove_at (pdf obj t array. Usage example pdf_obj_t array. pdf_obj_t elem. Parameters array index Returns A PDF array. . [Function] Note that it is not safe to call pdf_obj_array_remove while executing a pdf_obj_ enum. The index of the element to remove from the array. 2. [Function] Note that it not safe to call pdf_obj_array_remove_at while executing a pdf_obj_ enum. pdf obj t obj ) Find the first element equal to obj and remove it from the array. /* Remove the third element of the array */ pdf_obj_array_get (array. &elem)... PDF_EINVOBJ array is not an array object. A PDF status value: PDF_OK obj was found and removed from the array.

The first object of each pair is a name object..2. Usage example pdf_obj_t array. A PDF status value: PDF_OK PDF_ENOMEM Not enough memory to create the object. . PDF_ERROR Some error prevented the operation to complete..Chapter 3: Object Layer 204 PDF_EINVOBJ array is not an array object. /* Remove the third element of the array */ if (pdf_obj_array_remove_at (array. pdf obj t *obj ) Create a new PDF Dictionary object. obj Returns A pointer to a pdf_obj_t variable to store the newly created object. [Function] indirect p A boolean value indicating whether to create an indirect object. 3) == PDF_OK) { /* The element was removed */ } 3. An empty dictionary object was created and stored in obj. A dictionary entry whose value is null is equivalent to an absent entry. pdf_obj_t dict. Usage example pdf_obj_doc_t doc. doc An object document. PDF_ERROR Some error prevented to complete the operation.. PDF_EBADDATA The specified index is invalid. pdf bool t indirect_p. The value of obj shall be considered undefined. .. pdf_status_t pdf_obj_dict_new (pdf obj doc t doc. The type of the second object in the pair is unrestricted. .12 Dictionary Objects A PDF dictionary is an associative table containing pairs of objects.

"Foo". The value in obj shall be considered undefined. &dict) == PDF_OK) { /* Dictionary object created and stored in ’dict’. key. . pdf_obj_t value. PDF_EBADDATA key is not in the dictionary or it is not a name object. if (pdf_obj_dict_get (dict. pdf obj t *obj ) Get the value associated with key in dict and store it in obj. [Function] . pdf_obj_t dict. PDF_TRUE. [Function] A pointer to pdf_obj_t to store the value associated with key.. PDF_ERROR An error prevented the operation to complete. Parameters dict key obj Returns A PDF dictionary object. &value) == PDF_OK) { /* The object associated with "/Foo" in the dictionary is now in ’foo’. Usage example pdf_obj_doc_t doc.. A PDF name object. pdf obj t *obj ) Get the value associated with key in dict and store it in obj. pdf char t *key. */ } pdf_status_t pdf_obj_dict_get (pdf obj t dict. /* Get the value associated with "/Foo" */ pdf_obj_name_new (doc. */ } pdf_status_t pdf_obj_dict_get_str (pdf obj t dict. A PDF status value: PDF_OK PDF_EINVOBJ key is not a name object or dict is not a dictionary object. pdf obj t key.Chapter 3: Object Layer 205 /* Create an empty dictionary object */ if (pdf_obj_dict_new (doc. A copy of the value associated with key was stored in obj. PDF_FALSE. pdf_obj_t key. &key).

pdf obj t key.Chapter 3: Object Layer 206 Parameters dict key obj Returns A PDF dictionary object. PDF_EBADDATA key is not in the dictionary. &value) == PDF_OK) { /* The object associated with "/Foo" in the dictionary is now in ’foo’. . PDF_ERROR An error prevented the operation to complete. */ } pdf_status_t pdf_obj_dict_set (pdf obj t dict. pdf_obj_t value. /* Get the value associated with "/Foo" */ if (pdf_obj_dict_get (dict. pdf_obj_t dict. A PDF name object.. If the entry do not exist then it is added. PDF_EINVOBJ key is not a name object or dict is not a dictionary object. [Function] A PDF status value: PDF_OK The value associated with key in dict was set to val. . pdf obj t val ) Set val as the new value for key in the PDF dictionary dict. without the preceding slash character. A PDF status value: PDF_OK A copy of the value associated with key was stored in obj.. The value in obj shall be considered undefined. A PDF object. "Foo". Usage example pdf_obj_doc_t doc. A pointer to pdf_obj_t to store the value associated with key. A string containing the name of the key. Parameters dict key val Returns A PDF dictionary object.

. pdf_obj_t value. . &value). The value in val is undefined. Parameters dict key val Returns A PDF dictionary object. if (pdf_obj_dict_set (dict. pdf_obj_name_new (doc. A PDF object. pdf_obj_t root_dict. value) == PDF_OK) { /* The pair key-value was inserted in ’dict’. pdf_obj_t pages_dict. PDF_TRUE. pdf obj t val ) Set val as the new value for key in the PDF dictionary dict. pdf_obj_t dict. key. "Age". */ pdf_obj_dict_new (doc. without the preceding slash character. */ } pdf_status_t pdf_obj_dict_set_str (pdf obj t dict. . The value in val is undefined. pdf_obj_integer_new (doc. /* Create a dictionary and insert a key-value pair into it: /Age -> 29. A PDF status value: PDF_OK The value associated with key in dict was set to PDF_EINVOBJ dict is not a dictionary object. pdf_obj_t key. If the entry do not exist then it is added.Chapter 3: Object Layer 207 PDF_ERROR Some error prevented the operation to complete. &key). &dict).. [Function] A string containing the name of the key. pdf char t *key. PDF_FALSE. Usage example pdf_obj_doc_t doc. 29. PDF_FALSE. PDF_ERROR Some error prevented the operation to complete. Usage example pdf_obj_doc_t doc.

*/ } . A PDF name object. &root_dir).. */ pdf_obj_doc_get_root (doc. &key).Chapter 3: Object Layer 208 . PDF_FALSE. was removed from the dictionary. /* Create a /Pages entry in the root dictionary. if it exists */ pdf_obj_name_new (doc. as an indirect object.... pdf_obj_dict_new (doc. containing an empty dictionary. pdf obj t key ) [Function] Remove a key-value pair from a dictionary. /* Remove the "/Foo" entry from ’dict’. . PDF_ERROR An error prevented the operation to complete. PDF_TRUE. pdf_obj_t dict. &pages_dict). pages_dict) != PDF_ERROR) { /* The root dictionary now contains a /Pages entry whose value is an object reference pointing to the indirect dictionary ’pages’. provided it was present. "Foo". Returns A PDF status value: PDF_OK key was found in the dictionary and the pair was removed. If key is not found in dict then this is a no-op. if (pdf_obj_dict_remove (dict. key) == PDF_OK) { /* The entry. */ } pdf_status_t pdf_obj_dict_remove (pdf obj t dict. "/Pages". pdf_obj_t key. Usage example pdf_obj_doc_t doc. PDF_EINVOBJ Either dict is not a dictionary object or key is not a name object. if (pdf_obj_dict_set_str (root_dir. Parameters dict key A PDF dictionary object.

"Foo") == PDF_OK) { /* The entry. provided it was present. pdf obj t key ) Determine if a given name object is a key into dict. PDF_ERROR An error prevented the operation to complete. */ } pdf_bool_t pdf_obj_dict_key_p (pdf obj t dict. Parameters dict key Returns A PDF Dictionary object. was removed from the dictionary. key is in a key-value pair into dict. or dict is not a dictionary object. [Function] A PDF boolean value: PDF_TRUE PDF_FALSE key is not in a key-value pair into dict. A PDF status value: PDF_OK key was found in the dictionary and the pair was removed. or key is not a name object. A string containing the textual representation of a PDF Name. Usage example pdf_obj_doc_t doc. PDF_EINVOBJ dict is not a dictionary object. Usage example pdf_obj_doc_t doc. pdf char t *key ) [Function] Remove a key-value pair from a dictionary.. pdf_obj_t key. pdf_obj_t dict. Parameters dict key Returns A PDF dictionary object. . A PDF Name object. /* Remove the "/Foo" entry from ’dict’. If key is not found in dict then this is a no-op. if it exists */ if (pdf_obj_dict_remove (dict.Chapter 3: Object Layer 209 pdf_status_t pdf_obj_dict_remove_str (pdf obj t dict.. pdf_obj_t dict. .

pdf_obj_t value. /* Returns PDF_TRUE */ pdf_bool_t pdf_obj_dict_key_str_p (pdf obj t dict. [Function] A PDF boolean value: PDF_TRUE key is in a weak reference into dict. /* Returns PDF_TRUE */ pdf_obj_dict_key_p (dict. pdf_obj_dict_key_str_p (dict. pdf_obj_integer_new (doc. &value). Parameters dict key Returns A PDF Dictionary object. "Foo". value).. key). value). pdf_obj_dict_key_p (dict. value). Parameters dict key Returns A PDF Dictionary object. . 10. /* Returns PDF_FALSE */ pdf_bool_t pdf_obj_dict_weak_p (pdf obj t dict. . pdf_obj_integer_new (doc. PDF_FALSE. pdf_obj_dict_set_str (dict. A PDF boolean value: PDF_TRUE PDF_FALSE key is not in a key-value pair into dict. pdf obj t key ) Determine if a given key object is a weak reference in dict. [Function] A string containing the string representation of a PDF Name. or dict is not a dictionary object. key. pdf_obj_t dict. "Foo".Chapter 3: Object Layer 210 pdf_obj_t value. Usage example pdf_obj_doc_t doc. pdf char t *key ) Determine if a given key string is a key into dict. value).. "Foo". key is in a key-value pair into dict. PDF_FALSE. value. 10. .. A PDF Name object.. &value). pdf_obj_dict_set_str (dict.

. or key does not exist in the dictionary. Usage example pdf_obj_doc_t doc. key is in a weak reference into dict. or dict is not a dictionary object. page 228. pdf obj t key. or key does not exist in the dictionary. pdf_obj_dict_weak_p (dict. pdf_bool_t pdf_obj_dict_weak_str_p (pdf obj t dict. pdf_status_t pdf_obj_dict_weak_set (pdf obj t dict. ..3. Parameters dict key Returns A PDF Dictionary object. . A PDF boolean value: PDF_TRUE PDF_FALSE key is not a weak reference into dict. Usage example pdf_obj_doc_t doc. See Section 3. Any key-value pair with weak_p == PDF_TRUE has a weak reference.Chapter 3: Object Layer 211 PDF_FALSE key is not a weak reference into dict. pdf_obj_t dict. key). or dict is not a dictionary object.. pdf char t *key ) Determine if a given key object is a weak reference in dict. &key). "Foo"). /* Determine if the entry "/Foo" has a weak reference in ’dict’ */ pdf_obj_name_new (doc. /* Determine if the entry "/Foo" has a weak reference in ’dict’ */ pdf_obj_dict_weak_p (dict. PDF_FALSE. or key is not a name object. Parameters dict A PDF dictionary object. [Function] A string containing the string representation of a PDF Name. pdf_obj_t key. . pdf bool t weak_p ) [Function] Set the weak p attribute of key in dict.5 [Garbage collection in object documents]. pdf_obj_t key. pdf_obj_t dict. "Foo"..

The new value for the weak attribute of the key. key. PDF_EINVOBJ dict is not a PDF dictionary object. "Foo". The new value for the weak attribute of the key-value pair. . Usage example pdf_obj_doc_t doc. */ pdf_obj_name_new (doc. . page 228..3. PDF_TRUE). pdf_status_t pdf_obj_dict_weak_set_str (pdf obj t dict. A string containing the string representation of a PDF name. pdf_obj_t key. pdf char t *key. Parameters dict key weak p Returns A PDF Dictionary object.5 [Garbage collection in object documents]. PDF_FALSE. PDF_EINVOBJ Either dict is not a PDF dictionary object or key is not a PDF name object. pdf_obj_t dict. /* Set the weak attribute of the key-value pair in ’dict’ with key "/Foo".Chapter 3: Object Layer 212 key weak p Returns A PDF name object. pdf_obj_t dict. PDF_ERROR Some error prevented the operation to complete. Any key-value pair with weak_p == PDF_TRUE has a weak reference. A PDF status value: PDF_OK The weak attribute for the pair was set to weak p. Usage example pdf_obj_doc_t doc. PDF_ERROR An error prevented the operation to complete. pdf bool t weak_p ) [Function] Set the weak p attribute of key in dict. See Section 3. pdf_obj_dict_weak_set (dict. &key).. A PDF status value: PDF_OK The weak attribute for the pair was set to weak p.

PDF_ENOMEM Not enough memory to create the object. size attrs dict obj Returns A PDF status value: PDF_OK The stream object was successfully created. */ pdf_obj_dict_weak_set (dict.. A pointer to a pdf_obj_t variable to store the newly created object. "Foo". a stream can be read incrementally and can be of unlimited length. pdf_status_t pdf_obj_stream_new (pdf obj doc t doc. If this parameter is zero then read from the stream until it gets exhausted. The properties of a stream object are specified by a dictionary that appears just before the stream in the PDF file. pdf obj t *obj ) Create a new PDF Stream object. The number of octects to read from stm.7 [Filtered Streams].Chapter 3: Object Layer 213 . page 68. pdf stm t stm. See the PDF specification for the expected content of the stream dictionary. Note that any /Length key present in stm will be ignored. . pdf size t size. Dictionary containing keys that will be copied to the dictionary describing the newly created stream. PDF_EINVOBJ stm is not a stream object or attr dict is not a dictionary object. The contents of this stream will be copied to an internal storage by this call. All streams must be indirect objects while the dictionary describing the stream must be a direct object.13 Stream Objects A PDF stream object is an arbitrary long sequence of bytes characterized by a set of properties. /* Set the weak attribute of the key-value pair in ’dict’ with key "/Foo". [Function] A base layer stream that will be used to retrieve the data for the stream object. If this dictionary contains a list of filters then those filters are applied in inverse order to the data read from stm. Unlike strings.. PDF_TRUE).2. Parameters doc stm An object document. and a reference to it was stored in obj. See Section 2. 3. pdf obj t attrs_dict.

pdf_stm_t stm. 0. "ASCII85Decode"). pdf_obj_array_set (filter_array.. 0. "LZWDecode").Chapter 3: Object Layer 214 PDF_ERROR Some error prevented the creation of the stream object. pdf_fsys_file_t data_file. PDF_FALSE. pdf_fsys_file_open (NULL. &filter_array). pdf_string_t data_file_path. PDF_FALSE. pdf_obj_string_new (doc. data_file_path. lzw_label). 0. data_ pdf_stm_file_new (data_file. The reference stored obj shall be considered invalid. pdf_obj_t filter_array. PDF_FSYS_OPEN_MODE_READ. pdf_obj_t dict. 1. PDF_FALSE. pdf_obj_dict_set_str (dict. /* Open a filtered stream to a file containing the data to be stored in the object stream */ pdf_text_new_from_unicode ("/path/to/data". pdf_obj_array_set (filter_array. 0. 14. &stm). &data_file_path). /* Exhaust the stream */ dict. PDF_FALSE. 2. stm. PDF_TEXT_UTF8. /* Create a filter array */ pdf_obj_string_new (doc.. ascii85_label). . /* Create the stream object */ if (pdf_obj_stream_new (doc. "Filter". /* Use the default cache size */ PDF_STM_READ. /* Create the dictionary */ pdf_obj_dict_new (doc. Usage example pdf_obj_doc_t doc. pdf_obj_t stream. &stream) != PDF_OK) { /* Some error prevented the creation of the stream */ . &dict). pdf_obj_array_new (doc. filter_array).

PDF_EINVOBJ stream is not a stream object. PDF_EINVOBJ stream is not a stream object. pdf_obj_t stream_dict. Parameters stream dict A stream object. A PDF status value: PDF_OK The length of the encoded stream is stored in length. PDF_ERROR An error prevented the operation to complete. &stream_dict) != PDF_OK) { /* Error getting the stream dictionary */ } pdf_status_t pdf_obj_stream_length (pdf obj t stream. */ if (pdf_obj_stream_dict (stream. /* Create a stream object. pdf obj t *dict ) Get the stream dictionary associated with stream. Parameters stream length Returns A stream object.Chapter 3: Object Layer 215 } pdf_status_t pdf_obj_stream_dict (pdf obj t stream. Returns A PDF status value: PDF_OK The dictionary describing stream is now stored in obj. PDF_ERROR An error prevented the operation to complete. Usage example pdf_obj_t stream. [Function] A pointer to a pdf_obj_t variable to store the newly created object. [Function] A pointer to a pdf size t variable to hold the returned value.. pdf off t *length ) Get the size of the encoded stream in octects. The returned object shall not be destroyed nor modified by the caller.. . The value of dict shall be considered invalid. The value of length shall be considered invalid.

in octects */ pdf_obj_stream_length (stream. pdf_off_t pdf_obj_stream_pos (pdf obj t stream ) Get the offset of the beginning of stream’s data in the PDF file. PDF_OBJ_DOC_SAVE_FULL. . /* Get the length of the stream.. pdf_obj_doc_t doc. The base layer stream stm is positioning at the beginning of the data contained in stream. pdf stm t *stm ) [Function] Create a base layer stream to read the contents of stream. enum pdf obj stm open mode e mode.. pdf_obj_t stream.. pdf_off_t stream_length. [Function] The offset (in octects) of the beginning of the stream data: the position just after the stream keyword. pdf_off_t stream_offset.. &stream_length). If the returned number is 0 then an error occurred. . save_params). Parameters stream Returns A Stream object. /* Get the offset where the data of the stream was stored */ if (stream_offset (stream) == 0) { /* Error obtaining the offset of the stream */ } Usage example pdf_status_t pdf_obj_stream_open (pdf obj t stream. NULL.Chapter 3: Object Layer 216 Usage example pdf_obj_t stream. . /* Try to get the offset without previously saving the object document */ if (stream_offset (stream) == 0) { /* Error: document was not saved before to call pdf_obj_stream_pos */ } /* Save the object document */ pdf_obj_doc_save (doc. You can use this call only after saving the object in a PDF file.

PDF_EINVOBJ stream is not a stream object.. Parameters stream mode stm Returns A Stream object. An indirect object reference to a nonexistant object is a reference to the null object. PDF_OBJ_STM_OPEN_MODE_FILTERED. &stm) != PDF_OK) { /* Error opening the stream */ } 3.. There is only one possible value for this object type: the null keyword. . Usage example pdf_obj_t stream. See Section 3.2. /* Get a filtered stream to read the contents of ’stream’ */ if (pdf_obj_stream_open (stream.1 [Object Data Types]. pdf_stm_t stm. obj Returns [Function] A pointer to a pdf_obj_t variable to store the newly created object. A PDF status value: PDF_OK A filtered stream was opened to read the contents of stream. page 171. pdf_status_t pdf_obj_null_new (pdf obj t *obj ) Create a direct Null object.2.Chapter 3: Object Layer 217 The configuration of the filter chain in stm depends on the opening mode in mode. The client is responsible to close the stream stm. PDF_ERROR An error prevented the operation to complete. The value of stm shall be considered invalid. A PDF status value: .14 Null Object A PDF null object has a type and a value that are unequal to those of any other object. PDF_ENOMEM Not enough memory to perform the operation. A pointer to a pdf stm t variable holding the returned base layer stream. Mode used to open the stream.

3. pdf_char_t *header A complete header string. 3.3.3 Object Documents At the syntactic level any PDF document can be viewed as a collection of objects organized in a certain way. page 125). void *monitor_client_data Client-specific data for the progress monitor callbacks.0 pdf_char_t *crypt_key An encryption key if the security of the document is activated. [Data Type] Structure to contain a localization of an error in the contents of an object document. pdf_char_t *error_description Description of the error. struct pdf_pm_s *progress_monitor A pointer to a progress monitor. 3. [Function] . pdf obj doc t *doc ) Create an empty object document.11 [The Filesystem Module]. or NULL. An object document can be associated with a file system file (see Section 2.Chapter 3: Object Layer 218 PDF_OK Usage example XXX 3. struct pdf_obj_doc_ctx_s pdf_off_t line Line number.2 Opening and Closing Object Documents pdf_status_t pdf_obj_doc_new (pdf u32 t flags. The newly created object document contains an empty root dictionary and an optional empty Document Information Dictionary. [Data Type] [Data Type] struct pdf_obj_doc_save_params_s Parameters used when saving an object document. like %FOO-1. pdf_size_t crypt_key_size Size of crypt_key.1 Object Document Data Types pdf_obj_doc_t Opaque type representing an object level document.

The reference stored in doc becomes invalid.11 [The Filesystem Module]. if (pdf_obj_doc_new (PDF_OBJ_DOC_CREATE_INFO_DIR. pdf_status_t pdf_obj_doc_open (pdf fsys t filesystem. doc Returns A PDF status value: PDF_OK . pdf text t [Function] path. pdf obj doc t *doc ) Open a document object from a file. Parameters filesystem A filesystem implementation. page 125. The object document was correctly loaded from path and stored in doc. Usage example pdf_obj_doc_t mydoc. path header string A string like "%PDF-". Returns A PDF status value: PDF_OK PDF_ERROR Error creating the object document. ctx Pointer to a pdf_obj_doc_ctx_s structure that will contain the localization of an error in the document if some arises.Chapter 3: Object Layer 219 Parameters doc flags A pointer to a pdf_obj_doc_t variable. &mydoc) == PDF_ERROR) { /* Error creating the object document */ } The object document was successfully created. The Info dictionary will be referenced in the document trailer. pdf obj doc ctx s *ctx. Valid flags are: PDF_OBJ_DOC_CREATE_INFO_DIR Create an empty Document Information Dictionary in the object document as an indirect dictionary. pdf char t *header_string. If this parameter is NULL then the default disk filesystem is used. The path to the file containing the object document. The string can be empty. A pointer to a pdf_obj_doc_t variable. If it is NULL then it won’t be used. See Section 2. An integer value containing the ORed value of zero or more flags. The string should appear as the first content of the specified file.

Information about the location of the error can be found in ctx if it was specified. Parameters doc An object document. 12. pdf_obj_doc_t doc. there is a limit in the number of PDF objects that can be contained in an object document. The performed saving operation is equivalent to a call to pdf_obj_doc_save with NULL flags. The value of doc is undefined and should not be used. . if (pdf_obj_doc_open (NULL. PDF_EIMPLLIMIT Some implementation limit was exceeded.Chapter 3: Object Layer 220 PDF_ENOMEM Not enough memory to perform the operation.pdf". /* Use the default filesystem */ file_path. "%PDF-". page 231. See Chapter 6 [Implementation Limits]. PDF_EBADNAME The path specified in path is not correct. Usage example pdf_text_t file_path.pdf */ } pdf_status_t pdf_obj_doc_close (pdf obj doc t doc ) Close an object document. PDF_EBADPERMS The file in path could not be read due to a lack of permissions. [Function] If the dirty flag of the object document is set then the contents are saved before closing. &doc) != PDF_OK) { /* Error opening /foo/bar. PDF_EBADFILE Parser error while interpreting the contents of the file in path. &file_path).pdf */ pdf_text_new_from_unicode ("/foo/bar. PDF_ERROR Some error prevented the operation to complete. For example. /* Open a PDF object document from /foo/bar. PDF_TEXT_UTF8.

The reference in doc should be considered invalid and shall not be used. An ORed value of the following defined flags: PDF_OBJ_DOC_SAVE_DONT_CREATE_CR Do not create a cross reference table (or stream) when saving the document. The object document was saved properly. This option recreates the whole file with all the objects with a generation number of 0. If this parameter is NULL then the file associated with doc is used for the save operation. pdf fsys file t [Function] file. The value of doc is still valid. /* Close an object document. The value of doc should be considered invalid and shall not be used. . Usage example pdf_obj_doc_t mydoc.Chapter 3: Object Layer 221 Returns A PDF status value: PDF_OK PDF_ERROR Error while closing the object document. PDF_OBJ_DOC_SAVE_FULL Do a “full save”. A fsys open file (opened for write) used to write the document data into. pdf u32 t flags. struct pdf obj doc save params s params ) Save a document to a file.. writing all the objects instead of just the modified ones. The object document has been closed. flags A PDF status value: PDF_OK PDF_ERROR An error prevented the document to be saved. */ if (pdf_obj_doc_close (mydoc) != PDF_OK) { /* Error closing the object document */ } pdf_status_t pdf_obj_doc_save (pdf obj doc t doc.. Parameters doc file An object document. params Returns A pdf_obj_doc_save_params_s structure containing the parameters of the save operation.

3. The document id was correctly stored into instance id and permanent id. */ /* Fill in the save parameters */ save_params.crypt_key = NULL.monitor_client_data = NULL. /* Open an object document ’doc’. The value of instance id and permanent id is undefined. [Function] .. /* Use the associated file */ PDF_OBJ_DOC_SAVE_FULL. If the document does not have a instance id then the null object is returned. An object document.crypt_key_size = 0.6".Chapter 3: Object Layer 222 Usage example struct pdf_obj_doc_save_params_s save_params. NULL.header = "%PDF-1. /* No encryption */ save_params. save_params. /* Do not use a progress monitor */ save_params. pdf obj t *permanent_id ) Return two ID byte arrays identifying the object document.progress_monitor = NULL. pdf_obj_doc_t doc. pdf obj t *instance_id..3 Managing Object Document Properties pdf_status_t pdf_obj_doc_get_id (pdf obj doc t doc. save_params. Parameters doc instance id A pointer to a string object to hold the returned instance id. /* Save the document in its associated file */ if (pdf_obj_doc_save (doc. permanent id A pointer to a string object to hold the returned permanent id. If the document does not have a instance id then the null object is returned. Returns A PDF status value: PDF_OK PDF_ERROR Some error prevented the operation to complete. save_params) != PDF_OK) { /* Error saving the object document */ } 3.

pdf obj t instance_id. [Function] The new instance id and permanent id were set in doc.Chapter 3: Object Layer 223 Usage example pdf_obj_doc_t doc. pdf_obj_t instance_id. permanent_id. Returns A PDF status value: PDF_OK Usage example pdf_obj_doc_t doc.. permanent id A string object with the new permanent id. pdf obj t permanent_id ) Set the two ID byte arrays identifying the object document doc. An object document.. */ . /* Create an object document and instance_id.. /* Create an object document . pdf_obj_t instance_id.. Parameters doc instance id A string object with the new instance id. pdf_obj_t permanent_id. pdf_obj_t permanent_id. */ if (pdf_obj_doc_get_id (doc. &instance_id. &permanent_id) != PDF_ERROR) { if (pdf_obj_get_type (instance_id) != PDF_OBJ_NULL) { /* ’instance_id’ is a PDF string object containing the instance ID of the document */ } if (pdf_obj_get_type (permanent_id) != PDF_OBJ_NULL) { /* ’permanent_id’ is a PDF string object containing the permanent ID of the document */ } } pdf_status_t pdf_obj_doc_set_id (pdf obj doc t doc.

&doc). */ pdf_obj_doc_get_root (doc. pdf_text_t file_path. pdf bool t dirty_p ) [Function] Explicitly set the dirty flag of the object document doc to dirty p. /* Open an object document */ pdf_text_new_from_unicode ("/foo/bar. Note that if the dirty flag of the document is cleared using this function then any modified data will be lost upon closing.pdf". . &catalog). pdf_obj_t foo_value. &foo_value). */ pdf_obj_doc_set_dirty (doc. The dirty flag was properly set. /* Use the default filesystem */ file_path. Boolean value. /* Clear the dirty flag of the document. 10. A PDF status value: PDF_OK Usage example pdf_obj_doc_t doc. } */ pdf_status_t pdf_obj_doc_set_dirty (pdf obj doc t doc. pdf_obj_doc_open (NULL. instance_id. PDF_FALSE. 12. pdf_obj_dict_put_str (catalog. &file_path). Parameters doc dirty p Returns An object document.Chapter 3: Object Layer 224 if (pdf_obj_doc_set_id (doc. permanent_id) != PDF_ERROR) { /* The instance Id and permanent Id of the document were set. /* Modify the object document by adding a /Foo entry to the catalog. If the dirty flag of a document is set then its contents are saved before the document is closed. "Foo". "%PDF-". pdf_obj_t catalog. PDF_TEXT_UTF8. PDF_FALSE). pdf_obj_integer_new (doc. This operation will set the dirty flag of the document. foo_value).

PDF_ERROR Usage example pdf_obj_doc_t doc. If the object document does not contain an info dictionary then the null object is returned.3. */ if (pdf_obj_doc_get_info_dict (doc. /* Get the Document Information Dictionary of the object document. − The root object.Chapter 3: Object Layer 225 /* Close the document. 3. Any other indirect object contained in the object document can be accessed using an object identifier. pdf obj t *info_dict ) [Function] Return the Document Information Dictionary of the object document. pdf_obj_t info_dict. that is the catalog dictionary in a well-formed PDF document. */ } else . It is mandatory. Otherwise the null object was stored in info dict. Error while getting the Info dictionary of the document object. */ pdf_obj_doc_close (doc). The value in info dict should be considered undefined. Parameters doc info dict Returns An object document. It is optional. A pointer to a pdf_obj_t variable. The /Foo entry in the catalog dictionary is lost.4 Retrieving and Storing Objects A PDF object document contains two special objects that can be accessed using specificpurpose functions: − The Document Information Dictionary. A PDF status value: PDF_OK If the object document features an Info dictionary it was stored in info dict. &info_dict) != PDF_ERROR) { if (pdf_obj_get_type (info_dict) != PDF_OBJ_NULL) { /* The info dictionary of the document is stored in ’info_dict’. since the document is not saved. pdf_status_t pdf_obj_doc_get_info_dict (pdf obj doc t doc.

. Parameters doc info dict Returns An object document. &doc). /* Create an info dictionary */ pdf_obj_dict_new (doc. If it is associated with a different document then a deep copy is performed before to set it as the Document Information Dictionary of doc. info_dict) == PDF_OK) { /* ’info_dict’ is now the Document Information Dictionary of ’doc’ */ } pdf_status_t pdf_obj_doc_get_root (pdf obj doc t doc. /* Set it as the new info dictionary in ’doc’ */ if (pdf_obj_doc_set_info_dict (doc.Chapter 3: Object Layer 226 { /* The object document does not feature an info dictionary. &info_dict). PDF_EINVOBJ The specified object info dict is not of the proper type. */ } } pdf_status_t pdf_obj_doc_set_info_dict (pdf obj doc t doc. A PDF status value: PDF_OK The dictionary info dict was set as the new Document Information Dictionary of doc. info dict should be an indirect dictionary object. An indirect dictionary object. /* Create an object document without an info dictionary */ pdf_obj_doc_new (0. Usage example pdf_obj_doc_t doc. PDF_ERROR An error prevented the operation to complete. pdf_obj_t info_dict. pdf obj t info_dict [Function] Set info dict as the Document Information Dictionary of doc. pdf obj t *root_dict ) [Function] Get the root object (maybe the catalog of a well-formed PDF document) of the object document doc and store it in root dict. PDF_TRUE.

pdf obj t *obj ) Get an object from doc given its obj in and obj gen and store it in obj. [Function] A PDF status value: Error while getting the object. Any previous content of obj is lost. The generation number of the desired object. Usage example pdf_obj_doc_t doc. 5. pdf_obj_t pages_dict.Chapter 3: Object Layer 227 Parameters doc obj Returns PDF_OK PDF_ERROR Error while getting the root object of the document. A PDF status value: pdf_status_t pdf_obj_doc_get_obj (pdf obj doc t doc. &root_dict) != PDF_ERROR) { /* ’root_dict’ contains the root dictionary of the object document. */ } . 0. A pointer to a pdf_obj_t variable. The object was stored in obj. The value of root dict is invalid. pdf_obj_t root_dict. Parameters doc obj in obj gn obj Returns PDF_OK PDF_ERROR An object document. /* Get the pages dictionary of ’doc’ using its object id */ if (pdf_obj_doc_get_obj (doc. Usage example pdf_obj_doc_t doc. /* Get the root object of an object document */ if (pdf_obj_doc_get_root (doc. A pointer to a pdf_obj_t variable. */ } An object document. The root object has been stored in root dict. The value of obj is invalid. pdf obj gen t obj_gn. &catalog_dir) != PDF_ERROR) { /* ’catalog_dir’ contains the pages dictionary. pdf obj id t obj_id. The object identifier of the desired object.

If it is present it is never collected even if it is not reachable. pdf_obj_t unreachable_obj. 10.. pdf_status_t pdf_obj_doc_gc (pdf obj doc t doc ) Parameters doc Returns An object document. mark any reachable object that is not a weak reference. The algorithm implemented by the collector is: 1. &unreachable_obj). */ if (pdf_obj_doc_gc (doc) != PDF_ERROR) { /* ’unreachable_obj’ has been collected and its value is now undefined. Any pdf_obj_t referencing the object becomes invalid. */ } . The collection was successful..Chapter 3: Object Layer 228 3. removing non-reachable non-acquired objects. pdf_obj_integer_new (doc. Mark the Document Information Dictionary if it exists. Starting from the root dictionary. 2. For every non-marked object. The document doc should be considered invalid. /* Garbage-collect the document and save its content.5 Garbage collection in object documents A garbage collector is provided by the library to remove non-reachable objects from an object document. A PDF status value: PDF_OK PDF_ERROR [Function] Call the garbage collector on doc. Note that the garbage collector is never called implicitly. PDF_TRUE.3. 3. Usage example pdf_obj_doc_t doc. An error prevented the collector to terminate. destroy it freeing any used memory. inclusive. If its acquire counter is 1. A special case is the Document Information Dictionary. */ } else { /* The collector failed and the document in ’doc’ should be considered invalid. 1. A non-reachable object is an indirect object that cannot be reached starting from the root dictionary of the object document.

Chapter 4: Document Layer 229 4 Document Layer .

Chapter 5: Page Contents Layer 230 5 Page Contents Layer .

Chapter 6: Implementation Limits 231 6 Implementation Limits The limits documented in this chapter are not imposed by neither of the supported PDF specifications. bytes 2147483647 Largest integer value. 2^32 Maximum number of objects in a content stream. 2^32 Maximum number of objects in linked content streams. 6.1 Architectural limits Quantity Size of a PDF file integer integer Limit Description 10^10 Largest supported PDF file using a cross-reference table. in bytes. in bytes. ?? Maximum number of indirect objects in a PDF file. 21474836471 FLT MAX Largest real value. 32768 Maximum length of a name. In no case the implementation limits are violating the PDF specifications.2 Memory limits TBC. but by this specific implementation. . Smallest integer value. FLT MIN Smallest real value. real real string in content stream name indirect object content stream objects linked content stream objects 6. SIZE MAX/2Maximum length of a string contained in a content stream.

because free software needs free documentation: a free program should come with manuals providing the same freedoms that the software does. in the notice that says that the Document is released . We recommend this License principally for works whose purpose is instruction or reference. philosophical. in any medium. if the Document is in part a textbook of mathematics. We have designed this License in order to use it for manuals for free software. 1. This License is a kind of “copyleft”. 0. A “Secondary Section” is a named appendix or a front-matter section of the Document that deals exclusively with the relationship of the publishers or authors of the Document to the Document’s overall subject (or to related matters) and contains nothing that could fall directly within that overall subject. royalty-free license. Inc. The “Document”. MA 02110-1301. as being those of Invariant Sections. this License preserves for the author and publisher a way to get credit for their work. unlimited in duration. A “Modified Version” of the Document means any work containing the Document or a portion of it. which is a copyleft license designed for free software. or of legal. PREAMBLE The purpose of this License is to make a manual. textbook. Any member of the public is a licensee. Boston. or with modifications and/or translated into another language.Appendix A: GNU Free Documentation License 232 Appendix A GNU Free Documentation License Version 1. But this License is not limited to software manuals.) The relationship could be a matter of historical connection with the subject or with related matters. APPLICABILITY AND DEFINITIONS This License applies to any manual or other work. either commercially or noncommercially. (Thus. commercial. below. ethical or political position regarding them. and is addressed as “you”. USA Everyone is permitted to copy and distribute verbatim copies of this license document. Copyright 51 Franklin St. You accept the license if you copy. or other functional and useful document free in the sense of freedom: to assure everyone the effective freedom to copy and redistribute it.2002 Free Software Foundation.2. November 2002 c 2000. Fifth Floor. modify or distribute the work in a way requiring permission under copyright law.2001. The “Invariant Sections” are certain Secondary Sections whose titles are designated. with or without modifying it. to use that work under the conditions stated herein. that contains a notice placed by the copyright holder saying it can be distributed under the terms of this License. It complements the GNU General Public License. regardless of subject matter or whether it is published as a printed book. but changing it is not allowed. Secondarily. which means that derivative works of the document must themselves be free in the same sense. it can be used for any textual work. a Secondary Section may not explain any mathematics. refers to any such manual or work. Such a notice grants a world-wide. either copied verbatim. while not being considered responsible for modifications made by others.

and that is suitable for input to text formatters or for automatic translation to a variety of formats suitable for input to text formatters. The “Title Page” means. provided that this License. An image format is not Transparent if used for any substantial amount of text. “Title Page” means the text near the most prominent appearance of the work’s title. A Front-Cover Text may be at most 5 words. “Endorsements”. legibly. Texinfo input format. either commercially or noncommercially. the material this License requires to appear in the title page. in the notice that says that the Document is released under this License. the copyright notices. the title page itself. as Front-Cover Texts or Back-Cover Texts. or absence of markup. for a printed book. and standard-conforming simple HTML. LaTEX input format.Appendix A: GNU Free Documentation License 233 under this License. “Dedications”. and the machine-generated HTML. PostScript or PDF designed for human modification. plus such following pages as are needed to hold. PostScript or PDF produced by some word processors for output purposes only. If the Document does not identify any Invariant Sections then there are none. The Document may contain zero Invariant Sections. preceding the beginning of the body of the text. The “Cover Texts” are certain short passages of text that are listed. represented in a format whose specification is available to the general public. For works in formats which do not have any title page as such. A copy that is not “Transparent” is called “Opaque”. Examples of transparent image formats include PNG. and the license notice saying this License applies to the Document are reproduced in all copies. and . A copy made in an otherwise Transparent file format whose markup. If a section does not fit the above definition of Secondary then it is not allowed to be designated as Invariant. and a Back-Cover Text may be at most 25 words. 2. A section “Entitled XYZ” means a named subunit of the Document whose title either is precisely XYZ or contains XYZ in parentheses following text that translates XYZ in another language.) To “Preserve the Title” of such a section when you modify the Document means that it remains a section “Entitled XYZ” according to this definition. The Document may include Warranty Disclaimers next to the notice which states that this License applies to the Document. SGML or XML for which the DTD and/or processing tools are not generally available. VERBATIM COPYING You may copy and distribute the Document in any medium. XCF and JPG. A “Transparent” copy of the Document means a machine-readable copy. but only as regards disclaiming warranties: any other implication that these Warranty Disclaimers may have is void and has no effect on the meaning of this License. that is suitable for revising the document straightforwardly with generic text editors or (for images composed of pixels) generic paint programs or (for drawings) some widely available drawing editor. has been arranged to thwart or discourage subsequent modification by readers is not Transparent. or “History”. such as “Acknowledgements”. Opaque formats include proprietary formats that can be read and edited only by proprietary word processors. Examples of suitable formats for Transparent copies include plain ascii without markup. (Here XYZ stands for a specific section name mentioned below. SGML or XML using a publicly available DTD. These Warranty Disclaimers are considered to be included by reference in this License.

Both covers must also clearly and legibly identify you as the publisher of these copies. with the Modified Version filling the role of the Document. However. You may also lend copies. If you distribute a large enough number of copies you must also follow the conditions in section 3. all these Cover Texts: Front-Cover Texts on the front cover. you must do these things in the Modified Version: A. If the required texts for either cover are too voluminous to fit legibly.Appendix A: GNU Free Documentation License 234 that you add no other conditions whatsoever to those of this License. COPYING IN QUANTITY If you publish printed copies (or copies in media that commonly have printed covers) of the Document. if there were any. or state in or with each Opaque copy a computer-network location from which the general network-using public has access to download using public-standard network protocols a complete Transparent copy of the Document. and from those of previous versions (which should. to give them a chance to provide you with an updated version of the Document. 4. but not required. . that you contact the authors of the Document well before redistributing any large number of copies. and you may publicly display copies. as long as they preserve the title of the Document and satisfy these conditions. you may accept compensation in exchange for copies. you must enclose the copies in covers that carry. you must either include a machine-readable Transparent copy along with each Opaque copy. numbering more than 100. clearly and legibly. You may not use technical measures to obstruct or control the reading or further copying of the copies you make or distribute. can be treated as verbatim copying in other respects. you should put the first ones listed (as many as fit reasonably) on the actual cover. If you publish or distribute Opaque copies of the Document numbering more than 100. and the Document’s license notice requires Cover Texts. and continue the rest onto adjacent pages. It is requested. free of added material. provided that you release the Modified Version under precisely this License. you must take reasonably prudent steps. 3. If you use the latter option. to ensure that this Transparent copy will remain thus accessible at the stated location until at least one year after the last time you distribute an Opaque copy (directly or through your agents or retailers) of that edition to the public. The front cover must present the full title with all words of the title equally prominent and visible. MODIFICATIONS You may copy and distribute a Modified Version of the Document under the conditions of sections 2 and 3 above. under the same conditions stated above. Copying with changes limited to the covers. if any) a title distinct from that of the Document. thus licensing distribution and modification of the Modified Version to whoever possesses a copy of it. and Back-Cover Texts on the back cover. You may use the same title as a previous version if the original publisher of that version gives permission. In addition. You may add other material on the covers in addition. be listed in the History section of the Document). when you begin distribution of Opaque copies in quantity. Use in the Title Page (and on the covers.

For any section Entitled “Acknowledgements” or “Dedications”. Preserve its Title. These titles must be distinct from any other section titles. These may be placed in the “History” section. and publisher of the Document as given on its Title Page. a license notice giving the public permission to use the Modified Version under the terms of this License. add their titles to the list of Invariant Sections in the Modified Version’s license notice. or if the original publisher of the version it refers to gives permission. as authors. You may omit a network location for a work that was published at least four years before the Document itself. D. K. new authors. and add to it an item stating at least the title. H. in the form shown in the Addendum below. If the Modified Version includes new front-matter sections or appendices that qualify as Secondary Sections and contain no material copied from the Document. Preserve the network location. Such a section may not be included in the Modified Version. Preserve in that license notice the full lists of Invariant Sections and required Cover Texts given in the Document’s license notice. J. Add an appropriate copyright notice for your modifications adjacent to the other copyright notices. year. M. then add an item describing the Modified Version as stated in the previous sentence. create one stating the title. unaltered in their text and in their titles. State on the Title page the name of the publisher of the Modified Version. L. G. you may at your option designate some or all of these sections as invariant. unless they release you from this requirement. Section numbers or the equivalent are not considered part of the section titles. . N. and publisher of the Modified Version as given on the Title Page.Appendix A: GNU Free Documentation License 235 B. Preserve the section Entitled “History”. Preserve all the Invariant Sections of the Document. Include. I. Preserve the Title of the section. Include an unaltered copy of this License. authors. Delete any section Entitled “Endorsements”. given in the Document for public access to a Transparent copy of the Document. together with at least five of the principal authors of the Document (all of its principal authors. O. Preserve any Warranty Disclaimers. C. To do this. if any. year. Do not retitle any existing section to be Entitled “Endorsements” or to conflict in title with any Invariant Section. E. and likewise the network locations given in the Document for previous versions it was based on. If there is no section Entitled “History” in the Document. List on the Title Page. Preserve all the copyright notices of the Document. immediately after the copyright notices. and preserve in the section all the substance and tone of each of the contributor acknowledgements and/or dedications given therein. F. as the publisher. if it has fewer than five). one or more persons or entities responsible for authorship of the modifications in the Modified Version.

provided that you follow the rules of this License for verbatim copying of each of the documents in all other respects. The combined work need only contain one copy of this License. The author(s) and publisher(s) of the Document do not by this License give permission to use their names for publicity for or to assert or imply endorsement of any Modified Version. provided you insert a copy of this License into the extracted document. and that you preserve all their Warranty Disclaimers. or else a unique number. In the combination. is called . and multiple identical Invariant Sections may be replaced with a single copy. 5. Only one passage of Front-Cover Text and one of Back-Cover Text may be added by (or through arrangements made by) any one entity. in or on a volume of a storage or distribution medium. previously added by you or by arrangement made by the same entity you are acting on behalf of. you must combine any sections Entitled “History” in the various original documents. to the end of the list of Cover Texts in the Modified Version. provided that you include in the combination all of the Invariant Sections of all of the original documents. on explicit permission from the previous publisher that added the old one. forming one section Entitled “History”. 7. and follow this License in all other respects regarding verbatim copying of that document. AGGREGATION WITH INDEPENDENT WORKS A compilation of the Document or its derivatives with other separate and independent documents or works. COLLECTIONS OF DOCUMENTS You may make a collection consisting of the Document and other documents released under this License. You may add a passage of up to five words as a Front-Cover Text. and replace the individual copies of this License in the various documents with a single copy that is included in the collection. Make the same adjustment to the section titles in the list of Invariant Sections in the license notice of the combined work. statements of peer review or that the text has been approved by an organization as the authoritative definition of a standard. provided it contains nothing but endorsements of your Modified Version by various parties—for example. and a passage of up to 25 words as a Back-Cover Text. and list them all as Invariant Sections of your combined work in its license notice. and distribute it individually under this License. unmodified. under the terms defined in section 4 above for modified versions.Appendix A: GNU Free Documentation License 236 You may add a section Entitled “Endorsements”. but you may replace the old one. likewise combine any sections Entitled “Acknowledgements”. and any sections Entitled “Dedications”. you may not add another. You must delete all sections Entitled “Endorsements.” 6. If there are multiple Invariant Sections with the same name but different contents. COMBINING DOCUMENTS You may combine the Document with other documents released under this License. the name of the original author or publisher of that section if known. If the Document already includes a cover text for the same cover. You may extract a single document from such a collection. make the title of each such section unique by adding at the end of it. in parentheses.

TRANSLATION Translation is considered a kind of modification. or “History”. See http://www. but may differ in detail to address new problems or concerns. from you under this License will not have their licenses terminated so long as such parties remain in full compliance. You may include a translation of this License. the original version will prevail. you have the option of following the terms and conditions either of that specified version or of any later version that has been published (not as a draft) by the Free Software Foundation. Replacing Invariant Sections with translations requires special permission from their copyright holders. then if the Document is less than one half of the entire aggregate. 9. 8. this License does not apply to the other works in the aggregate which are not themselves derivative works of the Document. the Document’s Cover Texts may be placed on covers that bracket the Document within the aggregate. modify. If the Document does not specify a version number of this License. “Dedications”. sublicense or distribute the Document is void. FUTURE REVISIONS OF THIS LICENSE The Free Software Foundation may publish new. If a section in the Document is Entitled “Acknowledgements”. Such new versions will be similar in spirit to the present version. and all the license notices in the Document.gnu. If the Document specifies that a particular numbered version of this License “or any later version” applies to it. Each version of the License is given a distinguishing version number. Any other attempt to copy. or the electronic equivalent of covers if the Document is in electronic form. parties who have received copies. you may choose any version ever published (not as a draft) by the Free Software Foundation. TERMINATION You may not copy. In case of a disagreement between the translation and the original version of this License or a notice or disclaimer. However. but you may include translations of some or all Invariant Sections in addition to the original versions of these Invariant Sections. or rights. If the Cover Text requirement of section 3 is applicable to these copies of the Document.Appendix A: GNU Free Documentation License 237 an “aggregate” if the copyright resulting from the compilation is not used to limit the legal rights of the compilation’s users beyond what the individual works permit. and will automatically terminate your rights under this License. Otherwise they must appear on printed covers that bracket the whole aggregate. 10. . When the Document is included in an aggregate. provided that you also include the original English version of this License and the original versions of those notices and disclaimers. and any Warranty Disclaimers.org/copyleft/. sublicense. the requirement (section 4) to Preserve its Title (section 1) will typically require changing the actual title. or distribute the Document except as expressly provided for under this License. revised versions of the GNU Free Documentation License from time to time. modify. so you may distribute translations of the Document under the terms of section 4.

. Permission is granted to copy. distribute and/or modify this document under the terms of the GNU Free Documentation License. Texts.3 or any later version published by the Free Software Foundation. If your document contains nontrivial examples of program code. merge those two alternatives to suit the situation. Version 1. If you have Invariant Sections without Cover Texts. and no Back-Cover Texts. A copy of the license is included in the section entitled ‘‘GNU Free Documentation License’’.” line with this: with the Invariant Sections being list their titles. . with no Invariant Sections. and with the Back-Cover Texts being list. to permit their use in free software. or some other combination of the three.Appendix A: GNU Free Documentation License 238 ADDENDUM: How to use this License for your documents To use this License in a document you have written. such as the GNU General Public License. no Front-Cover Texts. include a copy of the License in the document and put the following copyright and license notices just after the title page: Copyright (C) year your name. with the Front-Cover Texts being list. replace the “with. . we recommend releasing these examples in parallel under your choice of free software license. If you have Invariant Sections. Front-Cover Texts and Back-Cover Texts.

Global variable index 239 Global variable index (Index is nonexistent) .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148 pdf_bool_t (*pdf_fsys_file_same_p_fn_t) (pdf_fsys_file_t file. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 pdf_list_t. . . . . . . . . . pdf_text_t path_name ) . . . . . . . . . . . . . . . 2 PDF_EINVRANGE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . pdf_text_t path_name ) . . . . . . . . . 172 pdf_buffer_t . . . . 146 pdf_bool_t (*pdf_obj_enum_fn_t) (pdf_obj_t obj. 86 pdf_fsys_file_t . . . . . . . . . . . . . . . . . . . . . . . . . 165 enum pdf_fsys_file_mode_e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . pdf_obj_t value. . . . . . . . . . . . . . . . 88 enum pdf_time_format_e . . .Data type index 240 Data type index E enum pdf_crypt_cipher_algo_e . . . . . . . . . . . . . . . . . . . . . . . 2 PDF_ERROR . . . . . . . . . . . . . . . . . . . . . . . . . 20 pdf_crypt_cipher_t . . . . . . . . . . . . . . . . . . . . . . . 76 pdf_size_t. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 enum pdf_stm_mode_e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 pdf_hash_t. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 pdf_list_iterator_t . 146 pdf_status_t . . . . . 146 pdf_bool_t (*pdf_fsys_item_readable_p_fn_t) (pdf_text_t path_name ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145 pdf_status_t (*pdf_fsys_file_cancel_ria_fn_t) (pdf_fsys_file_t file ) . . . . . . . . . . 2 PDF_EEOF . . . . . . . . . . . . . . 76 PDF_REAL_MAX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . pdf_text_t *output. . . . . . . . . . . . . . . . 46 pdf_list_node_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171 PDF_OK . . . . . . . . 75 pdf_obj_col_t . . . . . . pdf_size_t pos ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172 enum pdf_obj_type_e . . . . . . . . . 47 pdf_size_t (*pdf_fsys_get_free_space_fn_t) (pdf_text_t path_name ) . . . . . . . . . . . pdf_text_t first_name. . . . . . . . . . . . . . . . . . . . . . . 134 pdf_fsys_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172 pdf_obj_id_t . . . . . . . . 2 PDF_PI . . . . . . . 76 PDF_FP_FUNC_TYPE4_FALSE . . . . . . . . . . . . . . 2 PDF_EDIVBYZERO . . . 171 enum pdf_stm_filter_type_e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150 enum pdf_uuid_type_e . . 46 pdf_matrix_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 enum pdf_token_type_e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146 pdf_bool_t (*pdf_fsys_file_has_ria_fn_t) (pdf_fsys_file_t file ) . . . . . . . . . . . . . . . . . . . . . . . . . . . 6. . . . . . . . . . . . 146 pdf_bool_t (*pdf_fsys_item_writable_p_fn_t) (pdf_fsys_t filename. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162 pdf_crypt_md_t . . . . . . . . . . . . 144 pdf_status_t (*pdf_fsys_create_folder_fn_t) (pdf_text_t path_name ) . . . 75 pdf_real_t. . . . . . . . . . . . . . . . . . . . . . . . 6 PDF_I32_MIN. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 PDF_REAL_MIN . . . . . . . . . . . . . . . . . . . . . . . . 26 PDF_ETEXTENC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 pdf_bool_t (*pdf_fsys_file_can_set_size_fn_t) (pdf_fsys_file_t file. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218 pdf_obj_gen_t . . . . . . . . . . . . . . . . . . . . . . . . . 3 PDF_ENOMEM . . . . . . . . . . . . . . . . 127 pdf_hash_iterator_t . 6 pdf_i64_t . . . . . . . . . . . . . . . . . . . . . . . . . . void *client_data ) . . . . . . . . . . . . . . . . . . . . 86 pdf_fp_func_t . . . . . . . . . 2 PDF_FALSE . . . . . . . . . . . . 75 pdf_rect_t. . . . . . . . . . . . . . . . . . . . . . 172 pdf_obj_doc_t . . . 162 enum pdf_crypt_md_algo_e . . . . 86 PDF_FP_FUNC_TYPE4_TRUE . . . . . . . . . . . . . . . . . . . . . . 165 PDF_EBADDATA . . . . . . 6 pdf_fp_func_debug_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144 pdf_status_t (*pdf_fsys_close_fn_t) (pdf_fsys_file_t file ) . . . . . . . . . . 47 P pdf_bool_t . . . . . . . . . . . . . 68 enum pdf_text_filter_type_e . . . . . . . . . . . . . . . . . . . . . . . 2 PDF_ENONODE. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148 pdf_status_t (*pdf_fsys_file_close_fn_t) (pdf_fsys_file_t file ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 pdf_quad_t. . . 75 pdf_point_t . . . . . . . . . . . . . . 145 I int . . . . . . . . . 148 pdf_bool_t (*pdf_fsys_item_p_fn_t) (pdf_text_t path_name ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147 enum pdf_obj_stm_open_mode_e . . . . . . . . . . . . . . pdf_list_t rest ) . . . . . . . . . . . . . . . . . . . . . . . . . . . 172 pdf_obj_t . . . . . . . . . . . . . . . . . 88 enum pdf_text_unicode_encoding_e . . . . . . . . . . . . . . . . . . . . . . . . 134 enum pdf_fsys_file_mode_e (*pdf_fsys_file_get_mode_fn_t) (pdf_fsys_file_t file ) . . . . . . 2 PDF_ENOMATCH . . . . . . . 146 pdf_status_t (*pdf_fsys_cleanup_fn_t) (void *data ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 PDF_I32_MAX. . . . . . . . . . . . . . . . . . 148 pdf_status_t (*pdf_fsys_file_flush_fn_t) (pdf_fsys_file_t file ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 pdf_i32_t . . . . . . . . . 2 pdf_status_t (*pdf_fsys_build_path_fn_t) (void * data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

24 pdf_status_t (*pdf_pm_set_text_fn_t) (void *client_data. . . . . 145 pdf_status_t (*pdf_pm_begin_operation_fn_t) (void *client_data ) . . . pdf_size_t pos ) . . 145 pdf_status_t (*pdf_fsys_get_folder_contents_fn_t) (pdf_text_t path_name. . . . . . . . void *text ) . . . . . . . . . . . . . . . . . . . . . . . 127. . . . . . . . . . . . . . . . . . . 24 pdf_status_t (*pdf_pm_end_operation_fn_t) (void *client_data ) . . . pdf_size_t bytes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147 pdf_status_t (*pdf_fsys_file_set_pos_fn_t) (pdf_fsys_file_t file. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144 pdf_status_t (*pdf_fsys_remove_folder_fn_t) (pdf_text_t path_name ) . . 20 struct pdf_matrix_s . . . . . . . . . . . . . . . . . . void *duration ) . . . . . . . 218 struct pdf_pm_s . . . 89 pdf_text_t (*pdf_fsys_file_get_url_fn_t) (pdf_fsys_file_t file ) . . . . . . . . . . . . . . . . . . . . . . . . . . 151 pdf_token_t . . struct pdf_fsys_item_props_s *props ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . pdf_char_t*buf. . . . . . . . . . . . . . . . . . . . . . . . . . . . . pdf_size_t pos ) . . 25 pdf_stm_t . . . . . 28. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144 pdf_status_t (*pdf_fsys_file_open_tmp_fn_t) (pdf_fsys_file_t *file ) . . . . . . . . . . . . . . . . . . . . . . . 145 pdf_status_t (*pdf_fsys_get_parent_fn_t) (pdf_text_t path_name. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . pdf_size_t *pos ) . . . . . . . . . . . void *duration ) . . . . . 25 pdf_status_t (*pdf_pm_get_duration_fn_t) (void *client_data. . . . . . . . . . 6 PDF_U32_MAX. . . . . . . . . . . . . . . . . . . . . . pdf_size_t*written_bytes ) . . . . . . . . . . . . . . 23 struct pdf_point_s . . . . . 76 struct pdf_rect_s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 pdf_time_t . . . . . . . . . . . . . . . . . pdf_size_t bytes. . . . . 145 pdf_status_t (*pdf_fsys_init_fn_t) (void **data ) . . . . . . . . . . . . . . . . . . . . . . . . 105. . . . . . . . . 145 pdf_status_t (*pdf_fsys_get_item_props_fn_t) (pdf_text_t path_name. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 PDF_U32_MIN. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 pdf_uuid_t. . . . . . . 149 struct pdf_buffer_s . . enum pdf_fsys_file_mode_e mode ) . . . . . . . . . . . . . . . . 46 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 pdf_token_reader_t . . . . . . . . 150 pdf_token_writer_t . . . . . . . . . . . . pdf_char_t*buf. . . . . . . . . . 151 PDF_TRUE . . . . . . . . . . . . . . . . . . . . . . pdf_size_t*read_bytes ) . . . . . . . void *duration ) . . . . . . . . . . . . . . . . . . . . . . . . . 147 pdf_status_t (*pdf_fsys_file_set_size_fn_t) (pdf_fsys_file_t file. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . enum pdf_fsys_file_mode_e new_mode ) . . . . 75 V void . . . . . . . . . . . . . . . . . pdf_list_t item_list ) . . . . . . . . 24 pdf_status_t (*pdf_pm_set_current_value_fn_t) (void *client_data. . . . . . . . . . 218 struct pdf_obj_doc_save_params_s. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 pdf_time_span_t . 75 struct pdf_obj_doc_ctx_s . . . . . . . . pdf_size_t count ) . . . . . . . . . . . . . 75 struct pdf_quad_s . . 89 pdf_text_t. . . . . . . . 144 pdf_status_t (*pdf_fsys_file_read_fn_t) (pdf_fsys_file_t file. . . . . . pdf_size_t pos ) . . . . . . . . . pdf_size_t offset. . . . . . . 147 pdf_status_t (*pdf_fsys_file_open_fn_t) (pdf_text_t path_name. 147 pdf_status_t (*pdf_fsys_file_write_fn_t) (pdf_fsys_file_t file. 26 S struct. . 148 pdf_status_t (*pdf_fsys_file_request_ria_fn_t) (pdf_fsys_file_t file. . . . . . . . . . 24 pdf_status_t (*pdf_pm_get_current_value_fn_t) (void *client_data. . . . . . . . . . . . . . . . pdf_text_t parent_path ) . . . . .Data type index 241 pdf_status_t (*pdf_fsys_file_get_pos_fn_t) (pdf_fsys_file_t file. . . . . . . 7 pdf_u32_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145 pdf_status_t (*pdf_fsys_file_reopen_fn_t) (pdf_fsys_file_t file. . . . . . . . . . . . . . . . . . . . . . pdf_fsys_file_t *file ) . . . . . . . 25 pdf_status_t (*pdf_pm_set_duration_fn_t) (void *client_data. . . . . . . . . . . . 148 pdf_text_unicode_options_e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148 pdf_status_t (*pdf_fsys_file_set_mode_fn_t) (pdf_fsys_file_t file. . . . . . . 147 pdf_status_t (*pdf_fsys_file_get_size_fn_t) (pdf_fsys_file_t file. . . . . . . . . . . . . . . . enum pdf_fsys_file_mode_e mode. . . . . . . . . . . . . . . . . . . . . 68 pdf_text_host_encoding_t . . . . . . . . . . . . . . . . . . . . . void *duration ) . . . . . . . .

. . . . . . 4 PDF_DEBUG_OBJECT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 pdf_hash_element_dealloc_fn . 34 P pdf_alloc . . . . . . . . . . . . . 160. . 163 pdf_crypt_md_destroy . . 132 pdf_fsys_item_writable_p . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134 pdf_fsys_file_open_tmp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140 pdf_fsys_file_write . . . . . . . . . . . . . . . 77 pdf_fp_cos. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 pdf_hash_get_list. . . . . . . . 20 pdf_buffer_eob_p . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167 pdf_crypt_md_write . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 pdf_hash_add_stm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70 pdf_fp_string_to_real . . . 44 pdf_hash_get_stm . . . . . . . . . . . . . . 22 pdf_buffer_rewind. . . . . . . . . . . . . . . . . . . . . . . . . 140 pdf_fsys_file_reopen . . . 80 . . . . . . . . . . . . . 80 pdf_fp_ceil . . . . . . . . . . . . . . . . 4 pdf_buffer_destroy . 128 pdf_fsys_get_free_space . . . . . . . . . . . . . . . . . . . . . . . . 23 pdf_char_t . . . . . . . . . . . . 82 pdf_fp_func_2_new. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 PDF_DEBUG_PAGE . . . . . . . . . . . . . . . . 31 pdf_hash_add_hash. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 pdf_fp_log10 . . . . . . . . . . . . . . . 80 pdf_fp_matrix_invert . . . . . . . 21 pdf_buffer_new . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 pdf_fsys_file_set_size . . . . . . . . . . . . 130 pdf_fsys_item_readable_p . . . . . . 135 pdf_fsys_file_read . . . . . . . . . . 127 pdf_fsys_get_item_props . . . . . . . . . . . . . . . . . . . . . . . . . . 137 pdf_fsys_file_has_ria . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 pdf_fp_sin. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164 pdf_crypt_cipher_destroy . . . . . . . . . . . . . . . . 3 pdf_fp_atan2 . . . . 167 pdf_crypt_md_new. . . . . 37 pdf_hash_add_time. . . . . . . . . . . . 5 PDF_DEBUG_BASE . . . . . 42 pdf_hash_add_string . . . . . . . . . 86 pdf_fp_log. . . . . . . . 128 pdf_fsys_destroy. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136 pdf_fsys_file_get_pos . . . . . . . . . . . . . . . . . . . . . .Function index 242 Function index ( (pdf_real_t . . 76 pdf_fp_func_0_new. . . . . . . . . . . . . . . . . . . . . . 43 pdf_hash_get_string . . . . . . . . . . . . . . . . . . 81 pdf_fp_matrix_transform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 pdf_hash_destroy . . . . . . . . . . . . . . . . . . . . . 161 pdf_crypt_cipher_decrypt . . . . . . . . . . . . . . . . . 141 pdf_fsys_get_folder_contents . 87 pdf_fp_func_get_bounds . . . . . . . . . . . . . . . . . . . . . . . . . . 32 pdf_hash_get_hash. . . . . . . . . . . . . . . . . . . . . . . 78 pdf_fsys_build_path . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 pdf_hash_iterator_destroy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166 pdf_crypt_nonce . . . . . . . . . . . . . . . 80 pdf_fp_exp. . . . 143 pdf_fsys_file_request_ria . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 pdf_hash_iterator_new . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163 pdf_crypt_cipher_new . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 pdf_fsys_file_set_mode . . . . . . . . . . . . . . 133 pdf_fsys_create . . . . . . . . . 45 pdf_hash_add_text. . . . . . 149 pdf_fsys_create_folder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162 pdf_crypt_cipher_encrypt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 pdf_hash_get_size. . . . 33 pdf_hash_iterator_next . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 PDF_ASSERT_DOCUMENT . . . . . . . . . . . . . . . . . 77 pdf_fp_floor . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 pdf_hash_add . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150 pdf_fsys_file_can_set_size_p . . . . . . . . . . . 136 pdf_fsys_file_get_url . . . . . . . 39 pdf_hash_add_size. . . . 4 PDF_ASSERT_PAGE . . . . . . . 162 pdf_crypt_cipher_setkey . . . 78 pdf_fp_matrix_concat . . . . . . . . . . . . . . . . . . . 136 pdf_fsys_file_get_mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 pdf_buffer_full_p. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 PDF_ASSERT_BASE . . . . . . . . . . . . . 4 PDF_DEBUG_DOCUMENT . . . . . . 84 pdf_fp_func_4_new. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168 pdf_dealloc. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 pdf_hash_get_text. . 143 pdf_fsys_file_flush . . . . . . . . . . . . . . . . . . 4 PDF_ASSERT_OBJECT . . . . . . . . . . 4 pdf_error . . . . . 83 pdf_fp_func_3_new. . . . . . . . . 132 pdf_fsys_remove_folder . . . . . . . . . 141 pdf_fsys_file_get_filesystem . . . . 140 pdf_fsys_file_cancel_ria . . . . . . . . . 41 pdf_hash_add_list. . 35 pdf_hash_get . . . . . . . 138 pdf_fsys_file_get_size . . . . . . . . . . . . . . . . . . 82 (pdf_stm_t. . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 pdf_buffer_resize. . 129 pdf_fsys_item_p . . . . . . . . . . . . . . 85 pdf_fp_func_destroy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137 pdf_fsys_file_set_pos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 pdf_fp_real_to_string . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142 pdf_fsys_file_same_p . . . . . . . . . . . . . . . . . . . . . 37 pdf_hash_get_time. . . . . . . . 130 pdf_fsys_get_parent . . . . . . . . . . . . . . . . . . . . . . . . . 81 pdf_fp_matrix_transform_rect . . . . . . 165 pdf_crypt_md_read . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 pdf_fp_func_eval . . . . . . . . 131 pdf_fsys_item_props_to_hash . . . . . 143 pdf_fsys_file_close . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142 pdf_fsys_file_open . . . . . . . . . .

. . . . . . . . . . . . . 61 pdf_list_search . . . . . . . . . . . 180 199 198 203 203 199 200 201 202 190 191 185 183 184 183 186 185 178 173 174 205 205 209 210 204 208 209 206 207 210 211 212 211 220 228 222 225 227 226 218 219 221 224 223 226 174 175 186 181 176 177 177 179 189 189 192 193 194 . . . . . . . pdf_obj_doc_get_root . . . . . . . . . . . . pdf_obj_col_size. . . . . . . . . . . . . pdf_obj_get_col . . . . . 29 pdf_hash_new . . . . . . . . . . . . . . . . . . . . 18 pdf_i64_cmp_i32 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . pdf_obj_dict_new. . 28 pdf_hash_remove . . . . . . . 13 pdf_i64_neg . . . . . . . . . . . . . . . . . . . . . .Function index 243 pdf_hash_key_dealloc_fn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 pdf_list_node_value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 pdf_i64_to_i32 . . . . . . . . . . . . . . . pdf_obj_dict_weak_p . . . . . . . . . . . . . . . . . pdf_obj_array_weak_set . . . pdf_obj_dict_remove . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 pdf_list_indexof_from_to . . . . . . 58 pdf_list_size . . . . . . . . . . . pdf_obj_col_equal_p . . . . . . . . . . . . . . . . pdf_obj_dict_key_str_p . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . pdf_obj_array_new . . . . . . . . . . . . . . . . . . . . . 36 pdf_hash_key_p . . . . . . . . . . . . . . . . . . 8 pdf_i64_div . . . . . pdf_obj_get_compressibility . . . . . . . . . . . . . . 49 pdf_list_search_from_to . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 pdf_list_indexof_from . . . . . . . . . . . . . . . . . 13 pdf_i64_div_i32_dividend . . . . . . . . . . . . . . . . . . . 47 pdf_list_next_node . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . pdf_obj_get_doc . . . . . . . . 7 pdf_i64_assign_quick . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 pdf_list_iterator_free . . . . . . . . . . pdf_obj_indirect_p . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 pdf_i64_mod_i32_divisor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 pdf_hash_rename . . . . . . . . . . . . . . . . . . . . . . 66 pdf_list_sorted_remove . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . pdf_obj_dict_key_p . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . pdf_obj_doc_get_obj . . . . . . pdf_obj_name_new. . . . . . 67 pdf_list_iterator_next . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 pdf_i64_abs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 pdf_i64_div_i32_divisor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . pdf_obj_get_generation . . . . . . . . . . . . . . pdf_obj_array_size . . . . . . . . . . . . . . . . . . . . 48 pdf_list_search_from . . . . . . . . . . . 9 pdf_i64_add_i32 . . . . . . . . . . . . . . . . . . . . . . . . . . . pdf_obj_doc_set_info_dict . . . . 68 pdf_list_iterator_from_to . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 pdf_list_previous_node . . . . . . . . . . . . . . . . . . . . pdf_obj_integer_new . . . . . . . . . . . pdf_obj_doc_set_dirty . . . . . . . . . . . . . 17 pdf_i64_add. . 59 pdf_list_destroy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 pdf_list_sorted_indexof_from_to . . . . . . . . . . . . . . . . . . . . . . . . . pdf_obj_name_value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . pdf_obj_destroy . pdf_obj_doc_close . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . pdf_obj_dict_set_str . . . . . . pdf_obj_doc_get_info_dict . . . . . . . . . . . . . 64 pdf_list_sorted_search . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 pdf_list_sorted_indexof . . . . . . . . . . . . . . . . . . . . . . 64 pdf_list_sorted_search_from_to . . . 7 pdf_i64_subtraction . . . . . . . . . . . . . . . . . . . . . pdf_obj_array_set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 pdf_list_iterator. . . . . . . . . . . 15 pdf_i64_mod . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 pdf_list_remove . . . . . . . . . . . . pdf_obj_array_weak_p . . . pdf_obj_doc_open. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . pdf_obj_array_remove_at . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 pdf_list_add_at . pdf_obj_name_size . . . 18 pdf_i64_copy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 pdf_i64_mod_i32_dividend . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . pdf_obj_doc_gc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . pdf_obj_col_enum. . . . . . . pdf_obj_enum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 pdf_list_remove_at . . . . . . . . . . . . . . . . . . . . . . 19 pdf_i64_new. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 pdf_hash_size . . . . pdf_obj_dict_weak_str_p . . . pdf_obj_dict_weak_set_str . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . pdf_obj_boolean_new . . . . . . . . . . pdf_obj_boolean_value . . . . . . . . . . . . . . . . . . . 62 pdf_list_remove_node . pdf_obj_equal_p . . . . . . . . . . . . . . . . . . 60 pdf_list_add_first . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 pdf_list_new . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . pdf_obj_dict_weak_set . . . . . . . . . . . . . pdf_obj_integer_value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . pdf_obj_col_remove_obj . . . . . . . . . . . . . . pdf_obj_dict_remove_str . . . . . . . . . . . . . . . . . . . . . . . . . pdf_obj_doc_get_id . . . . . . . . . . . . . . . . . . . . . . . . . . . pdf_obj_doc_save. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 pdf_list_indexof . . . . . . . . . . pdf_obj_dict_get_str . . . . . . . . . . . . . . . . . . . . . . 47 pdf_list_get_at . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 pdf_list_set_at . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 pdf_i64_mult_i32 . . . . . . . . . . . . . . . . . . . . . . 59 pdf_list_add_last. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . pdf_obj_dict_set. . . . . . . . . . . . . . pdf_obj_col_new . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 pdf_i64_subtraction_i32_min . . . . . . . 17 pdf_i64_mult . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . pdf_obj_array_get . . . pdf_obj_array_remove . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 pdf_list_sorted_add . . . . . . . . . . . . . . . . . . . . . . . . . . . . . pdf_obj_get_id . . . pdf_obj_doc_set_id . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . pdf_obj_copy . . . . . . . . . . . pdf_obj_col_add_obj . . . 8 pdf_i64_cmp . pdf_obj_doc_new . . . . . . . . . . . . . . . . . . . pdf_obj_dict_get. . . . 64 pdf_obj_acquire . . . . 9 pdf_i64_assign . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 pdf_i64_subtraction_i32_sub . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . pdf_obj_compressed_p . . . . . . . . . . . . . . . .

. . . . . . . . . . . pdf_time_to_string . . . . . . . . . . . . . . . . . . . pdf_token_name_new . . . . . . . . . . . . . . . 178 pdf_perror . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 pdf_text_concat_ascii . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . pdf_time_span_dup . . . . . . . 73 pdf_stm_read . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216 pdf_obj_stream_pos . . . . . . 95 pdf_text_set_host. . . . . . . . . . . . . . pdf_token_get_comment_size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . pdf_time_span_set_from_i32 . . . . . . . pdf_time_span_negate . . . . . . . . . . . . . . . . . . . . . . . . . 97 pdf_text_get_unicode . . . . . . . . . . . . pdf_time_copy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . pdf_token_get_type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 pdf_text_new_from_u32 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . pdf_time_set_from_i64 . . . . . . . . . . . . pdf_time_cmp . . . . . . . . . . . . . . . . . . . . . 74 pdf_stm_write . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 pdf_text_get_language . . . . . . . . . . . . . . . . . . . . . . . pdf_time_set_local_offset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Function index 244 pdf_obj_null_new. . . . . . . . . . . . . . . . 72 pdf_stm_tell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 pdf_stm_read_char. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217 pdf_obj_real_new. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . pdf_time_sub_span . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 pdf_stm_mem_new . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102 pdf_text_concat . . . . pdf_time_cal_span_cmp . . . . . . . pdf_token_read . . . . . . . . 89 pdf_text_new_from_host . . . . . . . . . . . . . . . . . . . 104 pdf_text_cmp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 pdf_text_new . pdf_time_destroy. 213 pdf_obj_stream_open . . . . . . . . . . 90 pdf_text_dup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70 pdf_stm_peek_char. . . . . pdf_time_cal_span_diff . . . . . . . . . . . . . . . . . . . . . . . 215 pdf_obj_stream_length . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . pdf_token_real_new . . . . . . . . . . . . 196 pdf_obj_type_e . . . pdf_time_clear . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93 pdf_text_new_from_unicode . . . . 74 pdf_stm_btell . . . . . . . 73 pdf_stm_install_filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94 pdf_text_get_pdfdocenc . . . . . . . pdf_time_span_cmp . . . . . . . . . . . pdf_time_get_local_cal . . . . . . . . . . . . . pdf_token_keyword_new . . . . . . . . . pdf_token_reader_new . . . . . . . . . . . . . . . . . . . . . . . . . . 101 pdf_text_set_country . . . . . . . . . pdf_token_equal_p . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 pdf_realloc. . . . . . . . . . . . . . . . . . . . . . . . . . . pdf_token_reader_destroy . . . . . 98 pdf_text_get_host. . . . . . . . . . . . . . . . . . . . . . . . . 90 pdf_text_new_from_pdf_string . . . . . . . . . . . . 197 pdf_obj_string_hex_set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 pdf_text_get_host_encoding . . . . . . . . . . . . . . . 195 pdf_obj_string_size . . . . . . . . . . . . . . . pdf_token_integer_new . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216 pdf_obj_string_hex_p . . . . . . . . . . . . . . . . . . . . . . . . . 72 pdf_text_check_host_encoding . . . . . 104 pdf_text_get_country . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . pdf_time_set_to_current_utc_time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . pdf_time_dup . . . . . . . . . . . . . pdf_time_get_utc_cal . . . . . . . . . . . . . . . . . . . . . . . . . . pdf_time_span_diff . . . . . . . . . . . pdf_time_add_span . . . . . . . . pdf_token_get_name_size . . . . . pdf_token_valueless_new . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . pdf_time_span_new . . . . . . . . . . . . . . . . . . . . . . . 109 122 111 123 124 108 114 107 107 114 113 106 112 116 111 112 106 108 108 113 117 117 119 121 120 118 120 118 119 117 118 119 121 110 111 115 125 158 159 158 159 161 160 161 161 160 160 159 156 157 157 154 153 151 155 156 157 158 . . . . . . . . . 98 pdf_text_set_language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . pdf_time_new . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . pdf_token_dup . . . . . . . . . . . . . . . . . . . . . . . . . . . . pdf_time_span_copy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . pdf_time_span_set . . . . . . . . . . 95 pdf_text_set_pdfdocenc . . . 215 pdf_obj_stream_new . . . . . . . . . pdf_time_from_cal . . . . . . . . . . . . . . . pdf_token_string_new . . pdf_time_span_add . 5 pdf_stm_bseek . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102 pdf_text_get_best_encoding . . 99 pdf_time_add_cal_span . . . . . . 197 pdf_obj_string_new . . . . . 195 pdf_obj_string_value . . . 187 pdf_obj_real_value . . . . . . . . pdf_time_set_to_current_local_time . . . . . . . . . . pdf_time_span_destroy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . pdf_token_reader_reset . . . . . . . . 92 pdf_text_replace. . . . . 101 pdf_text_replace_ascii . . . . . . . . . . . 70 pdf_stm_file_new . . . . . . . . . . . . . . . . pdf_time_sub_cal_span . . . . pdf_token_get_integer_value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . pdf_token_comment_new . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . pdf_token_get_real_value . . . . . . . . . . . . . . 94 pdf_text_get_hex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . pdf_time_w32_set_from_filetime . . . . . . . . . pdf_time_set_from_u32 . . . . . . 100 pdf_text_destroy . . . . . . . . . . . . . . . . . 181 pdf_obj_set_compressibility . . . . . . . . . pdf_time_from_string . . . . . . . . . . . . . . . . 69 pdf_stm_flush . . . . . 188 pdf_obj_release . . . . . . . . . . . . . . . . . . pdf_time_span_to_secs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . pdf_time_diff_cal . . . . . . . . . . . . . . . . . . . . . 99 pdf_text_set_unicode . . . . pdf_token_destroy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . pdf_time_diff . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90 pdf_text_empty_p . . . . . . . . . . . . . . . . . . . . . . pdf_token_get_keyword_size . pdf_time_add_cal_span_with_base . . . . . . . . . . . . . . . . . . . . . . . 182 pdf_obj_stream_dict . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . pdf_token_get_string_size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 pdf_stm_destroy . . . . . 96 pdf_text_filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 pdf_uuid_string . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Function index 245 pdf_token_write . . . . . . . . . 27 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152 pdf_token_writer_reset . . 156 pdf_uuid_equal_p . . . . . . . . . . 27 pdf_uuid_generate. . . . . . . . . . . . . . . 155 pdf_token_writer_destroy . . . . 154 pdf_token_writer_new . . . . . .

Sign up to vote on this title
UsefulNot useful