|
NPWBase.c File ReferenceNPW (base functions to write PDF files).
More...
#include "NPWBase.h"
#include <math.h>
Go to the source code of this file.
|
Defines |
#define | kHeaderStr "%PDF-1.5\n" |
| PDF header string.
|
#define | Chk(e) |
| Check error returned by a function and returns it unless kNPWErrOk.
|
#define | ChkG(e) |
| Check error returned by a function and goto error unless kNPWErrOk.
|
#define | kDigits 8 |
| maximum number of digits
|
#define | hex(n) ((n) >= 10 ? 'a' - 10 + (n) : '0' + (n)) |
| Convert a value in [0,15] to its ASCII hexadecimal representation.
|
#define | kRLEOD 128 |
| end of data
|
Functions |
void | NPWInit (NPW *pdf) |
| Initialize PDF.
|
void | NPWSetAllocCallback (NPW *pdf, NPWAllocCB alloc, void *userData) |
| Set memory allocation callback.
|
void | NPWSetWriteCallback (NPW *pdf, NPWWriteCB write, void *userData) |
| Set write callback.
|
void | NPWSetFonts (NPW *pdf, NPWInt fonts) |
| Specify which standard fonts should be made available.
|
NPWErr | NPWWrite (NPW *pdf, NPWConstText str, NPWInt length) |
| Write a string.
|
NPWErr | NPWWriteInt (NPW *pdf, NPWInt i, NPWInt pad) |
| Write an integer.
|
NPWErr | NPWWriteFloat (NPW *pdf, NPWFloat x) |
| Write an floating-point value.
|
NPWErr | NPWWriteString (NPW *pdf, NPWConstText str, NPWInt length) |
| Write a string value (should be ISO Latin 1 to match encoding set for standard fonts).
|
static void | RLInit (RLState *rl) |
| Initialize run-length filter state.
|
static NPWByte | RLNextByte (RLState *rl, NPWByte const *b, NPWInt len) |
| Get next output byte of run-length filtered stream.
|
void | NPWFilterBegin (NPW *pdf, NPWInt filter) |
| Begin writing filtered data to PDF.
|
static NPWErr | writeA85 (NPW *pdf, NPWByte const b[], NPWInt n, NPWBoolean end) |
| Write 4 bytes, or less if last bytes of stream, encoded with base-85.
|
static NPWErr | writeAHex (NPW *pdf, NPWByte b) |
| Write a byte as ASCII hexadecimal.
|
NPWErr | NPWFilterWrite (NPW *pdf, NPWByte const *b, NPWInt n) |
| Write filtered data to PDF.
|
NPWErr | NPWFilterEnd (NPW *pdf) |
| End writing filtered data to PDF.
|
static NPWErr | addXRef (NPW *pdf) |
| Add an entry to the cross-reference table.
|
static NPWErr | reserveXRef (NPW *pdf, NPWRef *ref) |
| Reserve an entry in the cross-reference table.
|
static NPWErr | writeHeader (NPW *pdf) |
| Write PDF header.
|
NPWErr | NPWBeginObj (NPW *pdf, NPWRef *ref) |
| Begin writing an object.
|
static NPWErr | beginReservedObj (NPW *pdf, NPWRef *ref) |
| Write the beginning of an object with the last xref obtained with reserveXRef.
|
NPWErr | NPWEndObj (NPW *pdf) |
| End writing an object.
|
static NPWErr | writePage (NPW *pdf, NPWInt i, NPWRef parent, NPWRef *ref) |
static NPWErr | writePages (NPW *pdf, NPWRef *ref) |
static NPWErr | writeCatalog (NPW *pdf, NPWRef pages, NPWRef *ref) |
| Write PDF catalog.
|
NPWErr | NPWBeginPage (NPW *pdf, NPWInt width, NPWInt height) |
| Beginning of page.
|
NPWErr | NPWEndPage (NPW *pdf) |
| End of page.
|
NPWErr | NPWTerminate (NPW *pdf) |
| Terminate PDF and flush output.
|
Detailed Description
NPW (base functions to write PDF files).
- Author:
- Yves Piguet. Copyright 2008-2010, Yves Piguet.
Definition in file NPWBase.c.
Define Documentation
Value: do { \
err = (e); \
if (err != kNPWErrOk) \
return err; \
} while (0)
Check error returned by a function and returns it unless kNPWErrOk.
Definition at line 19 of file NPWBase.c.
Value: do { \
err = (e); \
if (err != kNPWErrOk) \
goto error; \
} while (0)
Check error returned by a function and goto error unless kNPWErrOk.
Definition at line 27 of file NPWBase.c.
Function Documentation
Add an entry to the cross-reference table.
- Parameters:
-
| pdf | reference to NPW structure |
Definition at line 423 of file NPWBase.c.
Write the beginning of an object with the last xref obtained with reserveXRef.
- Parameters:
-
| pdf | reference to NPW structure |
[out] | ref | |
- Returns:
- kNPWErrOk for success, else error code
Definition at line 504 of file NPWBase.c.
Begin writing an object.
- Parameters:
-
| pdf | reference to NPW structure |
[out] | ref | object reference number |
- Returns:
- error code (kNPWErrOk for success)
Definition at line 482 of file NPWBase.c.
Beginning of page.
- Parameters:
-
| pdf | reference to NPW structure |
[in] | width | page width |
[in] | height | page height |
- Returns:
- error code (kNPWErrOk for success)
Definition at line 692 of file NPWBase.c.
End writing an object.
- Parameters:
-
| pdf | reference to NPW structure |
- Returns:
- error code (kNPWErrOk for success)
Definition at line 526 of file NPWBase.c.
End of page.
- Parameters:
-
| pdf | reference to NPW structure |
- Returns:
- error code (kNPWErrOk for success)
Definition at line 730 of file NPWBase.c.
void NPWFilterBegin |
( |
NPW * |
pdf, |
|
|
NPWInt |
filter | |
|
) |
| | |
Begin writing filtered data to PDF.
- Parameters:
-
| pdf | reference to NPW structure |
[in] | filter | (kNPWFilterNone for none) |
Definition at line 303 of file NPWBase.c.
End writing filtered data to PDF.
- Parameters:
-
| pdf | reference to NPW structure |
- Returns:
- error code (kNPWErrOk for success)
Definition at line 412 of file NPWBase.c.
Write filtered data to PDF.
- Parameters:
-
| pdf | reference to NPW structure |
[in] | b | address of unfiltered data |
[in] | n | number of unfiltered bytes |
- Returns:
- error code (kNPWErrOk for success)
Definition at line 355 of file NPWBase.c.
void NPWInit |
( |
NPW * |
pdf |
) |
|
Initialize PDF.
- Parameters:
-
[out] | pdf | reference to NPW structure |
Definition at line 39 of file NPWBase.c.
void NPWSetAllocCallback |
( |
NPW * |
pdf, |
|
|
NPWAllocCB |
alloc, |
|
|
void * |
userData | |
|
) |
| | |
Set memory allocation callback.
- Parameters:
-
| pdf | reference to NPW structure |
[in] | alloc | memory allocation callback |
[in] | userData | callback user data |
Definition at line 55 of file NPWBase.c.
Specify which standard fonts should be made available.
- Parameters:
-
| pdf | reference to NPW structure |
[in] | fonts | font flags (kNPWFontAll for all) |
Definition at line 69 of file NPWBase.c.
void NPWSetWriteCallback |
( |
NPW * |
pdf, |
|
|
NPWWriteCB |
write, |
|
|
void * |
userData | |
|
) |
| | |
Set write callback.
- Parameters:
-
| pdf | reference to NPW structure |
[in] | write | allocation callback |
[in] | userData | callback user data |
Definition at line 62 of file NPWBase.c.
Terminate PDF and flush output.
- Parameters:
-
| pdf | reference to NPW structure |
- Returns:
- kNPWErrOk for success, else error code
Definition at line 748 of file NPWBase.c.
Write a string.
- Parameters:
-
| pdf | reference to NPW structure |
[in] | str | address of first character |
[in] | length | number of bytes, or -1 if str is null-terminated |
- Returns:
- error code (kNPWErrOk for success)
Definition at line 74 of file NPWBase.c.
Write an floating-point value.
- Parameters:
-
| pdf | reference to NPW structure |
[in] | x | number |
- Returns:
- error code (kNPWErrOk for success)
Definition at line 124 of file NPWBase.c.
Write an integer.
- Parameters:
-
| pdf | reference to NPW structure |
[in] | i | number |
[in] | pad | number of digits (0-padded), or -1 |
- Returns:
- error code (kNPWErrOk for success)
Definition at line 87 of file NPWBase.c.
Write a string value (should be ISO Latin 1 to match encoding set for standard fonts).
- Parameters:
-
| pdf | reference to NPW structure |
[in] | str | string |
[in] | length | string length in bytes, or -1 for null-terminated string |
- Returns:
- error code (kNPWErrOk for success)
Definition at line 167 of file NPWBase.c.
Reserve an entry in the cross-reference table.
- Parameters:
-
| pdf | reference to NPW structure |
[out] | ref | object reference |
Definition at line 449 of file NPWBase.c.
static void RLInit |
( |
RLState * |
rl |
) |
[static] |
Initialize run-length filter state.
- Parameters:
-
[out] | rl | run-length filter state |
Definition at line 239 of file NPWBase.c.
Get next output byte of run-length filtered stream.
- Parameters:
-
[in,out] | rl | run-length filter state |
[in] | b | input data |
[in] | len | number of bytes in b |
- Returns:
- output byte
Definition at line 254 of file NPWBase.c.
Write 4 bytes, or less if last bytes of stream, encoded with base-85.
- Parameters:
-
| pdf | reference to NPW structure |
[in] | b | bytes |
[in] | n | number of bytes (1-4) |
[in] | end | TRUE to write the end marker |
- Returns:
- error code (kNPWErrOk for success)
Definition at line 317 of file NPWBase.c.
Write a byte as ASCII hexadecimal.
- Parameters:
-
| pdf | reference to NPW structure |
[in] | b | byte |
- Returns:
- error code (kNPWErrOk for success)
Definition at line 346 of file NPWBase.c.
Write PDF catalog.
- Parameters:
-
| pdf | reference to NPW structure |
[in] | pages | reference of the Pages object |
[out] | ref | reference of the PDF catalog |
- Returns:
- error code (kNPWErrOk for success)
Definition at line 680 of file NPWBase.c.
static NPWErr writeHeader |
( |
NPW * |
pdf |
) |
[static] |
Write PDF header.
- Parameters:
-
| pdf | reference to NPW structure |
- Returns:
- kNPWErrOk for success, else error code
Definition at line 477 of file NPWBase.c.
< TRUE iff all pages have the same size inherited from Pages
Definition at line 534 of file NPWBase.c.
< TRUE iff all pages have the same size
Definition at line 567 of file NPWBase.c.
|
Generated by Doxygen.
Copyright 2007-2010, Yves Piguet.
All rights reserved.
|
|