nyctergatis.com

Contact

Projects
Sysquake Remote Live
NME
PDF
Hike
Sudoku
GifBuilder
jpeglib for Palm OS
MySQL Client
Cross-GCC for Mac OS

NPWBase.h File Reference

NPW (base functions to write PDF files). More...

Go to the source code of this file.


Data Structures

struct  NPWXRef
 Cross-reference description. More...
struct  NPWPage
 Page description. More...
struct  NPW
 NPW main structure. More...

Defines

#define NULL   0
 null pointer
#define FALSE   0
 false boolean value
#define TRUE   1
 true boolean value
#define kNPWUnitMM   2.835
 conversion factor from mm to pt
#define kNPWUnitCM   28.35
 conversion factor from cm to pt
#define kNPWUnitInch   72
 conversion factor from inch to pt
#define NPWFilterNameASCIIHex   "/AHx"
 hexadecimal filter name
#define NPWFilterNameASCII85   "/A85"
 base-85 filter name
#define NPWFilterNameRunLength   "/RL"
 run-length filter name
#define NPWFontNameCourier   "/FC"
 Courier font name.
#define NPWFontNameCourierOblique   "/FCo"
 Courier Oblique font name.
#define NPWFontNameCourierBold   "/FCb"
 Courier Bold font name.
#define NPWFontNameCourierBoldOblique   "/FCbo"
 Courier Bold Oblique font name.
#define NPWFontNameHelvetica   "/FH"
 Helvetica font name.
#define NPWFontNameHelveticaOblique   "/FHo"
 Helvetica Oblique font name.
#define NPWFontNameHelveticaBold   "/FHb"
 Helvetica Bold font name.
#define NPWFontNameHelveticaBoldOblique   "/FHbo"
 Helvetica Bold Oblique font name.
#define NPWFontNameTimesRoman   "/FT"
 Times Roman font name.
#define NPWFontNameTimesItalic   "/FTi"
 Time Italic font name.
#define NPWFontNameTimesBold   "/FTb"
 Times Bold font name.
#define NPWFontNameTimesBoldItalic   "/FTbi"
 Times Bold Italic font name.
#define NPWFontNameSymbol   "/FS"
 Symbol font name.
#define NPWFontNameZapfDingbats   "/FZ"
 Zapf Dingbats font name.

Typedefs

typedef char NPWChar
 Character (8-bit; processing possible with compatible charsets like UTF-8 or Shift-JIS).
typedef NPWCharNPWText
 Text.
typedef NPWChar const * NPWConstText
 Constant text.
typedef int NPWInt
 Integer.
typedef NPWInt NPWRef
 Object reference.
typedef NPWInt NPWOffset
 Offset in PDF file.
typedef unsigned char NPWByte
 Unsigned 8-bit integer.
typedef unsigned long NPWUInt32
 Unsigned 32-bit integer.
typedef short PDFInt16
 Signed 16-bit integer.
typedef double NPWFloat
 Floating-point number.
typedef int NPWBoolean
 Boolean.
typedef NPWErr(* NPWWriteCB )(NPWConstText str, NPWInt length, void *userData)
 Callback to write data to PDF file.
typedef NPWErr(* NPWAllocCB )(void **p, NPWInt size, void *userData)
 Callback to allocate, resize or free block of memory.

Enumerations

enum  { kNPWNoRef = -1 }
 Special references. More...
enum  NPWErr {
  kNPWErrOk = 0, kNPWErrNotEnoughMemory, kNPWErrNestedObject, kNPWErrUnbalancedObj,
  kNPWUnknownFont, kNPWNumTooLarge, kNPWErrIncomplete, kNPWErrSuspended,
  kNPWErrInternal
}
 Error codes. More...
enum  {
  kNPWPaperHeightA3 = 1191, kNPWPaperWidthA3 = 842, kNPWPaperHeightA4 = 842, kNPWPaperWidthA4 = 595,
  kNPWPaperHeightA5 = 595, kNPWPaperWidthA5 = 420, kNPWPaperHeightA6 = 420, kNPWPaperWidthA6 = 298,
  kNPWPaperHeightB3 = 1417, kNPWPaperWidthB3 = 1001, kNPWPaperHeightB4 = 1001, kNPWPaperWidthB4 = 709,
  kNPWPaperHeightB5 = 709, kNPWPaperWidthB5 = 499, kNPWPaperHeightB6 = 499, kNPWPaperWidthB6 = 354,
  kNPWPaperHeightC3 = 1298, kNPWPaperWidthC3 = 918, kNPWPaperHeightC4 = 918, kNPWPaperWidthC4 = 649,
  kNPWPaperHeightC5 = 649, kNPWPaperWidthC5 = 459, kNPWPaperHeightC6 = 459, kNPWPaperWidthC6 = 323,
  kNPWPaperHeightDL = 312, kNPWPaperWidthDL = 624, kNPWPaperHeightID1 = 153, kNPWPaperWidthID1 = 243,
  kNPWPaperHeightID2 = 210, kNPWPaperWidthID2 = 298, kNPWPaperHeightID3 = 249, kNPWPaperWidthID3 = 354,
  kNPWPaperHeightLetter = 792, kNPWPaperWidthLetter = 612, kNPWPaperHeightLegal = 1008, kNPWPaperWidthLegal = 612,
  kNPWPaperHeightExecutive = 756, kNPWPaperWidthExecutive = 522, kNPWPaperHeightLedger = 1224, kNPWPaperWidthLedger = 792
}
 Paper size. More...
enum  { kNPWFilterNone = 0, kNPWFilterASCIIHex = 1, kNPWFilterASCII85 = 2, kNPWFilterRunLength = 4 }
 Filter flags (encoding: first rl, then hex or 85). More...
enum  {
  kNPWFontCourier = 1, kNPWFontCourierOblique = 2, kNPWFontCourierBold = 4, kNPWFontCourierBoldOblique = 010,
  kNPWFontHelvetica = 020, kNPWFontHelveticaOblique = 040, kNPWFontHelveticaBold = 0100, kNPWFontHelveticaBoldOblique = 0200,
  kNPWFontTimesRoman = 0400, kNPWFontTimesItalic = 01000, kNPWFontTimesBold = 02000, kNPWFontTimesBoldItalic = 04000,
  kNPWFontSymbol = 010000, kNPWFontZapfDingbats = 020000, kNPWFontNone = 0, kNPWFontAll = 037777
}
 Standard font flags. More...

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 NPWTerminate (NPW *pdf)
 Terminate PDF and flush output.
NPWErr NPWBeginPage (NPW *pdf, NPWInt width, NPWInt height)
 Beginning of page.
NPWErr NPWEndPage (NPW *pdf)
 End of page.
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).
NPWErr NPWBeginObj (NPW *pdf, NPWRef *ref)
 Begin writing an object.
NPWErr NPWEndObj (NPW *pdf)
 End writing an object.
void NPWFilterBegin (NPW *pdf, NPWInt filter)
 Begin writing filtered data to PDF.
NPWErr NPWFilterWrite (NPW *pdf, NPWByte const *b, NPWInt n)
 Write filtered data to PDF.
NPWErr NPWFilterEnd (NPW *pdf)
 End writing filtered data to PDF.

Detailed Description

NPW (base functions to write PDF files).

Author:
Yves Piguet. Copyright 2008-2010, Yves Piguet

Definition in file NPWBase.h.


Typedef Documentation

typedef NPWErr(* NPWAllocCB)(void **p, NPWInt size, void *userData)

Callback to allocate, resize or free block of memory.

Parameters:
[in,out] p pointer to memory (NULL to allocate new block)
[in] size size of block (negative to free it)
[in,out] userData application-specific data
Returns:
kNPWErrOk for success, else error code

Definition at line 296 of file NPWBase.h.

typedef NPWErr(* NPWWriteCB)(NPWConstText str, NPWInt length, void *userData)

Callback to write data to PDF file.

Parameters:
[in] str address of string
[in] length length of string in bytes
[in,out] userData application-specific data
Returns:
kNPWErrOk for success, else error code

Definition at line 288 of file NPWBase.h.


Enumeration Type Documentation

anonymous enum

Special references.

Enumerator:
kNPWNoRef  Special value for nonexistent reference.

Definition at line 204 of file NPWBase.h.

anonymous enum

Paper size.

Enumerator:
kNPWPaperHeightA3  portrait A3 height (420 mm)
kNPWPaperWidthA3  portrait A3 width (297 mm)
kNPWPaperHeightA4  portrait A4 height (297 mm)
kNPWPaperWidthA4  portrait A4 width (210 mm)
kNPWPaperHeightA5  portrait A5 height (210 mm)
kNPWPaperWidthA5  portrait A5 width (148 mm)
kNPWPaperHeightA6  portrait A6 height (148 mm)
kNPWPaperWidthA6  portrait A6 width (105 mm)
kNPWPaperHeightB3  portrait B3 height (500 mm)
kNPWPaperWidthB3  portrait B3 width (353 mm)
kNPWPaperHeightB4  portrait B4 height (353 mm)
kNPWPaperWidthB4  portrait B4 width (250 mm)
kNPWPaperHeightB5  portrait B5 height (250 mm)
kNPWPaperWidthB5  portrait B5 width (176 mm)
kNPWPaperHeightB6  portrait B6 height (176 mm)
kNPWPaperWidthB6  portrait B6 width (125 mm)
kNPWPaperHeightC3  portrait C3 height (458 mm)
kNPWPaperWidthC3  portrait C3 width (324 mm)
kNPWPaperHeightC4  portrait C4 height (324 mm)
kNPWPaperWidthC4  portrait C4 width (229 mm)
kNPWPaperHeightC5  portrait C5 height (229 mm)
kNPWPaperWidthC5  portrait C5 width (162 mm)
kNPWPaperHeightC6  portrait C6 height (162 mm)
kNPWPaperWidthC6  portrait C6 width (114 mm)
kNPWPaperHeightDL  DL envelope height(110 mm).
kNPWPaperWidthDL  DL envelope width (220 mm).
kNPWPaperHeightID1  ID-1 (banking cards) height (53.98 mm).
kNPWPaperWidthID1  ID-1 (banking card) width (85.6 mm).
kNPWPaperHeightID2  ID-2 (A7) height (74 mm).
kNPWPaperWidthID2  ID-2 (A7) width (105 mm).
kNPWPaperHeightID3  ID-3 (B7, passport) height (88 mm).
kNPWPaperWidthID3  ID-3 (B7, passport) width (125 mm).
kNPWPaperHeightLetter  Letter height (279 mm).
kNPWPaperWidthLetter  Letter height (216 mm).
kNPWPaperHeightLegal  Legal height (356 mm).
kNPWPaperWidthLegal  Legal height (216 mm).
kNPWPaperHeightExecutive  Executive height (266.7 mm).
kNPWPaperWidthExecutive  Executive height (184.2 mm).
kNPWPaperHeightLedger  Ledger/Tabloid height (431.8 mm).
kNPWPaperWidthLedger  Ledger/Tabloid height (279.4 mm).

Definition at line 225 of file NPWBase.h.

anonymous enum

Filter flags (encoding: first rl, then hex or 85).

Enumerator:
kNPWFilterNone  no filter
kNPWFilterASCIIHex  ASCII Hexadecimal filter.
kNPWFilterASCII85  ASCII base-85 filter.
kNPWFilterRunLength  run-length compression filter

Definition at line 315 of file NPWBase.h.

anonymous enum

Standard font flags.

Enumerator:
kNPWFontCourier  Courier.
kNPWFontCourierOblique  Courier oblique.
kNPWFontCourierBold  Courier bold.
kNPWFontCourierBoldOblique  Courier bold oblique.
kNPWFontHelvetica  Helvetica.
kNPWFontHelveticaOblique  Helvetica oblique.
kNPWFontHelveticaBold  Helvetica bold.
kNPWFontHelveticaBoldOblique  Helvetica bold oblique.
kNPWFontTimesRoman  Times roman.
kNPWFontTimesItalic  Times italic.
kNPWFontTimesBold  Times bold.
kNPWFontTimesBoldItalic  Times bold italic.
kNPWFontSymbol  Symbol.
kNPWFontZapfDingbats  Zapf Dingbats.
kNPWFontNone  no font
kNPWFontAll  all fonts

Definition at line 362 of file NPWBase.h.

enum NPWErr

Error codes.

Enumerator:
kNPWErrOk  no error
kNPWErrNotEnoughMemory  not enough memory
kNPWErrNestedObject  try to start a new object without having ended previous one
kNPWErrUnbalancedObj  endobj without obj
kNPWUnknownFont  unknown font
kNPWNumTooLarge  floating-point number too large
kNPWErrIncomplete  incomplete operation
kNPWErrSuspended  operation suspended by callback to permit a lower-level action
kNPWErrInternal  internal error (should never occur)

Definition at line 210 of file NPWBase.h.


Function Documentation

NPWErr NPWBeginObj ( NPW pdf,
NPWRef ref 
)

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.

NPWErr NPWBeginPage ( NPW pdf,
NPWInt  width,
NPWInt  height 
)

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.

NPWErr NPWEndObj ( NPW pdf  ) 

End writing an object.

Parameters:
pdf reference to NPW structure
Returns:
error code (kNPWErrOk for success)

Definition at line 526 of file NPWBase.c.

NPWErr NPWEndPage ( NPW pdf  ) 

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.

NPWErr NPWFilterEnd ( NPW pdf  ) 

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.

NPWErr NPWFilterWrite ( NPW pdf,
NPWByte const *  b,
NPWInt  n 
)

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.

void NPWSetFonts ( NPW pdf,
NPWInt  fonts 
)

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.

NPWErr NPWTerminate ( NPW pdf  ) 

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.

NPWErr NPWWrite ( NPW pdf,
NPWConstText  str,
NPWInt  length 
)

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.

NPWErr NPWWriteFloat ( NPW pdf,
NPWFloat  x 
)

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.

NPWErr NPWWriteInt ( NPW pdf,
NPWInt  i,
NPWInt  pad 
)

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.

NPWErr NPWWriteString ( NPW pdf,
NPWConstText  str,
NPWInt  length 
)

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.

Generated by Doxygen.
Copyright 2007-2010, Yves Piguet.
All rights reserved.