pdf

Interface to create a PDF document.

File information

Filecommon/interface/pdf.h

Classes IPdfProvider
IPdf
IPdfPage
IPdfImageStream

class IPdfProvider members CreatePdf

class IPdf members SetCompressionMode
AddPage
Complete
Get

class IPdfPage members SetSize
SetDirection
GetWidth
GetHeight
AddImageStream
Complete

class IPdfImageStream members Write
SetStreamWidth
SetStreamHeight
Draw

Classes

IPdfProvider

class IPdfProvider {
public:
    virtual ~IPdfProvider() { };
    virtual class IPdf * CreatePdf() = 0;
};

Public functions

CreatePdf
Creates an IPdf object. This object is to be deleted after use.

IPdf

class IPdf {
public:
    virtual ~IPdf() { };
    enum Compressions {
        CompressionNone     = 0x0,
        CompressionText     = 0x1,
        CompressionImage    = 0x2,
        CompressionMetaData = 0x4,
        CompressionAll      = 0xf,
    };
    enum Directions {
        DirectionPortrait,
        DirectionLandscape,
    };
    enum Sizes {
        SizeA4,
    };
    enum StreamTypes {
        StreamTypeCcittG31D,
    };
    virtual void SetCompressionMode(unsigned compressionMode) = 0;
    virtual class IPdfPage * AddPage(enum IPdf::Sizes size = IPdf::SizeA4, 
                                     enum IPdf::Directions direction = IPdf::DirectionPortrait) = 0;
    virtual void Complete() = 0;
    virtual void Get(const byte * & data, unsigned & length, bool * last = 0) = 0;
};

Public functions

SetCompressionMode
The function sets the compression mode of the PDF document.

Parameters

unsigned compressionMode Bit mask which type of content should be compressed.
AddPage
Add a new page to the document.

Parameters

enum IPdf::Sizes size (Default IPdf::SizeA4) The size of the page.
enum IPdf::Directions direction (Default IPdf::DirectionPortrait) The direction of the page.

Return value

Returns the pointer to the internally used class IPdfPage.
Complete
The function is to be called if the document is completly defined and should be rendered.
Get
Get the document data. The data pointer is set to a pointer allocated by IPdf. The end of the document is reached if length is zero or last is true.

Parameters

const byte * & data Reference to the data pointer which is set by the function to the internal data.
unsigned & length Reference to a unsigned variable which is set by the function to the data length.
bool * last (Default 0) Reference to a bool variable, whose value is set by the function. The value is set to true if the end of the data is reached. This parameter can also be a null pointer, in which case it is not used.

IPdfPage

class IPdfPage {
public:
    virtual ~IPdfPage() { };
    virtual void SetSize(enum IPdf::Sizes size) = 0;
    virtual void SetDirection(enum IPdf::Directions direction) = 0;
    virtual float GetWidth() = 0;
    virtual float GetHeight() = 0;
    virtual class IPdfImageStream * AddImageStream(enum IPdf::StreamTypes type) = 0;
    virtual void Complete() = 0;
};

Public functions

SetSize
Set the page size.

Parameters

enum IPdf::Sizes size The supported size is A4.
SetDirection
Set the page direction.

Parameters

enum IPdf::Directions direction Portrait or landscape.
GetWidth
Get the page width.

Return value

Returns the width of the page.
GetHeight
Get the page height.

Return value

Returns the height of the page.
AddImageStream
Add an image stream to the page.

Parameters

enum IPdf::StreamTypes type The supported type is one-dimentional G3 data.

Return value

Returns the pointer to the internally used class IPdfImageStream.
Complete
The function is to be called if the page is complete. After this, IPdfPage is invalid.

IPdfImageStream

class IPdfImageStream {
public:
    virtual ~IPdfImageStream() { };
    virtual void Write(const byte * data, unsigned length) = 0;
    virtual void SetStreamWidth(unsigned int width) = 0;
    virtual void SetStreamHeight(unsigned int height) = 0;
    virtual void Draw(float x, float y, float width, float height) = 0;
};

Public functions

Write
The function is to be called to write data into the image stream.

Parameters

const byte * data Pointer to the data block to write.
unsigned length Length of the data block to write.
SetStreamWidth
This function must be called to set the internal width parameter to the width of the written image.

Parameters

unsigned int width The width in pixel.
SetStreamHeight
This function must be called to set the internal height parameter to the height of the written image.

Parameters

unsigned int height The height in pixel.
Draw
The function is to be called if the stream is complete. After this, IPdfImageStream is invalid.

Parameters

float x Horizontal start position of the image in the page.
float y Vertical start position of the image in the page.
float width Width of the image in the page.
float height Height of the image in the page.