Pdf3rdPtyForwardDecl.h   Pdf3rdPtyForwardDecl.h 
skipping to change at line 33 skipping to change at line 33
#endif #endif
// Provide access to FT_Library // Provide access to FT_Library
struct FT_LibraryRec_; struct FT_LibraryRec_;
typedef struct FT_LibraryRec_ *FT_Library; typedef struct FT_LibraryRec_ *FT_Library;
// Provide access to FT_Face // Provide access to FT_Face
struct FT_FaceRec_; struct FT_FaceRec_;
typedef struct FT_FaceRec_* FT_Face; typedef struct FT_FaceRec_* FT_Face;
#if !defined(_WIN32) && !defined(__APPLE_CC__) #if defined(HAVE_FONTCONFIG)
// Fontconfig // Fontconfig
struct _FcConfig; struct _FcConfig;
typedef struct _FcConfig FcConfig; typedef struct _FcConfig FcConfig;
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
}; // end extern "C" }; // end extern "C"
#endif #endif
// end PDF_FT_FORWARD_DECL // end PDF_FT_FORWARD_DECL
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 PdfAction.h   PdfAction.h 
skipping to change at line 43 skipping to change at line 43
/** The type of the action. /** The type of the action.
* PDF supports different action types, each of * PDF supports different action types, each of
* them has different keys and propeties. * them has different keys and propeties.
* *
* Not all action types listed here are supported yet. * Not all action types listed here are supported yet.
* *
* Please make also sure that the action type you use is * Please make also sure that the action type you use is
* supported by the PDF version you are using. * supported by the PDF version you are using.
*/ */
typedef enum EPdfAction { enum EPdfAction {
ePdfAction_GoTo = 0, ePdfAction_GoTo = 0,
ePdfAction_GoToR, ePdfAction_GoToR,
ePdfAction_GoToE, ePdfAction_GoToE,
ePdfAction_Launch, ePdfAction_Launch,
ePdfAction_Thread, ePdfAction_Thread,
ePdfAction_URI, ePdfAction_URI,
ePdfAction_Sound, ePdfAction_Sound,
ePdfAction_Movie, ePdfAction_Movie,
ePdfAction_Hide, ePdfAction_Hide,
ePdfAction_Named, ePdfAction_Named,
skipping to change at line 83 skipping to change at line 83
/** Create a new PdfAction object /** Create a new PdfAction object
* \param eAction type of this action * \param eAction type of this action
* \param pParent parent of this action * \param pParent parent of this action
*/ */
PdfAction( EPdfAction eAction, PdfVecObjects* pParent ); PdfAction( EPdfAction eAction, PdfVecObjects* pParent );
/** Create a new PdfAction object /** Create a new PdfAction object
* \param eAction type of this action * \param eAction type of this action
* \param pParent parent of this action * \param pParent parent of this action
*/ */
PdfAction( EPdfAction eAction, PdfStreamedDocument* pParent ); PdfAction( EPdfAction eAction, PdfDocument* pParent );
virtual ~PdfAction() { } virtual ~PdfAction() { }
/** Create a PdfAction object from an existing /** Create a PdfAction object from an existing
* PdfObject * PdfObject
*/ */
PdfAction( PdfObject* pObject ); PdfAction( PdfObject* pObject );
/** Set the URI of an ePdfAction_URI /** Set the URI of an ePdfAction_URI
* \param sUri must be a correct URI as PdfString * \param sUri must be a correct URI as PdfString
skipping to change at line 116 skipping to change at line 116
void SetScript( const PdfString & sScript ); void SetScript( const PdfString & sScript );
PdfString GetScript() const; PdfString GetScript() const;
bool HasScript() const; bool HasScript() const;
/** Get the type of this action /** Get the type of this action
* \returns the type of this action * \returns the type of this action
*/ */
inline const EPdfAction GetType() const; inline EPdfAction GetType() const;
private: private:
PdfAction( const PdfAction & rhs ); PdfAction( const PdfAction & rhs );
private: private:
static const long s_lNumActions; static const long s_lNumActions;
static const char* s_names[]; static const char* s_names[];
private: private:
EPdfAction m_eType; EPdfAction m_eType;
}; };
// ----------------------------------------------------- // -----------------------------------------------------
// //
// ----------------------------------------------------- // -----------------------------------------------------
inline const EPdfAction PdfAction::GetType() const inline EPdfAction PdfAction::GetType() const
{ {
return m_eType; return m_eType;
} }
}; };
#endif // _PDF_ACTION_H_ #endif // _PDF_ACTION_H_
 End of changes. 4 change blocks. 
4 lines changed or deleted 4 lines changed or added


 PdfAnnotation.h   PdfAnnotation.h 
skipping to change at line 48 skipping to change at line 48
/** The type of the annotation. /** The type of the annotation.
* PDF supports different annotation types, each of * PDF supports different annotation types, each of
* them has different keys and propeties. * them has different keys and propeties.
* *
* Not all annotation types listed here are supported yet. * Not all annotation types listed here are supported yet.
* *
* Please make also sure that the annotation type you use is * Please make also sure that the annotation type you use is
* supported by the PDF version you are using. * supported by the PDF version you are using.
*/ */
typedef enum EPdfAnnotation { enum EPdfAnnotation {
ePdfAnnotation_Text = 0, // - supported ePdfAnnotation_Text = 0, // - supported
ePdfAnnotation_Link, // - supported ePdfAnnotation_Link, // - supported
ePdfAnnotation_FreeText, // PDF 1.3 // - supported ePdfAnnotation_FreeText, // PDF 1.3 // - supported
ePdfAnnotation_Line, // PDF 1.3 // - supported ePdfAnnotation_Line, // PDF 1.3 // - supported
ePdfAnnotation_Square, // PDF 1.3 ePdfAnnotation_Square, // PDF 1.3
ePdfAnnotation_Circle, // PDF 1.3 ePdfAnnotation_Circle, // PDF 1.3
ePdfAnnotation_Polygon, // PDF 1.5 ePdfAnnotation_Polygon, // PDF 1.5
ePdfAnnotation_PolyLine, // PDF 1.5 ePdfAnnotation_PolyLine, // PDF 1.5
ePdfAnnotation_Highlight, // PDF 1.3 ePdfAnnotation_Highlight, // PDF 1.3
ePdfAnnotation_Underline, // PDF 1.3 ePdfAnnotation_Underline, // PDF 1.3
skipping to change at line 82 skipping to change at line 82
ePdfAnnotation_Watermark, // PDF 1.6 ePdfAnnotation_Watermark, // PDF 1.6
ePdfAnnotation_3D, // PDF 1.6 ePdfAnnotation_3D, // PDF 1.6
ePdfAnnotation_Unknown = 0xff ePdfAnnotation_Unknown = 0xff
}; };
/** Flags that control the appearance of a PdfAnnotation. /** Flags that control the appearance of a PdfAnnotation.
* You can OR them together and pass it to * You can OR them together and pass it to
* PdfAnnotation::SetFlags. * PdfAnnotation::SetFlags.
*/ */
typedef enum EPdfAnnotationFlags { enum EPdfAnnotationFlags {
ePdfAnnotationFlags_Invisible = 0x0001, ePdfAnnotationFlags_Invisible = 0x0001,
ePdfAnnotationFlags_Hidden = 0x0002, ePdfAnnotationFlags_Hidden = 0x0002,
ePdfAnnotationFlags_Print = 0x0004, ePdfAnnotationFlags_Print = 0x0004,
ePdfAnnotationFlags_NoZoom = 0x0008, ePdfAnnotationFlags_NoZoom = 0x0008,
ePdfAnnotationFlags_NoRotate = 0x0010, ePdfAnnotationFlags_NoRotate = 0x0010,
ePdfAnnotationFlags_NoView = 0x0020, ePdfAnnotationFlags_NoView = 0x0020,
ePdfAnnotationFlags_ReadOnly = 0x0040, ePdfAnnotationFlags_ReadOnly = 0x0040,
ePdfAnnotationFlags_Locked = 0x0080, ePdfAnnotationFlags_Locked = 0x0080,
ePdfAnnotationFlags_ToggleNoView = 0x0100, ePdfAnnotationFlags_ToggleNoView = 0x0100,
 End of changes. 2 change blocks. 
2 lines changed or deleted 2 lines changed or added


 PdfArray.h   PdfArray.h 
skipping to change at line 59 skipping to change at line 59
PdfArray( const PdfObject & var ); PdfArray( const PdfObject & var );
/** Deep copy an existing PdfArray /** Deep copy an existing PdfArray
* *
* \param rhs the array to copy * \param rhs the array to copy
*/ */
PdfArray( const PdfArray & rhs ); PdfArray( const PdfArray & rhs );
virtual ~PdfArray(); virtual ~PdfArray();
/**
* \returns the size of the array
*/
inline size_t GetSize() const;
/** Remove all elements from the array /** Remove all elements from the array
*/ */
inline void Clear(); inline void Clear();
/** Write the array to an output device. /** Write the array to an output device.
* This is an overloaded member function. * This is an overloaded member function.
* *
* \param pDevice write the object to this device * \param pDevice write the object to this device
* \param pEncrypt an encryption object which is used to encrypt this
object
* or NULL to not encrypt this object
*/ */
void Write( PdfOutputDevice* pDevice ) const; void Write( PdfOutputDevice* pDevice, const PdfEncrypt* pEncrypt = NULL ) const;
/** Utility method to determine if the array contains /** Utility method to determine if the array contains
* contains any objects of ePdfDataType_String whose * contains any objects of ePdfDataType_String whose
* value is the passed string. * value is the passed string.
* \param cmpString the string to compare against * \param cmpString the string to compare against
* \returns true if success, false if not * \returns true if success, false if not
*/ */
bool ContainsString( const std::string& cmpString ) const; bool ContainsString( const std::string& cmpString ) const;
/** Utility method to return the actual index in the /** Utility method to return the actual index in the
skipping to change at line 95 skipping to change at line 102
}; };
// ----------------------------------------------------- // -----------------------------------------------------
// //
// ----------------------------------------------------- // -----------------------------------------------------
void PdfArray::Clear() void PdfArray::Clear()
{ {
this->clear(); this->clear();
} }
// -----------------------------------------------------
//
// -----------------------------------------------------
size_t PdfArray::GetSize() const
{
return this->size();
}
typedef PdfArray TVariantList; typedef PdfArray TVariantList;
typedef PdfArray::iterator TIVariantList; typedef PdfArray::iterator TIVariantList;
typedef PdfArray::const_iterator TCIVariantList; typedef PdfArray::const_iterator TCIVariantList;
}; };
#endif // _PDF_ARRAY_H_ #endif // _PDF_ARRAY_H_
 End of changes. 4 change blocks. 
1 lines changed or deleted 17 lines changed or added


 PdfData.h   PdfData.h 
skipping to change at line 66 skipping to change at line 66
*/ */
PdfData( const PdfData & rhs ) PdfData( const PdfData & rhs )
: PdfDataType() : PdfDataType()
{ {
this->operator=( rhs ); this->operator=( rhs );
} }
/** Write the complete datatype to a file. /** Write the complete datatype to a file.
* \param pDevice write the object to this device * \param pDevice write the object to this device
*/ */
void Write( PdfOutputDevice* pDevice ) const; void Write( PdfOutputDevice* pDevice, const PdfEncrypt* pEncrypt = NULL ) const;
/** Copy an existing PdfData /** Copy an existing PdfData
* \param rhs another PdfData to copy * \param rhs another PdfData to copy
* \returns this object * \returns this object
*/ */
inline const PdfData & operator=( const PdfData & rhs ); inline const PdfData & operator=( const PdfData & rhs );
private: private:
std::string m_sData; std::string m_sData;
}; };
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 PdfDataType.h   PdfDataType.h 
skipping to change at line 28 skipping to change at line 28
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
************************************************************************** */ ************************************************************************** */
#ifndef _PDF_DATATYPE_H_ #ifndef _PDF_DATATYPE_H_
#define _PDF_DATATYPE_H_ #define _PDF_DATATYPE_H_
#include "PdfDefines.h" #include "PdfDefines.h"
namespace PoDoFo { namespace PoDoFo {
class PdfEncrypt;
class PdfOutputDevice; class PdfOutputDevice;
/** An interface for all PDF datatype classes. /** An interface for all PDF datatype classes.
* *
* *
* \see PdfName \see PdfArray \see PdfReference * \see PdfName \see PdfArray \see PdfReference
* \see PdfVariant \see PdfDictionary \see PdfString * \see PdfVariant \see PdfDictionary \see PdfString
*/ */
class PODOFO_API PdfDataType { class PODOFO_API PdfDataType {
skipping to change at line 49 skipping to change at line 50
/** Create a new PdfDataType. /** Create a new PdfDataType.
* Can only be called by subclasses * Can only be called by subclasses
*/ */
PdfDataType(); PdfDataType();
public: public:
virtual ~PdfDataType(); virtual ~PdfDataType();
/** Write the complete datatype to a file. /** Write the complete datatype to a file.
* \param pDevice write the object to this device * \param pDevice write the object to this device
* \param pEncrypt an encryption object which is used to encrypt this
object
* or NULL to not encrypt this object
*/ */
virtual void Write( PdfOutputDevice* pDevice ) const = 0; virtual void Write( PdfOutputDevice* pDevice, const PdfEncrypt* pEncryp t = NULL ) const = 0;
}; };
}; // namespace PoDoFo }; // namespace PoDoFo
#endif /* _PDF_DATATYPE_H_ */ #endif /* _PDF_DATATYPE_H_ */
 End of changes. 3 change blocks. 
1 lines changed or deleted 5 lines changed or added


 PdfDefines.h   PdfDefines.h 
skipping to change at line 33 skipping to change at line 33
/** \file PdfDefines.h /** \file PdfDefines.h
* This file should be included as the FIRST file in every header of * This file should be included as the FIRST file in every header of
* PoDoFo lib. It includes all standard files, defines some useful * PoDoFo lib. It includes all standard files, defines some useful
* macros, some datatypes and all important enumeration types. On * macros, some datatypes and all important enumeration types. On
* supporting platforms it will be precompiled to speed compilation. * supporting platforms it will be precompiled to speed compilation.
*/ */
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(disable: 4786) #pragma warning(disable: 4786)
#pragma warning(disable: 4251)
#endif #endif
// Include common system files // Include common system files
#include <cstdio> #include <cstdio>
// Include common STL files // Include common STL files
#include <map> #include <map>
#include <string> #include <string>
#include <vector> #include <vector>
#include <set> #include <set>
// Include common BOOST settings
#ifdef HAVE_BOOST
#include <boost/config.hpp>
#endif // HAVE_BOOST
/** \def PODOFO_VERBOSE_DEBUG /** \def PODOFO_VERBOSE_DEBUG
* Debug define. Enable it, if you need * Debug define. Enable it, if you need
* more debuf output to the commandline from PoDoFo * more debuf output to the commandline from PoDoFo
* *
* Setting PDF_VERBOSE_DEBUG will make PoDoFo * Setting PDF_VERBOSE_DEBUG will make PoDoFo
* EXTREMELY slow and verbose, so it's not practical * EXTREMELY slow and verbose, so it's not practical
* even for regular debuggin. * even for regular debuggin.
*/ */
#ifndef PODOFO_VERBOSE_DEBUG #ifndef PODOFO_VERBOSE_DEBUG
//#define PODOFO_VERBOSE_DEBUG //#define PODOFO_VERBOSE_DEBUG
#endif //PODOFO_VERBOSE_DEBUG #endif //PODOFO_VERBOSE_DEBUG
#ifdef DEBUG
#define PODOFO_ASSERT( x ) assert( x );
#else
#define PODOFO_ASSERT( x )
#endif // DEBUG
// Should we do lots of extra (expensive) sanity checking? You should not // Should we do lots of extra (expensive) sanity checking? You should not
// define this on production builds because of the runtime cost and because it // define this on production builds because of the runtime cost and because it
// might cause the library to abort() if it notices something nasty. // might cause the library to abort() if it notices something nasty.
// It may also change the size of some objects, and is thus not binary // It may also change the size of some objects, and is thus not binary
// compatible. // compatible.
#ifndef PODOFO_EXTRA_CHECKS #ifndef PODOFO_EXTRA_CHECKS
//#define PODOFO_EXTRA_CHECKS //#define PODOFO_EXTRA_CHECKS
#endif //PODOFO_EXTRA_CHECKS #endif //PODOFO_EXTRA_CHECKS
// Error Handling Defines // Error Handling Defines
skipping to change at line 100 skipping to change at line 112
*/ */
namespace PoDoFo { namespace PoDoFo {
// Datatypes which are required to have a certain size when porting // Datatypes which are required to have a certain size when porting
/** /**
* unsigned int which is defined to be 32 bits wide. * unsigned int which is defined to be 32 bits wide.
*/ */
typedef unsigned int pdf_uint32; typedef unsigned int pdf_uint32;
typedef unsigned short pdf_uint16; typedef unsigned short pdf_uint16;
typedef signed short pdf_int16;
typedef pdf_uint16 pdf_utf16be; typedef pdf_uint16 pdf_utf16be;
typedef unsigned char pdf_utf8; typedef unsigned char pdf_utf8;
// Enums // Enums
/** /**
* Enum to identify diferent versions of the PDF file format * Enum to identify diferent versions of the PDF file format
*/ */
typedef enum EPdfVersion { enum EPdfVersion {
ePdfVersion_1_0 = 0, /**< PDF 1.0 */ ePdfVersion_1_0 = 0, /**< PDF 1.0 */
ePdfVersion_1_1, /**< PDF 1.1 */ ePdfVersion_1_1, /**< PDF 1.1 */
ePdfVersion_1_2, /**< PDF 1.2 */ ePdfVersion_1_2, /**< PDF 1.2 */
ePdfVersion_1_3, /**< PDF 1.3 */ ePdfVersion_1_3, /**< PDF 1.3 */
ePdfVersion_1_4, /**< PDF 1.4 */ ePdfVersion_1_4, /**< PDF 1.4 */
ePdfVersion_1_5, /**< PDF 1.5 */ ePdfVersion_1_5, /**< PDF 1.5 */
ePdfVersion_1_6, /**< PDF 1.6 */ ePdfVersion_1_6, /**< PDF 1.6 */
ePdfVersion_1_7 /**< PDF 1.7 */
ePdfVersion_Unknown = 0xff /**< Unknown PDF version */
}; };
/** /**
* Every PDF datatype that can occur in a PDF file * Every PDF datatype that can occur in a PDF file
* is referenced by an own enum (e.g. Bool or String). * is referenced by an own enum (e.g. Bool or String).
* *
* \see PdfVariant * \see PdfVariant
* *
* Remember to update PdfVariant::GetDataTypeString() when adding members h ere. * Remember to update PdfVariant::GetDataTypeString() when adding members h ere.
*/ */
typedef enum EPdfDataType { enum EPdfDataType {
ePdfDataType_Bool, /**< Boolean datatype: Accepts the values "true" and "false" */ ePdfDataType_Bool, /**< Boolean datatype: Accepts the values "true" and "false" */
ePdfDataType_Number, /**< Number datatype for integer va lues */ ePdfDataType_Number, /**< Number datatype for integer va lues */
ePdfDataType_Real, /**< Real datatype for floating poi nt numbers */ ePdfDataType_Real, /**< Real datatype for floating poi nt numbers */
ePdfDataType_String, /**< String datatype in PDF file. S trings have the form (Hallo World!) in PDF files. \see PdfString */ ePdfDataType_String, /**< String datatype in PDF file. S trings have the form (Hallo World!) in PDF files. \see PdfString */
ePdfDataType_HexString, /**< HexString datatype in PDF file . Hex encoded strings have the form &lt;AF00BE&gt; in PDF files. \see PdfSt ring */ ePdfDataType_HexString, /**< HexString datatype in PDF file . Hex encoded strings have the form &lt;AF00BE&gt; in PDF files. \see PdfSt ring */
ePdfDataType_Name, /**< Name datatype. Names are used as keys in dictionary to reference values. \see PdfName */ ePdfDataType_Name, /**< Name datatype. Names are used as keys in dictionary to reference values. \see PdfName */
ePdfDataType_Array, /**< An array of other PDF data typ es. */ ePdfDataType_Array, /**< An array of other PDF data typ es. */
ePdfDataType_Dictionary, /**< A dictionary associates keys w ith values. A key can have another dictionary as value. */ ePdfDataType_Dictionary, /**< A dictionary associates keys w ith values. A key can have another dictionary as value. */
//ePdfDataType_Stream, /**< A stream can be attached to a dictionary and contain additional data. \see PdfStream */ //ePdfDataType_Stream, /**< A stream can be attached to a dictionary and contain additional data. \see PdfStream */
ePdfDataType_Null, /**< The null datatype is always nu ll. */ ePdfDataType_Null, /**< The null datatype is always nu ll. */
ePdfDataType_Reference, /**< The reference datatype contain s references to PDF objects in the PDF file of the form 4 0 R. \see PdfObje ct */ ePdfDataType_Reference, /**< The reference datatype contain s references to PDF objects in the PDF file of the form 4 0 R. \see PdfObje ct */
ePdfDataType_RawData, /**< Raw PDF data */ ePdfDataType_RawData, /**< Raw PDF data */
ePdfDataType_Unknown = 0xff /**< Unknown and unsupported PDF da
tatype. */ ePdfDataType_Unknown /**< The Datatype is unknown */
}; };
/** /**
* Every filter that can be used to encode a stream * Every filter that can be used to encode a stream
* in a PDF file is referenced by an own enum value. * in a PDF file is referenced by an own enum value.
* Common filters are ePdfFilter_FlateDecode (i.e. Zip) or * Common filters are ePdfFilter_FlateDecode (i.e. Zip) or
* ePdfFilter_ASCIIHexDecode * ePdfFilter_ASCIIHexDecode
*/ */
typedef enum EPdfFilter { enum EPdfFilter {
ePdfFilter_ASCIIHexDecode, /**< Converts data from and to he xadecimal. Increases size of the data by a factor of 2! \see PdfHexFilter * / ePdfFilter_ASCIIHexDecode, /**< Converts data from and to he xadecimal. Increases size of the data by a factor of 2! \see PdfHexFilter * /
ePdfFilter_ASCII85Decode, /**< Converts to and from Ascii85 encoding. \see PdfAscii85Filter */ ePdfFilter_ASCII85Decode, /**< Converts to and from Ascii85 encoding. \see PdfAscii85Filter */
ePdfFilter_LZWDecode, ePdfFilter_LZWDecode,
ePdfFilter_FlateDecode, /**< Compress data using the Flat e algorithm of ZLib. This filter is recommended to be used always. \see Pdf FlateFilter */ ePdfFilter_FlateDecode, /**< Compress data using the Flat e algorithm of ZLib. This filter is recommended to be used always. \see Pdf FlateFilter */
ePdfFilter_RunLengthDecode, /**< Run length decode data. \see PdfRLEFilter */ ePdfFilter_RunLengthDecode, /**< Run length decode data. \see PdfRLEFilter */
ePdfFilter_CCITTFaxDecode, ePdfFilter_CCITTFaxDecode,
ePdfFilter_JBIG2Decode, ePdfFilter_JBIG2Decode,
ePdfFilter_DCTDecode, ePdfFilter_DCTDecode,
ePdfFilter_JPXDecode, ePdfFilter_JPXDecode,
ePdfFilter_Crypt, ePdfFilter_Crypt
ePdfFilter_Unknown = 0xff /**< Unknown PDF filter */
}; };
/** /**
* Enum for the three colorspaces supported * Enum for the three colorspaces supported
* by PDF. * by PDF.
*/ */
typedef enum EPdfColorSpace { enum EPdfColorSpace {
ePdfColorSpace_DeviceGray, /**< Gray */ ePdfColorSpace_DeviceGray, /**< Gray */
ePdfColorSpace_DeviceRGB, /**< RGB */ ePdfColorSpace_DeviceRGB, /**< RGB */
ePdfColorSpace_DeviceCMYK, /**< CMYK */ ePdfColorSpace_DeviceCMYK /**< CMYK */
ePdfColorSpace_Unknown = 0xff
}; };
/** /**
* Enum for the different stroke styles that can be set * Enum for the different stroke styles that can be set
* when drawing to a PDF file (mostly for line drawing). * when drawing to a PDF file (mostly for line drawing).
*/ */
typedef enum EPdfStrokeStyle { enum EPdfStrokeStyle {
ePdfStrokeStyle_Solid, ePdfStrokeStyle_Solid,
ePdfStrokeStyle_Dash, ePdfStrokeStyle_Dash,
ePdfStrokeStyle_Dot, ePdfStrokeStyle_Dot,
ePdfStrokeStyle_DashDot, ePdfStrokeStyle_DashDot,
ePdfStrokeStyle_DashDotDot, ePdfStrokeStyle_DashDotDot,
ePdfStrokeStyle_Custom, ePdfStrokeStyle_Custom
ePdfStrokeStyle_Unknown = 0xff
}; };
/** /**
* Enum for line cap styles when drawing. * Enum for line cap styles when drawing.
*/ */
typedef enum EPdfLineCapStyle { enum EPdfLineCapStyle {
ePdfLineCapStyle_Butt = 0, ePdfLineCapStyle_Butt = 0,
ePdfLineCapStyle_Round = 1, ePdfLineCapStyle_Round = 1,
ePdfLineCapStyle_Square = 2, ePdfLineCapStyle_Square = 2
ePdfLineCapStyle_Unknown = 0xff
}; };
/** /**
* Enum for line join styles when drawing. * Enum for line join styles when drawing.
*/ */
typedef enum EPdfLineJoinStyle { enum EPdfLineJoinStyle {
ePdfLineJoinStyle_Miter = 0, ePdfLineJoinStyle_Miter = 0,
ePdfLineJoinStyle_Round = 1, ePdfLineJoinStyle_Round = 1,
ePdfLineJoinStyle_Bevel = 2, ePdfLineJoinStyle_Bevel = 2
};
ePdfLineJoinStyle_Unknown = 0xff /**
* Enum for vertical text alignment
*/
enum EPdfVerticalAlignment {
ePdfVerticalAlignment_Top = 0,
ePdfVerticalAlignment_Center = 1,
ePdfVerticalAlignment_Bottom = 2
};
/**
* Enum for text alignment
*/
enum EPdfAlignment {
ePdfAlignment_Left = 0,
ePdfAlignment_Center = 1,
ePdfAlignment_Right = 2
}; };
/** /**
* List of defined Rendering intents * List of defined Rendering intents
*/ */
#define ePdfRenderingIntent_AbsoluteColorimetric "AbsoluteColorimetri c" #define ePdfRenderingIntent_AbsoluteColorimetric "AbsoluteColorimetri c"
#define ePdfRenderingIntent_RelativeColorimetric "RelativeColorimetri c" #define ePdfRenderingIntent_RelativeColorimetric "RelativeColorimetri c"
#define ePdfRenderingIntent_Perceptual "Perceptual" #define ePdfRenderingIntent_Perceptual "Perceptual"
#define ePdfRenderingIntent_Saturation "Saturation" #define ePdfRenderingIntent_Saturation "Saturation"
/** /**
* List of defined transparency blending modes * List of defined transparency blending modes
*/ */
#define ePdfBlendMode_Normal "Normal" #define ePdfBlendMode_Normal "Normal"
#define ePdfBlendMode_Multiply "Multiply" #define ePdfBlendMode_Multiply "Multiply"
#define ePdfBlendMode_Screen "Screen" #define ePdfBlendMode_Screen "Screen"
#define ePdfBlendMode_Overlay "Overlay" #define ePdfBlendMode_Overlay "Overlay"
#define ePdfBlendMode_Darken "Darken" #define ePdfBlendMode_Darken "Darken"
#define ePdfBlendMode_Lighten "Lighten" #define ePdfBlendMode_Lighten "Lighten"
#define ePdfBlendMode_ColorDodge "ColorDodge" #define ePdfBlendMode_ColorDodge "ColorDodge"
#define ePdfBlendMode_ColorBurn "ColorBurn" #define ePdfBlendMode_ColorBurn "ColorBurn"
#define ePdfBlendMode_HardLight "HardLight" #define ePdfBlendMode_HardLight "HardLight"
#define ePdfBlendMode_SoftLight "SoftLight" #define ePdfBlendMode_SoftLight "SoftLight"
#define ePdfBlendMode_Difference "Difference" #define ePdfBlendMode_Difference "Difference"
#define ePdfBlendMode_Exclusion "Exclusion" #define ePdfBlendMode_Exclusion "Exclusion"
#define ePdfBlendMode_Hue "Hue" #define ePdfBlendMode_Hue "Hue"
#define ePdfBlendMode_Saturation "Saturation" #define ePdfBlendMode_Saturation "Saturation"
#define ePdfBlendMode_Color "Color" #define ePdfBlendMode_Color "Color"
#define ePdfBlendMode_Luminosity "Luminosity" #define ePdfBlendMode_Luminosity "Luminosity"
/** /**
* Enum holding the supported page sizes by PoDoFo. * Enum holding the supported page sizes by PoDoFo.
* Can be used to construct a PdfRect structure with * Can be used to construct a PdfRect structure with
* measurements of a page object. * measurements of a page object.
* *
* \see PdfPage * \see PdfPage
*/ */
typedef enum EPdfPageSize { enum EPdfPageSize {
ePdfPageSize_A4, /**< DIN A4 */ ePdfPageSize_A0, /**< DIN A0 */
ePdfPageSize_Letter, /**< Letter */ ePdfPageSize_A1, /**< DIN A1 */
ePdfPageSize_Legal, /**< Legal */ ePdfPageSize_A2, /**< DIN A2 */
ePdfPageSize_A3, /**< A3 */ ePdfPageSize_A3, /**< DIN A3 */
ePdfPageSize_A4, /**< DIN A4 */
ePdfPageSize_Unknown = 0xff ePdfPageSize_A5, /**< DIN A5 */
ePdfPageSize_A6, /**< DIN A6 */
ePdfPageSize_Letter, /**< Letter */
ePdfPageSize_Legal, /**< Legal */
ePdfPageSize_Tabloid /**< Tabloid */
}; };
/** /**
* Enum holding the supported of types of "PageModes" * Enum holding the supported of types of "PageModes"
* that define which (if any) of the "panels" are opened * that define which (if any) of the "panels" are opened
* in Acrobat when the document is opened. * in Acrobat when the document is opened.
* *
* \see PdfDocument * \see PdfDocument
*/ */
typedef enum EPdfPageMode { enum EPdfPageMode {
ePdfPageModeDontCare, ePdfPageModeDontCare,
ePdfPageModeUseNone, ePdfPageModeUseNone,
ePdfPageModeUseThumbs, ePdfPageModeUseThumbs,
ePdfPageModeUseBookmarks, ePdfPageModeUseBookmarks,
ePdfPageModeFullScreen, ePdfPageModeFullScreen,
ePdfPageModeUseOC, ePdfPageModeUseOC,
ePdfPageModeUseAttachments, ePdfPageModeUseAttachments
ePdfPageModeUnknown = 0xff
}; };
/** /**
* Enum holding the supported of types of "PageLayouts" * Enum holding the supported of types of "PageLayouts"
* that define how Acrobat will display the pages in * that define how Acrobat will display the pages in
* relation to each other * relation to each other
* *
* \see PdfDocument * \see PdfDocument
*/ */
typedef enum EPdfPageLayout { enum EPdfPageLayout {
ePdfPageLayoutIgnore, ePdfPageLayoutIgnore,
ePdfPageLayoutDefault, ePdfPageLayoutDefault,
ePdfPageLayoutSinglePage, ePdfPageLayoutSinglePage,
ePdfPageLayoutOneColumn, ePdfPageLayoutOneColumn,
ePdfPageLayoutTwoColumnLeft, ePdfPageLayoutTwoColumnLeft,
ePdfPageLayoutTwoColumnRight, ePdfPageLayoutTwoColumnRight,
ePdfPageLayoutTwoPageLeft, ePdfPageLayoutTwoPageLeft,
ePdfPageLayoutTwoPageRight, ePdfPageLayoutTwoPageRight
ePdfPageLayoutUnknown = 0xff
}; };
/** /**
*/ */
const bool ePdfCreateObject = true; const bool ePdfCreateObject = true;
const bool ePdfDontCreateObject = false; const bool ePdfDontCreateObject = false;
// data structures
struct TXRefEntry {
long lOffset;
long lGeneration;
char cUsed;
bool bParsed;
};
typedef std::vector<TXRefEntry> TVecOffsets;
typedef TVecOffsets::iterator TIVecOffsets;
typedef TVecOffsets::const_iterator TCIVecOffsets;
// character constants // character constants
#define MAX_PDF_VERSION_STRING_INDEX 6 #define MAX_PDF_VERSION_STRING_INDEX 7
// We use fixed bounds two dimensional arrays here so that // We use fixed bounds two dimensional arrays here so that
// they go into the const data section of the library. // they go into the const data section of the library.
static const char s_szPdfVersions[][9] = { static const char s_szPdfVersions[][9] = {
"%PDF-1.0", "%PDF-1.0",
"%PDF-1.1", "%PDF-1.1",
"%PDF-1.2", "%PDF-1.2",
"%PDF-1.3", "%PDF-1.3",
"%PDF-1.4", "%PDF-1.4",
"%PDF-1.5", "%PDF-1.5",
"%PDF-1.6" "%PDF-1.6",
"%PDF-1.7"
}; };
static const char s_szPdfVersionNums[][4] = { static const char s_szPdfVersionNums[][4] = {
"1.0", "1.0",
"1.1", "1.1",
"1.2", "1.2",
"1.3", "1.3",
"1.4", "1.4",
"1.5", "1.5",
"1.6" "1.6",
"1.7"
}; };
/// PDF Reference, Section 3.1.1, Table 3.1, White-space characters /// PDF Reference, Section 3.1.1, Table 3.1, White-space characters
const int s_nNumWhiteSpaces = 6; const int s_nNumWhiteSpaces = 6;
const char s_cWhiteSpaces[] = { const char s_cWhiteSpaces[] = {
0x00, // NULL 0x00, // NULL
0x09, // TAB 0x09, // TAB
0x0A, // Line Feed 0x0A, // Line Feed
0x0C, // Form Feed 0x0C, // Form Feed
0x0D, // Carriage Return 0x0D, // Carriage Return
 End of changes. 31 change blocks. 
59 lines changed or deleted 69 lines changed or added


 PdfDestination.h   PdfDestination.h 
skipping to change at line 35 skipping to change at line 35
#include "PdfArray.h" #include "PdfArray.h"
#include "PdfReference.h" #include "PdfReference.h"
namespace PoDoFo { namespace PoDoFo {
class PdfAction; class PdfAction;
class PdfPage; class PdfPage;
class PdfRect; class PdfRect;
typedef enum EPdfDestinationFit { enum EPdfDestinationFit {
ePdfDestinationFit_Fit, ePdfDestinationFit_Fit,
ePdfDestinationFit_FitH, ePdfDestinationFit_FitH,
ePdfDestinationFit_FitV, ePdfDestinationFit_FitV,
ePdfDestinationFit_FitB, ePdfDestinationFit_FitB,
ePdfDestinationFit_FitBH, ePdfDestinationFit_FitBH,
ePdfDestinationFit_FitBV, ePdfDestinationFit_FitBV,
ePdfDestinationFit_Unknown = 0xFF ePdfDestinationFit_Unknown = 0xFF
}; };
skipping to change at line 126 skipping to change at line 126
/** Get access to the internal object /** Get access to the internal object
* This is an overloaded member function. * This is an overloaded member function.
* *
* \returns the internal PdfObject * \returns the internal PdfObject
*/ */
inline const PdfObject* GetObject() const; inline const PdfObject* GetObject() const;
/** Adds this destination to an dictionary. /** Adds this destination to an dictionary.
* This method handles the all the complexities of making sure it's ad ded correctly * This method handles the all the complexities of making sure it's ad ded correctly
* *
* If this destination is empty. Nothing will be added.
*
* \param dictionary the destination will be added to this dictionary * \param dictionary the destination will be added to this dictionary
*/ */
void AddToDictionary( PdfDictionary & dictionary ) const; void AddToDictionary( PdfDictionary & dictionary ) const;
private: private:
static const long s_lNumDestinations; static const long s_lNumDestinations;
static const char* s_names[]; static const char* s_names[];
PdfArray m_array; PdfArray m_array;
PdfObject* m_pObject; PdfObject* m_pObject;
 End of changes. 2 change blocks. 
1 lines changed or deleted 3 lines changed or added


 PdfDictionary.h   PdfDictionary.h 
skipping to change at line 63 skipping to change at line 63
/** Asignment operator. /** Asignment operator.
* Asign another PdfDictionary to this dictionary. This is a deep copy ; * Asign another PdfDictionary to this dictionary. This is a deep copy ;
* all elements of the source dictionary are duplicated. * all elements of the source dictionary are duplicated.
* *
* \param rhs the PdfDictionary to copy. * \param rhs the PdfDictionary to copy.
* *
* \return this PdfDictionary * \return this PdfDictionary
*/ */
const PdfDictionary & operator=( const PdfDictionary & rhs ); const PdfDictionary & operator=( const PdfDictionary & rhs );
/**
* Comparison operator. If this dictionary contains all the same keys
* as the other dictionary, and for each key the values compare equal,
* the dictionaries are considered equal.
*/
bool operator==( const PdfDictionary& rhs ) const;
/**
* \see operator==
*/
inline bool operator!=( const PdfDictionary& rhs ) const;
/** Removes all keys from the dictionary /** Removes all keys from the dictionary
*/ */
void Clear(); void Clear();
/** Add a key to the dictionary. If an existing key of this name exists , its /** Add a key to the dictionary. If an existing key of this name exists , its
* value is replaced and the old value object will be deleted. The pas sed * value is replaced and the old value object will be deleted. The pas sed
* object is copied. * object is copied.
* *
* \param identifier the key is identified by this name in the diction ary * \param identifier the key is identified by this name in the diction ary
* \param rObject a variant object containing the data. The object is copied. * \param rObject a variant object containing the data. The object is copied.
skipping to change at line 136 skipping to change at line 148
* *
* \param identifier the name of the key to delete * \param identifier the name of the key to delete
* *
* \returns true if the key was found in the object and was removed if * \returns true if the key was found in the object and was removed if
* there was is no key with this name, false is returned. * there was is no key with this name, false is returned.
*/ */
bool RemoveKey( const PdfName & identifier ); bool RemoveKey( const PdfName & identifier );
/** Write the complete dictionary to a file. \param pDevice write the /** Write the complete dictionary to a file. \param pDevice write the
* object to this device \returns ErrOk on success * object to this device \returns ErrOk on success
*
* \param pEncrypt an encryption object which is used to encrypt this
object
* or NULL to not encrypt this object
*/ */
inline void Write( PdfOutputDevice* pDevice ) const; inline void Write( PdfOutputDevice* pDevice, const PdfEncrypt* pEncrypt = NULL ) const;
/** Write the complete dictionary to a file. \param pDevice write the /** Write the complete dictionary to a file. \param pDevice write the
* object to this device \param keyStop if not KeyNull and a key == key Stop * object to this device \param keyStop if not KeyNull and a key == key Stop
* is found writing will stop right before this key! \returns ErrOk on * is found writing will stop right before this key! \returns ErrOk on
* success * success
*
* \param pEncrypt an encryption object which is used to encrypt this
object
* or NULL to not encrypt this object
*/ */
void Write( PdfOutputDevice* pDevice, const PdfName & keyStop = void Write( PdfOutputDevice* pDevice, const PdfEncrypt* pEncrypt, const
PdfName::KeyNull ) const; PdfName & keyStop =
PdfName::KeyNull ) const;
/** Get access to the internal map of keys. /** Get access to the internal map of keys.
* *
* \returns all keys of this dictionary * \returns all keys of this dictionary
*/ */
inline const TKeyMap & GetKeys() const; inline const TKeyMap & GetKeys() const;
/** Get access to the internal map of keys. \returns all keys of this /** Get access to the internal map of keys. \returns all keys of this
* dictionary * dictionary
*/ */
skipping to change at line 185 skipping to change at line 203
// //
// ----------------------------------------------------- // -----------------------------------------------------
TKeyMap & PdfDictionary::GetKeys() TKeyMap & PdfDictionary::GetKeys()
{ {
return m_mapKeys; return m_mapKeys;
} }
// ----------------------------------------------------- // -----------------------------------------------------
// //
// ----------------------------------------------------- // -----------------------------------------------------
void PdfDictionary::Write( PdfOutputDevice* pDevice ) const void PdfDictionary::Write( PdfOutputDevice* pDevice, const PdfEncrypt* pEnc
rypt ) const
{
this->Write( pDevice, pEncrypt, PdfName::KeyNull );
}
// -----------------------------------------------------
//
// -----------------------------------------------------
bool PdfDictionary::operator!=( const PdfDictionary& rhs ) const
{ {
this->Write( pDevice, PdfName::KeyNull ); return !(*this == rhs);
} }
}; };
#endif // _PDF_DICTIONARY_H_ #endif // _PDF_DICTIONARY_H_
 End of changes. 7 change blocks. 
5 lines changed or deleted 35 lines changed or added


 PdfDocument.h   PdfDocument.h 
skipping to change at line 26 skipping to change at line 26
* License along with this program; if not, write to the * * License along with this program; if not, write to the *
* Free Software Foundation, Inc., * * Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
************************************************************************** */ ************************************************************************** */
#ifndef _PDF_DOCUMENT_H_ #ifndef _PDF_DOCUMENT_H_
#define _PDF_DOCUMENT_H_ #define _PDF_DOCUMENT_H_
#include "PdfDefines.h" #include "PdfDefines.h"
#include "PdfFontCache.h" #include "PdfFontCache.h"
#include "PdfInfo.h"
#include "PdfObject.h" #include "PdfObject.h"
#include "PdfParser.h" #include "PdfParser.h"
#include "PdfWriter.h" #include "PdfWriter.h"
namespace PoDoFo { namespace PoDoFo {
class PdfAcroForm; class PdfAcroForm;
class PdfDestination; class PdfDestination;
class PdfDictionary; class PdfDictionary;
class PdfFileSpec; class PdfFileSpec;
class PdfFont; class PdfFont;
class PdfInfo; class PdfInfo;
class PdfMemDocument;
class PdfNamesTree; class PdfNamesTree;
class PdfOutlines; class PdfOutlines;
class PdfPage; class PdfPage;
class PdfPagesTree; class PdfPagesTree;
class PdfRect; class PdfRect;
class PdfXObject;
/** PdfDocument is the core class for reading and manipulating /** PdfDocument is the core interface for working with PDF documents.
* PDF files and writing them back to disk.
* *
* PdfDocument provides easy access to the individual pages * PdfDocument provides easy access to the individual pages
* in the PDF file and to certain special dictionaries. * in the PDF file and to certain special dictionaries.
* *
* PdfDocument should be used whenever you want to change * PdfDocument cannot be used directly.
* the object structure of a PDF file. * Use PdfMemDocument whenever you want to change the object structure
* of a PDF file.
* *
* When you are only creating PDF files, please use PdfStreamedDocument * When you are only creating PDF files, please use PdfStreamedDocument
* which is usually faster for creating PDFs. * which is usually faster for creating PDFs.
* *
* \see PdfStreamedDocument * \see PdfStreamedDocument
* \see PdfParser * \see PdfMemDocument
* \see PdfWriter
*/ */
class PODOFO_API PdfDocument { class PODOFO_API PdfDocument {
friend class PdfWriter; friend class PdfWriter;
friend class PdfElement;
public: public:
/** Construct a new (empty) PdfDocument
*/
PdfDocument();
/** Construct a PdfDocument from an existing PDF (on disk)
* \param pszFilename filename of the file which is going to be parsed
/opened
*/
PdfDocument( const char* pszFilename );
/** Close down/destruct the PdfDocument /** Close down/destruct the PdfDocument
*/ */
virtual ~PdfDocument(); virtual ~PdfDocument();
/** Load a PdfDocument from a file
*
* \param pszFilename filename of the file which is going to be parsed
/opened
*/
void Load( const char* pszFilename );
/** Writes the complete document to a file
*
* \param pszFilename filename of the document
*
* \see Write
*
* This is an overloaded member function for your convinience.
*/
void Write( const char* pszFilename );
/** Writes the complete document to an output device
*
* \param pDevice write to this output device
*/
void Write( PdfOutputDevice* pDevice );
/** Set the PDF Version of the document. Has to be called before Write(
) to
* have an effect.
* \param eVersion version of the pdf document
*/
void SetPdfVersion( EPdfVersion eVersion ) { m_eVersion = eVersion;}
/** Get the PDF version of the document /** Get the PDF version of the document
* \returns EPdfVersion version of the pdf document * \returns EPdfVersion version of the pdf document
*/ */
EPdfVersion GetPdfVersion() const { return m_eVersion; } virtual EPdfVersion GetPdfVersion() const = 0;
/** Returns wether this PDF document is linearized, aka /** Returns wether this PDF document is linearized, aka
* weboptimized * weboptimized
* \returns true if the PDF document is linearized * \returns true if the PDF document is linearized
*/ */
bool IsLinearized() const { return m_bLinearized; } virtual bool IsLinearized() const = 0;
/** Get a reference to the sorted internal objects vector.
* \returns the internal objects vector.
*/
const PdfVecObjects & GetObjects() const { return m_vecObjects; }
/** Get a reference to the sorted internal objects vector.
* This is an overloaded function for your convinience.
* \returns the internal objects vector.
*/
PdfVecObjects & GetObjects() { return m_vecObjects; }
/** Get access to the internal Catalog dictionary
* or root object.
*
* \returns PdfObject the documents catalog or NULL
* if no catalog is available
*/
PdfObject* GetCatalog() const { return m_pCatalog; }
/** Get the trailer dictionary
* which can be written unmodified to a pdf file.
*/
const PdfObject* GetTrailer() const { return m_pTrailer; }
/** Get access to the internal Info dictionary /** Get access to the internal Info dictionary
* You can set the author, title etc. of the * You can set the author, title etc. of the
* document using the info dictionary. * document using the info dictionary.
* *
* \returns the info dictionary * \returns the info dictionary
*/ */
PdfInfo* GetInfo() const { return m_pInfo; } PdfInfo* GetInfo() const { return m_pInfo; }
/** Get access to the StructTreeRoot dictionary
* \returns PdfObject the StructTreeRoot dictionary
*/
PdfObject* GetStructTreeRoot() const { return GetNamedObjectFromCatalog
( "StructTreeRoot" ); }
/** Get access to the Metadata stream
* \returns PdfObject the Metadata stream (should be in XML, using XMP
grammar)
*/
PdfObject* GetMetadata() const { return GetNamedObjectFromCatalog( "Met
adata" ); }
/** Get access to the Outlines (Bookmarks) dictionary /** Get access to the Outlines (Bookmarks) dictionary
* The returned outlines object is owned by the PdfDocument. * The returned outlines object is owned by the PdfDocument.
* *
* \returns the Outlines/Bookmarks dictionary * \returns the Outlines/Bookmarks dictionary
*/ */
PdfOutlines* GetOutlines( bool bCreate = ePdfCreateObject ); PdfOutlines* GetOutlines( bool bCreate = ePdfCreateObject );
/** Get access to the Names dictionary (where all the named objects are stored) /** Get access to the Names dictionary (where all the named objects are stored)
* The returned PdfNamesTree object is owned by the PdfDocument. * The returned PdfNamesTree object is owned by the PdfDocument.
* *
skipping to change at line 194 skipping to change at line 125
/** Get the total number of pages in a document /** Get the total number of pages in a document
* \returns int number of pages * \returns int number of pages
*/ */
int GetPageCount() const; int GetPageCount() const;
/** Get the PdfPage for a specific page in a document /** Get the PdfPage for a specific page in a document
* The returned page is owned by the PdfDocument * The returned page is owned by the PdfDocument
* and will get deleted along with it! * and will get deleted along with it!
* *
* \param nIndex which page (0-based) * \param nIndex which page (0-based)
* \returns a pointer to a PdfPage for the requested page * \returns a pointer to a PdfPage for the requested page.
* The returned object is owned by the PdfDocument.
*/ */
PdfPage* GetPage( int nIndex ) const; PdfPage* GetPage( int nIndex ) const;
/** Creates a PdfFont object /** Creates a PdfFont object
* \param pszFontName name of the font as it is known to the system * \param pszFontName name of the font as it is known to the system
* \param pEncoding the encoding of the font. The font will not take o wnership of this object.
* \param bEmbedd specifies whether this font should be embedded in th e PDF file. * \param bEmbedd specifies whether this font should be embedded in th e PDF file.
* Embedding fonts is usually a good idea. * Embedding fonts is usually a good idea.
*
* \returns PdfFont* a pointer to a new PdfFont object. * \returns PdfFont* a pointer to a new PdfFont object.
* The returned object is owned by the PdfDocument.
*/ */
PdfFont* CreateFont( const char* pszFontName, bool bEmbedd = true ); PdfFont* CreateFont( const char* pszFontName, const PdfEncoding * const
pEncoding = &PdfFont::WinAnsiEncoding,
bool bEmbedd = true );
/** Creates a PdfFont object /** Creates a PdfFont object
* \param face a valid freetype font handle * \param pszFontName name of the font as it is known to the system
* \param bBold if true search for a bold font
* \param bItalic if true search for an italic font
* \param pEncoding the encoding of the font. The font will not take o
wnership of this object.
* \param bEmbedd specifies whether this font should be embedded in th e PDF file. * \param bEmbedd specifies whether this font should be embedded in th e PDF file.
* Embedding fonts is usually a good idea. * Embedding fonts is usually a good idea.
* \param optional: pszFileName path to a valid font file
*
* \returns PdfFont* a pointer to a new PdfFont object. * \returns PdfFont* a pointer to a new PdfFont object.
*/ */
PdfFont* CreateFont( FT_Face face, bool bEmbedd = true ); PdfFont* CreateFont( const char* pszFontName, bool bBold, bool bItalic,
const PdfEncoding * const pEncoding = &PdfFont::Wi
nAnsiEncoding,
bool bEmbedd = true, const char* pszFileName = NUL
L );
/** Creates a PdfFont object
* \param face a valid freetype font handle (will be free'd by PoDoFo)
* \param pEncoding the encoding of the font. The font will not take o
wnership of this object.
* \param bEmbedd specifies whether this font should be embedded in th
e PDF file.
* Embedding fonts is usually a good idea.
* \returns PdfFont* a pointer to a new PdfFont object.
* The returned object is owned by the PdfDocument.
*/
PdfFont* CreateFont( FT_Face face, const PdfEncoding * const pEncoding
= &PdfFont::WinAnsiEncoding, bool bEmbedd = true );
/** Creates a new page object and inserts it into the internal /** Creates a new page object and inserts it into the internal
* page tree. * page tree.
* The returned page is owned by the PdfDocument * The returned page is owned by the PdfDocument
* and will get deleted along with it! * and will get deleted along with it!
* *
* \param rSize a PdfRect spezifying the size of the page (i.e the /Me diaBox key) in 1/1000th mm * \param rSize a PdfRect spezifying the size of the page (i.e the /Me diaBox key) in 1/1000th mm
* \returns a pointer to a PdfPage object * \returns a pointer to a PdfPage object
*/ */
PdfPage* CreatePage( const PdfRect & rSize ); PdfPage* CreatePage( const PdfRect & rSize );
/** Appends another PdfDocument to this document /** Appends another PdfDocument to this document
* \param rDoc the document to append * \param rDoc the document to append
* \param bAppendAll specifies whether pages and outlines are appended too
* \returns this document * \returns this document
*/ */
const PdfDocument & Append( const PdfDocument & rDoc ); const PdfDocument & Append( const PdfMemDocument & rDoc, bool bAppendAl
l = true );
/** Fill an existing empty XObject from a page of another document
* \param pXObj pointer to the XOject
* \param rDoc the document to embedd into XObject
* \param nPage page-number to embedd into XObject
* \returns the bounding box
*/
PdfRect FillXObjectFromDocumentPage( PdfXObject * pXObj, const PdfMemDo
cument & rDoc, int nPage );
/** Attach a file to the document. /** Attach a file to the document.
* \param rFileSpec a file specification * \param rFileSpec a file specification
*/ */
void AttachFile( const PdfFileSpec & rFileSpec ); void AttachFile( const PdfFileSpec & rFileSpec );
/** Copies one or more pages from another PdfDocument to this document
* \param rDoc the document to append
* \param inFirstPage the first page number to copy (0-based)
* \param inNumPages the number of pages to copy
* \returns this document
*/
const PdfDocument & InsertPages( const PdfDocument & rDoc, int inFirstP
age, int inNumPages );
/** Deletes one or more pages from this document
* \param inFirstPage the first page number to delete (0-based)
* \param inNumPages the number of pages to delete
* \returns this document
*/
void DeletePages( int inFirstPage, int inNumPages );
/** Adds a PdfDestination into the global Names tree /** Adds a PdfDestination into the global Names tree
* with the specified name, optionally replacing one of the same name * with the specified name, optionally replacing one of the same name
* \param rDest the destination to be assigned * \param rDest the destination to be assigned
* \param rsName the name for the destination * \param rsName the name for the destination
*/ */
void AddNamedDestination( const PdfDestination& rDest, const PdfString & rsName ); void AddNamedDestination( const PdfDestination& rDest, const PdfString & rsName );
/** Sets the opening mode for a document /** Sets the opening mode for a document
* \param inMode which mode to set * \param inMode which mode to set
*/ */
void SetPageMode( EPdfPageMode inMode ) const; void SetPageMode( EPdfPageMode inMode );
/** Gets the opening mode for a document /** Gets the opening mode for a document
* \returns which mode is set * \returns which mode is set
*/ */
EPdfPageMode GetPageMode( void ) const; EPdfPageMode GetPageMode( void ) const;
/** Sets the opening mode for a document to be in full screen /** Sets the opening mode for a document to be in full screen
*/ */
void SetUseFullScreen( void ) const; void SetUseFullScreen( void );
/** Sets the page layout for a document /** Sets the page layout for a document
*/ */
void SetPageLayout( EPdfPageLayout inLayout ); void SetPageLayout( EPdfPageLayout inLayout );
/** Set the document's Viewer Preferences: /** Set the document's Viewer Preferences:
* Hide the toolbar in the viewer * Hide the toolbar in the viewer
*/ */
void SetHideToolbar( void ); void SetHideToolbar( void );
skipping to change at line 332 skipping to change at line 279
/** Set the document's Viewer Preferences: /** Set the document's Viewer Preferences:
* Set the language of the document * Set the language of the document
*/ */
void SetLanguage( const std::string& inLanguage ); void SetLanguage( const std::string& inLanguage );
/** Set the document's Viewer Preferences: /** Set the document's Viewer Preferences:
*/ */
void SetBindingDirection( PdfName& inDirection ); void SetBindingDirection( PdfName& inDirection );
private: /** Checks if printing this document is allowed.
* Every PDF consuming applications has to adhere this value!
*
* \returns true if you are allowed to print this document
*
* \see PdfEncrypt to set own document permissions.
*/
virtual bool IsPrintAllowed() const = 0;
/** Checks if modifiying this document (besides annotations, form field
s or changing pages) is allowed.
* Every PDF consuming applications has to adhere this value!
*
* \returns true if you are allowed to modfiy this document
*
* \see PdfEncrypt to set own document permissions.
*/
virtual bool IsEditAllowed() const = 0;
/** Checks if text and graphics extraction is allowed.
* Every PDF consuming applications has to adhere this value!
*
* \returns true if you are allowed to extract text and graphics from
this document
*
* \see PdfEncrypt to set own document permissions.
*/
virtual bool IsCopyAllowed() const = 0;
/** Checks if it is allowed to add or modify annotations or form fields
* Every PDF consuming applications has to adhere this value!
*
* \returns true if you are allowed to add or modify annotations or fo
rm fields
*
* \see PdfEncrypt to set own document permissions.
*/
virtual bool IsEditNotesAllowed() const = 0;
/** Checks if it is allowed to fill in existing form or signature field
s
* Every PDF consuming applications has to adhere this value!
*
* \returns true if you are allowed to fill in existing form or signat
ure fields
*
* \see PdfEncrypt to set own document permissions.
*/
virtual bool IsFillAndSignAllowed() const = 0;
/** Checks if it is allowed to extract text and graphics to support use
rs with disabillities
* Every PDF consuming applications has to adhere this value!
*
* \returns true if you are allowed to extract text and graphics to su
pport users with disabillities
*
* \see PdfEncrypt to set own document permissions.
*/
virtual bool IsAccessibilityAllowed() const = 0;
/** Checks if it is allowed to insert, create, rotate, delete pages or
add bookmarks
* Every PDF consuming applications has to adhere this value!
*
* \returns true if you are allowed to insert, create, rotate, delete
pages or add bookmarks
*
* \see PdfEncrypt to set own document permissions.
*/
virtual bool IsDocAssemblyAllowed() const = 0;
/** Checks if it is allowed to print a high quality version of this doc
ument
* Every PDF consuming applications has to adhere this value!
*
* \returns true if you are allowed to print a high quality version of
this document
*
* \see PdfEncrypt to set own document permissions.
*/
virtual bool IsHighPrintAllowed() const = 0;
protected:
/** Construct a new (empty) PdfDocument
*/
PdfDocument();
/** Set the info object containing meta information.
* Deletes any old info object.
*
* @param pInfo the new info object (will be owned by PdfDocument)
*/
void SetInfo( PdfInfo* pInfo );
/** Get access to the internal Catalog dictionary
* or root object.
*
* \returns PdfObject the documents catalog
*/
inline PdfObject* GetCatalog();
/** Get access to the internal Catalog dictionary
* or root object.
*
* \returns PdfObject the documents catalog
*/
inline const PdfObject* GetCatalog() const;
/** Set the catalog of this PdfDocument
* deleting the old one.
*
* @param pObject the new catalog object
* It will be owned by PdfDocument.
*/
inline void SetCatalog( PdfObject* pObject );
/** Get access to the internal trailer dictionary
* or root object.
*
* \returns PdfObject the documents catalog
*/
inline PdfObject* GetTrailer();
/** Get access to the internal trailer dictionary
* or root object.
*
* \returns PdfObject the documents catalog
*/
inline const PdfObject* GetTrailer() const;
/** Set the trailer of this PdfDocument
* deleting the old one.
*
* @param pObject the new trailer object
* It will be owned by PdfDocument.
*/
inline void SetTrailer( PdfObject* pObject );
/** Get access to the internal vector of objects
* or root object.
*
* \returns the vector of objects
*/
inline PdfVecObjects* GetObjects();
/** Get access to the internal vector of objects
* or root object.
*
* \returns the vector of objects
*/
inline const PdfVecObjects* GetObjects() const;
/** Get a dictioary from the catalog dictionary by its name. /** Get a dictioary from the catalog dictionary by its name.
* \param pszName will be converted into a PdfName * \param pszName will be converted into a PdfName
* \returns the dictionary if it was found or NULL * \returns the dictionary if it was found or NULL
*/ */
PdfObject* GetNamedObjectFromCatalog( const char* pszName ) const; PdfObject* GetNamedObjectFromCatalog( const char* pszName ) const;
/** Internal method for initializing the pages tree for this document /** Internal method for initializing the pages tree for this document
*/ */
void InitPagesTree(); void InitPagesTree();
/** Internal method to load all objects from a PdfParser object.
* The objects will be removed from the parser and are now
* owned by the PdfDocument.
*/
void InitFromParser( PdfParser* pParser );
/** Clear all internal variables
*/
void Clear();
/** Recursively changes every PdfReference in the PdfObject and in any child /** Recursively changes every PdfReference in the PdfObject and in any child
* that is either an PdfArray or a direct object. * that is either an PdfArray or a direct object.
* The reference is changed so that difference is added to the object number * The reference is changed so that difference is added to the object number
* if the reference. * if the reference.
* \param pObject object to change * \param pObject object to change
* \param difference add this value to every reference that is encount ered * \param difference add this value to every reference that is encount ered
*/ */
void FixObjectReferences( PdfObject* pObject, int difference ); void FixObjectReferences( PdfObject* pObject, int difference );
/** Low level APIs for setting a viewer preference /** Low level APIs for setting a viewer preference
* \param whichPrefs the dictionary key to set * \param whichPrefs the dictionary key to set
* \param the object to be set * \param the object to be set
*/ */
void SetViewerPreference( const PdfName& whichPref, const PdfObject & v void SetViewerPreference( const PdfName& whichPref, const PdfObject & v
alueObj ) const; alueObj );
void SetViewerPreference( const PdfName& whichPref, bool inValue ) cons void SetViewerPreference( const PdfName& whichPref, bool inValue );
t;
/** Clear all internal variables
* And reset PdfDocument to an intial state
*/
void Clear();
private: private:
// Prevent use of copy constructor and assignment operator. These meth ods // Prevent use of copy constructor and assignment operator. These meth ods
// should never be referenced (given that code referencing them outside // should never be referenced (given that code referencing them outside
// PdfDocument won't compile), and calling them will result in a link e rror // PdfDocument won't compile), and calling them will result in a link e rror
// as they're not defined. // as they're not defined.
explicit PdfDocument(const PdfDocument&); explicit PdfDocument(const PdfDocument&);
PdfDocument& operator=(const PdfDocument&); PdfDocument& operator=(const PdfDocument&);
bool m_bLinearized;
PdfVecObjects m_vecObjects; PdfVecObjects m_vecObjects;
PdfObject* m_pTrailer;
PdfObject* m_pCatalog;
PdfInfo* m_pInfo; PdfInfo* m_pInfo;
PdfOutlines* m_pOutlines; PdfOutlines* m_pOutlines;
PdfNamesTree* m_pNamesTree; PdfNamesTree* m_pNamesTree;
PdfPagesTree* m_pPagesTree; PdfPagesTree* m_pPagesTree;
PdfAcroForm* m_pAcroForms; PdfAcroForm* m_pAcroForms;
PdfObject* m_pTrailer;
PdfObject* m_pCatalog;
EPdfVersion m_eVersion; EPdfVersion m_eVersion;
PdfFontCache m_fontCache; PdfFontCache m_fontCache;
}; };
// ----------------------------------------------------- // -----------------------------------------------------
// //
// ----------------------------------------------------- // -----------------------------------------------------
inline PdfPagesTree* PdfDocument::GetPagesTree() const inline PdfPagesTree* PdfDocument::GetPagesTree() const
{ {
return m_pPagesTree; return m_pPagesTree;
} }
// -----------------------------------------------------
//
// -----------------------------------------------------
inline void PdfDocument::SetInfo( PdfInfo* pInfo )
{
delete m_pInfo;
m_pInfo = pInfo;
}
// -----------------------------------------------------
//
// -----------------------------------------------------
inline PdfObject* PdfDocument::GetCatalog()
{
return m_pCatalog;
}
// -----------------------------------------------------
//
// -----------------------------------------------------
inline const PdfObject* PdfDocument::GetCatalog() const
{
return m_pCatalog;
}
// -----------------------------------------------------
//
// -----------------------------------------------------
inline void PdfDocument::SetCatalog( PdfObject* pObject )
{
m_pCatalog = pObject; // m_pCatalog does not need to
// be reowned as it should
// alread by part of m_vecObjects
}
// -----------------------------------------------------
//
// -----------------------------------------------------
inline PdfObject* PdfDocument::GetTrailer()
{
return m_pTrailer;
}
// -----------------------------------------------------
//
// -----------------------------------------------------
inline const PdfObject* PdfDocument::GetTrailer() const
{
return m_pTrailer;
}
// -----------------------------------------------------
//
// -----------------------------------------------------
inline void PdfDocument::SetTrailer( PdfObject* pObject )
{
delete m_pTrailer;
m_pTrailer = pObject;
// Set owner so that GetIndirectKey will work
m_pTrailer->SetOwner( &m_vecObjects );
}
// -----------------------------------------------------
//
// -----------------------------------------------------
inline PdfVecObjects* PdfDocument::GetObjects()
{
return &m_vecObjects;
}
// -----------------------------------------------------
//
// -----------------------------------------------------
inline const PdfVecObjects* PdfDocument::GetObjects() const
{
return &m_vecObjects;
}
}; };
#endif // _PDF_DOCUMENT_H_ #endif // _PDF_DOCUMENT_H_
 End of changes. 33 change blocks. 
130 lines changed or deleted 300 lines changed or added


 PdfElement.h   PdfElement.h 
skipping to change at line 75 skipping to change at line 75
protected: protected:
/** Creates a new PdfElement /** Creates a new PdfElement
* \param pszType type entry of the elements object * \param pszType type entry of the elements object
* \param pParent parent vector of objects. * \param pParent parent vector of objects.
* Add a newly created object to this vector. * Add a newly created object to this vector.
*/ */
PdfElement( const char* pszType, PdfVecObjects* pParent ); PdfElement( const char* pszType, PdfVecObjects* pParent );
/** Creates a new PdfElement /** Creates a new PdfElement
* \param pszType type entry of the elements object * \param pszType type entry of the elements object
* \param pParent parent PdfStreamedDocument. * \param pParent parent PdfDocument.
* Add a newly created object to this vector. * Add a newly created object to this vector.
*/ */
PdfElement( const char* pszType, PdfStreamedDocument* pParent ); PdfElement( const char* pszType, PdfDocument* pParent );
/** Create a PdfElement from an existing PdfObject /** Create a PdfElement from an existing PdfObject
* \param pszType type entry of the elements object. * \param pszType type entry of the elements object.
* Throws an exception if the type in the * Throws an exception if the type in the
* PdfObject differs from pszType. * PdfObject differs from pszType.
* \param pObject pointer to the PdfObject that is modified * \param pObject pointer to the PdfObject that is modified
* by this PdfElement * by this PdfElement
*/ */
PdfElement( const char* pszType, PdfObject* pObject ); PdfElement( const char* pszType, PdfObject* pObject );
skipping to change at line 121 skipping to change at line 121
* *
* \param pszType the type as string * \param pszType the type as string
* \param ppTypes an array of strings containing * \param ppTypes an array of strings containing
* the string mapping of the index * the string mapping of the index
* \param lLen the length of the string array * \param lLen the length of the string array
* *
* \returns the index of the string in the array * \returns the index of the string in the array
*/ */
int TypeNameToIndex( const char* pszType, const char** ppTypes, long lL en ) const; int TypeNameToIndex( const char* pszType, const char** ppTypes, long lL en ) const;
/** Create a PdfObject in the parent of this PdfElement which
* might either be a PdfStreamedDocument, a PdfDocument or
* a PdfVecObjects
*
* Use this function in an own subclass of PdfElement to create new
* PdfObjects.
*
* \param pszType an optional /Type key of the created object
*
* \returns a PdfObject which is owned by the parent
*/
PdfObject* CreateObject( const char* pszType = NULL );
protected: protected:
PdfObject* m_pObject; PdfObject* m_pObject;
}; };
// ----------------------------------------------------- // -----------------------------------------------------
// //
// ----------------------------------------------------- // -----------------------------------------------------
inline PdfObject* PdfElement::GetObject() inline PdfObject* PdfElement::GetObject()
{ {
return m_pObject; return m_pObject;
 End of changes. 3 change blocks. 
2 lines changed or deleted 15 lines changed or added


 PdfEncrypt.h   PdfEncrypt.h 
skipping to change at line 26 skipping to change at line 26
* License along with this program; if not, write to the * * License along with this program; if not, write to the *
* Free Software Foundation, Inc., * * Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
*************************************************************************** / *************************************************************************** /
#ifndef _PDFENCRYPT_H_ #ifndef _PDFENCRYPT_H_
#define _PDFENCRYPT_H_ #define _PDFENCRYPT_H_
#include "PdfDefines.h" #include "PdfDefines.h"
#include "PdfString.h" #include "PdfString.h"
#include "PdfReference.h"
namespace PoDoFo { namespace PoDoFo {
class PdfDictionary;
class PdfInputStream;
class PdfRijndael;
class PdfObject;
class PdfOutputStream;
/// Class representing PDF encryption methods. (For internal use only) /// Class representing PDF encryption methods. (For internal use only)
/// Based on code from Ulrich Telle: http://wxcode.sourceforge.net/componen ts/wxpdfdoc/ /// Based on code from Ulrich Telle: http://wxcode.sourceforge.net/componen ts/wxpdfdoc/
/// Original Copyright header:
///////////////////////////////////////////////////////////////////////////
////
// Name: pdfencrypt.h
// Purpose:
// Author: Ulrich Telle
// Modified by:
// Created: 2005-08-16
// Copyright: (c) Ulrich Telle
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////
////
/** A class that is used to encrypt a PDF file and
* set document permisions on the PDF file.
*
* As a user of this class, you have only to instanciate a
* object of this class and pass it to PdfWriter, PdfMemDocument,
* PdfStreamedDocument or PdfImmediateWriter.
* You do not have to call any other method of this class. The above
* classes know how to handle encryption using Pdfencrypt.
*
*/
class PODOFO_API PdfEncrypt class PODOFO_API PdfEncrypt
{ {
public: public:
typedef enum {
PdfKeyLength40 = 40,
PdfKeyLength56 = 56,
PdfKeyLength80 = 80
} PdfKeyLength;
typedef enum {
PdfPermPrint = 0x00000004,
PdfPermEdit = 0x00000008,
PdfPermCopy = 0x00000010,
PdfPermEditNotes = 0x00000020,
PdfPermFillAndSign = 0x00000100,
PdfPermAccessible = 0x00000200,
PdfPermDocAssembly = 0x00000400,
PdfPermHighPrint = 0x00000800
} PdfPerms;
public:
/// Default constructor
PdfEncrypt();
/// Default destructor /** A enum specifying a valid keylength for a PDF encryption key.
virtual ~PdfEncrypt(); * Keys must be in the range 40 to 128 bit and have to be a
* multiple of 8.
/// Generate encryption key from user and owner passwords and protection *
key * Adobe Reader supports only keys with 40 or 128bit!
void GenerateEncryptionKey(const std::string& userPassword, */
const std::string& ownerPassword, typedef enum {
PdfKeyLength inKeyL ePdfKeyLength_40 = 40,
ength, ePdfKeyLength_56 = 56,
int protection); ePdfKeyLength_80 = 80,
ePdfKeyLength_96 = 96,
ePdfKeyLength_128 = 128
} EPdfKeyLength;
/** Set user permissions/restrictions on a document
*/
typedef enum {
ePdfPermissions_Print = 0x00000004, ///< Allow printing t
he document
ePdfPermissions_Edit = 0x00000008, ///< Allow modifying
the document besides annotations, form fields or chaning pages
ePdfPermissions_Copy = 0x00000010, ///< Allow text and g
raphic extraction
ePdfPermissions_EditNotes = 0x00000020, ///< Add or modify te
xt annoations or form fields (if ePdfPermissions_Edit is set also allow to
create interactive form fields including signature)
ePdfPermissions_FillAndSign = 0x00000100, ///< Fill in existing
form or signature fields
ePdfPermissions_Accessible = 0x00000200, ///< Extract text and
graphics to support user with disabillities
ePdfPermissions_DocAssembly = 0x00000400, ///< Assemble the doc
ument: insert, create, rotate delete pages or add bookmarks
ePdfPermissions_HighPrint = 0x00000800 ///< Print a high res
olution version of the document
} EPdfPermissions;
typedef enum {
ePdfEncryptAlgorithm_RC4V1, ///< RC4 Version 1 encryption using a 4
0bit key
ePdfEncryptAlgorithm_RC4V2, ///< RC4 Version 2 encryption using a k
ey with 40-128bit
ePdfEncryptAlgorithm_AESV2 ///< AES encryption with an 128 bit key
(PDF1.6)
} EPdfEncryptAlgorithm;
/** Create a PdfEncrypt object which can be used to encrypt a PDF file.
*
* \param userPassword the user password (if empty the user does not h
ave
* to enter a password to open the document)
* \param ownerPassword the owner password
* \param protection several EPdfPermissions values or'ed together to
set
* the users permissions for this document
* \param eRevision the revision of the encryption algorithm to be use
d
* \param eKeyLength the length of the encryption key ranging from 40
to 128 bits
* (only used if eAlgorithm == ePdfEncryptAlgorithm_
RC4V2)
*
* \see GenerateEncryptionKey with the documentID to generate the real
* encryption key using this information
*/
static PdfEncrypt * CreatePdfEncrypt( const std::string & userPassword,
const std::string & ownerPassword
,
int protection = ePdfPermissions_
Print |
ePdfPermissions_Edit |
ePdfPermissions_Copy |
ePdfPermissions_EditNotes |
ePdfPermissions_FillAndSign |
ePdfPermissions_Accessible |
ePdfPermissions_DocAssembly |
ePdfPermissions_HighPrint,
EPdfEncryptAlgorithm eAlgorithm =
ePdfEncryptAlgorithm_RC4V1,
EPdfKeyLength eKeyLength = ePdfKe
yLength_40 );
/** Initialize a PdfEncrypt object from an encryption dictionary in a P
DF file.
*
* This is required for encrypting a PDF file, but handled internally
in PdfParser
* for you.
*
* \param pObject a PDF encryption dictionary
*/
static PdfEncrypt * CreatePdfEncrypt( const PdfObject* pObject );
/** Copy constructor
*
* \param rhs another PdfEncrypt object which is copied
*/
static PdfEncrypt * CreatePdfEncrypt( const PdfEncrypt & rhs );
/** Destruct the PdfEncrypt object
*/
virtual ~PdfEncrypt();
/** Assignment operator
*
* \param rhs another PdfEncrypt object which is copied
*/
const PdfEncrypt & operator=( const PdfEncrypt & rhs );
/** Generate encryption key from user and owner passwords and protectio
n key
*
* \param documentId the documentId of the current document
*/
void GenerateEncryptionKey(const PdfString & documentId);
/** Fill all keys into a encryption dictionary.
* This dictionary is usually added to the PDF files trailer
* under the /Encryption key.
*
* \param rDictionary an empty dictionary which is filled with informa
tion about
* the used encryption algorithm
*/
virtual void CreateEncryptionDictionary( PdfDictionary & rDictionary )
const = 0;
/** Create a PdfOutputStream that encrypts all data written to
* it using the current settings of the PdfEncrypt object.
*
* Warning: Currently only RC4 based encryption is supported using out
put streams!
*
* \param pOutputStream the created PdfOutputStream writes all encrypt
ed
* data to this output stream.
*
* \returns a PdfOutputStream that encryts all data.
*/
virtual PdfOutputStream* CreateEncryptionOutputStream( PdfOutputStream*
pOutputStream ) = 0;
/** Create a PdfInputStream that decrypts all data read from
* it using the current settings of the PdfEncrypt object.
*
* Warning: Currently only RC4 based encryption is supported using out
put streams!
*
* \param pInputStream the created PdfInputStream reads all decrypted
* data to this input stream.
*
* \returns a PdfInputStream that decrypts all data.
*/
virtual PdfInputStream* CreateEncryptionInputStream( PdfInputStream* pI
nputStream ) = 0;
/**
* Tries to authenticate a user using either the user or owner password
*
* \param password owner or user password
* \param documentId the documentId of the PDF file
*
* \returns true if either the owner or user password matches password
*/
bool Authenticate( const std::string & password, const PdfString & docu
mentId );
/** Checks if printing this document is allowed.
* Every PDF consuming applications has to adhere this value!
*
* \returns true if you are allowed to print this document
*
* \see PdfEncrypt to set own document permissions.
*/
inline bool IsPrintAllowed() const;
/** Checks if modifiying this document (besides annotations, form field
s or changing pages) is allowed.
* Every PDF consuming applications has to adhere this value!
*
* \returns true if you are allowed to modfiy this document
*
* \see PdfEncrypt to set own document permissions.
*/
inline bool IsEditAllowed() const;
/** Checks if text and graphics extraction is allowed.
* Every PDF consuming applications has to adhere this value!
*
* \returns true if you are allowed to extract text and graphics from
this document
*
* \see PdfEncrypt to set own document permissions.
*/
inline bool IsCopyAllowed() const;
/** Checks if it is allowed to add or modify annotations or form fields
* Every PDF consuming applications has to adhere this value!
*
* \returns true if you are allowed to add or modify annotations or fo
rm fields
*
* \see PdfEncrypt to set own document permissions.
*/
inline bool IsEditNotesAllowed() const;
/** Checks if it is allowed to fill in existing form or signature field
s
* Every PDF consuming applications has to adhere this value!
*
* \returns true if you are allowed to fill in existing form or signat
ure fields
*
* \see PdfEncrypt to set own document permissions.
*/
inline bool IsFillAndSignAllowed() const;
/** Checks if it is allowed to extract text and graphics to support use
rs with disabillities
* Every PDF consuming applications has to adhere this value!
*
* \returns true if you are allowed to extract text and graphics to su
pport users with disabillities
*
* \see PdfEncrypt to set own document permissions.
*/
inline bool IsAccessibilityAllowed() const;
/** Checks if it is allowed to insert, create, rotate, delete pages or
add bookmarks
* Every PDF consuming applications has to adhere this value!
*
* \returns true if you are allowed to insert, create, rotate, delete
pages or add bookmarks
*
* \see PdfEncrypt to set own document permissions.
*/
inline bool IsDocAssemblyAllowed() const;
/** Checks if it is allowed to print a high quality version of this doc
ument
* Every PDF consuming applications has to adhere this value!
*
* \returns true if you are allowed to print a high quality version of
this document
*
* \see PdfEncrypt to set own document permissions.
*/
inline bool IsHighPrintAllowed() const;
bool Authenticate(const std::string & documentID, const std::string & p
assword,
const std::string & uValue, const std::string & oValu
e,
int pValue, int lengthValue, int rValue);
/// Get the U object value (user) /// Get the U object value (user)
unsigned char* GetUvalue() { return m_Uvalue; } const unsigned char* GetUValue() const { return m_uValue; }
/// Get the O object value (owner) /// Get the O object value (owner)
unsigned char* GetOvalue() { return m_Ovalue; } const unsigned char* GetOValue() const { return m_oValue; }
/// Get the P object value (protection) /// Get the P object value (protection)
int GetPvalue() { return m_Pvalue; } int GetPValue() const { return m_pValue; }
/// Get the revision number of the encryption method
int GetRevision() const { return m_rValue; }
/// Get the key length of the encryption key in bits
int GetKeyLength() const { return m_keyLength*8; }
/// Encrypt a wxString
void Encrypt( std::string & str, int inputLen ) const;
/// Encrypt a character string /// Encrypt a character string
void Encrypt(int n, unsigned char* str, int len); virtual void Encrypt(unsigned char* str, int len) const = 0;
/// Calculate stream size
virtual int CalculateStreamLength(int length) const;
/// Calculate stream offset
virtual int CalculateStreamOffset() const;
/** Create a PdfString of MD5 data generated from a buffer in memory. /** Create a PdfString of MD5 data generated from a buffer in memory.
* \param pBuffer the buffer of which to calculate the MD5 sum * \param pBuffer the buffer of which to calculate the MD5 sum
* \param nLength the length of the buffer * \param nLength the length of the buffer
* *
* \returns an MD5 sum as PdfString * \returns an MD5 sum as PdfString
*/ */
static PdfString GetMD5String( const unsigned char* pBuffer, int nLength ); static PdfString GetMD5String( const unsigned char* pBuffer, int nLength );
/** Set the reference of the object that is currently encrypted.
*
* This value will be used in following calls of Encrypt
* to encrypt the object.
*
* \see Encrypt
*/
inline void SetCurrentReference( const PdfReference & rRef );
protected: protected:
PdfEncrypt() {};
// copy constructor
PdfEncrypt( const PdfEncrypt & rhs );
/// Pad a password to 32 characters /// Pad a password to 32 characters
void PadPassword(const std::string& password, unsigned char pswd[32]); void PadPassword(const std::string& password, unsigned char pswd[32]);
/// Compute owner key
void ComputeOwnerKey(unsigned char userPad[32], unsigned char ownerPad[32
],
int keylength, int revision, bool authenticate,
unsigned char ownerKey[32]);
/// Compute encryption key and user key
void ComputeEncryptionKey(const std::string & documentID,
unsigned char userPad[32], unsigned char ownerK
ey[32],
int pValue, int keyLength, int revision,
unsigned char userKey[32]);
/// Check two keys for equality
bool CheckKey(unsigned char key1[32], unsigned char key2[32]);
/// RC4 encryption /// RC4 encryption
void RC4(unsigned char* key, int keylen, void RC4(unsigned char* key, int keylen,
unsigned char* textin, int textlen, unsigned char* textin, int textlen,
unsigned char* textout); unsigned char* textout);
/// Calculate the binary MD5 message digest of the given data /// Calculate the binary MD5 message digest of the given data
static void GetMD5Binary(const unsigned char* data, int length, unsigned char* digest); static void GetMD5Binary(const unsigned char* data, int length, unsigned char* digest);
/// Generate initial vector
void GenerateInitialVector(unsigned char iv[16]);
/** Create the encryption key for the current object.
*
* \param pObjkey pointer to an array of at least MD5_HASHBYTES (=16) by
tes length
* \param pnKeyLen pointer to an integer where the actual keylength is s
tored.
*/
void CreateObjKey( unsigned char objkey[16], int* pnKeyLen ) const;
EPdfEncryptAlgorithm m_eAlgorithm; ///< The used encryption algorithm
int m_keyLength; ///< Length of encryption key
int m_rValue; ///< Revision
int m_pValue; ///< P entry in pdf document
EPdfKeyLength m_eKeyLength; ///< The key length
std::string m_userPass; ///< User password
std::string m_ownerPass; ///< Owner password
unsigned char m_rc4key[16]; ///< last RC4 key
unsigned char m_rc4last[256]; ///< last RC4 state table
unsigned char m_uValue[32]; ///< U entry in pdf document
unsigned char m_oValue[32]; ///< O entry in pdf document
private: private:
unsigned char m_Uvalue[32]; ///< U entry in pdf document unsigned char m_encryptionKey[16]; ///< Encryption key
unsigned char m_Ovalue[32]; ///< O entry in pdf document
int m_Pvalue; ///< P entry in pdf document PdfReference m_curReference; ///< Reference of the current PdfObj
unsigned char m_encryptionKey[5]; ///< Encryption key ect
unsigned char m_rc4key[5]; ///< last RC4 key
unsigned char m_rc4last[256]; ///< last RC4 state table std::string m_documentId; ///< DocumentID of the current docum
ent
}; };
/** A class that is used to encrypt a PDF file (AES-128)
*
* Client code is working only with PdfEncrypt class and knows nothing
* about PdfEncryptAES, it is created through CreatePdfEncrypt factory
method
*
*/
class PdfEncryptAES : public PdfEncrypt {
public:
/*
* Constructors of PdfEncryptAES
*/
PdfEncryptAES(PdfString oValue, PdfString uValue, int pValue);
PdfEncryptAES(const PdfEncrypt & rhs);
PdfEncryptAES( const std::string & userPassword,
const std::string & ownerPassword,
int protection = ePdfPermissions_Print |
ePdfPermissions_Edit |
ePdfPermissions_Copy |
ePdfPermissions_EditNotes |
ePdfPermissions_FillAndSign |
ePdfPermissions_Accessible |
ePdfPermissions_DocAssembly |
ePdfPermissions_HighPrint
);
/*
* Destruct PdfEncryptAES object
*/
~PdfEncryptAES();
void Encrypt(unsigned char* str, int len) const;
/// Calculate stream offset
int CalculateStreamOffset() const;
PdfInputStream* CreateEncryptionInputStream( PdfInputStream* pInputS
tream );
PdfOutputStream* CreateEncryptionOutputStream( PdfOutputStream* pOut
putStream );
int CalculateStreamLength(int length) const;
void CreateEncryptionDictionary( PdfDictionary & rDictionary ) const
;
private:
/// AES encryption
void AES(unsigned char* key, int keylen,
unsigned char* textin, int textlen,
unsigned char* textout);
PdfRijndael* m_aes; ///< AES encryptor
}; };
/** A class that is used to encrypt a PDF file (RC4 40-bit and 128-bit)
*
* Client code is working only with PdfEncrypt class and knows nothing
* about PdfEncryptRC4, it is created through CreatePdfEncrypt factory
method
*
*/
class PdfEncryptRC4 : public PdfEncrypt {
public:
/*
* Constructors of PdfEncryptRC4 objects
*/
PdfEncryptRC4(PdfString oValue, PdfString uValue,
int pValue, int rValue, EPdfEncryptAlgorithm eAlgorithm, lon
g length);
PdfEncryptRC4( const std::string & userPassword,
const std::string & ownerPassword,
int protection = ePdfPermissions_Print |
ePdfPermissions_Edit |
ePdfPermissions_Copy |
ePdfPermissions_EditNotes |
ePdfPermissions_FillAndSign |
ePdfPermissions_Accessible |
ePdfPermissions_DocAssembly |
ePdfPermissions_HighPrint,
EPdfEncryptAlgorithm eAlgorithm = ePdfEncryptAlgorithm_RC
4V1,
EPdfKeyLength eKeyLength = ePdfKeyLength_40 );
PdfEncryptRC4(const PdfEncrypt & rhs) : PdfEncrypt(rhs) {}
void Encrypt(unsigned char* str, int len) const;
PdfInputStream* CreateEncryptionInputStream( PdfInputStream* pInputS
tream );
PdfOutputStream* CreateEncryptionOutputStream( PdfOutputStream* pOut
putStream );
void CreateEncryptionDictionary( PdfDictionary & rDictionary ) const
;
};
// -----------------------------------------------------
//
// -----------------------------------------------------
void PdfEncrypt::SetCurrentReference( const PdfReference & rRef )
{
m_curReference = rRef;
}
// -----------------------------------------------------
//
// -----------------------------------------------------
bool PdfEncrypt::IsPrintAllowed() const
{
// TODO: Check is this is correct (+/- 1 required ???)
return (m_pValue & ePdfPermissions_Print) == ePdfPermissions_Print;
}
// -----------------------------------------------------
//
// -----------------------------------------------------
bool PdfEncrypt::IsEditAllowed() const
{
return (m_pValue & ePdfPermissions_Edit) == ePdfPermissions_Edit;
}
// -----------------------------------------------------
//
// -----------------------------------------------------
bool PdfEncrypt::IsCopyAllowed() const
{
return (m_pValue & ePdfPermissions_Copy) == ePdfPermissions_Copy;
}
// -----------------------------------------------------
//
// -----------------------------------------------------
bool PdfEncrypt::IsEditNotesAllowed() const
{
return (m_pValue & ePdfPermissions_EditNotes) == ePdfPermissions_EditNo
tes;
}
// -----------------------------------------------------
//
// -----------------------------------------------------
bool PdfEncrypt::IsFillAndSignAllowed() const
{
return (m_pValue & ePdfPermissions_FillAndSign) == ePdfPermissions_Fill
AndSign;
}
// -----------------------------------------------------
//
// -----------------------------------------------------
bool PdfEncrypt::IsAccessibilityAllowed() const
{
return (m_pValue & ePdfPermissions_Accessible) == ePdfPermissions_Acces
sible;
}
// -----------------------------------------------------
//
// -----------------------------------------------------
bool PdfEncrypt::IsDocAssemblyAllowed() const
{
return (m_pValue & ePdfPermissions_DocAssembly) == ePdfPermissions_DocA
ssembly;
}
// -----------------------------------------------------
//
// -----------------------------------------------------
bool PdfEncrypt::IsHighPrintAllowed() const
{
return (m_pValue & ePdfPermissions_HighPrint) == ePdfPermissions_HighPr
int;
}
} //end namespace PoDoFo
#endif #endif
 End of changes. 16 change blocks. 
41 lines changed or deleted 541 lines changed or added


 PdfError.h   PdfError.h 
skipping to change at line 31 skipping to change at line 31
#ifndef _PDF_ERROR_H_ #ifndef _PDF_ERROR_H_
#define _PDF_ERROR_H_ #define _PDF_ERROR_H_
// PdfError.h should not include PdfDefines.h, since it is included by it. // PdfError.h should not include PdfDefines.h, since it is included by it.
// It should avoid depending on anything defined in PdfDefines.h . // It should avoid depending on anything defined in PdfDefines.h .
#include "podofoapi.h" #include "podofoapi.h"
#include <string> #include <string>
#include <queue> #include <queue>
#ifdef _MSC_VER // same pragma as in PdfDefines.h which we cannot include h
ere
#pragma warning(disable: 4251)
#endif
/** \file PdfError.h /** \file PdfError.h
* Error information and logging is implemented in this file. * Error information and logging is implemented in this file.
*/ */
namespace PoDoFo { namespace PoDoFo {
/** Error Code defines which are used in PdfError to describe the error. /** Error Code defines which are used in PdfError to describe the error.
* *
* If you add an error code to this enum, please also add it to PdfError:: ErrorName * If you add an error code to this enum, please also add it to PdfError:: ErrorName
* and PdfError::ErrorMessage. * and PdfError::ErrorMessage.
* *
* \see PdfError * \see PdfError
*/ */
typedef enum EPdfError { enum EPdfError {
ePdfError_ErrOk = 0, /**< The default value indicating n o error. */ ePdfError_ErrOk = 0, /**< The default value indicating n o error. */
ePdfError_TestFailed, /**< Used in PoDoFo tests, to indic ate that a test failed for some reason. */ ePdfError_TestFailed, /**< Used in PoDoFo tests, to indic ate that a test failed for some reason. */
ePdfError_InvalidHandle, /**< Null pointer was passed, but n ull pointer is not allowed. */ ePdfError_InvalidHandle, /**< Null pointer was passed, but n ull pointer is not allowed. */
ePdfError_FileNotFound, /**< A file was not found or cannot be opened. */ ePdfError_FileNotFound, /**< A file was not found or cannot be opened. */
ePdfError_InvalidDeviceOperation, /**< Tried to do something unsupport ed to an I/O device like seek a non-seekable input device */ ePdfError_InvalidDeviceOperation, /**< Tried to do something unsupport ed to an I/O device like seek a non-seekable input device */
ePdfError_UnexpectedEOF, /**< End of file was reached but da ta was expected. */ ePdfError_UnexpectedEOF, /**< End of file was reached but da ta was expected. */
ePdfError_OutOfMemory, /**< Not enough memory to complete an operation. */ ePdfError_OutOfMemory, /**< Not enough memory to complete an operation. */
ePdfError_ValueOutOfRange, /**< The specified memory is out of the allowed range. */ ePdfError_ValueOutOfRange, /**< The specified memory is out of the allowed range. */
ePdfError_InternalLogic, /**< An internal sanity check or as sertion failed. */ ePdfError_InternalLogic, /**< An internal sanity check or as sertion failed. */
ePdfError_InvalidEnumValue, /**< An invalid enum value was spec ified. */
ePdfError_NoPdfFile, /**< The file is no PDF file. */ ePdfError_NoPdfFile, /**< The file is no PDF file. */
ePdfError_NoXRef, /**< The PDF file has no or an inva lid XRef table. */ ePdfError_NoXRef, /**< The PDF file has no or an inva lid XRef table. */
ePdfError_NoTrailer, /**< The PDF file has no or an inva lid trailer. */ ePdfError_NoTrailer, /**< The PDF file has no or an inva lid trailer. */
ePdfError_NoNumber, /**< A number was expected in the P DF file, but the read string is no number. */ ePdfError_NoNumber, /**< A number was expected in the P DF file, but the read string is no number. */
ePdfError_NoObject, /**< A object was expected and non was found. */ ePdfError_NoObject, /**< A object was expected and non was found. */
ePdfError_InvalidTrailerSize, /**< The trailer size is invalid. * / ePdfError_InvalidTrailerSize, /**< The trailer size is invalid. * /
ePdfError_InvalidLinearization, /**< The linearization directory of a web-optimized PDF file is invalid. */ ePdfError_InvalidLinearization, /**< The linearization directory of a web-optimized PDF file is invalid. */
ePdfError_InvalidDataType, /**< The passed datatype is invalid or was not recognized */ ePdfError_InvalidDataType, /**< The passed datatype is invalid or was not recognized */
ePdfError_InvalidXRef, /**< The XRef table is invalid */ ePdfError_InvalidXRef, /**< The XRef table is invalid */
ePdfError_InvalidXRefStream, /**< A XRef steam is invalid */ ePdfError_InvalidXRefStream, /**< A XRef steam is invalid */
ePdfError_InvalidXRefType, /**< The XRef type is invalid or wa s not found */ ePdfError_InvalidXRefType, /**< The XRef type is invalid or wa s not found */
ePdfError_InvalidPredictor, /**< Invalid or unimplemented predi ctor */ ePdfError_InvalidPredictor, /**< Invalid or unimplemented predi ctor */
ePdfError_InvalidStrokeStyle, /**< Invalid stroke style during dr awing */ ePdfError_InvalidStrokeStyle, /**< Invalid stroke style during dr awing */
ePdfError_InvalidHexString, /**< Invalid hex string */ ePdfError_InvalidHexString, /**< Invalid hex string */
ePdfError_InvalidStream, /**< The stream is invalid */ ePdfError_InvalidStream, /**< The stream is invalid */
ePdfError_InvalidStreamLength, /**< The stream length is invlaid * / ePdfError_InvalidStreamLength, /**< The stream length is invlaid * /
ePdfError_InvalidKey, /**< The specified key is invalid * / ePdfError_InvalidKey, /**< The specified key is invalid * /
ePdfError_InvalidName, /**< The specified Name is not vali d in this context */ ePdfError_InvalidName, /**< The specified Name is not vali d in this context */
ePdfError_InvalidEncryptionDict, /**< The encryption dictionary is i
nvalid or misses a required key */
ePdfError_InvalidPassword, /**< The password used to open the
PDF file was invalid */
ePdfError_InvalidFontFile, /**< The font file is invalid */
ePdfError_InvalidContentStream, /**< The content stream is invalid
due to mismatched context pairing or other problems */
ePdfError_UnsupportedFilter, /**< The requested filter is not ye t implemented. */ ePdfError_UnsupportedFilter, /**< The requested filter is not ye t implemented. */
ePdfError_UnsupportedFontFormat, /**< This font format is not suppor ted by PoDoFO. */ ePdfError_UnsupportedFontFormat, /**< This font format is not suppor ted by PoDoFO. */
ePdfError_ActionAlreadyPresent, /**< An Action was already present when trying to add a Destination */ ePdfError_ActionAlreadyPresent, /**< An Action was already present when trying to add a Destination */
ePdfError_MissingEndStream, /**< The required token endstream w as not found. */ ePdfError_MissingEndStream, /**< The required token endstream w as not found. */
ePdfError_Date, /**< Date/time error */ ePdfError_Date, /**< Date/time error */
ePdfError_Flate, /**< Error in zlib */ ePdfError_Flate, /**< Error in zlib */
ePdfError_FreeType, /**< Error in FreeType */ ePdfError_FreeType, /**< Error in FreeType */
ePdfError_SignatureError, /**< Error in signature */ ePdfError_SignatureError, /**< Error in signature */
ePdfError_UnsupportedImageFormat, /**< This image format is not suppo
rted by PoDoFO. */
ePdfError_Unknown = 0xffff /**< Unknown error */ ePdfError_Unknown = 0xffff /**< Unknown error */
}; };
/** /**
* Used in PdfError::LogMessage to specify the log level. * Used in PdfError::LogMessage to specify the log level.
* *
* \see PdfError::LogMessage * \see PdfError::LogMessage
*/ */
typedef enum ELogSeverity { enum ELogSeverity {
eLogSeverity_Critical, /**< Critical unexpected error */ eLogSeverity_Critical, /**< Critical unexpected error */
eLogSeverity_Error, /**< Error */ eLogSeverity_Error, /**< Error */
eLogSeverity_Warning, /**< Warning */ eLogSeverity_Warning, /**< Warning */
eLogSeverity_Information, /**< Information message */ eLogSeverity_Information, /**< Information message */
eLogSeverity_Debug, /**< Debug information */ eLogSeverity_Debug, /**< Debug information */
eLogSeverity_None, /**< No specified level */ eLogSeverity_None, /**< No specified level */
eLogSeverity_Unknown = 0xffff /**< Unknown log level */ eLogSeverity_Unknown = 0xffff /**< Unknown log level */
}; };
/** \def PODOFO_RAISE_ERROR( x ) /** \def PODOFO_RAISE_ERROR( x )
* *
* Set the value of the variable eCode (which has to exist in the current function) to x * Set the value of the variable eCode (which has to exist in the current function) to x
* and return the eCode. * and return the eCode.
*/ */
#define PODOFO_RAISE_ERROR( x ) throw PdfError( x, __FILE__, __LINE__ ); #define PODOFO_RAISE_ERROR( x ) throw ::PoDoFo::PdfError( x, __FILE__, __LI NE__ );
/** \def PODOFO_RAISE_ERROR_INFO( x, y ) /** \def PODOFO_RAISE_ERROR_INFO( x, y )
* *
* Set the value of the variable eCode (which has to exist in the current function) to x * Set the value of the variable eCode (which has to exist in the current function) to x
* and return the eCode. Additionally additional information on the error y is set. y has * and return the eCode. Additionally additional information on the error y is set. y has
* to be an c-string. * to be an c-string.
*/ */
#define PODOFO_RAISE_ERROR_INFO( x, y ) throw PdfError( x, __FILE__, __LINE __, y ); #define PODOFO_RAISE_ERROR_INFO( x, y ) throw ::PoDoFo::PdfError( x, __FILE __, __LINE__, y );
/** \def PODOFO_RAISE_LOGIC_IF( x, y ) /** \def PODOFO_RAISE_LOGIC_IF( x, y )
* *
* Evaluate `x' as a binary predicate and if it is true, raise a logic err or with the * Evaluate `x' as a binary predicate and if it is true, raise a logic err or with the
* info string `y' . * info string `y' .
* *
* This macro will be undefined when NDEBUG is set, so it's compiled out f or release * This macro will be undefined when NDEBUG is set, so it's compiled out f or release
* builds. Use it for expensive or extremely frequent sanity checking. * builds. Use it for expensive or extremely frequent sanity checking.
* *
* We define it then UNDEF it to help out doxygen. * We define it then UNDEF it to help out doxygen.
*/ */
#ifndef NDEBUG #ifndef NDEBUG
// Woo for double-negatives. We define PODOFO_RAISE_LOGIC_IF unless we' ve been told not to by NDEBUG. // Woo for double-negatives. We define PODOFO_RAISE_LOGIC_IF unless we' ve been told not to by NDEBUG.
#define PODOFO_RAISE_LOGIC_IF( x, y ) { if (x) throw PdfError( ePdfErro r_InternalLogic, __FILE__, __LINE__, y ); }; #define PODOFO_RAISE_LOGIC_IF( x, y ) { if (x) throw ::PoDoFo::PdfError ( ePdfError_InternalLogic, __FILE__, __LINE__, y ); };
#else #else
#define PODOFO_RAISE_LOGIC_IF( x, y ) {}; #define PODOFO_RAISE_LOGIC_IF( x, y ) {};
#endif #endif
class PODOFO_API PdfErrorInfo { class PODOFO_API PdfErrorInfo {
public: public:
PdfErrorInfo(); PdfErrorInfo();
PdfErrorInfo( int line, const char* pszFile, const char* pszInfo ); PdfErrorInfo( int line, const char* pszFile, const char* pszInfo );
PdfErrorInfo( const PdfErrorInfo & rhs ); PdfErrorInfo( const PdfErrorInfo & rhs );
 End of changes. 9 change blocks. 
5 lines changed or deleted 21 lines changed or added


 PdfExtGState.h   PdfExtGState.h 
#ifndef _PDF_EXTGSTATE_H_ #ifndef _PDF_EXTGSTATE_H_
#define _PDF_EXTGSTATE_H_ #define _PDF_EXTGSTATE_H_
#include "PdfDefines.h" #include "PdfDefines.h"
#include "PdfName.h" #include "PdfName.h"
#include "PdfElement.h" #include "PdfElement.h"
namespace PoDoFo { namespace PoDoFo {
class PdfObject; class PdfObject;
class PdfPage; class PdfPage;
class PdfWriter; class PdfWriter;
/** This class wraps the ExtGState object used in the Resource /** This class wraps the ExtGState object used in the Resource
* Dictionary of a Content-supporting element (page, Pattern, etc.) * Dictionary of a Content-supporting element (page, Pattern, etc.)
* The main usage is for transparency, but it also support a variet * The main usage is for transparency, but it also support a variety
y * of prepress features.
* of prepress features. */
*/ class PODOFO_API PdfExtGState : public PdfElement {
class PODOFO_API PdfExtGState : public PdfElement { public:
public: /** Create a new PdfExtGState object which will introduce itself
/** Create a new PdfExtGState object which will introduce it * automatically to every page object it is used on.
self *
* automatically to every page object it is used on. * \param pParent parent vector of objects
* *
* \param pParent parent of the font object */
* PdfExtGState( PdfVecObjects* pParent );
*/
PdfExtGState( PdfVecObjects* pParent ); /** Create a new PdfExtGState object which will introduce itself
virtual ~PdfExtGState(); * automatically to every page object it is used on.
*
/** Returns the identifier of this ExtGState how it is known * \param pParent parent document
* in the pages resource dictionary. *
* \returns PdfName containing the identifier (e.g. /ExtGS13 */
) PdfExtGState( PdfDocument* pParent );
*/
inline const PdfName & GetIdentifier() const; virtual ~PdfExtGState();
/** Sets the opacity value to be used for fill operations /** Returns the identifier of this ExtGState how it is known
* \param opac a floating point value from 0 (transparent) * in the pages resource dictionary.
to 1 (opaque) * \returns PdfName containing the identifier (e.g. /ExtGS13)
*/ */
void SetFillOpacity( float opac ); inline const PdfName & GetIdentifier() const;
/** Sets the opacity value to be used for stroking operation /** Sets the opacity value to be used for fill operations
s * \param opac a floating point value from 0 (transparent) to 1 (opaqu
* \param opac a floating point value from 0 (transparent) e)
to 1 (opaque) */
*/ void SetFillOpacity( float opac );
void SetStrokeOpacity( float opac );
/** Sets the opacity value to be used for stroking operations
/** Sets the transparency blend mode * \param opac a floating point value from 0 (transparent) to 1 (opaqu
* \param blendMode one of the predefined blending modes (s e)
ee Podofo.h) */
*/ void SetStrokeOpacity( float opac );
void SetBlendMode( char* blendMode );
/** Sets the transparency blend mode
/** Enables/Disables overprinting for both Fill & Stroke * \param blendMode one of the predefined blending modes (see Podofo.h
* \param enable enable or disable )
*/ */
void SetOverprint( bool enable=true ); void SetBlendMode( char* blendMode );
/** Enables/Disables overprinting for Fill operations /** Enables/Disables overprinting for both Fill & Stroke
* \param enable enable or disable * \param enable enable or disable
*/ */
void SetFillOverprint( bool enable=true ); void SetOverprint( bool enable=true );
/** Enables/Disables overprinting for Stroke operations /** Enables/Disables overprinting for Fill operations
* \param enable enable or disable * \param enable enable or disable
*/ */
void SetStrokeOverprint( bool enable=true ); void SetFillOverprint( bool enable=true );
/** Enables/Disables non-zero overprint mode /** Enables/Disables overprinting for Stroke operations
* \param enable enable or disable * \param enable enable or disable
*/ */
void SetNonZeroOverprint( bool enable=true ); void SetStrokeOverprint( bool enable=true );
/** Set the Rendering Intent /** Enables/Disables non-zero overprint mode
* \param intent one of the predefined intents (see Podofo.h * \param enable enable or disable
) */
*/ void SetNonZeroOverprint( bool enable=true );
void SetRenderingIntent( char* intent );
/** Set the Rendering Intent
private: * \param intent one of the predefined intents (see Podofo.h)
/** Initialize the object */
*/ void SetRenderingIntent( char* intent );
void Init( void );
private:
private: /** Initialize the object
PdfName m_Identifier; */
}; void Init( void );
const PdfName & PdfExtGState::GetIdentifier() const private:
{ PdfName m_Identifier;
return m_Identifier; };
}
const PdfName & PdfExtGState::GetIdentifier() const
{
return m_Identifier;
}
}; };
#endif // _PDF_EXTGSTATE_H_ #endif // _PDF_EXTGSTATE_H_
 End of changes. 1 change blocks. 
87 lines changed or deleted 92 lines changed or added


 PdfField.h   PdfField.h 
skipping to change at line 44 skipping to change at line 44
class PdfAnnotation; class PdfAnnotation;
class PdfDocument; class PdfDocument;
class PdfObject; class PdfObject;
class PdfPage; class PdfPage;
class PdfRect; class PdfRect;
class PdfReference; class PdfReference;
class PdfStreamedDocument; class PdfStreamedDocument;
/** The type of PDF field /** The type of PDF field
*/ */
typedef enum EPdfField { enum EPdfField {
ePdfField_PushButton, ePdfField_PushButton,
ePdfField_CheckBox, ePdfField_CheckBox,
ePdfField_RadioButton, ePdfField_RadioButton,
ePdfField_TextField, ePdfField_TextField,
ePdfField_ComboBox, ePdfField_ComboBox,
ePdfField_ListBox, ePdfField_ListBox,
ePdfField_Signature, ePdfField_Signature,
ePdfField_Unknown = 0xff ePdfField_Unknown = 0xff
}; };
/** The possible highlighting modes /** The possible highlighting modes
* for a PdfField. I.e the visual effect * for a PdfField. I.e the visual effect
* that is to be used when the mouse * that is to be used when the mouse
* button is pressed. * button is pressed.
* *
* The default value is * The default value is
* ePdfHighlightingMode_Invert * ePdfHighlightingMode_Invert
*/ */
typedef enum EPdfHighlightingMode { enum EPdfHighlightingMode {
ePdfHighlightingMode_None, ///< Do no highlighting ePdfHighlightingMode_None, ///< Do no highlighting
ePdfHighlightingMode_Invert, ///< Invert the PdfField ePdfHighlightingMode_Invert, ///< Invert the PdfField
ePdfHighlightingMode_InvertOutline, ///< Invert the fields border ePdfHighlightingMode_InvertOutline, ///< Invert the fields border
ePdfHighlightingMode_Push, ///< Display the fields down appea rance (requires an additional appearance stream to be set) ePdfHighlightingMode_Push, ///< Display the fields down appea rance (requires an additional appearance stream to be set)
ePdfHighlightingMode_Unknown = 0xff ePdfHighlightingMode_Unknown = 0xff
}; };
class PODOFO_API PdfField { class PODOFO_API PdfField {
enum { ePdfField_ReadOnly = 0x0001, enum { ePdfField_ReadOnly = 0x0001,
 End of changes. 2 change blocks. 
2 lines changed or deleted 2 lines changed or added


 PdfFileSpec.h   PdfFileSpec.h 
skipping to change at line 32 skipping to change at line 32
#define _PDF_FILE_SPEC_H_ #define _PDF_FILE_SPEC_H_
#include "PdfDefines.h" #include "PdfDefines.h"
#include "PdfElement.h" #include "PdfElement.h"
#include "PdfString.h" #include "PdfString.h"
namespace PoDoFo { namespace PoDoFo {
class PdfDocument;
/** /**
* A file specification is used in the PDF file to referr to another file. * A file specification is used in the PDF file to referr to another file.
* The other file can be a file outside of the PDF or can be embedded into * The other file can be a file outside of the PDF or can be embedded into
* the PDF file itself. * the PDF file itself.
*/ */
class PODOFO_API PdfFileSpec : public PdfElement { class PODOFO_API PdfFileSpec : public PdfElement {
public: public:
PdfFileSpec( const char* pszFilename, bool bEmbedd, PdfDocument* pParen
t );
PdfFileSpec( const char* pszFilename, bool bEmbedd, PdfVecObjects* pPar ent ); PdfFileSpec( const char* pszFilename, bool bEmbedd, PdfVecObjects* pPar ent );
PdfFileSpec( PdfObject* pObject ); PdfFileSpec( PdfObject* pObject );
/** \returns the filename of this file specification. /** \returns the filename of this file specification.
* if no general name is available * if no general name is available
* it will try the Unix, Mac and DOS keys too. * it will try the Unix, Mac and DOS keys too.
*/ */
const PdfString & GetFilename() const; const PdfString & GetFilename() const;
 End of changes. 2 change blocks. 
0 lines changed or deleted 5 lines changed or added


 PdfFileStream.h   PdfFileStream.h 
skipping to change at line 62 skipping to change at line 62
* The stream will be deleted along with the parent. * The stream will be deleted along with the parent.
* This constructor will be called by PdfObject::Stream() for you. * This constructor will be called by PdfObject::Stream() for you.
* *
* \param pParent parent object * \param pParent parent object
* \param pDevice output device * \param pDevice output device
*/ */
PdfFileStream( PdfObject* pParent, PdfOutputDevice* pDevice ); PdfFileStream( PdfObject* pParent, PdfOutputDevice* pDevice );
virtual ~PdfFileStream(); virtual ~PdfFileStream();
/** Set an encryption object which is used to encrypt
* all data written to this stream.
*
* \param pEncrypt an encryption object or NULL if no encryption shoul
d be done
*/
void SetEncrypted( PdfEncrypt* pEncrypt );
/** Write the stream to an output device /** Write the stream to an output device
* \param pDevice write to this outputdevice. * \param pDevice write to this outputdevice.
* \param pEncrypt encrypt stream data using this object
*/ */
virtual void Write( PdfOutputDevice* pDevice ); virtual void Write( PdfOutputDevice* pDevice, PdfEncrypt* pEncrypt = NU LL );
/** Get a malloced buffer of the current stream. /** Get a malloced buffer of the current stream.
* No filters will be applied to the buffer, so * No filters will be applied to the buffer, so
* if the stream is Flate compressed the compressed copy * if the stream is Flate compressed the compressed copy
* will be returned. * will be returned.
* *
* The caller has to free() the buffer. * The caller has to free() the buffer.
* *
* This is currently not implemented for PdfFileStreams * This is currently not implemented for PdfFileStreams
* and will raise an ePdfError_InternalLogic exception * and will raise an ePdfError_InternalLogic exception
skipping to change at line 127 skipping to change at line 135
virtual void AppendImpl( const char* pszString, size_t lLen ); virtual void AppendImpl( const char* pszString, size_t lLen );
/** Finish appending data to the stream /** Finish appending data to the stream
*/ */
virtual void EndAppendImpl(); virtual void EndAppendImpl();
private: private:
PdfOutputDevice* m_pDevice; PdfOutputDevice* m_pDevice;
PdfOutputStream* m_pStream; PdfOutputStream* m_pStream;
PdfOutputStream* m_pDeviceStream; PdfOutputStream* m_pDeviceStream;
PdfOutputStream* m_pEncryptStream;
unsigned long m_lLenInitial; unsigned long m_lLenInitial;
unsigned long m_lLength; unsigned long m_lLength;
PdfObject* m_pLength; PdfObject* m_pLength;
PdfEncrypt* m_pCurEncrypt;
}; };
// ----------------------------------------------------- // -----------------------------------------------------
// //
// ----------------------------------------------------- // -----------------------------------------------------
unsigned long PdfFileStream::GetLength() const unsigned long PdfFileStream::GetLength() const
{ {
return m_lLength; return m_lLength;
} }
 End of changes. 5 change blocks. 
1 lines changed or deleted 13 lines changed or added


 PdfFiltersPrivate.h   PdfFiltersPrivate.h 
skipping to change at line 24 skipping to change at line 24
* * * *
* You should have received a copy of the GNU Library General Public * * You should have received a copy of the GNU Library General Public *
* License along with this program; if not, write to the * * License along with this program; if not, write to the *
* Free Software Foundation, Inc., * * Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
************************************************************************** */ ************************************************************************** */
#ifndef _PDF_FILTERS_PRIVATE_H_ #ifndef _PDF_FILTERS_PRIVATE_H_
#define _PDF_FILTERS_PRIVATE_H_ #define _PDF_FILTERS_PRIVATE_H_
/**
* \file PdfFiltersPrivate.h
*
* Provides implementations of various PDF stream filters.
*
* This is an internal header. It should not be included in podofo.h, and
* should not be included directly by client applications. These filters sh
ould
* only be accessed through the factory interface in PdfFilters.h .
*/
#include "PdfDefines.h" #include "PdfDefines.h"
#include "PdfFilter.h" #include "PdfFilter.h"
#include "PdfRefCountedBuffer.h"
#include <zlib.h> #include <zlib.h>
#ifdef PODOFO_HAVE_JPEG_LIB
extern "C" {
#include "jpeglib.h"
}
#endif // PODOFO_HAVE_JPEG_LIB
#ifdef PODOFO_HAVE_TIFF_LIB
extern "C" {
#include "tiffio.h"
#ifdef WIN32 // Collision between tiff and jpeg-headers
#define XMD_H
#undef FAR
#endif
}
#endif // PODOFO_HAVE_TIFF_LIB
namespace PoDoFo { namespace PoDoFo {
#define PODOFO_FILTER_INTERNAL_BUFFER_SIZE 4096 #define PODOFO_FILTER_INTERNAL_BUFFER_SIZE 4096
class PdfPredictorDecoder; class PdfPredictorDecoder;
class PdfOutputDevice;
/** The ascii hex filter. /** The ascii hex filter.
*/ */
class PdfHexFilter : public PdfFilter { class PdfHexFilter : public PdfFilter {
public: public:
virtual ~PdfHexFilter() { } virtual ~PdfHexFilter() { }
/** Check wether the encoding is implemented for this filter. /** Check wether the encoding is implemented for this filter.
* *
* \returns true if the filter is able to encode data * \returns true if the filter is able to encode data
skipping to change at line 118 skipping to change at line 146
/** GetType of this filter. /** GetType of this filter.
* \returns the GetType of this filter * \returns the GetType of this filter
*/ */
inline virtual EPdfFilter GetType() const; inline virtual EPdfFilter GetType() const;
private: private:
char m_cDecodedByte; char m_cDecodedByte;
bool m_bLow; bool m_bLow;
}; };
// -----------------------------------------------------
//
// -----------------------------------------------------
bool PdfHexFilter::CanEncode() const bool PdfHexFilter::CanEncode() const
{ {
return true; return true;
} }
// -----------------------------------------------------
//
// -----------------------------------------------------
bool PdfHexFilter::CanDecode() const bool PdfHexFilter::CanDecode() const
{ {
return true; return true;
} }
// -----------------------------------------------------
//
// -----------------------------------------------------
EPdfFilter PdfHexFilter::GetType() const EPdfFilter PdfHexFilter::GetType() const
{ {
return ePdfFilter_ASCIIHexDecode; return ePdfFilter_ASCIIHexDecode;
} }
/** The Ascii85 filter. /** The Ascii85 filter.
*/ */
class PdfAscii85Filter : public PdfFilter { class PdfAscii85Filter : public PdfFilter {
public: public:
virtual ~PdfAscii85Filter() { } virtual ~PdfAscii85Filter() { }
skipping to change at line 236 skipping to change at line 273
private: private:
void EncodeTuple ( unsigned long tuple, int bytes ); void EncodeTuple ( unsigned long tuple, int bytes );
void WidePut( unsigned long tuple, int bytes ) const; void WidePut( unsigned long tuple, int bytes ) const;
private: private:
int m_count; int m_count;
unsigned long m_tuple; unsigned long m_tuple;
}; };
// -----------------------------------------------------
//
// -----------------------------------------------------
bool PdfAscii85Filter::CanEncode() const bool PdfAscii85Filter::CanEncode() const
{ {
return true; return true;
} }
// -----------------------------------------------------
//
// -----------------------------------------------------
bool PdfAscii85Filter::CanDecode() const bool PdfAscii85Filter::CanDecode() const
{ {
return true; return true;
} }
// -----------------------------------------------------
//
// -----------------------------------------------------
EPdfFilter PdfAscii85Filter::GetType() const EPdfFilter PdfAscii85Filter::GetType() const
{ {
return ePdfFilter_ASCII85Decode; return ePdfFilter_ASCII85Decode;
} }
/** The flate filter. /** The flate filter.
*/ */
class PdfFlateFilter : public PdfFilter { class PdfFlateFilter : public PdfFilter {
public: public:
PdfFlateFilter(); PdfFlateFilter();
skipping to change at line 359 skipping to change at line 405
private: private:
void EncodeBlockInternal( const char* pBuffer, long lLen, int nMode ); void EncodeBlockInternal( const char* pBuffer, long lLen, int nMode );
private: private:
unsigned char m_buffer[PODOFO_FILTER_INTERNAL_BUFFER_SIZE]; unsigned char m_buffer[PODOFO_FILTER_INTERNAL_BUFFER_SIZE];
z_stream m_stream; z_stream m_stream;
PdfPredictorDecoder* m_pPredictor; PdfPredictorDecoder* m_pPredictor;
}; };
// -----------------------------------------------------
//
// -----------------------------------------------------
bool PdfFlateFilter::CanEncode() const bool PdfFlateFilter::CanEncode() const
{ {
return true; return true;
} }
// -----------------------------------------------------
//
// -----------------------------------------------------
bool PdfFlateFilter::CanDecode() const bool PdfFlateFilter::CanDecode() const
{ {
return true; return true;
} }
// -----------------------------------------------------
//
// -----------------------------------------------------
EPdfFilter PdfFlateFilter::GetType() const EPdfFilter PdfFlateFilter::GetType() const
{ {
return ePdfFilter_FlateDecode; return ePdfFilter_FlateDecode;
} }
/** The RLE filter. /** The RLE filter.
*/ */
class PdfRLEFilter : public PdfFilter { class PdfRLEFilter : public PdfFilter {
public: public:
virtual ~PdfRLEFilter() {} virtual ~PdfRLEFilter() {}
skipping to change at line 455 skipping to change at line 510
/** GetType of this filter. /** GetType of this filter.
* \returns the GetType of this filter * \returns the GetType of this filter
*/ */
inline virtual EPdfFilter GetType() const; inline virtual EPdfFilter GetType() const;
private: private:
int m_nCodeLen; int m_nCodeLen;
}; };
// -----------------------------------------------------
//
// -----------------------------------------------------
bool PdfRLEFilter::CanEncode() const bool PdfRLEFilter::CanEncode() const
{ {
return false; return false;
} }
// -----------------------------------------------------
//
// -----------------------------------------------------
bool PdfRLEFilter::CanDecode() const bool PdfRLEFilter::CanDecode() const
{ {
return true; return true;
} }
// -----------------------------------------------------
//
// -----------------------------------------------------
EPdfFilter PdfRLEFilter::GetType() const EPdfFilter PdfRLEFilter::GetType() const
{ {
return ePdfFilter_RunLengthDecode; return ePdfFilter_RunLengthDecode;
} }
/** The LZW filter. /** The LZW filter.
*/ */
class PdfLZWFilter : public PdfFilter { class PdfLZWFilter : public PdfFilter {
struct TLzwItem { struct TLzwItem {
std::vector<unsigned char> value; std::vector<unsigned char> value;
skipping to change at line 595 skipping to change at line 659
unsigned int m_mask; unsigned int m_mask;
unsigned int m_code_len; unsigned int m_code_len;
unsigned char m_character; unsigned char m_character;
bool m_bFirst; bool m_bFirst;
PdfPredictorDecoder* m_pPredictor; PdfPredictorDecoder* m_pPredictor;
}; };
// -----------------------------------------------------
//
// -----------------------------------------------------
bool PdfLZWFilter::CanEncode() const bool PdfLZWFilter::CanEncode() const
{ {
return false; return false;
} }
// -----------------------------------------------------
//
// -----------------------------------------------------
bool PdfLZWFilter::CanDecode() const bool PdfLZWFilter::CanDecode() const
{ {
return true; return true;
} }
// -----------------------------------------------------
//
// -----------------------------------------------------
EPdfFilter PdfLZWFilter::GetType() const EPdfFilter PdfLZWFilter::GetType() const
{ {
return ePdfFilter_LZWDecode; return ePdfFilter_LZWDecode;
} }
#ifdef PODOFO_HAVE_JPEG_LIB
/** The DCT filter can decoded JPEG compressed data.
*
* This filter requires JPEG lib to be available
*/
class PdfDCTFilter : public PdfFilter {
public:
PdfDCTFilter();
virtual ~PdfDCTFilter();
/** Check wether the encoding is implemented for this filter.
*
* \returns true if the filter is able to encode data
*/
inline virtual bool CanEncode() const;
/** Begin encoding data using this filter. Called by PdfFilter::BeginEn
code.
*
* \see EncodeBlockImpl
* \see EndEncodeImpl
* \see PdfFilter::BeginEncode
*/
virtual void BeginEncodeImpl();
/** Encode a block of data and write it to the PdfOutputStream
* specified by BeginEncodeImpl.
*
* BeginEncodeImpl() has to be called before this function.
*
* \param pBuffer pointer to a buffer with data to encode
* \param lLen length of data to encode.
*
* Call EndEncodeImpl() after all data has been encoded
*
*
* \see BeginEncodeImpl
* \see EndEncodeImpl
*/
virtual void EncodeBlockImpl( const char* pBuffer, long lLen );
/**
* Finish encoding of data.
*
* \see BeginEncodeImpl
* \see EncodeBlockImpl
*/
virtual void EndEncodeImpl();
/** Check wether the decoding is implemented for this filter.
*
* \returns true if the filter is able to decode data
*/
inline virtual bool CanDecode() const;
/** Real implementation of `BeginDecode()'. NEVER call this method dire
ctly.
*
* By default this function does nothing. If your filter needs to do s
etup for decoding,
* you should override this method.
*
* PdfFilter ensures that a valid stream is available when this method
is called, and
* that EndDecode() was called since the last BeginDecode()/DecodeBloc
k().
*
* \see BeginDecode */
virtual void BeginDecodeImpl( const PdfDictionary* );
/** Real implementation of `DecodeBlock()'. NEVER call this method dire
ctly.
*
* You must override this method to decode the buffer passed by the ca
ller.
*
* You are not obliged to immediately process any or all of the data i
n
* the passed buffer, but you must ensure that you have processed it a
nd
* written it out by the end of EndDecodeImpl(). You must copy the buf
fer
* if you're going to store it, as ownership is not transferred to the
* filter and the caller may free the buffer at any time.
*
* PdfFilter ensures that a valid stream is available when this method
is
* called, ensures that BeginDecode() has been called, and ensures tha
t
* EndDecode() has not been called since the last BeginDecode().
*
* \see DecodeBlock */
virtual void DecodeBlockImpl( const char* pBuffer, long lLen );
/** Real implementation of `EndDecode()'. NEVER call this method direct
ly.
*
* By the time this method returns, all filtered data must be written t
o the stream
* and the filter must be in a state where BeginDecode() can be safely
called.
*
* PdfFilter ensures that a valid stream is available when this method
is
* called, and ensures that BeginDecodeImpl() has been called.
*
* \see EndDecode */
virtual void EndDecodeImpl();
/** GetType of this filter.
* \returns the GetType of this filter
*/
inline virtual EPdfFilter GetType() const;
private:
struct jpeg_decompress_struct m_cinfo;
struct jpeg_error_mgr m_jerr;
PdfRefCountedBuffer m_buffer;
PdfOutputDevice* m_pDevice;
};
// -----------------------------------------------------
//
// -----------------------------------------------------
bool PdfDCTFilter::CanEncode() const
{
return false;
}
// -----------------------------------------------------
//
// -----------------------------------------------------
bool PdfDCTFilter::CanDecode() const
{
return true;
}
// -----------------------------------------------------
//
// -----------------------------------------------------
EPdfFilter PdfDCTFilter::GetType() const
{
return ePdfFilter_DCTDecode;
}
#endif // PODOFO_HAVE_JPEG_LIB
#ifdef PODOFO_HAVE_TIFF_LIB
/** The CCITT filter can decoded CCITTFaxDecode compressed data.
*
* This filter requires TIFFlib to be available
*/
class PdfCCITTFilter : public PdfFilter {
public:
PdfCCITTFilter();
virtual ~PdfCCITTFilter();
/** Check wether the encoding is implemented for this filter.
*
* \returns true if the filter is able to encode data
*/
inline virtual bool CanEncode() const;
/** Begin encoding data using this filter. Called by PdfFilter::BeginEn
code.
*
* \see EncodeBlockImpl
* \see EndEncodeImpl
* \see PdfFilter::BeginEncode
*/
virtual void BeginEncodeImpl();
/** Encode a block of data and write it to the PdfOutputStream
* specified by BeginEncodeImpl.
*
* BeginEncodeImpl() has to be called before this function.
*
* \param pBuffer pointer to a buffer with data to encode
* \param lLen length of data to encode.
*
* Call EndEncodeImpl() after all data has been encoded
*
*
* \see BeginEncodeImpl
* \see EndEncodeImpl
*/
virtual void EncodeBlockImpl( const char* pBuffer, long lLen );
/**
* Finish encoding of data.
*
* \see BeginEncodeImpl
* \see EncodeBlockImpl
*/
virtual void EndEncodeImpl();
/** Check wether the decoding is implemented for this filter.
*
* \returns true if the filter is able to decode data
*/
inline virtual bool CanDecode() const;
/** Real implementation of `BeginDecode()'. NEVER call this method dire
ctly.
*
* By default this function does nothing. If your filter needs to do s
etup for decoding,
* you should override this method.
*
* PdfFilter ensures that a valid stream is available when this method
is called, and
* that EndDecode() was called since the last BeginDecode()/DecodeBloc
k().
*
* \see BeginDecode */
virtual void BeginDecodeImpl( const PdfDictionary* );
/** Real implementation of `DecodeBlock()'. NEVER call this method dire
ctly.
*
* You must override this method to decode the buffer passed by the ca
ller.
*
* You are not obliged to immediately process any or all of the data i
n
* the passed buffer, but you must ensure that you have processed it a
nd
* written it out by the end of EndDecodeImpl(). You must copy the buf
fer
* if you're going to store it, as ownership is not transferred to the
* filter and the caller may free the buffer at any time.
*
* PdfFilter ensures that a valid stream is available when this method
is
* called, ensures that BeginDecode() has been called, and ensures tha
t
* EndDecode() has not been called since the last BeginDecode().
*
* \see DecodeBlock */
virtual void DecodeBlockImpl( const char* pBuffer, long lLen );
/** Real implementation of `EndDecode()'. NEVER call this method direct
ly.
*
* By the time this method returns, all filtered data must be written t
o the stream
* and the filter must be in a state where BeginDecode() can be safely
called.
*
* PdfFilter ensures that a valid stream is available when this method
is
* called, and ensures that BeginDecodeImpl() has been called.
*
* \see EndDecode */
virtual void EndDecodeImpl();
/** GetType of this filter.
* \returns the GetType of this filter
*/
inline virtual EPdfFilter GetType() const;
private:
TIFF* m_tiff;
};
// -----------------------------------------------------
//
// -----------------------------------------------------
bool PdfCCITTFilter::CanEncode() const
{
return false;
}
// -----------------------------------------------------
//
// -----------------------------------------------------
bool PdfCCITTFilter::CanDecode() const
{
return true;
}
// -----------------------------------------------------
//
// -----------------------------------------------------
EPdfFilter PdfCCITTFilter::GetType() const
{
return ePdfFilter_CCITTFaxDecode;
}
#endif // PODOFO_HAVE_TIFF_LIB
}; };
#endif /* _PDF_FILTERS_PRIVATE_H_ */ #endif /* _PDF_FILTERS_PRIVATE_H_ */
 End of changes. 20 change blocks. 
0 lines changed or deleted 367 lines changed or added


 PdfFont.h   PdfFont.h 
/**************************************************************************
*
* Copyright (C) 2007 by Dominik Seichter
*
* domseichter@web.de
*
*
*
* This program is free software; you can redistribute it and/or modify
*
* it under the terms of the GNU Library General Public License as
*
* published by the Free Software Foundation; either version 2 of the
*
* License, or (at your option) any later version.
*
*
*
* This program is distributed in the hope that it will be useful,
*
* but WITHOUT ANY WARRANTY; without even the implied warranty of
*
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
*
* GNU General Public License for more details.
*
*
*
* You should have received a copy of the GNU Library General Public
*
* License along with this program; if not, write to the
*
* Free Software Foundation, Inc.,
*
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
**************************************************************************
*/
#ifndef _PDF_FONT_H_ #ifndef _PDF_FONT_H_
#define _PDF_FONT_H_ #define _PDF_FONT_H_
#include "PdfDefines.h" #include "PdfDefines.h"
#include "PdfName.h" #include "PdfName.h"
#include "PdfElement.h" #include "PdfElement.h"
#include "PdfEncoding.h"
#include "PdfFontMetrics.h"
namespace PoDoFo { namespace PoDoFo {
class PdfFontMetrics;
class PdfObject; class PdfObject;
class PdfPage; class PdfPage;
class PdfWriter; class PdfWriter;
/** Before you can draw text on a PDF document, you have to create /** Before you can draw text on a PDF document, you have to create
* a font object first. You can reuse this font object as often * a font object first. You can reuse this font object as often
* as you want. * as you want.
* You will use PdfSimpleWriter::CreateFont most of the time *
* to create a new font object. * Use PdfDocument::CreateFont to create a new font object.
* It will choose a correct subclass using PdfFontFactory.
*
* This is only an abstract base class which is implemented
* for different font formats.
*/ */
class PODOFO_API PdfFont : public PdfElement { class PODOFO_API PdfFont : public PdfElement {
friend class PdfFontFactory;
public: public:
/** Always use this static declaration,
* if you need an instance of PdfWinAnsiEncoding
* as heap allocation is expensive for PdfWinAnsiEncoding.
*/
static const PdfWinAnsiEncoding WinAnsiEncoding;
/** Always use this static declaration,
* if you need an instance of PdfWinAnsiEncoding
* as heap allocation is expensive for PdfWinAnsiEncoding.
*/
static const PdfMacRomanEncoding MacRomanEncoding;
/** Create a new PdfFont object which will introduce itself /** Create a new PdfFont object which will introduce itself
* automatically to every page object it is used on. * automatically to every page object it is used on.
* *
* The font has a default font size of 12.0pt. * The font has a default font size of 12.0pt.
* *
* \param pMetrics pointer to a font metrics object. The font in the P DF * \param pMetrics pointer to a font metrics object. The font in the P DF
* file will match this fontmetrics object. The metrics object is * file will match this fontmetrics object. The metrics object is
* deleted along with the font. * deleted along with the font.
* \param bEmbed specifies whether this font should be embedded in the * \param pEncoding the encoding of this font. The font will not take
PDF file. ownership of this object.
* Embedding fonts is usually a good idea.
* \param pParent parent of the font object * \param pParent parent of the font object
* *
*/ */
PdfFont( PdfFontMetrics* pMetrics, bool bEmbed, PdfVecObjects* pParent PdfFont( PdfFontMetrics* pMetrics, const PdfEncoding* const pEncoding,
); PdfVecObjects* pParent );
virtual ~PdfFont(); virtual ~PdfFont();
/** Set the font size before drawing with this font. /** Set the font size before drawing with this font.
* \param fSize font size in points * \param fSize font size in points
*/ */
void SetFontSize( float fSize ); inline void SetFontSize( float fSize );
/** Retrieve the current font size of this font object /** Retrieve the current font size of this font object
* \returns the current font size * \returns the current font size
*/ */
inline float GetFontSize() const; inline float GetFontSize() const;
/** Set the horizontal scaling of the font for compressing (< 100) and
expanding (>100)
* \param fScale scaling in percent
*/
inline void SetFontScale( float fScale );
/** Retrieve the current horizontal scaling of this font object
* \returns the current font scaling
*/
inline float GetFontScale() const;
/** Set the character spacing of the font
* \param fCharSpace character spacing in percent
*/
inline void SetFontCharSpace( float fCharSpace );
/** Retrieve the current character spacing of this font object
* \returns the current font character spacing
*/
inline float GetFontCharSpace() const;
/** Set the underlined property of the font /** Set the underlined property of the font
* \param bUnder if true any text drawn with this font * \param bUnder if true any text drawn with this font
* by a PdfPainter will be underlined. * by a PdfPainter will be underlined.
* Default is false * Default is false
*/ */
inline void SetUnderlined( bool bUnder ); inline void SetUnderlined( bool bUnder );
/** \returns true if the font is underlined /** \returns true if the font is underlined
* \see IsBold
* \see IsItalic
*/ */
inline bool IsUnderlined() const; inline bool IsUnderlined() const;
/** \returns true if this font is bold
* \see IsItalic
* \see IsUnderlined
*/
inline bool IsBold() const;
/** \returns true if this font is italic
* \see IsBold
* \see IsUnderlined
*/
inline bool IsItalic() const;
/** Set the strikeout property of the font
* \param bStrikeOut if true any text drawn with this font
* by a PdfPainter will be strikedout.
* Default is false
*/
inline void SetStrikeOut( bool bStrikeOut );
/** \returns true if the font is striked out
*/
inline bool IsStrikeOut() const;
/** Returns the identifier of this font how it is known /** Returns the identifier of this font how it is known
* in the pages resource dictionary. * in the pages resource dictionary.
* \returns PdfName containing the identifier (e.g. /Ft13) * \returns PdfName containing the identifier (e.g. /Ft13)
*/ */
inline const PdfName & GetIdentifier() const; inline const PdfName & GetIdentifier() const;
/** Returns a reference to the fonts encoding
* \returns a PdfEncoding object.
*/
inline const PdfEncoding* GetEncoding() const;
/** Returns a handle to the fontmetrics object of this font. /** Returns a handle to the fontmetrics object of this font.
* This can be used for size calculations of text strings when * This can be used for size calculations of text strings when
* drawn using this font. * drawn using this font.
* \returns a handle to the font metrics object * \returns a handle to the font metrics object
*/ */
inline const PdfFontMetrics* GetFontMetrics() const; inline const PdfFontMetrics* GetFontMetrics() const;
private: /** Write a PdfString to a PdfStream in a format so that it can
/** Embed the font file directly into the PDF file. * be used with this font.
* \param pDescriptor font descriptor object * This is used by PdfPainter::DrawText to display a text string.
* The following PDF operator will be Tj
*
* \param rsString a unicode or ansi string which will be displayed
* \param pStream the string will be appended to pStream without any l
eading
* or following whitespaces.
*/ */
void EmbedFont( PdfObject* pDescriptor ); virtual void WriteStringToStream( const PdfString & rsString, PdfStream * pStream );
/** Embed the font file directly into the PDF file. protected:
/** Get the base font name of this font
* *
* The font file is a true type file. * \returns the base font name
*
* \param pDescriptor font descriptor object
*/ */
void EmbedTrueTypeFont( PdfObject* pDescriptor ); inline const PdfName& GetBaseFont() const;
/** Embed the font file directly into the PDF file. private:
/** Initialize all variables
*/
void InitVars();
/** Used to specify if this represents a bold font
* \param bBold if true this is a bold font.
* *
* The font file is a true type file. * \see IsBold
* *
* \param pDescriptor font descriptor object * This can be called by PdfFontFactory to tell this font
* object that it belongs to a bold font.
*/ */
void EmbedType1Font( PdfObject* pDescriptor ); inline void SetBold( bool bBold );
/** Initialize the object /** Used to specify if this represents an italic font
* \param bEmbed if true the font will be embeded into the PDF * \param bItalic if true this is an italic font.
*
* \see IsItalc
*
* This can be called by PdfFontFactory to tell this font
* object that it belongs to an italic font.
*/ */
void Init( bool bEmbed ); inline void SetItalic( bool bItalic );
private: private:
float m_fFontSize; PdfName m_BaseFont;
protected:
const PdfEncoding* const m_pEncoding;
PdfFontMetrics* m_pMetrics;
bool m_bBold; bool m_bBold;
bool m_bItalic; bool m_bItalic;
bool m_bUnderlined; bool m_bUnderlined;
bool m_bStrikedOut;
PdfName m_Identifier; PdfName m_Identifier;
PdfName m_BaseFont;
PdfFontMetrics* m_pMetrics;
}; };
// -----------------------------------------------------
//
// -----------------------------------------------------
void PdfFont::SetBold( bool bBold )
{
m_bBold = bBold;
}
// -----------------------------------------------------
//
// -----------------------------------------------------
void PdfFont::SetItalic( bool bItalic )
{
m_bItalic = bItalic;
}
// -----------------------------------------------------
//
// -----------------------------------------------------
const PdfName& PdfFont::GetBaseFont() const
{
return m_BaseFont;
}
// -----------------------------------------------------
//
// -----------------------------------------------------
const PdfName & PdfFont::GetIdentifier() const const PdfName & PdfFont::GetIdentifier() const
{ {
return m_Identifier; return m_Identifier;
} }
// -----------------------------------------------------
//
// -----------------------------------------------------
void PdfFont::SetFontSize( float fSize )
{
m_pMetrics->SetFontSize( fSize );
}
// -----------------------------------------------------
//
// -----------------------------------------------------
float PdfFont::GetFontSize() const float PdfFont::GetFontSize() const
{ {
return m_fFontSize; return m_pMetrics->GetFontSize();
}
// -----------------------------------------------------
//
// -----------------------------------------------------
void PdfFont::SetFontScale( float fScale )
{
m_pMetrics->SetFontScale( fScale );
}
// -----------------------------------------------------
//
// -----------------------------------------------------
float PdfFont::GetFontScale() const
{
return m_pMetrics->GetFontScale();
}
// -----------------------------------------------------
//
// -----------------------------------------------------
void PdfFont::SetFontCharSpace( float fCharSpace )
{
m_pMetrics->SetFontCharSpace( fCharSpace );
}
// -----------------------------------------------------
//
// -----------------------------------------------------
float PdfFont::GetFontCharSpace() const
{
return m_pMetrics->GetFontCharSpace();
}
// -----------------------------------------------------
//
// -----------------------------------------------------
const PdfEncoding* PdfFont::GetEncoding() const
{
return m_pEncoding;
} }
// -----------------------------------------------------
//
// -----------------------------------------------------
const PdfFontMetrics* PdfFont::GetFontMetrics() const const PdfFontMetrics* PdfFont::GetFontMetrics() const
{ {
return m_pMetrics; return m_pMetrics;
} }
// -----------------------------------------------------
//
// -----------------------------------------------------
void PdfFont::SetUnderlined( bool bUnder ) void PdfFont::SetUnderlined( bool bUnder )
{ {
m_bUnderlined = bUnder; m_bUnderlined = bUnder;
} }
// -----------------------------------------------------
//
// -----------------------------------------------------
bool PdfFont::IsUnderlined() const bool PdfFont::IsUnderlined() const
{ {
return m_bUnderlined; return m_bUnderlined;
} }
// -----------------------------------------------------
//
// -----------------------------------------------------
void PdfFont::SetStrikeOut( bool bStrikeOut )
{
m_bStrikedOut = bStrikeOut;
}
// -----------------------------------------------------
//
// -----------------------------------------------------
bool PdfFont::IsStrikeOut() const
{
return m_bStrikedOut;
}
// -----------------------------------------------------
//
// -----------------------------------------------------
bool PdfFont::IsBold() const
{
return m_bBold;
}
// -----------------------------------------------------
//
// -----------------------------------------------------
bool PdfFont::IsItalic() const
{
return m_bItalic;
}
}; };
#endif // _PDF_FONT_H_ #endif // _PDF_FONT_H_
 End of changes. 34 change blocks. 
30 lines changed or deleted 277 lines changed or added


 PdfFontCache.h   PdfFontCache.h 
skipping to change at line 26 skipping to change at line 26
* License along with this program; if not, write to the * * License along with this program; if not, write to the *
* Free Software Foundation, Inc., * * Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
************************************************************************** */ ************************************************************************** */
#ifndef _PDF_FONT_CACHE_H_ #ifndef _PDF_FONT_CACHE_H_
#define _PDF_FONT_CACHE_H_ #define _PDF_FONT_CACHE_H_
#include "PdfDefines.h" #include "PdfDefines.h"
#include "Pdf3rdPtyForwardDecl.h" #include "Pdf3rdPtyForwardDecl.h"
#include "PdfFont.h"
namespace PoDoFo { namespace PoDoFo {
class PdfFont;
class PdfFontMetrics; class PdfFontMetrics;
class PdfVecObjects; class PdfVecObjects;
/** A private structure,
* which represents a font in the cache.
*/
struct TFontCacheElement {
TFontCacheElement()
: m_pFont( NULL ),
m_pEncoding( NULL ),
m_bBold( false ),
m_bItalic( false )
{
}
TFontCacheElement( const TFontCacheElement & rhs )
{
this->operator=(rhs);
}
const TFontCacheElement & operator=( const TFontCacheElement & rhs )
{
m_pFont = rhs.m_pFont;
m_pEncoding = rhs.m_pEncoding;
m_bBold = rhs.m_bBold;
m_bItalic = rhs.m_bItalic;
m_sFontName = rhs.m_sFontName;
return *this;
}
bool operator<( const TFontCacheElement & rhs ) const
{
if( m_sFontName == rhs.m_sFontName )
{
if( m_pEncoding == rhs.m_pEncoding )
{
if( m_bBold == rhs.m_bBold)
return m_bItalic < rhs.m_bItalic;
else
return m_bBold < rhs.m_bBold;
}
else
return *m_pEncoding < *rhs.m_pEncoding;
}
else
return (m_sFontName < rhs.m_sFontName);
}
PdfFont* m_pFont;
const PdfEncoding* m_pEncoding;
bool m_bBold;
bool m_bItalic;
std::string m_sFontName;
};
/** /**
* This class assists PdfDocument * This class assists PdfDocument
* with caching font information. * with caching font information.
* *
* Additional to font caching, this class is also
* responsible for font matching.
*
* PdfFont is an actual font that can be used in
* a PDF file (i.e. it does also font embedding)
* and PdfFontMetrics provides only metrics informations.
*
* This class is an internal class of PoDoFo * This class is an internal class of PoDoFo
* and should not be used in user applications * and should not be used in user applications
* *
* \see PdfDocument * \see PdfDocument
*/ */
class PODOFO_API PdfFontCache { class PODOFO_API PdfFontCache {
public: public:
/** Create an empty font cache /** Create an empty font cache
* *
* \param pParent a PdfVecObjects which is required * \param pParent a PdfVecObjects which is required
skipping to change at line 66 skipping to change at line 126
* Empty the internal font cache. * Empty the internal font cache.
* This should be done when ever a new document * This should be done when ever a new document
* is created or openened. * is created or openened.
*/ */
void EmptyCache(); void EmptyCache();
/** Get a font from the cache. If the font does not yet /** Get a font from the cache. If the font does not yet
* exist, add it to the cache. * exist, add it to the cache.
* *
* \param pszFontName a valid fontname * \param pszFontName a valid fontname
* \param bBold if true search for a bold font
* \param bItalic if true search for an italic font
* \param bEmbedd if true a font for embedding into * \param bEmbedd if true a font for embedding into
* PDF will be created * PDF will be created
* \param pEncoding the encoding of the font. The font will not take o
wnership of this object.
* \param optional: pszFileName path to a valid font file
* *
* \returns a PdfFont object or NULL if the font could * \returns a PdfFont object or NULL if the font could
* not be found. * not be created or found.
*/ */
PdfFont* GetFont( const char* pszFontName, bool bEmbedd ); PdfFont* GetFont( const char* pszFontName, bool bBold, bool bItalic,
bool bEmbedd, const PdfEncoding * const = &PdfFont::W
inAnsiEncoding,
const char* pszFileName = NULL );
/** Get a font from the cache. If the font does not yet /** Get a font from the cache. If the font does not yet
* exist, add it to the cache. * exist, add it to the cache.
* *
* \param face a valid freetype font face * \param face a valid freetype font face (will be free'd by PoDoFo)
* \param bEmbedd if true a font for embedding into * \param bEmbedd if true a font for embedding into
* PDF will be created * PDF will be created
* \param pEncoding the encoding of the font. The font will not take o
wnership of this object.
*
* \returns a PdfFont object or NULL if the font could
* not be created or found.
*/
PdfFont* GetFont( FT_Face face, bool bEmbedd, const PdfEncoding * const
= &PdfFont::WinAnsiEncoding );
/** Get a fontsubset from the cache. If the font does not yet
* exist, add it to the cache.
*
* \param pszFontName a valid fontname
* \param bBold if true search for a bold font
* \param bItalic if true search for an italic font
* \param vecGlyphs a list of Unicode glyph indeces that should be emb
edded in the subset
* *
* \returns a PdfFont object or NULL if the font could * \returns a PdfFont object or NULL if the font could
* not be found. * not be created or found.
*/
/*
PdfFont* GetFontSubset( const char* pszFontName, bool bBold,
bool bItalic, const std::vector<int> & vecGlyph
s );
*/
#if defined(HAVE_FONTCONFIG)
/** Get the path of a font file on a Unix system using fontconfig
*
* This method is only available if PoDoFo was compiled with
* fontconfig support.
*
* \param pConfig a handle to an initialized fontconfig library
* \param pszFontName name of the requested font
* \param bBold if true find a bold font
* \param bItalic if true find an italic font
* \returns the path to the fontfile or an empty string
*/ */
PdfFont* GetFont( FT_Face face, bool bEmbedd ); static std::string GetFontConfigFontPath( FcConfig* pConfig, const char
* pszFontName, bool bBold, bool bItalic );
#endif // (HAVE_FONTCONFIG)
private: private:
/** /**
* Get the path to a font file for a certain fontname * Get the path to a font file for a certain fontname
* *
* \param pszFontName a valid fontname * \param pszFontName a valid fontname
* \param bBold if true search for a bold font
* \param bItalic if true search for an italic font
* *
* \returns the path to the fonts file if it was found. * \returns the path to the fonts file if it was found.
*/ */
std::string GetFontPath( const char* pszFontName ); std::string GetFontPath( const char* pszFontName, bool bBold, bool bIta lic );
/** Create a font and put it into the fontcache /** Create a font and put it into the fontcache
* \param pMetrics a font metrics * \param pMetrics a font metrics
* \param bEmbedd if true the font will be embedded in the pdf file * \param bEmbedd if true the font will be embedded in the pdf file
* \param bBold if true this font will be treated as bold font
* \param bItalic if true this font will be treated as italic font
* \param pszFontName a font name for debug output * \param pszFontName a font name for debug output
* \param pEncoding the encoding of the font. The font will not take o
wnership of this object.
*
* \returns a font handle or NULL in case of error
*/
PdfFont* CreateFontObject( PdfFontMetrics* pMetrics, bool bEmbedd, bool
bBold,
bool bItalic, const char* pszFontName, const
PdfEncoding * const pEncoding );
/** Create a font subset.
* \param pMetrics a font metrics
* \param pszFontName a font name for debug output
* \param bBold if true this font will be treated as bold font
* \param bItalic if true this font will be treated as italic font
* \param vecGlyphs the list of all glyphs that should get embedded in
to this subset
*
* \returns a font handle or NULL in case of error
*/
/*
PdfFont* CreateFontSubset( PdfFontMetrics* pMetrics, const char* pszFon
tName, bool bBold,
bool bItalic, const std::vector<int> & vecGl
yphs );
*/
#ifdef _WIN32
/** Load and create a font with windows API calls
*
* This method is only available on Windows systems.
*
* \param pszFontName a fontnanme
* \param bBold if true search for a bold font
* \param bItalic if true search for an italic font
* \param bEmbedd if true embedd the font
* \param pEncoding the encoding of the font. The font will not take o
wnership of this object.
* *
* \returns a font handle or NULL in case of error * \returns a font handle or NULL in case of error
*/ */
PdfFont* CreateFont( PdfFontMetrics* pMetrics, bool bEmbedd, const char PdfFont* GetWin32Font( const char* pszFontName, bool bBold, bool bItali
* pszFontName = NULL ); c, bool bEmbedd, const PdfEncoding * const pEncoding );
#endif // _WIN32
private: private:
typedef std::vector<PdfFont*> TSortedFontList; typedef std::vector<TFontCacheElement> TSortedFontList;
typedef TSortedFontList::iterator TISortedFontList; typedef TSortedFontList::iterator TISortedFontList;
typedef TSortedFontList::const_iterator TCISortedFontList; typedef TSortedFontList::const_iterator TCISortedFontList;
TSortedFontList m_vecFonts; TSortedFontList m_vecFonts; ///< Sorted list of all fonts,
FT_Library m_ftLibrary; currently in the cache
TSortedFontList m_vecFontSubsets;
FT_Library m_ftLibrary; ///< Handle to the freetype li
brary
#if !defined(_WIN32) && !defined(__APPLE_CC__) void* m_pFcConfig; ///< Handle to fontconfig on u
FcConfig* m_pFcConfig; nix systems
#endif
PdfVecObjects* m_pParent; PdfVecObjects* m_pParent; ///< Handle to parent for crea ting new fonts and objects
}; };
}; };
#endif /* _PDF_FONT_CACHE_H_ */ #endif /* _PDF_FONT_CACHE_H_ */
 End of changes. 21 change blocks. 
16 lines changed or deleted 165 lines changed or added


 PdfFontMetrics.h   PdfFontMetrics.h 
skipping to change at line 26 skipping to change at line 26
* License along with this program; if not, write to the * * License along with this program; if not, write to the *
* Free Software Foundation, Inc., * * Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
************************************************************************** */ ************************************************************************** */
#ifndef _PDF_FONT_METRICS_H_ #ifndef _PDF_FONT_METRICS_H_
#define _PDF_FONT_METRICS_H_ #define _PDF_FONT_METRICS_H_
#include "PdfDefines.h" #include "PdfDefines.h"
#include "Pdf3rdPtyForwardDecl.h" #include "Pdf3rdPtyForwardDecl.h"
#include "PdfString.h"
#ifndef CONVERSION_CONSTANT #ifndef PODOFO_CONVERSION_CONSTANT
#define CONVERSION_CONSTANT 0.002834645669291339 #define PODOFO_CONVERSION_CONSTANT 0.002834645669291339
#endif // CONVERSION_CONSTANT #endif // PODOFO_CONVERSION_CONSTANT
namespace PoDoFo { namespace PoDoFo {
class PdfArray; class PdfArray;
class PdfVariant; class PdfVariant;
/** /**
* Enum for the different font formats supported by PoDoFo * Enum for the different font formats supported by PoDoFo
*/ */
typedef enum EPdfFontType { enum EPdfFontType {
ePdfFontType_TrueType, ePdfFontType_TrueType,
ePdfFontType_Type1Pfa, ePdfFontType_Type1Pfa,
ePdfFontType_Type1Pfb, ePdfFontType_Type1Pfb,
ePdfFontType_Unknown = 0xff ePdfFontType_Unknown = 0xff
}; };
class PODOFO_API PdfFontMetrics { class PODOFO_API PdfFontMetrics {
public: public:
/** Create a font metrics object for a given true type file /** Create a font metrics object for a given true type file
* \param pLibrary handle to an initialized FreeType2 library handle * \param pLibrary handle to an initialized FreeType2 library handle
* \param pszFilename filename of a truetype file * \param pszFilename filename of a truetype file
*/ */
PdfFontMetrics( FT_Library* pLibrary, const char* pszFilename ); PdfFontMetrics( FT_Library* pLibrary, const char* pszFilename );
/** Create a font metrics object for a given memory buffer /** Create a font metrics object for a given memory buffer
* \param pLibrary handle to an initialized FreeType2 library handle * \param pLibrary handle to an initialized FreeType2 library handle
* \param pBuffer block of memory representing the font data * \param pBuffer block of memory representing the font data (PdfFontM etrics will copy the buffer)
* \param nBufLen the length of the buffer * \param nBufLen the length of the buffer
*/ */
PdfFontMetrics( FT_Library* pLibrary, const char* pBuffer, unsigned int nBufLen ); PdfFontMetrics( FT_Library* pLibrary, const char* pBuffer, unsigned int nBufLen );
/** Create a font metrics object for a given true type file
* \param pLibrary handle to an initialized FreeType2 library handle
* \param rBuffer a buffer containing a font file
*/
PdfFontMetrics( FT_Library* pLibrary, const PdfRefCountedBuffer & rBuff
er );
/** Create a font metrics object for a given freetype font. /** Create a font metrics object for a given freetype font.
* \param pLibrary handle to an initialized FreeType2 library handle * \param pLibrary handle to an initialized FreeType2 library handle
* \param face a valid freetype font face * \param face a valid freetype font face
*/ */
PdfFontMetrics( FT_Library* pLibrary, FT_Face face ); PdfFontMetrics( FT_Library* pLibrary, FT_Face face );
virtual ~PdfFontMetrics(); virtual ~PdfFontMetrics();
/** Create a width array for this font which is a required part /** Create a width array for this font which is a required part
* of every font dictionary. * of every font dictionary.
* \param var the final width array is written to this PdfVariant * \param var the final width array is written to this PdfVariant
* \param nFirst first character to be in the array * \param nFirst first character to be in the array
* \param nLast last character code to be in the array * \param nLast last character code to be in the array
*/ */
void GetWidthArray( PdfVariant & var, unsigned int nFirst, unsigned int nLast ) const; void GetWidthArray( PdfVariant & var, unsigned int nFirst, unsigned int nLast ) const;
/** Get the width of a single glyph id
*
* \returns the width of a single glyph id
*/
double GetGlyphWidth( int nGlyphId ) const;
/** Create the bounding box array as required by the PDF reference /** Create the bounding box array as required by the PDF reference
* so that it can be written directly to a PDF file. * so that it can be written directly to a PDF file.
* *
* \param array write the bounding box to this array. * \param array write the bounding box to this array.
*/ */
void GetBoundingBox( PdfArray & array ) const; void GetBoundingBox( PdfArray & array ) const;
/** Retrieve the width of a given text string in PDF units when /** Retrieve the width of a given text string in PDF units when
* drawn with the current font * drawn with the current font
* \param rsString a PdfString from which the width shall be calculate
d
* \returns the width in PDF units
*
* This is an overloaded method for your convinience!
*/
inline double StringWidth( const PdfString & rsString ) const;
/** Retrieve the width of a given text string in PDF units when
* drawn with the current font
* \param pszText a text string of which the width should be calculate d * \param pszText a text string of which the width should be calculate d
* \param nLength if != 0 only the width of the nLength first characte rs is calculated * \param nLength if != 0 only the width of the nLength first characte rs is calculated
* \returns the width in PDF units * \returns the width in PDF units
*/ */
double StringWidth( const char* pszText, unsigned int nLength = 0 ) con st; double StringWidth( const char* pszText, unsigned int nLength = 0 ) con st;
/** Retrieve the width of a given text string in 1/1000th mm when /** Retrieve the width of a given text string in 1/1000th mm when
* drawn with the current font * drawn with the current font
* \param pszText a text string of which the width should be calculate d * \param pszText a text string of which the width should be calculate d
* \param nLength if != 0 only the width of the nLength first characte rs is calculated * \param nLength if != 0 only the width of the nLength first characte rs is calculated
* \returns the width in 1/1000th mm * \returns the width in 1/1000th mm
*/ */
unsigned long StringWidthMM( const char* pszText, unsigned int nLength = 0 ) const; unsigned long StringWidthMM( const char* pszText, unsigned int nLength = 0 ) const;
/** Retrieve the width of the given character in PDF units in the curre nt font /** Retrieve the width of the given character in PDF units in the curre nt font
* \param c character * \param c character
* \returns the width in PDF units * \returns the width in PDF units
*/ */
double CharWidth( char c ) const; double CharWidth( unsigned char c ) const;
/** Retrieve the width of the given character in 1/1000th mm in the cur rent font /** Retrieve the width of the given character in 1/1000th mm in the cur rent font
* \param c character * \param c character
* \returns the width in 1/1000th mm * \returns the width in 1/1000th mm
*/ */
unsigned long CharWidthMM( char c ) const; unsigned long CharWidthMM( unsigned char c ) const;
/** Retrieve the line spacing for this font /** Retrieve the line spacing for this font
* \returns the linespacing in PDF units * \returns the linespacing in PDF units
*/ */
inline double GetLineSpacing() const; inline double GetLineSpacing() const;
/** Retrieve the line spacing for this font /** Retrieve the line spacing for this font
* \returns the linespacing in 1/1000th mm * \returns the linespacing in 1/1000th mm
*/ */
inline unsigned long GetLineSpacingMM() const; inline unsigned long GetLineSpacingMM() const;
skipping to change at line 147 skipping to change at line 169
* \returns the underline position in PDF units * \returns the underline position in PDF units
*/ */
inline double GetUnderlinePosition() const; inline double GetUnderlinePosition() const;
/** Return the position of the underline for the current font /** Return the position of the underline for the current font
* size in 1/1000th mm * size in 1/1000th mm
* \returns the underline position in 1/1000th mm * \returns the underline position in 1/1000th mm
*/ */
inline long GetUnderlinePositionMM() const; inline long GetUnderlinePositionMM() const;
/** Return the position of the strikeout for the current font
* size in PDF units
* \returns the underline position in PDF units
*/
inline double GetStrikeOutPosition() const;
/** Return the position of the strikeout for the current font
* size in 1/1000th mm
* \returns the underline position in 1/1000th mm
*/
inline unsigned long GetStrikeOutPositionMM() const;
/** Get the width of the strikeout for the current
* font size in PDF units
* \returns the thickness of the strikeout in PDF units
*/
inline double GetStrikeoutThickness() const;
/** Get the width of the strikeout for the current
* font size in 1/1000th mm
* \returns the thickness of the strikeout in 1/1000th mm
*/
inline unsigned long GetStrikeoutThicknessMM() const;
/** Get a pointer to the path of the font file. /** Get a pointer to the path of the font file.
* \returns a zero terminated string containing the filename of the fo nt file * \returns a zero terminated string containing the filename of the fo nt file
*/ */
inline const char* GetFilename() const; inline const char* GetFilename() const;
/** Get a pointer to the actual font data - if it was loaded from memor y. /** Get a pointer to the actual font data - if it was loaded from memor y.
* \returns a binary buffer of data containing the font data * \returns a binary buffer of data containing the font data
*/ */
inline const char* GetFontData() const; inline const char* GetFontData() const;
/** Get the length of the actual font data - if it was loaded from memo ry. /** Get the length of the actual font data - if it was loaded from memo ry.
* \returns a the length of the font data * \returns a the length of the font data
*/ */
inline unsigned int GetFontDataLen() const; inline unsigned int GetFontDataLen() const;
/** Get a string with the postscript name of the font. /** Get a string with the postscript name of the font.
* \returns the postscript name of the font or NULL string if no posts cript name is available. * \returns the postscript name of the font or NULL string if no posts cript name is available.
*/ */
const char* GetFontname() const; const char* GetFontname() const;
/** Get a string with the postscript name of the font.
* \returns the postscript name of the font or empty string if no post
script name is available.
*/
// const std::string Fontname() const;
/** Get the weight of this font. /** Get the weight of this font.
* Used to build the font dictionay * Used to build the font dictionay
* \returns the weight of this font (500 is normal). * \returns the weight of this font (500 is normal).
*/ */
inline unsigned int GetWeight() const; inline unsigned int GetWeight() const;
/** Get the ascent of this font in PDF /** Get the ascent of this font in PDF
* units for the current font size. * units for the current font size.
* *
* \returns the ascender for this font * \returns the ascender for this font
skipping to change at line 227 skipping to change at line 268
inline int GetItalicAngle() const; inline int GetItalicAngle() const;
/** Set the font size of this metrics object for width and height /** Set the font size of this metrics object for width and height
* calculations. * calculations.
* This is typically called from PdfFont for you. * This is typically called from PdfFont for you.
* *
* \param fSize font size in points * \param fSize font size in points
*/ */
void SetFontSize( float fSize ); void SetFontSize( float fSize );
/** Get the filename where a font is located on the system /** Retrieve the current font size of this metrics object
* On Unix systems the FontConfig library is used to find fonts. * \returns the current font size
*/
inline float GetFontSize() const;
/** Set the horizontal scaling of the font for compressing (< 100) and
expanding (>100)
* This is typically called from PdfFont for you.
* *
* Everytime you call this function. The fontconfig library will be in * \param fScale scaling in percent
itialized */
* and deinitialized afterwards, which is kind of slow. void SetFontScale( float fScale );
* You should use the version below which can use an existing FcConfig
object. /** Retrieve the current horizontal scaling of this metrics object
* * \returns the current font scaling
* \param pszFontname name of the font e.g "Arial" or "Times New Roman */
" inline float GetFontScale() const;
* \returns the compelte absolute path to a matching font file or NULL
* if none was found. /** Set the character spacing of this metrics object
*/ * \param fCharSpace character spacing in percent
static std::string GetFilenameForFont( const char* pszFontname ); */
void SetFontCharSpace( float fCharSpace );
/** Get the filename where a font is located on the system
* On Unix systems the FontConfig library is used to find fonts. /** Retrieve the current character spacing of this metrics object
* \param pConfig a handle to a fontconfig config object, * \returns the current font character spacing
* using this function is fast as Fontconfig is not initialized */
in this function. inline float GetFontCharSpace() const;
* \param pszFontname name of the font e.g "Arial" or "Times New Roman
"
* \returns the compelte absolute path to a matching font file or NULL
* if none was found.
*/
#if defined(_WIN32) || defined(__APPLE_CC__)
#else
static std::string GetFilenameForFont( FcConfig* pConfig, const char* p
szFontname );
#endif
/** /**
* \returns the fonttype of the loaded font * \returns the fonttype of the loaded font
*/ */
inline EPdfFontType GetFontType() const; inline EPdfFontType GetFontType() const;
/** Get the glyph id for a unicode character
* in the current font.
*
* \param lUnicode the unicode character value
* \returns the glyhph id for the character or 0 if the glyph was not
found.
*/
long GetGlyphId( long lUnicode ) const;
FT_Face GetFace() { return m_face; };
private: private:
/** Initialize this object from an in memory buffer
* Called internally by the constructors
*/
void InitFromBuffer();
/** Load the metric data from the FTFace data /** Load the metric data from the FTFace data
* Called internally by the constructors * Called internally by the constructors
*/ */
void InitFromFace(); void InitFromFace();
/** Try to detect the internal fonttype from /** Try to detect the internal fonttype from
* the file extension of a fontfile. * the file extension of a fontfile.
* *
* This function will set the member m_eFontType. * This function will set the member m_eFontType.
* *
skipping to change at line 289 skipping to change at line 346
int m_nItalicAngle; int m_nItalicAngle;
double m_dAscent; double m_dAscent;
double m_dPdfAscent; double m_dPdfAscent;
double m_dDescent; double m_dDescent;
double m_dPdfDescent; double m_dPdfDescent;
double m_dLineSpacing; double m_dLineSpacing;
double m_dUnderlineThickness; double m_dUnderlineThickness;
double m_dUnderlinePosition; double m_dUnderlinePosition;
double m_dStrikeOutThickness;
double m_dStrikeOutPosition;
std::string m_sFilename; std::string m_sFilename;
char* m_pFontData; PdfRefCountedBuffer m_bufFontData;
unsigned int m_nFontDataLen;
float m_fFontSize; float m_fFontSize;
float m_fFontScale;
float m_fFontCharSpace;
std::vector<double> m_vecWidth; std::vector<double> m_vecWidth;
EPdfFontType m_eFontType; EPdfFontType m_eFontType;
}; };
// ----------------------------------------------------- // -----------------------------------------------------
// //
// ----------------------------------------------------- // -----------------------------------------------------
double PdfFontMetrics::StringWidth( const PdfString & rsString ) const
{
return this->StringWidth( rsString.GetString() );
}
// -----------------------------------------------------
//
// -----------------------------------------------------
double PdfFontMetrics::GetLineSpacing() const double PdfFontMetrics::GetLineSpacing() const
{ {
return m_dLineSpacing; return m_dLineSpacing;
} }
// ----------------------------------------------------- // -----------------------------------------------------
// //
// ----------------------------------------------------- // -----------------------------------------------------
unsigned long PdfFontMetrics::GetLineSpacingMM() const unsigned long PdfFontMetrics::GetLineSpacingMM() const
{ {
return static_cast<unsigned long>(m_dLineSpacing / CONVERSION_CONSTANT) ; return static_cast<unsigned long>(m_dLineSpacing / PODOFO_CONVERSION_CO NSTANT);
} }
// ----------------------------------------------------- // -----------------------------------------------------
// //
// ----------------------------------------------------- // -----------------------------------------------------
double PdfFontMetrics::GetUnderlinePosition() const double PdfFontMetrics::GetUnderlinePosition() const
{ {
return m_dUnderlinePosition; return m_dUnderlinePosition;
} }
// ----------------------------------------------------- // -----------------------------------------------------
// //
// ----------------------------------------------------- // -----------------------------------------------------
long PdfFontMetrics::GetUnderlinePositionMM() const long PdfFontMetrics::GetUnderlinePositionMM() const
{ {
return static_cast<long>(m_dUnderlinePosition / CONVERSION_CONSTANT); return static_cast<long>(m_dUnderlinePosition / PODOFO_CONVERSION_CONS
TANT);
}
// -----------------------------------------------------
//
// -----------------------------------------------------
double PdfFontMetrics::GetStrikeOutPosition() const
{
return m_dStrikeOutPosition;
}
// -----------------------------------------------------
//
// -----------------------------------------------------
unsigned long PdfFontMetrics::GetStrikeOutPositionMM() const
{
return static_cast<long>(m_dStrikeOutPosition / PODOFO_CONVERSI
ON_CONSTANT);
} }
// ----------------------------------------------------- // -----------------------------------------------------
// //
// ----------------------------------------------------- // -----------------------------------------------------
double PdfFontMetrics::GetUnderlineThickness() const double PdfFontMetrics::GetUnderlineThickness() const
{ {
return m_dUnderlineThickness; return m_dUnderlineThickness;
} }
// ----------------------------------------------------- // -----------------------------------------------------
// //
// ----------------------------------------------------- // -----------------------------------------------------
unsigned long PdfFontMetrics::GetUnderlineThicknessMM() const unsigned long PdfFontMetrics::GetUnderlineThicknessMM() const
{ {
return static_cast<unsigned long>(m_dUnderlineThickness / CONVERSION_CO return static_cast<unsigned long>(m_dUnderlineThickness / PODOFO_CONVER
NSTANT); SION_CONSTANT);
}
// -----------------------------------------------------
//
// -----------------------------------------------------
double PdfFontMetrics::GetStrikeoutThickness() const
{
return m_dStrikeOutThickness;
}
// -----------------------------------------------------
//
// -----------------------------------------------------
unsigned long PdfFontMetrics::GetStrikeoutThicknessMM() const
{
return static_cast<unsigned long>(m_dStrikeOutThickness / PODOFO_CONVER
SION_CONSTANT);
} }
// ----------------------------------------------------- // -----------------------------------------------------
// //
// ----------------------------------------------------- // -----------------------------------------------------
const char* PdfFontMetrics::GetFilename() const const char* PdfFontMetrics::GetFilename() const
{ {
return m_sFilename.c_str(); return m_sFilename.c_str();
} }
// ----------------------------------------------------- // -----------------------------------------------------
// //
// ----------------------------------------------------- // -----------------------------------------------------
const char* PdfFontMetrics::GetFontData() const const char* PdfFontMetrics::GetFontData() const
{ {
return m_pFontData; return m_bufFontData.GetBuffer();
} }
// ----------------------------------------------------- // -----------------------------------------------------
// //
// ----------------------------------------------------- // -----------------------------------------------------
unsigned int PdfFontMetrics::GetFontDataLen() const unsigned int PdfFontMetrics::GetFontDataLen() const
{ {
return m_nFontDataLen; return m_bufFontData.GetSize();
} }
// ----------------------------------------------------- // -----------------------------------------------------
// //
// ----------------------------------------------------- // -----------------------------------------------------
unsigned int PdfFontMetrics::GetWeight() const unsigned int PdfFontMetrics::GetWeight() const
{ {
return m_nWeight; return m_nWeight;
} }
skipping to change at line 428 skipping to change at line 528
} }
// ----------------------------------------------------- // -----------------------------------------------------
// //
// ----------------------------------------------------- // -----------------------------------------------------
EPdfFontType PdfFontMetrics::GetFontType() const EPdfFontType PdfFontMetrics::GetFontType() const
{ {
return m_eFontType; return m_eFontType;
} }
// -----------------------------------------------------
//
// -----------------------------------------------------
float PdfFontMetrics::GetFontSize() const
{
return m_fFontSize;
}
// -----------------------------------------------------
//
// -----------------------------------------------------
float PdfFontMetrics::GetFontScale() const
{
return m_fFontScale;
}
// -----------------------------------------------------
//
// -----------------------------------------------------
float PdfFontMetrics::GetFontCharSpace() const
{
return m_fFontCharSpace;
}
}; };
#endif // _PDF_FONT_METRICS_H_ #endif // _PDF_FONT_METRICS_H_
 End of changes. 26 change blocks. 
52 lines changed or deleted 176 lines changed or added


 PdfHintStream.h   PdfHintStream.h 
skipping to change at line 32 skipping to change at line 32
#define _PDF_HINT_STREAM_H_ #define _PDF_HINT_STREAM_H_
#include "PdfDefines.h" #include "PdfDefines.h"
#include "PdfElement.h" #include "PdfElement.h"
#include "PdfWriter.h" #include "PdfWriter.h"
namespace PoDoFo { namespace PoDoFo {
class PdfPagesTree; class PdfPagesTree;
// FIXME CR: Should PdfHintStream be part of the public API? namespace NonPublic {
class PODOFO_API PdfHintStream : public PdfElement {
// PdfHintStream is not part of the public API and is NOT exported as part
of
// the DLL/shared library interface. Do not rely on it.
class PdfHintStream : public PdfElement {
public: public:
PdfHintStream( PdfVecObjects* pParent, PdfPagesTree* pPagesTree ); PdfHintStream( PdfVecObjects* pParent, PdfPagesTree* pPagesTree );
~PdfHintStream(); ~PdfHintStream();
/** Create the hint stream /** Create the hint stream
* \param pXRef pointer to a valid XREF table structure * \param pXRef pointer to a valid XREF table structure
*/ */
//void Create( TVecXRefTable* pXRef ); //void Create( TVecXRefTable* pXRef );
/** Write a pdf_uint16 to the stream in big endian format. /** Write a pdf_uint16 to the stream in big endian format.
skipping to change at line 63 skipping to change at line 67
private: private:
//void CreatePageHintTable( TVecXRefTable* pXRef ); //void CreatePageHintTable( TVecXRefTable* pXRef );
void CreateSharedObjectHintTable(); void CreateSharedObjectHintTable();
private: private:
PdfPagesTree* m_pPagesTree; PdfPagesTree* m_pPagesTree;
bool m_bLittleEndian; bool m_bLittleEndian;
}; };
}; }; // end namespace NonPublic
}; // end namespace PoDoFo
#endif /* _PDF_HINT_STREAM_H_ */ #endif /* _PDF_HINT_STREAM_H_ */
 End of changes. 2 change blocks. 
3 lines changed or deleted 10 lines changed or added


 PdfImage.h   PdfImage.h 
skipping to change at line 33 skipping to change at line 33
#include "PdfDefines.h" #include "PdfDefines.h"
#include "PdfFilter.h" #include "PdfFilter.h"
#include "PdfXObject.h" #include "PdfXObject.h"
namespace PoDoFo { namespace PoDoFo {
class PdfDocument; class PdfDocument;
class PdfInputStream; class PdfInputStream;
class PdfObject; class PdfObject;
class PdfStreamedDocument;
class PdfVecObjects; class PdfVecObjects;
/** A PdfImage object is needed when ever you want to embedd an image /** A PdfImage object is needed when ever you want to embedd an image
* file into a PDF document. * file into a PDF document.
* The PdfImage object is embedded once and can be drawn as often * The PdfImage object is embedded once and can be drawn as often
* as you want on any page in the document using a PdfImageRef object * as you want on any page in the document using a PdfImageRef object
* which has to be retrieved from the PdfImage object before drawing. * which has to be retrieved from the PdfImage object before drawing.
* *
* \see GetImageReference * \see GetImageReference
* \see PdfPainter::DrawImage * \see PdfPainter::DrawImage
skipping to change at line 62 skipping to change at line 61
*/ */
PdfImage( PdfVecObjects* pParent ); PdfImage( PdfVecObjects* pParent );
/** Constuct a new PdfImage object /** Constuct a new PdfImage object
* This is an overloaded constructor. * This is an overloaded constructor.
* *
* \param pParent parent document * \param pParent parent document
*/ */
PdfImage( PdfDocument* pParent ); PdfImage( PdfDocument* pParent );
/** Constuct a new PdfImage object
* This is an overloaded constructor.
*
* \param pParent parent document
*/
PdfImage( PdfStreamedDocument* pParent );
/** Construct an image from an existing PdfObject /** Construct an image from an existing PdfObject
* *
* \param pObject a PdfObject that has to be an image * \param pObject a PdfObject that has to be an image
*/ */
PdfImage( PdfObject* pObject ); PdfImage( PdfObject* pObject );
~PdfImage(); ~PdfImage();
/** Set the color space of this image. The default value is /** Set the color space of this image. The default value is
* ePdfColorSpace_DeviceRGB. * ePdfColorSpace_DeviceRGB.
* \param eColorSpace one of ePdfColorSpace_DeviceGray, ePdfColorSpace _DeviceRGB and * \param eColorSpace one of ePdfColorSpace_DeviceGray, ePdfColorSpace _DeviceRGB and
* ePdfColorSpace_DeviceCMYK * ePdfColorSpace_DeviceCMYK
*
* \see SetImageICCProfile to set an ICC profile instead of a simple c
olorspace
*/ */
void SetImageColorSpace( EPdfColorSpace eColorSpace ); void SetImageColorSpace( EPdfColorSpace eColorSpace );
/** Set an ICC profile for this image.
*
* \param pStream an input stream from which the ICC profiles data can
be read
* \param lColorComponents the number of colorcomponents of the ICC pr
ofile
* \param eAlternateColorSpace an alternate colorspace to use if the I
CC profile cannot be used
*
* \see SetImageColorSpace to set an colorspace instead of an ICC prof
ile for this image
*/
void SetImageICCProfile( PdfInputStream* pStream, long lColorComponents
,
EPdfColorSpace eAlternateColorSpace = ePdfColo
rSpace_DeviceRGB );
//EPdfColorSpace GetImageColorSpace() const; //EPdfColorSpace GetImageColorSpace() const;
/** Get the width of the image when drawn in PDF units /** Get the width of the image when drawn in PDF units
* \returns the width in PDF units * \returns the width in PDF units
*/ */
inline double GetWidth() const; inline double GetWidth() const;
/** Get the height of the image when drawn in PDF units /** Get the height of the image when drawn in PDF units
* \returns the height in PDF units * \returns the height in PDF units
*/ */
skipping to change at line 126 skipping to change at line 131
* \param nWidth width of the image in pixels * \param nWidth width of the image in pixels
* \param nHeight height of the image in pixels * \param nHeight height of the image in pixels
* \param nBitsPerComponent bits per color component of the image (dep ends on the image colorspace you have set * \param nBitsPerComponent bits per color component of the image (dep ends on the image colorspace you have set
* but is 8 in most cases) * but is 8 in most cases)
* \param pStream stream supplieding raw image data * \param pStream stream supplieding raw image data
* \param vecFilters these filters will be applied to compress the ima ge data * \param vecFilters these filters will be applied to compress the ima ge data
*/ */
void SetImageData( unsigned int nWidth, unsigned int nHeight, void SetImageData( unsigned int nWidth, unsigned int nHeight,
unsigned int nBitsPerComponent, PdfInputStream* pStr eam, const TVecFilters & vecFilters ); unsigned int nBitsPerComponent, PdfInputStream* pStr eam, const TVecFilters & vecFilters );
/** Load the image data from a file
* \param pszFilename
*/
void LoadFromFile( const char* pszFilename );
#ifdef PODOFO_HAVE_JPEG_LIB #ifdef PODOFO_HAVE_JPEG_LIB
/** Load the image data from a JPEG file /** Load the image data from a JPEG file
* \param pszFilename * \param pszFilename
*/ */
void LoadFromFile( const char* pszFilename ); void LoadFromJpeg( const char* pszFilename );
#endif // PODOFO_HAVE_JPEG_LIB #endif // PODOFO_HAVE_JPEG_LIB
#ifdef PODOFO_HAVE_TIFF_LIB
/** Load the image data from a TIFF file
* \param pszFilename
*/
void LoadFromTiff( const char* pszFilename );
#endif // PODOFO_HAVE_TIFF_LIB
private: private:
/** Set the actual image data from an input stream. /** Set the actual image data from an input stream.
* The data has to be encoded already and an appropriate * The data has to be encoded already and an appropriate
* filters key entry has to be set manually before! * filters key entry has to be set manually before!
* *
* \param nWidth width of the image in pixels * \param nWidth width of the image in pixels
* \param nHeight height of the image in pixels * \param nHeight height of the image in pixels
* \param nBitsPerComponent bits per color component of the image (dep ends on the image colorspace you have set * \param nBitsPerComponent bits per color component of the image (dep ends on the image colorspace you have set
* but is 8 in most cases) * but is 8 in most cases)
 End of changes. 7 change blocks. 
9 lines changed or deleted 31 lines changed or added


 PdfImmediateWriter.h   PdfImmediateWriter.h 
skipping to change at line 30 skipping to change at line 30
#ifndef _PDF_IMMEDIATE_WRITER_H_ #ifndef _PDF_IMMEDIATE_WRITER_H_
#define _PDF_IMMEDIATE_WRITER_H_ #define _PDF_IMMEDIATE_WRITER_H_
#include "PdfDefines.h" #include "PdfDefines.h"
#include "PdfVecObjects.h" #include "PdfVecObjects.h"
#include "PdfWriter.h" #include "PdfWriter.h"
namespace PoDoFo { namespace PoDoFo {
class PdfEncrypt;
class PdfOutputDevice; class PdfOutputDevice;
class PdfXRef; class PdfXRef;
class PODOFO_API PdfImmediateWriter : private PdfWriter, class PODOFO_API PdfImmediateWriter : private PdfWriter,
private PdfVecObjects::Observer, private PdfVecObjects::Observer,
private PdfVecObjects::StreamFactory { private PdfVecObjects::StreamFactory {
public: public:
PdfImmediateWriter( PdfOutputDevice* pDevice, PdfVecObjects* pVecObject /** Create a new PdfWriter that writes objects with streams immediately
s, const PdfObject* pTrailer, EPdfVersion eVersion = ePdfVersion_1_5 ); to a PdfOutputDevice
*
* This has the advantage that large documents can be created without
* having to keep the whole document in memory.
*
* @param pDevice all stream streams are immediately written to this o
utput device
* while the document is created.
* @param pVecObjects a vector of objects containing the objects which
are written to disk
* @param pTrailer the trailer object
* @param eVersion the PDF version of the document to write.
* The PDF version can only be set in the construc
tor
* as it is the first item written to the document
on disk.
* @param pEncrypt pointer to an encryption object or NULL. If not NUL
L
* the PdfEncrypt object will be copied and used to en
crypt the
* created document.
*/
PdfImmediateWriter( PdfOutputDevice* pDevice, PdfVecObjects* pVecObject
s, const PdfObject* pTrailer,
EPdfVersion eVersion = ePdfVersion_1_5, PdfEncrypt*
pEncrypt = NULL );
~PdfImmediateWriter(); ~PdfImmediateWriter();
/** Get the PDF version of the document
* The PDF version can only be set in the constructor
* as it is the first item written to the document on disk
*
* \returns EPdfVersion version of the pdf document
*/
inline EPdfVersion GetPdfVersion() const;
private: private:
void WriteObject( const PdfObject* pObject ); void WriteObject( const PdfObject* pObject );
/** Called when the PdfVecObjects we observer is deleted. /** Called when the PdfVecObjects we observer is deleted.
*/ */
void ParentDestructed(); void ParentDestructed();
/** Finish the PDF file. /** Finish the PDF file.
* I.e. write the XRef and close the output device. * I.e. write the XRef and close the output device.
*/ */
skipping to change at line 89 skipping to change at line 116
private: private:
PdfVecObjects* m_pParent; PdfVecObjects* m_pParent;
PdfOutputDevice* m_pDevice; PdfOutputDevice* m_pDevice;
PdfXRef* m_pXRef; PdfXRef* m_pXRef;
PdfObject* m_pLast; PdfObject* m_pLast;
bool m_bOpenStream; bool m_bOpenStream;
}; };
inline EPdfVersion PdfImmediateWriter::GetPdfVersion() const
{
return PdfWriter::GetPdfVersion();
}
}; };
#endif /* _PDF_IMMEDIATE_WRITER_H_ */ #endif /* _PDF_IMMEDIATE_WRITER_H_ */
 End of changes. 4 change blocks. 
2 lines changed or deleted 42 lines changed or added


 PdfMemStream.h   PdfMemStream.h 
skipping to change at line 32 skipping to change at line 32
#define _PDF_MEM_STREAM_H_ #define _PDF_MEM_STREAM_H_
#include "PdfDefines.h" #include "PdfDefines.h"
#include "PdfStream.h" #include "PdfStream.h"
#include "PdfDictionary.h" #include "PdfDictionary.h"
#include "PdfRefCountedBuffer.h" #include "PdfRefCountedBuffer.h"
namespace PoDoFo { namespace PoDoFo {
class PdfBufferOutputStream;
class PdfName; class PdfName;
class PdfObject; class PdfObject;
/** A PDF stream can be appended to any PdfObject /** A PDF stream can be appended to any PdfObject
* and can contain abitrary data. * and can contain abitrary data.
* *
* A PDF memory stream is held completely in memory. * A PDF memory stream is held completely in memory.
* *
* Most of the time it will contain either drawing commands * Most of the time it will contain either drawing commands
* to draw onto a page or binary data like a font or an image. * to draw onto a page or binary data like a font or an image.
skipping to change at line 67 skipping to change at line 68
/** Create a shallow copy of a PdfStream object /** Create a shallow copy of a PdfStream object
* *
* \param rhs the object to clone * \param rhs the object to clone
*/ */
PdfMemStream( const PdfMemStream & rhs ); PdfMemStream( const PdfMemStream & rhs );
~PdfMemStream(); ~PdfMemStream();
/** Write the stream to an output device /** Write the stream to an output device
* \param pDevice write to this outputdevice. * \param pDevice write to this outputdevice.
* \param pEncrypt encrypt stream data using this object
*/ */
virtual void Write( PdfOutputDevice* pDevice ); virtual void Write( PdfOutputDevice* pDevice, PdfEncrypt* pEncrypt = NU LL );
/** Get a malloced buffer of the current stream. /** Get a malloced buffer of the current stream.
* No filters will be applied to the buffer, so * No filters will be applied to the buffer, so
* if the stream is Flate compressed the compressed copy * if the stream is Flate compressed the compressed copy
* will be returned. * will be returned.
* *
* The caller has to free() the buffer. * The caller has to free() the buffer.
* *
* \param pBuffer pointer to the buffer * \param pBuffer pointer to the buffer
* \param lLen pointer to the buffer length * \param lLen pointer to the buffer length
skipping to change at line 167 skipping to change at line 169
virtual void EndAppendImpl(); virtual void EndAppendImpl();
private: private:
/** Compress the current data using the FlateDecode(ZIP) algorithm /** Compress the current data using the FlateDecode(ZIP) algorithm
* Expects that all filters are setup correctly. * Expects that all filters are setup correctly.
* \returns ErrOk on success * \returns ErrOk on success
*/ */
void FlateCompressStreamData(); void FlateCompressStreamData();
private: private:
PdfRefCountedBuffer m_buffer; PdfRefCountedBuffer m_buffer;
PdfOutputStream* m_pStream; PdfOutputStream* m_pStream;
PdfOutputStream* m_pBufferStream; PdfBufferOutputStream* m_pBufferStream;
long m_lLength;
}; };
// ----------------------------------------------------- // -----------------------------------------------------
// //
// ----------------------------------------------------- // -----------------------------------------------------
const char* PdfMemStream::Get() const const char* PdfMemStream::Get() const
{ {
return m_buffer.GetBuffer(); return m_buffer.GetBuffer();
} }
// ----------------------------------------------------- // -----------------------------------------------------
// //
// ----------------------------------------------------- // -----------------------------------------------------
unsigned long PdfMemStream::GetLength() const unsigned long PdfMemStream::GetLength() const
{ {
return m_buffer.GetSize(); return m_lLength;
} }
// ----------------------------------------------------- // -----------------------------------------------------
// //
// ----------------------------------------------------- // -----------------------------------------------------
const char* PdfMemStream::GetInternalBuffer() const const char* PdfMemStream::GetInternalBuffer() const
{ {
return m_buffer.GetBuffer(); return m_buffer.GetBuffer();
} }
// ----------------------------------------------------- // -----------------------------------------------------
// //
// ----------------------------------------------------- // -----------------------------------------------------
unsigned long PdfMemStream::GetInternalBufferSize() const unsigned long PdfMemStream::GetInternalBufferSize() const
{ {
return m_buffer.GetSize(); return m_lLength;
} }
}; };
#endif // _PDF_MEM_STREAM_H_ #endif // _PDF_MEM_STREAM_H_
 End of changes. 6 change blocks. 
6 lines changed or deleted 10 lines changed or added


 PdfName.h   PdfName.h 
skipping to change at line 122 skipping to change at line 122
{ {
} }
virtual ~PdfName(); virtual ~PdfName();
/** Write the name to an output device in PDF format. /** Write the name to an output device in PDF format.
* This is an overloaded member function. * This is an overloaded member function.
* *
* \param pDevice write the object to this device * \param pDevice write the object to this device
*/ */
void Write( PdfOutputDevice* pDevice ) const; void Write( PdfOutputDevice* pDevice, const PdfEncrypt* pEncrypt = NULL ) const;
/** \returns the unescaped value of this name object /** \returns the unescaped value of this name object
* without the leading slash * without the leading slash
*/ */
PODOFO_NOTHROW inline const std::string& GetName() const; PODOFO_NOTHROW inline const std::string& GetName() const;
/** \returns the unescaped length of this /** \returns the unescaped length of this
* name object * name object
*/ */
PODOFO_NOTHROW inline size_t GetLength() const; PODOFO_NOTHROW inline size_t GetLength() const;
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 PdfNamesTree.h   PdfNamesTree.h 
skipping to change at line 35 skipping to change at line 35
#include "PdfElement.h" #include "PdfElement.h"
namespace PoDoFo { namespace PoDoFo {
class PdfDictionary; class PdfDictionary;
class PdfName; class PdfName;
class PdfObject; class PdfObject;
class PdfString; class PdfString;
class PdfVecObjects; class PdfVecObjects;
typedef enum EPdfNameLimits { enum EPdfNameLimits {
ePdfNameLimits_Before, ePdfNameLimits_Before,
ePdfNameLimits_Inside, ePdfNameLimits_Inside,
ePdfNameLimits_After ePdfNameLimits_After
}; };
class PODOFO_API PdfNamesTree : public PdfElement { class PODOFO_API PdfNamesTree : public PdfElement {
public: public:
/** Create a new PdfNamesTree object /** Create a new PdfNamesTree object
* \param pParent parent of this action * \param pParent parent of this action
*/ */
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 PdfObject.h   PdfObject.h 
skipping to change at line 33 skipping to change at line 33
#include "PdfDefines.h" #include "PdfDefines.h"
#include "PdfName.h" #include "PdfName.h"
#include "PdfParser.h" #include "PdfParser.h"
#include "PdfReference.h" #include "PdfReference.h"
#include "PdfString.h" #include "PdfString.h"
#include "PdfVariant.h" #include "PdfVariant.h"
namespace PoDoFo { namespace PoDoFo {
class PdfEncrypt;
class PdfObject; class PdfObject;
class PdfOutputDevice; class PdfOutputDevice;
class PdfStream; class PdfStream;
class PdfVecObjects; class PdfVecObjects;
/** /**
* This class represents a PDF indirect Object in memory * This class represents a PDF indirect Object in memory
* *
* It is possible to manipulate the stream which can be appended to the obj ect * It is possible to manipulate the stream which can be appended to the obj ect
* (if the object is of underlying type dictionary). A PdfObject is unique ly * (if the object is of underlying type dictionary). A PdfObject is unique ly
* identified by an object number and a generation number which has to be * identified by an object number and a generation number which has to be
* passed to the constructor. * passed to the constructor.
* *
* The object can be written to a file easily using the Write() function. * The object can be written to a file easily using the WriteObject() funct ion.
* *
* \see Write() * \see WriteObject()
*/ */
class PODOFO_API PdfObject : public PdfVariant { class PODOFO_API PdfObject : public PdfVariant {
friend class PdfVecObjects; friend class PdfVecObjects;
public: public:
/** Create a PDF object with object and generation number -1 /** Create a PDF object with object and generation number -1
* and the value of being an empty PdfDictionary. * and the value of being an empty PdfDictionary.
*/ */
PdfObject(); PdfObject();
skipping to change at line 148 skipping to change at line 149
* All assosiated objects and streams will be copied along with the Pd fObject * All assosiated objects and streams will be copied along with the Pd fObject
* \param rhs PdfObject to clone * \param rhs PdfObject to clone
*/ */
PdfObject( const PdfObject & rhs ); PdfObject( const PdfObject & rhs );
virtual ~PdfObject(); virtual ~PdfObject();
/** Get the keys value out of the dictionary. If the key is a reference , /** Get the keys value out of the dictionary. If the key is a reference ,
* the reference is resolved and the object pointed to by the referenc e is returned. * the reference is resolved and the object pointed to by the referenc e is returned.
* *
*
* \param key look for the key named key in the dictionary * \param key look for the key named key in the dictionary
* *
* \returns the found value or NULL if the value is not in the * \returns the found value or NULL if the value is not in the
* dictionary or if this object is no dictionary * dictionary or if this object is no dictionary
*/ */
PdfObject* GetIndirectKey( const PdfName & key ); PdfObject* GetIndirectKey( const PdfName & key ) const;
/**
* MustGetIndirectKey() wraps GetIndirectKey to throw on null return.
* This makes it MUCH more readable to look up deep chains of linked ke
ys
* with the cost that it's not easy to tell at which point a missing ke
y/object
* was encountered.
*
* \returns the found value, which is never null
* \throws PdfError(ePdfError_NoObject) .
*/
inline PdfObject* MustGetIndirectKey( const PdfName & key ) const;
/** Write the complete object to a file. /** Write the complete object to a file.
* \param pDevice write the object to this device * \param pDevice write the object to this device
* \param pEncrypt an encryption object which is used to encrypt this
object
* or NULL to not encrypt this object
* \param keyStop if not KeyNull and a key == keyStop is found * \param keyStop if not KeyNull and a key == keyStop is found
* writing will stop right before this key! * writing will stop right before this key!
*/ */
void WriteObject( PdfOutputDevice* pDevice, const PdfName & keyStop = P dfName::KeyNull ) const; void WriteObject( PdfOutputDevice* pDevice, PdfEncrypt* pEncrypt, const PdfName & keyStop = PdfName::KeyNull ) const;
/** Get the length of the object in bytes if it was written to disk now . /** Get the length of the object in bytes if it was written to disk now .
* \returns the length of the object * \returns the length of the object
*/ */
unsigned long GetObjectLength(); unsigned long GetObjectLength();
/** Get a indirect reference to this object /** Get a indirect reference to this object
* \returns a PdfReference pointing to this object. * \returns a PdfReference pointing to this object.
*/ */
inline const PdfReference & Reference() const; inline const PdfReference & Reference() const;
skipping to change at line 198 skipping to change at line 211
* appended. * appended.
* *
* \returns true if the object has a stream * \returns true if the object has a stream
*/ */
inline bool HasStream() const; inline bool HasStream() const;
/** This operator is required for sorting a list of /** This operator is required for sorting a list of
* PdfObjects. It compares the objectnumber. If objectnumbers * PdfObjects. It compares the objectnumber. If objectnumbers
* are equal, the generation number is compared. * are equal, the generation number is compared.
*/ */
inline bool operator<( const PdfObject & rhs ) const; PODOFO_NOTHROW inline bool operator<( const PdfObject & rhs ) const;
/** Comperasion operator. /** Comperasion operator.
* Compares two PDF object only based on their object and generation n umber * Compares two PDF object only based on their object and generation n umber
*/ */
inline bool operator==( const PdfObject & rhs ) const; PODOFO_NOTHROW inline bool operator==( const PdfObject & rhs ) const;
/** Set the owner of this object, i.e. the PdfVecObjects to which /** Set the owner of this object, i.e. the PdfVecObjects to which
* this object belongs. * this object belongs.
* *
* \param pVecObjects a vector of pdf objects * \param pVecObjects a vector of pdf objects
*/ */
inline void SetOwner( PdfVecObjects* pVecObjects ); inline void SetOwner( PdfVecObjects* pVecObjects );
/** Get the owner of this object. /** Get the owner of this object.
* \return the creator of this object * \return the creator of this object
*/ */
inline PdfVecObjects* GetOwner() const; inline PdfVecObjects* GetOwner() const;
/** Get the parent of this object. /** Get the parent of this object.
* \return the parent of this object in the object hierarchie * \return the parent of this object in the object heirachy
*/ */
inline PdfObject* GetParent() const; inline PdfObject* GetParent() const;
/** Creates a copy of an existing PdfObject /** Creates a copy of an existing PdfObject
* All assosiated objects and streams will be copied along with the Pd fObject * All assosiated objects and streams will be copied along with the Pd fObject
* \param rhs PdfObject to clone * \param rhs PdfObject to clone
* \returns a reference to this object * \returns a reference to this object
*/ */
const PdfObject & operator=( const PdfObject & rhs ); const PdfObject & operator=( const PdfObject & rhs );
skipping to change at line 316 skipping to change at line 329
mutable bool m_bDelayedStreamLoadDone; mutable bool m_bDelayedStreamLoadDone;
#if defined(PODOFO_EXTRA_CHECKS) #if defined(PODOFO_EXTRA_CHECKS)
protected: protected:
PODOFO_NOTHROW bool DelayedStreamLoadInProgress() const { return m_bDel ayedStreamLoadInProgress; } PODOFO_NOTHROW bool DelayedStreamLoadInProgress() const { return m_bDel ayedStreamLoadInProgress; }
private: private:
mutable bool m_bDelayedStreamLoadInProgress; mutable bool m_bDelayedStreamLoadInProgress;
#endif #endif
}; };
// -----------------------------------------------------
//
// -----------------------------------------------------
bool PdfObject::DelayedStreamLoadDone() const bool PdfObject::DelayedStreamLoadDone() const
{ {
return m_bDelayedStreamLoadDone; return m_bDelayedStreamLoadDone;
} }
// -----------------------------------------------------
//
// -----------------------------------------------------
void PdfObject::EnableDelayedStreamLoading() void PdfObject::EnableDelayedStreamLoading()
{ {
m_bDelayedStreamLoadDone = false; m_bDelayedStreamLoadDone = false;
} }
// ----------------------------------------------------- // -----------------------------------------------------
// //
// ----------------------------------------------------- // -----------------------------------------------------
const PdfReference & PdfObject::Reference() const const PdfReference & PdfObject::Reference() const
{ {
skipping to change at line 379 skipping to change at line 398
inline bool PdfObject::HasStream() const inline bool PdfObject::HasStream() const
{ {
DelayedStreamLoad(); DelayedStreamLoad();
return ( m_pStream != NULL ); return ( m_pStream != NULL );
} }
// ----------------------------------------------------- // -----------------------------------------------------
// //
// ----------------------------------------------------- // -----------------------------------------------------
PdfObject* PdfObject::MustGetIndirectKey( const PdfName & key ) const
{
PdfObject* obj = GetIndirectKey(key);
if (!obj)
PODOFO_RAISE_ERROR( ePdfError_NoObject );
return obj;
}
// -----------------------------------------------------
//
// -----------------------------------------------------
// Default implementation of virtual void DelayedStreamLoadImpl() // Default implementation of virtual void DelayedStreamLoadImpl()
// throws, since delayed loading of steams should not be enabled // throws, since delayed loading of steams should not be enabled
// except by types that support it. // except by types that support it.
inline void PdfObject::DelayedStreamLoadImpl() inline void PdfObject::DelayedStreamLoadImpl()
{ {
PODOFO_RAISE_ERROR( ePdfError_InternalLogic ); PODOFO_RAISE_ERROR( ePdfError_InternalLogic );
} }
inline void PdfObject::DelayedStreamLoad() const inline void PdfObject::DelayedStreamLoad() const
{ {
 End of changes. 13 change blocks. 
8 lines changed or deleted 41 lines changed or added


 PdfOutlines.h   PdfOutlines.h 
skipping to change at line 39 skipping to change at line 39
class PdfDestination; class PdfDestination;
class PdfObject; class PdfObject;
class PdfOutlineItem; class PdfOutlineItem;
class PdfString; class PdfString;
class PdfVecObjects; class PdfVecObjects;
/** /**
* The title of an outline item can be displayed * The title of an outline item can be displayed
* in different formating styles since PDF 1.4. * in different formating styles since PDF 1.4.
*/ */
typedef enum EPdfOutlineFormat { enum EPdfOutlineFormat {
ePdfOutlineFormat_Default = 0x00, /**< Default format */ ePdfOutlineFormat_Default = 0x00, /**< Default format */
ePdfOutlineFormat_Italic = 0x01, /**< Italic */ ePdfOutlineFormat_Italic = 0x01, /**< Italic */
ePdfOutlineFormat_Bold = 0x02, /**< Bold */ ePdfOutlineFormat_Bold = 0x02, /**< Bold */
ePdfOutlineFormat_BoldItalic = 0x03, /**< Bold Italic */ ePdfOutlineFormat_BoldItalic = 0x03, /**< Bold Italic */
ePdfOutlineFormat_Unknown = 0xFF ePdfOutlineFormat_Unknown = 0xFF
}; };
/** /**
* A PDF outline item has an title and a destination. * A PDF outline item has an title and a destination.
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 PdfOutputDevice.h   PdfOutputDevice.h 
skipping to change at line 32 skipping to change at line 32
#define _PDF_OUTPUT_DEVICE_H_ #define _PDF_OUTPUT_DEVICE_H_
#include <cstdarg> #include <cstdarg>
#include <ostream> #include <ostream>
#include "PdfDefines.h" #include "PdfDefines.h"
#include "PdfLocale.h" #include "PdfLocale.h"
namespace PoDoFo { namespace PoDoFo {
class PdfRefCountedBuffer;
/** This class provides an output device which operates /** This class provides an output device which operates
* either on a file or on a buffer in memory. * either on a file or on a buffer in memory.
* Additionally it can count the bytes written to the device. * Additionally it can count the bytes written to the device.
* *
* This class is suitable for inheritance to provide output * This class is suitable for inheritance to provide output
* devices of your own for PoDoFo. * devices of your own for PoDoFo.
* Just overide the required virtual methods. * Just overide the required virtual methods.
*/ */
class PODOFO_API PdfOutputDevice { class PODOFO_API PdfOutputDevice {
public: public:
skipping to change at line 70 skipping to change at line 72
* \param lLen the length of the buffer in memory * \param lLen the length of the buffer in memory
*/ */
PdfOutputDevice( char* pBuffer, long lLen ); PdfOutputDevice( char* pBuffer, long lLen );
/** Construct a new PdfOutputDevice that writes all data to a std::ostr eam. /** Construct a new PdfOutputDevice that writes all data to a std::ostr eam.
* *
* \param pOutStream write to this std::ostream * \param pOutStream write to this std::ostream
*/ */
PdfOutputDevice( const std::ostream* pOutStream ); PdfOutputDevice( const std::ostream* pOutStream );
/** Construct a new PdfOutputDevice that writes all data to a PdfRefCou
ntedBuffer.
* This output device has the advantage that the PdfRefCountedBuffer w
ill resize itself
* if more memory is needed to hold all data.
*
* \param pOutBuffer write to this PdfRefCountedBuffer
*
* \see PdfRefCountedBuffer
*/
PdfOutputDevice( PdfRefCountedBuffer* pOutBuffer );
/** Destruct the PdfOutputDevice object and close any open files. /** Destruct the PdfOutputDevice object and close any open files.
*/ */
virtual ~PdfOutputDevice(); virtual ~PdfOutputDevice();
/** The number of bytes written to this object. /** The number of bytes written to this object.
* \returns the number of bytes written to this object. * \returns the number of bytes written to this object.
* *
* \see Init * \see Init
*/ */
virtual inline unsigned long GetLength() const; virtual inline unsigned long GetLength() const;
skipping to change at line 106 skipping to change at line 118
* *
* \see Print * \see Print
*/ */
virtual void Write( const char* pBuffer, long lLen ); virtual void Write( const char* pBuffer, long lLen );
/** Seek the device to the position offset from the begining /** Seek the device to the position offset from the begining
* \param offset from the beginning of the file * \param offset from the beginning of the file
*/ */
virtual void Seek( size_t offset ); virtual void Seek( size_t offset );
/** Get the current offset from the beginning of the file.
* \return the offset form the beginning of the file.
*/
virtual inline unsigned long Tell() const;
/** Flush the output files buffer to disk if this devices /** Flush the output files buffer to disk if this devices
* operates on a disk. * operates on a disk.
*/ */
virtual void Flush(); virtual void Flush();
private: private:
/** Initialize all private members /** Initialize all private members
*/ */
void Init(); void Init();
protected: protected:
unsigned long m_ulLength; unsigned long m_ulLength;
private: private:
FILE* m_hFile; FILE* m_hFile;
char* m_pBuffer; char* m_pBuffer;
unsigned long m_lBufferLen; unsigned long m_lBufferLen;
std::ostream* m_pStream;
PdfRefCountedBuffer* m_pRefCountedBuffer;
unsigned long m_ulPosition;
std::ostream* m_pStream;
}; };
// -----------------------------------------------------
//
// -----------------------------------------------------
unsigned long PdfOutputDevice::GetLength() const unsigned long PdfOutputDevice::GetLength() const
{ {
return m_ulLength; return m_ulLength;
} }
// -----------------------------------------------------
//
// -----------------------------------------------------
unsigned long PdfOutputDevice::Tell() const
{
return m_ulPosition;
}
}; };
#endif // _PDF_OUTPUT_DEVICE_H_ #endif // _PDF_OUTPUT_DEVICE_H_
 End of changes. 8 change blocks. 
5 lines changed or deleted 38 lines changed or added


 PdfOutputStream.h   PdfOutputStream.h 
skipping to change at line 25 skipping to change at line 25
* You should have received a copy of the GNU Library General Public * * You should have received a copy of the GNU Library General Public *
* License along with this program; if not, write to the * * License along with this program; if not, write to the *
* Free Software Foundation, Inc., * * Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
************************************************************************** */ ************************************************************************** */
#ifndef _PDF_OUTPUT_STREAM_H_ #ifndef _PDF_OUTPUT_STREAM_H_
#define _PDF_OUTPUT_STREAM_H_ #define _PDF_OUTPUT_STREAM_H_
#include "PdfDefines.h" #include "PdfDefines.h"
#include "PdfRefCountedBuffer.h"
#include <string>
namespace PoDoFo { namespace PoDoFo {
#define INITIAL_SIZE 4096 #define INITIAL_SIZE 4096
class PdfOutputDevice; class PdfOutputDevice;
/** An interface for writing blocks of data to /** An interface for writing blocks of data to
* a data source. * a data source.
*/ */
skipping to change at line 49 skipping to change at line 52
/** Write data to the output stream /** Write data to the output stream
* *
* \param pBuffer the data is read from this buffer * \param pBuffer the data is read from this buffer
* \param lLen the size of the buffer * \param lLen the size of the buffer
* *
* \returns the number of bytes written, -1 if an error ocurred * \returns the number of bytes written, -1 if an error ocurred
*/ */
virtual long Write( const char* pBuffer, long lLen ) = 0; virtual long Write( const char* pBuffer, long lLen ) = 0;
/**
* Helper that writes a string via Write(const char*,long)
*/
inline long Write( const std::string & s );
/** Close the PdfOutputStream. /** Close the PdfOutputStream.
* This method may throw exceptions and has to be called * This method may throw exceptions and has to be called
* before the descructor to end writing. * before the descructor to end writing.
* *
* No more data may be written to the output device * No more data may be written to the output device
* after calling close. * after calling close.
*/ */
virtual void Close() = 0; virtual void Close() = 0;
}; };
inline long PdfOutputStream::Write( const std::string & s )
{
return this->Write( s.data(), s.size() );
}
/** An output stream that writes data to a file /** An output stream that writes data to a file
*/ */
class PODOFO_API PdfFileOutputStream : public PdfOutputStream { class PODOFO_API PdfFileOutputStream : public PdfOutputStream {
public: public:
/** Open a file for writing data /** Open a file for writing data
* *
* \param pszFilename the filename of the file to read * \param pszFilename the filename of the file to read
*/ */
PdfFileOutputStream( const char* pszFilename ); PdfFileOutputStream( const char* pszFilename );
skipping to change at line 94 skipping to change at line 107
* after calling close. * after calling close.
*/ */
virtual void Close(); virtual void Close();
private: private:
FILE* m_hFile; FILE* m_hFile;
}; };
/** An output stream that writes data to a memory buffer /** An output stream that writes data to a memory buffer
* If the buffer is to small, it will be enlarged automatically. * If the buffer is to small, it will be enlarged automatically.
*
* DS: TODO: remove in favour of PdfBufferOutputStream.
*/ */
class PODOFO_API PdfMemoryOutputStream : public PdfOutputStream { class PODOFO_API PdfMemoryOutputStream : public PdfOutputStream {
public: public:
/** /**
* Construct a new PdfMemoryOutputStream * Construct a new PdfMemoryOutputStream
* \param lInitial initial size of the buffer * \param lInitial initial size of the buffer
*/ */
PdfMemoryOutputStream( long lInitial = INITIAL_SIZE); PdfMemoryOutputStream( long lInitial = INITIAL_SIZE);
skipping to change at line 208 skipping to change at line 223
* *
* No more data may be written to the output device * No more data may be written to the output device
* after calling close. * after calling close.
*/ */
virtual void Close() {} virtual void Close() {}
private: private:
PdfOutputDevice* m_pDevice; PdfOutputDevice* m_pDevice;
}; };
/** An output stream that writes to a PdfRefCountedBuffer.
*
* The PdfRefCountedBuffer is resized automatically if necessary.
*/
class PODOFO_API PdfBufferOutputStream : public PdfOutputStream {
public:
/**
* Write to an already opened input device
*
* \param pBuffer data is written to this buffer
*/
PdfBufferOutputStream( PdfRefCountedBuffer* pBuffer )
: m_pBuffer( pBuffer ), m_lLength( pBuffer->GetSize() )
{
}
/** Write data to the output stream
*
* \param pBuffer the data is read from this buffer
* \param lLen the size of the buffer
*
* \returns the number of bytes written, -1 if an error ocurred
*/
virtual long Write( const char* pBuffer, long lLen );
virtual void Close()
{
}
/**
* \returns the length of the buffers contents
*/
inline long GetLength() const
{
return m_lLength;
}
private:
PdfRefCountedBuffer* m_pBuffer;
long m_lLength;
};
}; };
#endif // _PDF_OUTPUT_STREAM_H_ #endif // _PDF_OUTPUT_STREAM_H_
 End of changes. 5 change blocks. 
0 lines changed or deleted 59 lines changed or added


 PdfPage.h   PdfPage.h 
skipping to change at line 82 skipping to change at line 82
* \returns the number of the page inside of the document * \returns the number of the page inside of the document
* *
* \see PdfPagesTree:GetTotalNumberOfPages() * \see PdfPagesTree:GetTotalNumberOfPages()
*/ */
unsigned int GetPageNumber() const; unsigned int GetPageNumber() const;
/** Creates a PdfRect with the page size as values which is needed to c reate a PdfPage object /** Creates a PdfRect with the page size as values which is needed to c reate a PdfPage object
* from an enum which are defined for a few standard page sizes. * from an enum which are defined for a few standard page sizes.
* *
* \param ePageSize the page size you want * \param ePageSize the page size you want
* \param bLandscape create a landscape pagesize instead of portrait ( by exchanging width and height)
* \returns a PdfRect object which can be passed to the PdfPage constr uctor * \returns a PdfRect object which can be passed to the PdfPage constr uctor
*/ */
static PdfRect CreateStandardPageSize( const EPdfPageSize ePageSize ); static PdfRect CreateStandardPageSize( const EPdfPageSize ePageSize, bo ol bLandscape = false );
/** Get access to the contents object of this page. /** Get access to the contents object of this page.
* If you want to draw onto the page, you have to add * If you want to draw onto the page, you have to add
* drawing commands to the stream of the Contents object. * drawing commands to the stream of the Contents object.
* \returns a contents object * \returns a contents object
*/ */
virtual PdfObject* GetContents() const { return m_pContents->GetContent s(); } virtual PdfObject* GetContents() const { return m_pContents->GetContent s(); }
/** Get access an object that you can use to ADD drawing to. /** Get access an object that you can use to ADD drawing to.
* If you want to draw onto the page, you have to add * If you want to draw onto the page, you have to add
skipping to change at line 134 skipping to change at line 135
virtual const PdfRect GetBleedBox() const { return GetPageBox( "BleedBo x" ); } virtual const PdfRect GetBleedBox() const { return GetPageBox( "BleedBo x" ); }
/** Get the current ArtBox in PDF units. /** Get the current ArtBox in PDF units.
* \returns PdfRect the page box * \returns PdfRect the page box
*/ */
virtual const PdfRect GetArtBox() const { return GetPageBox( "ArtBox" ) ; } virtual const PdfRect GetArtBox() const { return GetPageBox( "ArtBox" ) ; }
/** Get the current page rotation (if any). /** Get the current page rotation (if any).
* \returns int 0, 90, 180 or 270 * \returns int 0, 90, 180 or 270
*/ */
virtual const int GetRotation() const; virtual int GetRotation() const;
/** Get the number of annotations associated with this page /** Get the number of annotations associated with this page
* \ returns int number of annotations * \ returns int number of annotations
*/ */
virtual const int GetNumAnnots() const; virtual int GetNumAnnots() const;
/** Create a new annotation to this page. /** Create a new annotation to this page.
* \param eType the type of the annotation * \param eType the type of the annotation
* \param rRect rectangle of the annotation on the page * \param rRect rectangle of the annotation on the page
* *
* \returns the annotation object which is owned by the PdfPage * \returns the annotation object which is owned by the PdfPage
*/ */
PdfAnnotation* CreateAnnotation( EPdfAnnotation eType, const PdfRect & rRect ); PdfAnnotation* CreateAnnotation( EPdfAnnotation eType, const PdfRect & rRect );
/** Get the annotation with index index of the current page. /** Get the annotation with index index of the current page.
skipping to change at line 175 skipping to change at line 176
/** Delete the annotation object with reference ref from this page. /** Delete the annotation object with reference ref from this page.
* \param ref the reference of an annotation object of this page. * \param ref the reference of an annotation object of this page.
* *
* \see GetNumAnnots * \see GetNumAnnots
*/ */
void DeleteAnnotation( const PdfReference & ref ); void DeleteAnnotation( const PdfReference & ref );
/** /**
* \returns the number of PdfFields on this page. * \returns the number of PdfFields on this page.
*/ */
const int GetNumFields() const; int GetNumFields() const;
/** Get a PdfField with a certain index. /** Get a PdfField with a certain index.
* \param index of the PdfField (must be smaller than GetNumFields() ) * \param index of the PdfField (must be smaller than GetNumFields() )
* *
* \see GetNumFields * \see GetNumFields
* *
* \returns a PdfField * \returns a PdfField
*/ */
PdfField GetField( int index ); PdfField GetField( int index );
/** Get a PdfField with a certain index. /** Get a PdfField with a certain index.
* \param index of the PdfField (must be smaller than GetNumFields() ) * \param index of the PdfField (must be smaller than GetNumFields() )
* *
* \see GetNumFields * \see GetNumFields
* *
* \returns a const PdfField * \returns a constP dfField
*/ */
const PdfField GetField( int index ) const; const PdfField GetField( int index ) const;
private: private:
/** Get the bounds of a specified page box in PDF units. /** Get the bounds of a specified page box in PDF units.
* This function is internal, since there are wrappers for all standard boxes * This function is internal, since there are wrappers for all standard boxes
* \returns PdfRect the page box * \returns PdfRect the page box
*/ */
const PdfRect GetPageBox( const char* inBox ) const; const PdfRect GetPageBox( const char* inBox ) const;
 End of changes. 6 change blocks. 
5 lines changed or deleted 6 lines changed or added


 PdfPagesTree.h   PdfPagesTree.h 
skipping to change at line 128 skipping to change at line 128
*/ */
void DeletePage( int inPageNumber ); void DeletePage( int inPageNumber );
private: private:
PdfPagesTree(); // don't allow construction from nothing! PdfPagesTree(); // don't allow construction from nothing!
/** Private method for actually traversing the /Pages tree /** Private method for actually traversing the /Pages tree
*/ */
PdfObject* GetPageNode( int nPageNum, PdfObject* pPagesObject ); PdfObject* GetPageNode( int nPageNum, PdfObject* pPagesObject );
/** Private method for actually traversing the /Pages tree
* This method directly traverses the tree and does no
* optimization for nodes with only one element like GetPageNode does.
*/
PdfObject* GetPageNodeFromTree( int nPageNum, const PdfArray & kidsArra
y );
/** Private method to access the Root of the tree using a logical name /** Private method to access the Root of the tree using a logical name
*/ */
PdfObject* GetRoot() { return m_pObject; } PdfObject* GetRoot() { return m_pObject; }
const PdfObject* GetRoot() const { return m_pObject; }
/** Private method for getting the Parent of a node in the /Pages tree /** Private method for getting the Parent of a node in the /Pages tree
*/ */
static PdfObject* GetParent( PdfObject* inObject ); static PdfObject* GetParent( PdfObject* inObject );
/** Private method for getting the Kids of a node in the /Pages tree /** Private method for getting the Kids of a node in the /Pages tree
*/ */
static PdfObject* GetKids( PdfObject* inObject ); static PdfObject* GetKids( PdfObject* inObject );
/** Private method for determining where a page is in the /Pages tree /** Private method for determining where a page is in the /Pages tree
skipping to change at line 154 skipping to change at line 161
/** Private method for adjusting the page count in a tree /** Private method for adjusting the page count in a tree
*/ */
int ChangePagesCount( PdfObject* inPageObj, int inDelta ); int ChangePagesCount( PdfObject* inPageObj, int inDelta );
/** Private method for cleaning up after an insertion /** Private method for cleaning up after an insertion
*/ */
void InsertPages( int inAfterIndex, PdfObject* inPageOrPagesObj, PdfObj ect* inParentObj, int inNumPages ); void InsertPages( int inAfterIndex, PdfObject* inPageOrPagesObj, PdfObj ect* inParentObj, int inNumPages );
/** Private method for getting the PdfObject* for a Page from a specifi c /Kids array /** Private method for getting the PdfObject* for a Page from a specifi c /Kids array
*/ */
PdfObject* GetPageFromKidArray( PdfArray& inArray, int inIndex ); PdfObject* GetPageFromKidArray( const PdfArray& inArray, int inIndex ) const;
private: private:
PdfPageObjects m_deqPageObjs; PdfPageObjects m_deqPageObjs;
}; };
}; };
#endif // _PDF_PAGES_TREE_H_ #endif // _PDF_PAGES_TREE_H_
 End of changes. 3 change blocks. 
1 lines changed or deleted 9 lines changed or added


 PdfPainter.h   PdfPainter.h 
skipping to change at line 26 skipping to change at line 26
* License along with this program; if not, write to the * * License along with this program; if not, write to the *
* Free Software Foundation, Inc., * * Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
************************************************************************** */ ************************************************************************** */
#ifndef _PDF_PAINTER_H_ #ifndef _PDF_PAINTER_H_
#define _PDF_PAINTER_H_ #define _PDF_PAINTER_H_
#include "PdfDefines.h" #include "PdfDefines.h"
#include "PdfRect.h"
#include <sstream> #include <sstream>
namespace PoDoFo { namespace PoDoFo {
class PdfCanvas; class PdfCanvas;
class PdfColor;
class PdfExtGState; class PdfExtGState;
class PdfFont; class PdfFont;
class PdfImage; class PdfImage;
class PdfName; class PdfName;
class PdfObject; class PdfObject;
class PdfReference; class PdfReference;
class PdfShadingPattern;
class PdfStream; class PdfStream;
class PdfString; class PdfString;
class PdfXObject; class PdfXObject;
/** /**
* This class provides an easy to use painter object which allows you to dr aw on a PDF page * This class provides an easy to use painter object which allows you to dr aw on a PDF page
* object. * object.
* *
* During all drawing operations, you are still able to access the stream o f the object you are * During all drawing operations, you are still able to access the stream o f the object you are
* drawing on directly. * drawing on directly.
skipping to change at line 69 skipping to change at line 73
/** Set the page on which the painter should draw. /** Set the page on which the painter should draw.
* The painter will draw of course on the pages * The painter will draw of course on the pages
* contents object. * contents object.
* *
* Calls FinishPage() on the last page if it was not yet called. * Calls FinishPage() on the last page if it was not yet called.
* *
* \param pPage a PdfCanvas object (most likely a PdfPage or PdfXObjec t). * \param pPage a PdfCanvas object (most likely a PdfPage or PdfXObjec t).
* *
* \see PdfPage \see PdfXObject * \see PdfPage \see PdfXObject
* \see FinishPage() * \see FinishPage()
* \see GetPage()
*/ */
void SetPage( PdfCanvas* pPage ); void SetPage( PdfCanvas* pPage );
/** Return the current page that is that on the painter.
*
* \returns the current page of the painter or NULL if none is set
*/
inline const PdfCanvas* GetPage() const;
/** Finish drawing onto a page. /** Finish drawing onto a page.
* *
* This has to be called whenever a page has been drawn complete. * This has to be called whenever a page has been drawn complete.
*/ */
void FinishPage(); void FinishPage();
/** Set the color for all following stroking operations /** Set the color for all following stroking operations
* in grayscale colorspace. This operation used the 'G' * in grayscale colorspace. This operation used the 'G'
* PDF operator. * PDF operator.
* \param g gray scale value in the range 0.0 - 1.0 * \param g gray scale value in the range 0.0 - 1.0
skipping to change at line 133 skipping to change at line 144
/** Set the color for all following non-stroking operations /** Set the color for all following non-stroking operations
* in cmyk colorspace. This operation used the 'k' * in cmyk colorspace. This operation used the 'k'
* PDF operator. * PDF operator.
* \param c cyan value in the range 0.0 - 1.0 * \param c cyan value in the range 0.0 - 1.0
* \param m magenta value in the range 0.0 - 1.0 * \param m magenta value in the range 0.0 - 1.0
* \param y yellow value in the range 0.0 - 1.0 * \param y yellow value in the range 0.0 - 1.0
* \param k black value in the range 0.0 - 1.0 * \param k black value in the range 0.0 - 1.0
*/ */
void SetColorCMYK( double c, double m, double y, double k ); void SetColorCMYK( double c, double m, double y, double k );
/** Set the shading pattern for all following stroking operations.
* This operation uses the 'SCN' PDF operator.
*
* \param rPattern a shading pattern
*/
void SetStrokingShadingPattern( const PdfShadingPattern & rPattern );
/** Set the shading pattern for all following non-stroking operations.
* This operation uses the 'scn' PDF operator.
*
* \param rPattern a shading pattern
*/
void SetShadingPattern( const PdfShadingPattern & rPattern );
/** Set the color for all following stroking operations.
*
* \param rColor a PdfColor object
*/
void SetStrokingColor( const PdfColor & rColor );
/** Set the color for all following non-stroking operations.
*
* \param rColor a PdfColor object
*/
void SetColor( const PdfColor & rColor );
/** Set the line width for all stroking operations. /** Set the line width for all stroking operations.
* \param dWidth in PDF User Units. * \param dWidth in PDF User Units.
*/ */
void SetStrokeWidth( double dWidth ); void SetStrokeWidth( double dWidth );
/** Set the stoke style for all stroking operations. /** Set the stoke style for all stroking operations.
* \param eStyle style of the stroking operations * \param eStyle style of the stroking operations
* \param pszCustom a custom stroking style which is used when * \param pszCustom a custom stroking style which is used when
* eStyle == ePdfStrokeStyle_Custom. * eStyle == ePdfStrokeStyle_Custom.
* *
skipping to change at line 187 skipping to change at line 224
* *
* \see DrawText * \see DrawText
*/ */
void SetFont( PdfFont* pFont ); void SetFont( PdfFont* pFont );
/** Get the current font: /** Get the current font:
* \returns a font object or NULL if no font was set. * \returns a font object or NULL if no font was set.
*/ */
inline PdfFont* GetFont() const; inline PdfFont* GetFont() const;
/** Set a clipping rectangle
*
* \param dX x coordinate of the rectangle (left coordinate)
* \param dY y coordinate of the rectangle (bottom coordinate)
* \param dWidth width of the rectangle
* \param dHeight absolute height of the rectangle
*/
void SetClipRect( double dX, double dY, double dWidth, double dHeight )
;
/** Set a clipping rectangle
*
* \param rRect rectangle
*/
inline void SetClipRect( const PdfRect & rRect );
/** Draw a line with the current color and line settings. /** Draw a line with the current color and line settings.
* \param dStartX x coordinate of the starting point * \param dStartX x coordinate of the starting point
* \param dStartY y coordinate of the starting point * \param dStartY y coordinate of the starting point
* \param dEndX x coordinate of the ending point * \param dEndX x coordinate of the ending point
* \param dEndY y coordinate of the ending point * \param dEndY y coordinate of the ending point
*/ */
void DrawLine( double dStartX, double dStartY, double dEndX, double dEn dY ); void DrawLine( double dStartX, double dStartY, double dEndX, double dEn dY );
/** Draw a rectangle with the current stroking settings /** Draw a rectangle with the current stroking settings
* \param dX x coordinate of the rectangle (left coordinate) * \param dX x coordinate of the rectangle (left coordinate)
* \param dY y coordinate of the rectangle (bottom coordinate) * \param dY y coordinate of the rectangle (bottom coordinate)
* \param dWidth width of the rectangle * \param dWidth width of the rectangle
* \param dHeight absolute height of the rectangle * \param dHeight absolute height of the rectangle
* \param dRoundX rounding factor, x direction * \param dRoundX rounding factor, x direction
* \param dRoundY rounding factor, y direction * \param dRoundY rounding factor, y direction
*/ */
void DrawRect( double dX, double dY, double dWidth, double dHeight, void DrawRect( double dX, double dY, double dWidth, double dHeight,
double dRoundX=0.0, double dRoundY=0.0 ); double dRoundX=0.0, double dRoundY=0.0 );
/** Draw a rectangle with the current stroking settings
*
* \param rRect the rectangle area
* \param dRoundX rounding factor, x direction
* \param dRoundY rounding factor, y direction
*
* \see DrawRect
*/
inline void DrawRect( const PdfRect & rRect, double dRoundX=0.0, dou
ble dRoundY=0.0 );
/** Fill a rectangle with the current fill settings /** Fill a rectangle with the current fill settings
* \param dX x coordinate of the rectangle (left coordinate) * \param dX x coordinate of the rectangle (left coordinate)
* \param dY y coordinate of the rectangle (bottom coordinate) * \param dY y coordinate of the rectangle (bottom coordinate)
* \param dWidth width of the rectangle * \param dWidth width of the rectangle
* \param dHeight absolute height of the rectangle * \param dHeight absolute height of the rectangle
* \param dRoundX rounding factor, x direction * \param dRoundX rounding factor, x direction
* \param dRoundY rounding factor, y direction * \param dRoundY rounding factor, y direction
*/ */
void FillRect( double dX, double dY, double dWidth, double dHeight, void FillRect( double dX, double dY, double dWidth, double dHeight,
double dRoundX=0.0, double dRoundY=0.0 ); double dRoundX=0.0, double dRoundY=0.0 );
/** Fill a rectangle with the current fill settings
*
* \param rRect the rectangle area
* \param dRoundX rounding factor, x direction
* \param dRoundY rounding factor, y direction
*
* \see FillRect
*/
inline void FillRect( const PdfRect & rRect, double dRoundX=0.0, double
dRoundY=0.0 );
/** Draw an ellipse with the current stroking settings /** Draw an ellipse with the current stroking settings
* \param dX x coordinate of the ellipse (left coordinate) * \param dX x coordinate of the ellipse (left coordinate)
* \param dY y coordinate of the ellipse (top coordinate) * \param dY y coordinate of the ellipse (top coordinate)
* \param dWidth width of the ellipse * \param dWidth width of the ellipse
* \param dHeight absolute height of the ellipse * \param dHeight absolute height of the ellipse
*/ */
void DrawEllipse( double dX, double dY, double dWidth, double dHeight ) ; void DrawEllipse( double dX, double dY, double dWidth, double dHeight ) ;
/** Fill an ellipse with the current fill settings /** Fill an ellipse with the current fill settings
skipping to change at line 247 skipping to change at line 319
*/ */
void DrawCircle( double dX, double dY, double dRadius ); void DrawCircle( double dX, double dY, double dRadius );
/** Fill a Circle with the current fill settings /** Fill a Circle with the current fill settings
* \param dX x center coordinate of the circle * \param dX x center coordinate of the circle
* \param dY y coordinate of the circle * \param dY y coordinate of the circle
* \param dRadius radius of the circle * \param dRadius radius of the circle
*/ */
void FillCircle( double dX, double dY, double dRadius ); void FillCircle( double dX, double dY, double dRadius );
/** Draw a text string on a page using a given font object. /** Draw a single-line text string on a page using a given font object.
* You have to call SetFont before calling this function. * You have to call SetFont before calling this function.
* \param dX the x coordinate * \param dX the x coordinate
* \param dY the y coordinate * \param dY the y coordinate
* \param sText the text string which should be printed * \param sText the text string which should be printed
* *
* \see SetFont() * \see SetFont()
*/ */
void DrawText( double dX, double dY, const PdfString & sText); void DrawText( double dX, double dY, const PdfString & sText);
/** Draw a text string on a page using a given font object. /** Draw a single-line text string on a page using a given font object.
* You have to call SetFont before calling this function. * You have to call SetFont before calling this function.
* \param dX the x coordinate * \param dX the x coordinate
* \param dY the y coordinate * \param dY the y coordinate
* \param sText the text string which should be printed (is not allowe d to be NULL!) * \param sText the text string which should be printed (is not allowe d to be NULL!)
* \param lLen draw only lLen characters of pszText * \param lLen draw only lLen characters of pszText
* *
* \see SetFont() * \see SetFont()
*/ */
void DrawText( double dX, double dY, const PdfString & sText, long lLen ); void DrawText( double dX, double dY, const PdfString & sText, long lLen );
/** Draw multiline text into a rectangle doing automatic wordwrapping.
* The current font is used and SetFont has to be called at least once
* before using this function
*
* \param dX the x coordinate of the text area (left)
* \param dY the y coordinate of the text area (bottom)
* \param dWidth width of the text area
* \param dHeight height of the text area
* \param rsText the text which should be drawn
* \param eAlignment alignment of the individual text lines in the giv
en bounding box
* \param eVertical vertical alignment of the text in the given boundi
ng box
*/
void DrawMultiLineText( double dX, double dY, double dWidth, double dHe
ight,
const PdfString & rsText, EPdfAlignment eAlignm
ent = ePdfAlignment_Left,
EPdfVerticalAlignment eVertical = ePdfVerticalA
lignment_Top);
/** Draw multiline text into a rectangle doing automatic wordwrapping.
* The current font is used and SetFont has to be called at least once
* before using this function
*
* \param rRect bounding rectangle of the text
* \param rsText the text which should be drawn
* \param eAlignment alignment of the individual text lines in the giv
en bounding box
* \param eVertical vertical alignment of the text in the given boundi
ng box
*/
inline void DrawMultiLineText( const PdfRect & rRect, const PdfString &
rsText, EPdfAlignment eAlignment = ePdfAlignment_Left,
EPdfVerticalAlignment eVertical = ePdfVe
rticalAlignment_Top);
/** Draw a single line of text horizontally aligned.
* \param dX the x coordinate of the text line
* \param dY the y coordinate of the text line
* \param dWidth the width of the text line
* \param rsText the text to draw
* \param eAlignmet alignment of the text line
*/
void DrawTextAligned( double dX, double dY, double dWidth, const PdfStr
ing & rsText, EPdfAlignment eAlignment );
/** Draw an image on the current page. /** Draw an image on the current page.
* \param dX the x coordinate (bottom left position of the image) * \param dX the x coordinate (bottom left position of the image)
* \param dY the y coordinate (bottom position of the image) * \param dY the y coordinate (bottom position of the image)
* \param pObject an PdfXObject * \param pObject an PdfXObject
* \param dScaleX option scaling factor in x direction * \param dScaleX option scaling factor in x direction
* \param dScaleY option scaling factor in y direction * \param dScaleY option scaling factor in y direction
*/ */
inline void DrawImage( double dX, double dY, PdfImage* pObject, double dScaleX = 1.0, double dScaleY = 1.0); void DrawImage( double dX, double dY, PdfImage* pObject, double dScaleX = 1.0, double dScaleY = 1.0);
/** Draw an XObject on the current page. /** Draw an XObject on the current page. For PdfImage use DrawImage.
*
* \param dX the x coordinate (bottom left position of the XObject) * \param dX the x coordinate (bottom left position of the XObject)
* \param dY the y coordinate (bottom position of the XObject) * \param dY the y coordinate (bottom position of the XObject)
* \param pObject an PdfXObject * \param pObject an PdfXObject
* \param dScaleX option scaling factor in x direction * \param dScaleX option scaling factor in x direction
* \param dScaleY option scaling factor in y direction * \param dScaleY option scaling factor in y direction
*
* \see DrawImage
*/ */
void DrawXObject( double dX, double dY, PdfXObject* pObject, double dSc aleX = 1.0, double dScaleY = 1.0); void DrawXObject( double dX, double dY, PdfXObject* pObject, double dSc aleX = 1.0, double dScaleY = 1.0);
/** Closes the current path by drawing a line from the current point /** Closes the current path by drawing a line from the current point
* to the starting point of the path. Matches the PDF 'h' operator. * to the starting point of the path. Matches the PDF 'h' operator.
* This function is useful to construct an own path * This function is useful to construct an own path
* for drawing or clipping. * for drawing or clipping.
*/ */
void ClosePath(); void ClosePath();
skipping to change at line 393 skipping to change at line 505
* for drawing or clipping. * for drawing or clipping.
*/ */
void Stroke(); void Stroke();
/** Fill the current path. Matches the PDF 'f' operator. /** Fill the current path. Matches the PDF 'f' operator.
* This function is useful to construct an own path * This function is useful to construct an own path
* for drawing or clipping. * for drawing or clipping.
*/ */
void Fill(); void Fill();
/** Clip the current path. Matches the PDF 'W' operator.
* This function is useful to construct an own path
* for drawing or clipping.
*/
void Clip();
/** Save the current graphics settings onto the graphics /** Save the current graphics settings onto the graphics
* stack. Operator 'q' in PDF. * stack. Operator 'q' in PDF.
* This call has to be balanced with a corresponding call * This call has to be balanced with a corresponding call
* to Restore()! * to Restore()!
* *
* \see Restore * \see Restore
*/ */
void Save(); void Save();
/** Restore the current graphics settings from the graphics /** Restore the current graphics settings from the graphics
skipping to change at line 504 skipping to change at line 622
void ConvertRectToBezier( double dX, double dY, double dWidth, double d Height, double pdPointX[], double pdPointY[] ); void ConvertRectToBezier( double dX, double dY, double dWidth, double d Height, double pdPointX[], double pdPointY[] );
protected: protected:
/** Sets the color that was last set by the user as the current strokin g color. /** Sets the color that was last set by the user as the current strokin g color.
* You should always enclose this function by Save() and Restore() * You should always enclose this function by Save() and Restore()
* *
* \see Save() \see Restore() * \see Save() \see Restore()
*/ */
void SetCurrentStrokingColor(); void SetCurrentStrokingColor();
/** Expand all tab characters in a string
* using spaces.
*
* \param rsString expand all tabs in this string using spaces
* \param lLen use only lLen characters of rsString
* \returns an expanded copy of the passed string
* \see SetTabWidth
*/
PdfString ExpandTabs( const PdfString & rsString, long lLen ) const;
template<typename C>
PdfString ExpandTabsPrivate( const C* pszText, long lStringLen, int
nTabCnt, const C cTab, const C cSpace ) const;
protected: protected:
/** All drawing operations work on this stream. /** All drawing operations work on this stream.
* This object may not be NULL. If it is NULL any function accessing i t should * This object may not be NULL. If it is NULL any function accessing i t should
* return ERROR_PDF_INVALID_HANDLE * return ERROR_PDF_INVALID_HANDLE
*/ */
PdfStream* m_pCanvas; PdfStream* m_pCanvas;
/** The page object is needed so that fonts etc. can be added /** The page object is needed so that fonts etc. can be added
* to the page resource dictionary as appropriate. * to the page resource dictionary as appropriate.
*/ */
skipping to change at line 545 skipping to change at line 676
std::ostringstream m_oss; std::ostringstream m_oss;
double lpx, lpy, lpx2, lpy2, lpx3, lpy3, // points fo r this operation double lpx, lpy, lpx2, lpy2, lpx3, lpy3, // points fo r this operation
lcx, lcy, // l ast "current" point lcx, lcy, // l ast "current" point
lrx, lry; // " reflect points" lrx, lry; // " reflect points"
}; };
// ----------------------------------------------------- // -----------------------------------------------------
// //
// ----------------------------------------------------- // -----------------------------------------------------
void PdfPainter::DrawImage( double dX, double dY, PdfImage* pObject, double dScaleX, double dScaleY ) const PdfCanvas* PdfPainter::GetPage() const
{ {
// we know pObject is a PdfXObject, but the compiler doesn't return m_pPage;
// so we must use a reinterpret_cast here.
this->DrawXObject( dX, dY, reinterpret_cast<PdfXObject*>(pObject), dSca
leX, dScaleY );
} }
// ----------------------------------------------------- // -----------------------------------------------------
// //
// ----------------------------------------------------- // -----------------------------------------------------
PdfFont* PdfPainter::GetFont() const PdfFont* PdfPainter::GetFont() const
{ {
return m_pFont; return m_pFont;
} }
skipping to change at line 591 skipping to change at line 720
m_oss.precision( inPrec ); m_oss.precision( inPrec );
} }
// ----------------------------------------------------- // -----------------------------------------------------
// //
// ----------------------------------------------------- // -----------------------------------------------------
unsigned short PdfPainter::GetPrecision() const unsigned short PdfPainter::GetPrecision() const
{ {
return m_oss.precision(); return m_oss.precision();
} }
// -----------------------------------------------------
//
// -----------------------------------------------------
void PdfPainter::SetClipRect( const PdfRect & rRect )
{
this->SetClipRect( rRect.GetLeft(), rRect.GetBottom(), rRect.GetWidth()
, rRect.GetHeight() );
}
// -----------------------------------------------------
//
// -----------------------------------------------------
void PdfPainter::DrawRect( const PdfRect & rRect, double dRoundX, double dR
oundY )
{
this->DrawRect( rRect.GetLeft(), rRect.GetBottom(),
rRect.GetWidth(), rRect.GetHeight(),
dRoundX, dRoundY );
}
// -----------------------------------------------------
//
// -----------------------------------------------------
void PdfPainter::FillRect( const PdfRect & rRect, double dRoundX, double dR
oundY )
{
this->FillRect( rRect.GetLeft(), rRect.GetBottom(),
rRect.GetWidth(), rRect.GetHeight(),
dRoundX, dRoundY );
}
// -----------------------------------------------------
//
// -----------------------------------------------------
void PdfPainter::DrawMultiLineText( const PdfRect & rRect, const PdfString
& rsText,
EPdfAlignment eAlignment, EPdfVerticalA
lignment eVertical)
{
this->DrawMultiLineText( rRect.GetLeft(), rRect.GetBottom(), rRect.GetW
idth(), rRect.GetHeight(),
rsText, eAlignment, eVertical );
}
}; };
#endif // _PDF_PAINTER_H_ #endif // _PDF_PAINTER_H_
 End of changes. 21 change blocks. 
12 lines changed or deleted 199 lines changed or added


 PdfParser.h   PdfParser.h 
skipping to change at line 37 skipping to change at line 37
#define W_ARRAY_SIZE 3 #define W_ARRAY_SIZE 3
#define W_MAX_BYTES 4 #define W_MAX_BYTES 4
namespace PoDoFo { namespace PoDoFo {
typedef std::map<int,PdfObject*> TMapObjects; typedef std::map<int,PdfObject*> TMapObjects;
typedef TMapObjects::iterator TIMapObjects; typedef TMapObjects::iterator TIMapObjects;
typedef TMapObjects::const_iterator TCIMapObjects; typedef TMapObjects::const_iterator TCIMapObjects;
class PdfEncrypt;
class PdfString;
/** /**
* PdfParser reads a PDF file into memory. * PdfParser reads a PDF file into memory.
* The file can be modified in memory and written back using * The file can be modified in memory and written back using
* the PdfWriter class. * the PdfWriter class.
* Most PDF features are supported * Most PDF features are supported
*/ */
class PODOFO_API PdfParser : public PdfTokenizer { class PODOFO_API PdfParser : public PdfTokenizer {
friend class PdfDocument; friend class PdfDocument;
friend class PdfWriter; friend class PdfWriter;
skipping to change at line 66 skipping to change at line 69
/** Create a new PdfParser object and open a PDF file and parse /** Create a new PdfParser object and open a PDF file and parse
* it into memory. * it into memory.
* *
* \param pVecObjects vector to write the parsed PdfObjects to * \param pVecObjects vector to write the parsed PdfObjects to
* \param pszFilename filename of the file which is going to be parsed * \param pszFilename filename of the file which is going to be parsed
* \param bLoadOnDemand If true all objects will be read from the file at * \param bLoadOnDemand If true all objects will be read from the file at
* the time they are accesed first. * the time they are accesed first.
* If false all objects will be read immediately. * If false all objects will be read immediately.
* This is faster if you do not need the complete PDF * This is faster if you do not need the complete PDF
* file in memory. * file in memory.
*
* This might throw a PdfError( ePdfError_InvalidPassword ) exception
* if a password is required to read this PDF.
* Call SetPassword with the correct password in this case.
*
* \see SetPassword
*/ */
PdfParser( PdfVecObjects* pVecObjects, const char* pszFilename, bool bL oadOnDemand = true ); PdfParser( PdfVecObjects* pVecObjects, const char* pszFilename, bool bL oadOnDemand = true );
/** Create a new PdfParser object and open a PDF file and parse
* it into memory.
*
* \param pVecObjects vector to write the parsed PdfObjects to
* \param pBuffer buffer containing a PDF file in memory
* \param lLen length of the buffer containing the PDF file
* \param bLoadOnDemand If true all objects will be read from the file
at
* the time they are accesed first.
* If false all objects will be read immediately.
* This is faster if you do not need the complete
PDF
* file in memory.
*
* This might throw a PdfError( ePdfError_InvalidPassword ) exception
* if a password is required to read this PDF.
* Call SetPassword with the correct password in this case.
*
* \see SetPassword
*/
PdfParser( PdfVecObjects* pVecObjects, const char* pBuffer, long lLen,
bool bLoadOnDemand = true );
/** Create a new PdfParser object and open a PDF file and parse
* it into memory.
*
* \param pVecObjects vector to write the parsed PdfObjects to
* \param rDevice read from this PdfRefCountedInputDevice
* \param bLoadOnDemand If true all objects will be read from the file
at
* the time they are accesed first.
* If false all objects will be read immediately.
* This is faster if you do not need the complete
PDF
* file in memory.
*
* This might throw a PdfError( ePdfError_InvalidPassword ) exception
* if a password is required to read this PDF.
* Call SetPassword with the correct password in this case.
*
* \see SetPassword
*/
PdfParser( PdfVecObjects* pVecObjects, const PdfRefCountedInputDevice &
rDevice,
bool bLoadOnDemand = true );
/** Delete the PdfParser and all PdfObjects /** Delete the PdfParser and all PdfObjects
*/ */
virtual ~PdfParser(); virtual ~PdfParser();
/** Open a PDF file and parse it. /** Open a PDF file and parse it.
* *
* \param pszFilename filename of the file which is going to be parsed * \param pszFilename filename of the file which is going to be parsed
* \param bLoadOnDemand If true all objects will be read from the file at * \param bLoadOnDemand If true all objects will be read from the file at
* the time they are accesed first. * the time they are accesed first.
* If false all objects will be read immediately. * If false all objects will be read immediately.
* This is faster if you do not need the complete PDF * This is faster if you do not need the complete PDF
* file in memory. * file in memory.
*
*
* This might throw a PdfError( ePdfError_InvalidPassword ) exception
* if a password is required to read this PDF.
* Call SetPassword with the correct password in this case.
*
* \see SetPassword
*/ */
void ParseFile( const char* pszFilename, bool bLoadOnDemand = true ); void ParseFile( const char* pszFilename, bool bLoadOnDemand = true );
/** Open a PDF file and parse it.
*
* \param pBuffer buffer containing a PDF file in memory
* \param lLen length of the buffer containing the PDF file
* \param bLoadOnDemand If true all objects will be read from the file
at
* the time they are accesed first.
* If false all objects will be read immediately.
* This is faster if you do not need the complete
PDF
* file in memory.
*
*
* This might throw a PdfError( ePdfError_InvalidPassword ) exception
* if a password is required to read this PDF.
* Call SetPassword with the correct password in this case.
*
* \see SetPassword
*/
void ParseFile( const char* pBuffer, long lLen, bool bLoadOnDemand = t
rue );
/** Open a PDF file and parse it.
*
* \param rDevice the input device to read from
* \param bLoadOnDemand If true all objects will be read from the file
at
* the time they are accesed first.
* If false all objects will be read immediately.
* This is faster if you do not need the complete
PDF
* file in memory.
*
*
* This might throw a PdfError( ePdfError_InvalidPassword ) exception
* if a password is required to read this PDF.
* Call SetPassword with the correct password in this case.
*
* \see SetPassword
*/
void ParseFile( const PdfRefCountedInputDevice & rDevice, bool bLoadOnD
emand = true );
/** Get a reference to the sorted internal objects vector. /** Get a reference to the sorted internal objects vector.
* \returns the internal objects vector. * \returns the internal objects vector.
*/ */
inline const PdfVecObjects* GetObjects() const; inline const PdfVecObjects* GetObjects() const;
/** Get the file format version of the pdf /** Get the file format version of the pdf
* \returns the file format version as enum * \returns the file format version as enum
*/ */
inline EPdfVersion GetPdfVersion() const; inline EPdfVersion GetPdfVersion() const;
skipping to change at line 119 skipping to change at line 212
inline bool GetLoadOnDemand() const; inline bool GetLoadOnDemand() const;
/** \returns whether the parsed document contains linearization tables /** \returns whether the parsed document contains linearization tables
*/ */
bool IsLinearized() const { return m_pLinearization != NULL; } bool IsLinearized() const { return m_pLinearization != NULL; }
/** \returns the length of the file /** \returns the length of the file
*/ */
size_t GetFileSize() const { return m_nFileSize; } size_t GetFileSize() const { return m_nFileSize; }
/**
* \returns true if this PdfWriter creates an encrypted PDF file
*/
bool GetEncrypted() const { return (m_pEncrypt != NULL); }
/**
* \returns the parsers encryption object or NULL if the read PDF file
was not encrypted
*/
const PdfEncrypt* GetEncrypt() const { return m_pEncrypt; }
/**
* Takes the encryption object fro mthe parser. The internal handle wil
l be set
* to NULL and the ownership of the object is given to the caller.
*
* Only call this if you need access to the encryption object
* before deleting the parser.
*
* \returns the parsers encryption object or NULL if the read PDF file
was not encrypted
*/
inline PdfEncrypt* TakeEncrypt();
/** If you try to open an encrypted PDF file, which requires
* a password to open, PoDoFo will throw a PdfError( ePdfError_Invalid
Password )
* exception.
*
* If you got such an exception, you have to set a password
* which should be used for opening the PDF.
*
* The usual way will be to ask the user for the password
* and set the password using this method.
*
* PdfParser will immediately continue to read the PDF file.
*
* \param sPassword a user or owner password which can be used to open
an encrypted PDF file
* If the password is invalid, a PdfError( ePdfError_
InvalidPassword ) exception is thrown!
*/
void SetPassword( const std::string & sPassword );
protected: protected:
/** Searches backwards from the end of the file /** Searches backwards from the end of the file
* and tries to find a token. * and tries to find a token.
* The current file is positioned right after the token. * The current file is positioned right after the token.
* *
* \param pszToken a token to find * \param pszToken a token to find
* \param lRange range in bytes in which to search * \param lRange range in bytes in which to search
* begining at the end of the file * begining at the end of the file
*/ */
void FindToken( const char* pszToken, const long lRange ); void FindToken( const char* pszToken, const long lRange );
skipping to change at line 168 skipping to change at line 299
* If there is no xref table, ReadXRefStreamContents() is called. * If there is no xref table, ReadXRefStreamContents() is called.
* \param lOffset read the table from this offset * \param lOffset read the table from this offset
* \param bPositionAtEnd if true the xref table is not read, but the * \param bPositionAtEnd if true the xref table is not read, but the
* file stream is positioned directly * file stream is positioned directly
* after the table, which allows reading * after the table, which allows reading
* a following trailer dictionary. * a following trailer dictionary.
*/ */
void ReadXRefContents( long lOffset, bool bPositionAtEnd = false ); void ReadXRefContents( long lOffset, bool bPositionAtEnd = false );
/** Read a xref subsection /** Read a xref subsection
*
* Throws ePdfError_NoXref if the number of objects read was not
* the number specified by the subsection header (as passed in
* `nNumObjects').
*
* \param nFirstObject object number of the first object * \param nFirstObject object number of the first object
* \param nNumObjects how many objects should be read from this secti on * \param nNumObjects how many objects should be read from this secti on
*/ */
void ReadXRefSubsection( long & nFirstObject, long & nNumObjects ); void ReadXRefSubsection( long & nFirstObject, long & nNumObjects );
/** Reads a xref stream contens object /** Reads a xref stream contens object
* \param lOffset read the stream from this offset * \param lOffset read the stream from this offset
* \param bReadOnlyTrailer only the trailer is skipped over, the conte nts * \param bReadOnlyTrailer only the trailer is skipped over, the conte nts
* of the xref stream are not parsed * of the xref stream are not parsed
*/ */
void ReadXRefStreamContents( long lOffset, bool bReadOnlyTrailer ); void ReadXRefStreamContents( long lOffset, bool bReadOnlyTrailer );
void ReadXRefStreamEntry( char* pBuffer, long lLen, long lW[W_ARRAY_SIZ E], int nObjNo ); void ReadXRefStreamEntry( char* pBuffer, long lLen, long lW[W_ARRAY_SIZ E], int nObjNo );
/** Reads all objects from the pdf into memory /** Reads all objects from the pdf into memory
* from the offsets listed in m_vecOffsets. * from the offsets listed in m_vecOffsets.
*
* If required an encryption object is setup first.
*
* The actual reading happens in ReadObjectsInternal()
* either if no encryption is required or a correct
* encryption object was initialized from SetPassword.
*/ */
void ReadObjects(); void ReadObjects();
/** Reads all objects from the pdf into memory
* from the offsets listed in m_vecOffsets.
*
* Requires a correctly setup PdfEncrypt object
* with correct password.
*
* This method is called from ReadObjects
* or SetPassword.
*
* \see ReadObjects
* \see SetPassword
*/
void ReadObjectsInternal();
/** Read the object with index nIndex from the object stream nObjNo /** Read the object with index nIndex from the object stream nObjNo
* and push it on the objects vector m_vecOffsets. * and push it on the objects vector m_vecOffsets.
* *
* All objects are read from this stream and the stream object * All objects are read from this stream and the stream object
* is free'd from memory. Further calls who try to read from the * is free'd from memory. Further calls who try to read from the
* same stream simply do nothing. * same stream simply do nothing.
* *
* \param nObjNo object number of the stream object * \param nObjNo object number of the stream object
* \param nIndex index of the object which should be parsed * \param nIndex index of the object which should be parsed
* *
skipping to change at line 220 skipping to change at line 376
private: private:
/** Free all internal data structures /** Free all internal data structures
*/ */
void Clear(); void Clear();
/** Initializes all private members /** Initializes all private members
* with their initial values. * with their initial values.
*/ */
void Init(); void Init();
/** Small helper method to retrieve the document id from the trailer
*
* \returns the document id of this PDF document
*/
const PdfString & GetDocumentId();
private: private:
struct TXRefEntry {
inline TXRefEntry() : lOffset(0), lGeneration(0), cUsed('\x00'), bP
arsed(false) { }
long lOffset;
long lGeneration;
char cUsed;
bool bParsed;
};
typedef std::vector<TXRefEntry> TVecOffsets;
typedef TVecOffsets::iterator TIVecOffsets;
typedef TVecOffsets::const_iterator TCIVecOffsets;
EPdfVersion m_ePdfVersion; EPdfVersion m_ePdfVersion;
bool m_bLoadOnDemand; bool m_bLoadOnDemand;
long m_nXRefOffset; long m_nXRefOffset;
long m_nFirstObject; long m_nFirstObject;
long m_nNumObjects; long m_nNumObjects;
long m_nXRefLinearizedOffset; long m_nXRefLinearizedOffset;
size_t m_nFileSize; size_t m_nFileSize;
TXRefEntry* m_pOffsets; TVecOffsets m_offsets;
PdfVecObjects* m_vecObjects; PdfVecObjects* m_vecObjects;
PdfObject* m_pTrailer; PdfObject* m_pTrailer;
PdfObject* m_pLinearization; PdfObject* m_pLinearization;
PdfEncrypt* m_pEncrypt;
bool m_xrefSizeUnknown;
std::set<int> m_setObjectStreams; std::set<int> m_setObjectStreams;
}; };
// ----------------------------------------------------- // -----------------------------------------------------
// //
// ----------------------------------------------------- // -----------------------------------------------------
bool PdfParser::GetLoadOnDemand() const bool PdfParser::GetLoadOnDemand() const
{ {
return m_bLoadOnDemand; return m_bLoadOnDemand;
skipping to change at line 272 skipping to change at line 450
} }
// ----------------------------------------------------- // -----------------------------------------------------
// //
// ----------------------------------------------------- // -----------------------------------------------------
const PdfObject* PdfParser::GetTrailer() const const PdfObject* PdfParser::GetTrailer() const
{ {
return m_pTrailer; return m_pTrailer;
} }
// -----------------------------------------------------
//
// -----------------------------------------------------
PdfEncrypt* PdfParser::TakeEncrypt()
{
PdfEncrypt* pEncrypt = m_pEncrypt;
m_pEncrypt = NULL;
return pEncrypt;
}
}; };
#endif // _PDF_PARSER_H_ #endif // _PDF_PARSER_H_
 End of changes. 14 change blocks. 
1 lines changed or deleted 208 lines changed or added


 PdfParserObject.h   PdfParserObject.h 
skipping to change at line 30 skipping to change at line 30
#ifndef _PDF_PARSER_OBJECT_H_ #ifndef _PDF_PARSER_OBJECT_H_
#define _PDF_PARSER_OBJECT_H_ #define _PDF_PARSER_OBJECT_H_
#include "PdfDefines.h" #include "PdfDefines.h"
#include "PdfObject.h" #include "PdfObject.h"
#include "PdfTokenizer.h" #include "PdfTokenizer.h"
namespace PoDoFo { namespace PoDoFo {
class PdfEncrypt;
class PdfParser; class PdfParser;
/** /**
* A PdfParserObject constructs a PdfObject from a PDF file. * A PdfParserObject constructs a PdfObject from a PDF file.
* Parsing starts always at the current file position. * Parsing starts always at the current file position.
*/ */
class PODOFO_API PdfParserObject : public PdfObject, public PdfTokenizer { class PODOFO_API PdfParserObject : public PdfObject, public PdfTokenizer {
public: public:
/** Parse the object data from the given file handle starting at /** Parse the object data from the given file handle starting at
skipping to change at line 69 skipping to change at line 70
* \param rBuffer buffer to use for parsing to avoid reallocations * \param rBuffer buffer to use for parsing to avoid reallocations
*/ */
explicit PdfParserObject( const PdfRefCountedBuffer & rBuffer ); explicit PdfParserObject( const PdfRefCountedBuffer & rBuffer );
virtual ~PdfParserObject(); virtual ~PdfParserObject();
/** Parse the object data from the given file handle /** Parse the object data from the given file handle
* If delayed loading is enabled, only the object and generation numbe r * If delayed loading is enabled, only the object and generation numbe r
* is read now and everything else is read later. * is read now and everything else is read later.
* *
* \param pEncrypt an encryption dictionary which is used to decrypt
* strings and streams during parsing or NULL if the P
DF
* file was not encrypted
* \param bIsTrailer wether this is a trailer dictionary or not. * \param bIsTrailer wether this is a trailer dictionary or not.
* trailer dictionaries do not have a object number etc. * trailer dictionaries do not have a object number etc.
*/ */
void ParseFile( bool bIsTrailer = false ); void ParseFile( PdfEncrypt* pEncrypt, bool bIsTrailer = false );
/** Returns if this object has a stream object appended. /** Returns if this object has a stream object appended.
* which has to be parsed. * which has to be parsed.
* \returns true if there is a stream * \returns true if there is a stream
*/ */
inline bool HasStreamToParse() const; inline bool HasStreamToParse() const;
/** \returns true if this PdfParser loads all objects at /** \returns true if this PdfParser loads all objects at
* the time they are accessed for the first time. * the time they are accessed for the first time.
* The default is to load all object immediately. * The default is to load all object immediately.
skipping to change at line 136 skipping to change at line 140
/** Parse the object data from the given file handle /** Parse the object data from the given file handle
* \param bIsTrailer wether this is a trailer dictionary or not. * \param bIsTrailer wether this is a trailer dictionary or not.
* trailer dictionaries do not have a object number etc. * trailer dictionaries do not have a object number etc.
*/ */
void ParseFileComplete( bool bIsTrailer ); void ParseFileComplete( bool bIsTrailer );
void ReadObjectNumber(); void ReadObjectNumber();
private: private:
bool m_bIsTrailer; PdfEncrypt* m_pEncrypt;
bool m_bIsTrailer;
// Should the object try to defer loading of its contents until needed? // Should the object try to defer loading of its contents until needed?
// If false, object contents will be loaded during ParseFile(...). Note that // If false, object contents will be loaded during ParseFile(...). Note that
// this still uses the delayed loading infrastructure. // this still uses the delayed loading infrastructure.
// If true, loading will be triggered the first time the information is needed by // If true, loading will be triggered the first time the information is needed by
// an external caller. // an external caller.
// Outside callers should not be able to tell the difference between th e two modes // Outside callers should not be able to tell the difference between th e two modes
// of operation. // of operation.
bool m_bLoadOnDemand; bool m_bLoadOnDemand;
 End of changes. 4 change blocks. 
2 lines changed or deleted 8 lines changed or added


 PdfRefCountedBuffer.h   PdfRefCountedBuffer.h 
skipping to change at line 32 skipping to change at line 32
#define _PDF_REF_COUNTED_BUFFER_H_ #define _PDF_REF_COUNTED_BUFFER_H_
#include "PdfDefines.h" #include "PdfDefines.h"
namespace PoDoFo { namespace PoDoFo {
/** /**
* A reference counted buffer object * A reference counted buffer object
* which is deleted as soon as the last * which is deleted as soon as the last
* object having access to it is delteted. * object having access to it is delteted.
*
* The attached memory object can be resized.
*/ */
class PODOFO_API PdfRefCountedBuffer { class PODOFO_API PdfRefCountedBuffer {
public: public:
/** Created an empty reference counted buffer /** Created an empty reference counted buffer
* The buffer will be initialize to NULL * The buffer will be initialize to NULL
*/ */
PdfRefCountedBuffer(); inline PdfRefCountedBuffer();
/** Created an reference counted buffer and use an exiting buffer /** Created an reference counted buffer and use an exiting buffer
* The buffer will be owned by this object. * The buffer will be owned by this object.
* *
* \param pBuffer a pointer to an allocated buffer * \param pBuffer a pointer to an allocated buffer
* \param lSize size of the allocated buffer * \param lSize size of the allocated buffer
* *
* \see SetTakePossesion * \see SetTakePossesion
*/ */
PdfRefCountedBuffer( char* pBuffer, long lSize ); PdfRefCountedBuffer( char* pBuffer, long lSize );
/** Create a new PdfRefCountedBuffer. /** Create a new PdfRefCountedBuffer.
* \param lSize buffer size * \param lSize buffer size
*/ */
PdfRefCountedBuffer( long lSize ); inline PdfRefCountedBuffer( long lSize );
/** Copy an existing PdfRefCountedBuffer and increase /** Copy an existing PdfRefCountedBuffer and increase
* the reference count * the reference count
* \param rhs the PdfRefCountedBuffer to copy * \param rhs the PdfRefCountedBuffer to copy
*/ */
PdfRefCountedBuffer( const PdfRefCountedBuffer & rhs ); inline PdfRefCountedBuffer( const PdfRefCountedBuffer & rhs );
/** Decrease the reference count and delete the buffer /** Decrease the reference count and delete the buffer
* if this is the last owner * if this is the last owner
*/ */
~PdfRefCountedBuffer(); inline ~PdfRefCountedBuffer();
/** Append to the current buffers contents. /** Append to the current buffers contents.
* If the buffer is referenced by another PdfRefCountedBuffer * If the buffer is referenced by another PdfRefCountedBuffer
* this object detaches from this buffer and allocates an own * this object detaches from this buffer and allocates an own
* buffer. Otherwise the internal buffer is used and resized if * buffer. Otherwise the internal buffer is used and resized if
* necessary. * necessary.
* *
* \param pszString a buffer * \param pszString a buffer
* \param lLen length of the buffer * \param lLen length of the buffer
*/ */
void Append( const char* pszString, long lLen ); //void Append( const char* pszString, long lLen );
/** Get access to the buffer /** Get access to the buffer
* \returns the buffer * \returns the buffer
*/ */
inline char* GetBuffer() const; inline char* GetBuffer() const;
/** Return the buffer size /** Return the buffer size.
*
* \returns the buffer size * \returns the buffer size
*/ */
inline long GetSize() const; inline long GetSize() const;
/** Resize the buffer to hold at least
* lSize bytes.
*
* \param lSize the size of bytes the buffer can at least hold
*
* If the buffer is larger no operation is performed.
*/
inline void Resize( size_t lSize );
/** Copy an existing PdfRefCountedBuffer and increase /** Copy an existing PdfRefCountedBuffer and increase
* the reference count * the reference count
* \param rhs the PdfRefCountedBuffer to copy * \param rhs the PdfRefCountedBuffer to copy
* \returns the copied object * \returns the copied object
*/ */
const PdfRefCountedBuffer & operator=( const PdfRefCountedBuffer & rhs ); const PdfRefCountedBuffer & operator=( const PdfRefCountedBuffer & rhs );
/** If the PdfRefCountedBuffer has no possesion on its buffer, /** If the PdfRefCountedBuffer has no possesion on its buffer,
* it won't delete the buffer. By default the buffer is owned * it won't delete the buffer. By default the buffer is owned
* and deleted by the PdfRefCountedBuffer object. * and deleted by the PdfRefCountedBuffer object.
skipping to change at line 127 skipping to change at line 139
*/ */
bool operator<( const PdfRefCountedBuffer & rhs ) const; bool operator<( const PdfRefCountedBuffer & rhs ) const;
/** Compare to buffers. /** Compare to buffers.
* \param rhs compare to this buffer * \param rhs compare to this buffer
* \returns true if this buffer is lexically greater than rhs * \returns true if this buffer is lexically greater than rhs
*/ */
bool operator>( const PdfRefCountedBuffer & rhs ) const; bool operator>( const PdfRefCountedBuffer & rhs ) const;
private: private:
/** Detach from the reference counted buffer /**
* Indicate that the buffer is no longer being used, freeing it if ther
e
* are no further users. The buffer becomes inaccessible to this
* PdfRefCountedBuffer in either case.
*/
inline void DerefBuffer();
/**
* Free a buffer if the refcount is zero. Internal method used by Deref
Buffer.
*/
void FreeBuffer();
/** Detach from a shared buffer or do nothing if we are the only
* one referencing the buffer.
*
* Call this function before any operation modifiying the buffer!
*
* \param lLen an additional parameter specifiying extra bytes
* to be allocated to optimize allocations of a new buffer
.
*/
inline void Detach( long lExtraLen = 0 );
/**
* Called by Detach() to do the work if action is actually required.
* \see Detach
*/ */
void Detach(); void ReallyDetach( long lExtraLen );
/**
* Do the hard work of resizing the buffer if it turns out not to alrea
dy be big enough.
* \see Resize
*/
void ReallyResize( size_t lSize );
private: private:
typedef struct TRefCountedBuffer { struct TRefCountedBuffer {
char* m_pBuffer; enum { INTERNAL_BUFSIZE = 32 };
long m_lSize; // Convenience inline for buffer switching
long m_lInternalSize; PODOFO_NOTHROW inline char * GetRealBuffer() { return m_bOnHeap? m_
pHeapBuffer : &(m_sInternalBuffer[0]); }
// size in bytes of the buffer. If and only if this is strictly >IN
TERNAL_BUFSIZE,
// this buffer is on the heap in memory pointed to by m_pHeapBuffer
. If it is <=INTERNAL_BUFSIZE,
// the buffer is in the in-object buffer m_sInternalBuffer.
long m_lBufferSize;
// Size in bytes of m_pBuffer that should be reported to clients. W
e
// over-allocate on the heap for efficiency and have a minimum 32 b
yte
// size, but this extra should NEVER be visible to a client.
long m_lVisibleSize;
long m_lRefCount; long m_lRefCount;
char* m_pHeapBuffer;
char m_sInternalBuffer[INTERNAL_BUFSIZE];
bool m_bPossesion; bool m_bPossesion;
// Are we using the heap-allocated buffer in place of our small int
ernal one?
bool m_bOnHeap;
}; };
TRefCountedBuffer* m_pBuffer; TRefCountedBuffer* m_pBuffer;
}; };
// ----------------------------------------------------- // -----------------------------------------------------
// //
// ----------------------------------------------------- // -----------------------------------------------------
PdfRefCountedBuffer::PdfRefCountedBuffer()
: m_pBuffer( NULL )
{
}
// -----------------------------------------------------
//
// -----------------------------------------------------
PdfRefCountedBuffer::PdfRefCountedBuffer( long lSize )
: m_pBuffer( NULL )
{
this->Resize( lSize );
}
// -----------------------------------------------------
//
// -----------------------------------------------------
// We define the copy ctor separately to the assignment
// operator since it's a *LOT* faster this way.
PdfRefCountedBuffer::PdfRefCountedBuffer( const PdfRefCountedBuffer & rhs )
: m_pBuffer( rhs.m_pBuffer )
{
if (m_pBuffer)
++(m_pBuffer->m_lRefCount);
}
// -----------------------------------------------------
//
// -----------------------------------------------------
PdfRefCountedBuffer::~PdfRefCountedBuffer()
{
DerefBuffer();
}
// -----------------------------------------------------
//
// -----------------------------------------------------
inline char* PdfRefCountedBuffer::GetBuffer() const inline char* PdfRefCountedBuffer::GetBuffer() const
{ {
return m_pBuffer ? m_pBuffer->m_pBuffer : NULL; if (!m_pBuffer) return NULL;
return m_pBuffer->GetRealBuffer();
} }
// ----------------------------------------------------- // -----------------------------------------------------
// //
// ----------------------------------------------------- // -----------------------------------------------------
inline long PdfRefCountedBuffer::GetSize() const inline long PdfRefCountedBuffer::GetSize() const
{ {
return m_pBuffer ? m_pBuffer->m_lSize : 0; return m_pBuffer ? m_pBuffer->m_lVisibleSize : 0;
} }
// ----------------------------------------------------- // -----------------------------------------------------
// //
// ----------------------------------------------------- // -----------------------------------------------------
inline void PdfRefCountedBuffer::SetTakePossesion( bool bTakePossession ) inline void PdfRefCountedBuffer::SetTakePossesion( bool bTakePossession )
{ {
if( m_pBuffer ) if( m_pBuffer )
m_pBuffer->m_bPossesion = bTakePossession; m_pBuffer->m_bPossesion = bTakePossession;
} }
// ----------------------------------------------------- // -----------------------------------------------------
// //
// ----------------------------------------------------- // -----------------------------------------------------
inline bool PdfRefCountedBuffer::TakePossesion() const inline bool PdfRefCountedBuffer::TakePossesion() const
{ {
return m_pBuffer ? m_pBuffer->m_bPossesion : false; return m_pBuffer ? m_pBuffer->m_bPossesion : false;
} }
// -----------------------------------------------------
//
// -----------------------------------------------------
inline void PdfRefCountedBuffer::Detach( long lExtraLen )
{
if (m_pBuffer && m_pBuffer->m_lRefCount > 1L)
ReallyDetach(lExtraLen);
}
// -----------------------------------------------------
//
// -----------------------------------------------------
inline void PdfRefCountedBuffer::Resize( size_t lSize )
{
if (m_pBuffer && m_pBuffer->m_lRefCount == 1L && static_cast<size_t>(m
_pBuffer->m_lBufferSize) >= lSize)
{
// We have a solely owned buffer the right size already; no need to
// waste any time detaching or resizing it. Just let the client see
// more of it (or less if they're shrinking their view).
m_pBuffer->m_lVisibleSize = lSize;
}
else
{
ReallyResize( lSize );
}
}
// -----------------------------------------------------
//
// -----------------------------------------------------
inline void PdfRefCountedBuffer::DerefBuffer()
{
if ( m_pBuffer && !(--m_pBuffer->m_lRefCount) )
FreeBuffer();
// Whether or not it still exists, we no longer have anything to do wit
h
// the buffer we just released our claim on.
m_pBuffer = NULL;
}
}; };
#endif // _PDF_REF_COUNTED_BUFFER_H_ #endif // _PDF_REF_COUNTED_BUFFER_H_
 End of changes. 17 change blocks. 
14 lines changed or deleted 157 lines changed or added


 PdfRefCountedInputDevice.h   PdfRefCountedInputDevice.h 
skipping to change at line 56 skipping to change at line 56
*/ */
PdfRefCountedInputDevice( const char* pszFilename, const char* pszMode ); PdfRefCountedInputDevice( const char* pszFilename, const char* pszMode );
/** Create a new PdfRefCountedInputDevice which operates on a in memory buffer /** Create a new PdfRefCountedInputDevice which operates on a in memory buffer
* *
* \param pBuffer pointer to the buffer * \param pBuffer pointer to the buffer
* \param lLen length of the buffer * \param lLen length of the buffer
*/ */
PdfRefCountedInputDevice( const char* pBuffer, long lLen ); PdfRefCountedInputDevice( const char* pBuffer, long lLen );
/** Create a new PdfRefCountedInputDevice from an PdfInputDevice
*
* \param pDevice the input device. It will be owned and deleted by th
is object.
*/
PdfRefCountedInputDevice( PdfInputDevice* pDevice );
/** Copy an existing PdfRefCountedFile and increase /** Copy an existing PdfRefCountedFile and increase
* the reference count * the reference count
* \param rhs the PdfRefCountedFile to copy * \param rhs the PdfRefCountedFile to copy
*/ */
PdfRefCountedInputDevice( const PdfRefCountedInputDevice & rhs ); PdfRefCountedInputDevice( const PdfRefCountedInputDevice & rhs );
/** Decrease the reference count and close the file /** Decrease the reference count and close the file
* if this is the last owner * if this is the last owner
*/ */
~PdfRefCountedInputDevice(); ~PdfRefCountedInputDevice();
skipping to change at line 85 skipping to change at line 91
* \returns the copied object * \returns the copied object
*/ */
const PdfRefCountedInputDevice & operator=( const PdfRefCountedInputDev ice & rhs ); const PdfRefCountedInputDevice & operator=( const PdfRefCountedInputDev ice & rhs );
private: private:
/** Detach from the reference counted file /** Detach from the reference counted file
*/ */
void Detach(); void Detach();
private: private:
typedef struct TRefCountedInputDevice { typedef struct {
PdfInputDevice* m_pDevice; PdfInputDevice* m_pDevice;
long m_lRefCount; long m_lRefCount;
}; } TRefCountedInputDevice;
TRefCountedInputDevice* m_pDevice; TRefCountedInputDevice* m_pDevice;
}; };
// ----------------------------------------------------- // -----------------------------------------------------
// //
// ----------------------------------------------------- // -----------------------------------------------------
inline PdfInputDevice* PdfRefCountedInputDevice::Device() const inline PdfInputDevice* PdfRefCountedInputDevice::Device() const
{ {
return m_pDevice ? m_pDevice->m_pDevice : NULL; return m_pDevice ? m_pDevice->m_pDevice : NULL;
 End of changes. 3 change blocks. 
2 lines changed or deleted 9 lines changed or added


 PdfReference.h   PdfReference.h 
skipping to change at line 92 skipping to change at line 92
* *
* \param rhs the object to copy * \param rhs the object to copy
*/ */
PODOFO_NOTHROW inline const PdfReference & operator=( const PdfReferenc e & rhs ); PODOFO_NOTHROW inline const PdfReference & operator=( const PdfReferenc e & rhs );
/** Write the complete variant to an output device. /** Write the complete variant to an output device.
* This is an overloaded member function. * This is an overloaded member function.
* *
* \param pDevice write the object to this device * \param pDevice write the object to this device
*/ */
void Write( PdfOutputDevice* pDevice ) const; void Write( PdfOutputDevice* pDevice, const PdfEncrypt* pEncrypt = NULL ) const;
/** /**
* Compare to PdfReference objects. * Compare to PdfReference objects.
* \returns true if both reference the same object * \returns true if both reference the same object
*/ */
PODOFO_NOTHROW inline bool operator==( const PdfReference & rhs ) const ; PODOFO_NOTHROW inline bool operator==( const PdfReference & rhs ) const ;
/** /**
* Compare to PdfReference objects. * Compare to PdfReference objects.
* \returns false if both reference the same object * \returns false if both reference the same object
skipping to change at line 163 skipping to change at line 163
m_nObjectNo = rhs.m_nObjectNo; m_nObjectNo = rhs.m_nObjectNo;
m_nGenerationNo = rhs.m_nGenerationNo; m_nGenerationNo = rhs.m_nGenerationNo;
return *this; return *this;
} }
// ----------------------------------------------------- // -----------------------------------------------------
// //
// ----------------------------------------------------- // -----------------------------------------------------
bool PdfReference::operator<( const PdfReference & rhs ) const bool PdfReference::operator<( const PdfReference & rhs ) const
{ {
if( m_nObjectNo == rhs.m_nObjectNo ) return m_nObjectNo == rhs.m_nObjectNo ? m_nGenerationNo < rhs.m_nGenera
return m_nGenerationNo < rhs.m_nGenerationNo; tionNo : m_nObjectNo < rhs.m_nObjectNo;
else
return m_nObjectNo < rhs.m_nObjectNo;
} }
// ----------------------------------------------------- // -----------------------------------------------------
// //
// ----------------------------------------------------- // -----------------------------------------------------
bool PdfReference::operator==( const PdfReference & rhs ) const bool PdfReference::operator==( const PdfReference & rhs ) const
{ {
return ( m_nObjectNo == rhs.m_nObjectNo && m_nGenerationNo == rhs.m_nGe nerationNo); return ( m_nObjectNo == rhs.m_nObjectNo && m_nGenerationNo == rhs.m_nGe nerationNo);
} }
 End of changes. 2 change blocks. 
5 lines changed or deleted 3 lines changed or added


 PdfStream.h   PdfStream.h 
skipping to change at line 30 skipping to change at line 30
#ifndef _PDF_STREAM_H_ #ifndef _PDF_STREAM_H_
#define _PDF_STREAM_H_ #define _PDF_STREAM_H_
#include "PdfDefines.h" #include "PdfDefines.h"
#include "PdfDictionary.h" #include "PdfDictionary.h"
#include "PdfFilter.h" #include "PdfFilter.h"
#include "PdfRefCountedBuffer.h" #include "PdfRefCountedBuffer.h"
#include <string.h>
namespace PoDoFo { namespace PoDoFo {
class PdfInputStream; class PdfInputStream;
class PdfName; class PdfName;
class PdfObject; class PdfObject;
class PdfOutputStream; class PdfOutputStream;
/** A PDF stream can be appended to any PdfObject /** A PDF stream can be appended to any PdfObject
* and can contain arbitrary data. * and can contain arbitrary data.
* *
skipping to change at line 63 skipping to change at line 65
* The stream will be deleted along with the parent. * The stream will be deleted along with the parent.
* This constructor will be called by PdfObject::Stream() for you. * This constructor will be called by PdfObject::Stream() for you.
* \param pParent parent object * \param pParent parent object
*/ */
PdfStream( PdfObject* pParent ); PdfStream( PdfObject* pParent );
virtual ~PdfStream(); virtual ~PdfStream();
/** Write the stream to an output device /** Write the stream to an output device
* \param pDevice write to this outputdevice. * \param pDevice write to this outputdevice.
* \param pEncrypt encrypt stream data using this object
*/ */
virtual void Write( PdfOutputDevice* pDevice ) = 0; virtual void Write( PdfOutputDevice* pDevice, PdfEncrypt* pEncrypt = NU LL ) = 0;
/** Set a binary buffer as stream data, optionally taking ownership of /** Set a binary buffer as stream data.
the
* buffer.
* *
* Use PdfFilterFactory::CreateFilterList if you want to use the conten ts * Use PdfFilterFactory::CreateFilterList if you want to use the conten ts
* of the stream dictionary's existing filter key. * of the stream dictionary's existing filter key.
* *
* \param szBuffer buffer containing the stream data * \param szBuffer buffer containing the stream data
* \param lLen length of the buffer * \param lLen length of the buffer
* \param vecFilters a list of filters to use when appending data * \param vecFilters a list of filters to use when appending data
*/ */
void Set( char* szBuffer, long lLen, const TVecFilters & vecFilters ); void Set( const char* szBuffer, long lLen, const TVecFilters & vecFilte rs );
/** Set a binary buffer as stream data, optionally taking ownership of the buffer. /** Set a binary buffer as stream data.
* All data will be flate encoded. * All data will be flate encoded.
* *
* \param szBuffer buffer containing the stream data * \param szBuffer buffer containing the stream data
* \param lLen length of the buffer * \param lLen length of the buffer
*/ */
void Set( char* szBuffer, long lLen ); void Set( const char* szBuffer, long lLen );
/** Set a binary buffer whose contents are read from a PdfInputStream /** Set a binary buffer whose contents are read from a PdfInputStream
* All data will be flate encoded. * All data will be flate encoded.
* *
* \param pStream read stream contents from this PdfInputStream * \param pStream read stream contents from this PdfInputStream
*/ */
void Set( PdfInputStream* pStream ); void Set( PdfInputStream* pStream );
/** Set a binary buffer whose contents are read from a PdfInputStream /** Set a binary buffer whose contents are read from a PdfInputStream
* *
 End of changes. 7 change blocks. 
7 lines changed or deleted 8 lines changed or added


 PdfStreamedDocument.h   PdfStreamedDocument.h 
skipping to change at line 27 skipping to change at line 27
* Free Software Foundation, Inc., * * Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
************************************************************************** */ ************************************************************************** */
#ifndef _PDF_STREAMED_DOCUMENT_H_ #ifndef _PDF_STREAMED_DOCUMENT_H_
#define _PDF_STREAMED_DOCUMENT_H_ #define _PDF_STREAMED_DOCUMENT_H_
#include "PdfDefines.h" #include "PdfDefines.h"
#include "PdfDocument.h" #include "PdfDocument.h"
#include "PdfImmediateWriter.h"
namespace PoDoFo { namespace PoDoFo {
class PdfImmediateWriter;
class PdfOutputDevice; class PdfOutputDevice;
/** PdfStreamedDocument is the preferred class for /** PdfStreamedDocument is the preferred class for
* creating new PDF documents. * creating new PDF documents.
* *
* Page contents, fonts and images are written to disk * Page contents, fonts and images are written to disk
* as soon as possible and are not kept in memory. * as soon as possible and are not kept in memory.
* This results in faster document generation and * This results in faster document generation and
* less memory being used. * less memory being used.
* *
* Please use PdfDocument if you intend to work * Please use PdfMemDocument if you intend to work
* on the object structure of a PDF file. * on the object structure of a PDF file.
* *
* One of the design goals of PdfStreamedDocument was
* to hide the underlying object structure of a PDF
* file as far as possible.
*
* \see PdfDocument * \see PdfDocument
* \see PdfMemDocument
*
* Example of using PdfStreamedDocument:
*
* PdfStreamedDocument document( "outputfile.pdf" );
* PdfPage* pPage = document.CreatePage( PdfPage::CreateStandardPageSize(
ePdfPageSize_A4 ) );
* PdfFont* pFont = document.CreateFont( "Arial" );
*
* PdfPainter painter;
* painter.SetPage( pPage );
* painter.SetFont( pFont );
* painter.DrawText( 56.69, pPage->GetPageSize().GetHeight() - 56.69, "Hel
lo World!" );
* painter.FinishPage();
*
* document.Close();
*/ */
class PODOFO_API PdfStreamedDocument { class PODOFO_API PdfStreamedDocument : public PdfDocument {
friend class PdfImage; friend class PdfImage;
friend class PdfElement; friend class PdfElement;
public: public:
/** Create a new PdfStreamedDocument. /** Create a new PdfStreamedDocument.
* All data is written to an output device * All data is written to an output device
* immediately. * immediately.
* *
* \param pDevice an output device * \param pDevice an output device
* \param eVersion the PDF version of the document to write.
* The PDF version can only be set in the constructor
* as it is the first item written to the document on
disk.
* \param pEncrypt pointer to an encryption object or NULL. If not NUL
L
* the PdfEncrypt object will be copied and used to en
crypt the
* created document.
*/ */
PdfStreamedDocument( PdfOutputDevice* pDevice ); PdfStreamedDocument( PdfOutputDevice* pDevice, EPdfVersion eVersion = e PdfVersion_1_5, PdfEncrypt* pEncrypt = NULL );
/** Create a new PdfStreamedDocument. /** Create a new PdfStreamedDocument.
* All data is written to a file immediately. * All data is written to a file immediately.
* *
* \param pszFilename resulting PDF file * \param pszFilename resulting PDF file
* \param eVersion the PDF version of the document to write.
* The PDF version can only be set in the constructor
* as it is the first item written to the document on
disk.
* \param pEncrypt pointer to an encryption object or NULL. If not NUL
L
* the PdfEncrypt object will be copied and used to en
crypt the
* created document.
*/ */
PdfStreamedDocument( const char* pszFilename ); PdfStreamedDocument( const char* pszFilename, EPdfVersion eVersion = eP dfVersion_1_5, PdfEncrypt* pEncrypt = NULL );
~PdfStreamedDocument(); ~PdfStreamedDocument();
/** Close the document. The PDF file on disk is finished. /** Close the document. The PDF file on disk is finished.
* No other member function of this class maybe called * No other member function of this class maybe called
* after calling this function. * after calling this function.
*/ */
void Close(); void Close();
/** Get access to the internal Info dictionary /** Get the PDF version of the document
* You can set the author, title etc. of the * \returns EPdfVersion version of the pdf document
* document using the info dictionary.
*
* \returns the info dictionary
*/
inline PdfInfo* GetInfo() const;
/** Get access to the Outlines (Bookmarks) dictionary
* The returned outlines object is owned by the PdfDocument.
*
* \returns the Outlines/Bookmarks dictionary
*/
inline PdfOutlines* GetOutlines( bool bCreate = ePdfCreateObject );
/** Get the total number of pages in a document
* \returns int number of pages
*/
inline int GetPageCount() const;
/** Creates a PdfFont object
* \param pszFontName name of the font as it is known to the system
* \param bEmbedd specifies whether this font should be embedded in th
e PDF file.
* Embedding fonts is usually a good idea.
* \returns PdfFont* a pointer to a new PdfFont object.
*/ */
inline PdfFont* CreateFont( const char* pszFontName, bool bEmbedd = tru e ); inline virtual EPdfVersion GetPdfVersion() const;
/** Creates a PdfFont object /** Returns wether this PDF document is linearized, aka
* \param face a valid freetype font handle * weboptimized
* \param bEmbedd specifies whether this font should be embedded in th * \returns true if the PDF document is linearized
e PDF file.
* Embedding fonts is usually a good idea.
* \returns PdfFont* a pointer to a new PdfFont object.
*/ */
inline PdfFont* CreateFont( FT_Face face, bool bEmbedd = true ); inline virtual bool IsLinearized() const;
/** Creates a new page object and inserts it into the internal /** Checks if printing this document is allowed.
* page tree. * Every PDF consuming applications has to adhere this value!
* The returned page is owned by the PdfDocument
* and will get deleted along with it!
* *
* \param rSize a PdfRect spezifying the size of the page (i.e the /Me * \returns true if you are allowed to print this document
diaBox key) in 1/1000th mm *
* \returns a pointer to a PdfPage object * \see PdfEncrypt to set own document permissions.
*/
inline PdfPage* CreatePage( const PdfRect & rSize );
/** Appends another PdfDocument to this document
* \param rDoc the document to append
* \returns this document
*/
inline const PdfDocument & Append( const PdfDocument & rDoc );
/** Attach a file to the document.
* \param rFileSpec a file specification
*/
inline void AttachFile( const PdfFileSpec & rFileSpec );
/** Sets the opening mode for a document
* \param inMode which mode to set
*/
inline void SetPageMode( EPdfPageMode inMode ) const;
/** Gets the opening mode for a document
* \returns which mode is set
*/
inline EPdfPageMode GetPageMode() const;
/** Sets the opening mode for a document to be in full screen
*/
inline void SetUseFullScreen( void ) const;
/** Sets the page layout for a document
*/
inline void SetPageLayout( EPdfPageLayout inLayout );
/** Set the document's Viewer Preferences:
* Hide the toolbar in the viewer
*/
inline void SetHideToolbar( void );
/** Set the document's Viewer Preferences:
* Hide the menubar in the viewer
*/
inline void SetHideMenubar( void );
/** Set the document's Viewer Preferences:
* Show only the documents contents and no controll
* elements such as buttons and scrollbars in the viewer
*/
inline void SetHideWindowUI( void );
/** Set the document's Viewer Preferences:
* Fit the document in the viewers window
*/ */
inline void SetFitWindow( void ); inline virtual bool IsPrintAllowed() const;
/** Set the document's Viewer Preferences: /** Checks if modifiying this document (besides annotations, form field
* Center the document in the viewers window s or changing pages) is allowed.
* Every PDF consuming applications has to adhere this value!
*
* \returns true if you are allowed to modfiy this document
*
* \see PdfEncrypt to set own document permissions.
*/ */
inline void SetCenterWindow( void ); inline virtual bool IsEditAllowed() const;
/** Set the document's Viewer Preferences: /** Checks if text and graphics extraction is allowed.
* Display the title from the document information * Every PDF consuming applications has to adhere this value!
* in the title of the viewer.
* *
* \see SetTitle * \returns true if you are allowed to extract text and graphics from
this document
*
* \see PdfEncrypt to set own document permissions.
*/ */
inline void SetDisplayDocTitle( void ); inline virtual bool IsCopyAllowed() const;
/** Set the document's Viewer Preferences: /** Checks if it is allowed to add or modify annotations or form fields
* Set the default print scaling of the document * Every PDF consuming applications has to adhere this value!
*
* \returns true if you are allowed to add or modify annotations or fo
rm fields
*
* \see PdfEncrypt to set own document permissions.
*/ */
inline void SetPrintScaling( PdfName& inScalingType ); inline virtual bool IsEditNotesAllowed() const;
/** Set the document's Viewer Preferences: /** Checks if it is allowed to fill in existing form or signature field
* Set the base URI of the document s
* Every PDF consuming applications has to adhere this value!
*
* \returns true if you are allowed to fill in existing form or signat
ure fields
*
* \see PdfEncrypt to set own document permissions.
*/ */
inline void SetBaseURI( const std::string& inBaseURI ); inline virtual bool IsFillAndSignAllowed() const;
/** Set the document's Viewer Preferences: /** Checks if it is allowed to extract text and graphics to support use
* Set the language of the document rs with disabillities
* Every PDF consuming applications has to adhere this value!
*
* \returns true if you are allowed to extract text and graphics to su
pport users with disabillities
*
* \see PdfEncrypt to set own document permissions.
*/ */
inline void SetLanguage( const std::string& inLanguage ); inline virtual bool IsAccessibilityAllowed() const;
/** Set the document's Viewer Preferences: /** Checks if it is allowed to insert, create, rotate, delete pages or
add bookmarks
* Every PDF consuming applications has to adhere this value!
*
* \returns true if you are allowed to insert, create, rotate, delete
pages or add bookmarks
*
* \see PdfEncrypt to set own document permissions.
*/ */
inline void SetBindingDirection( PdfName& inDirection ); inline virtual bool IsDocAssemblyAllowed() const;
/** Get access to the AcroForm dictionary /** Checks if it is allowed to print a high quality version of this doc
* \returns PdfObject the AcroForm dictionary ument
* Every PDF consuming applications has to adhere this value!
*
* \returns true if you are allowed to print a high quality version of
this document
*
* \see PdfEncrypt to set own document permissions.
*/ */
inline PdfAcroForm* GetAcroForm( bool bCreate = ePdfCreateObject ); inline virtual bool IsHighPrintAllowed() const;
private: private:
/** Initialize the PdfStreamedDocument with an output device /** Initialize the PdfStreamedDocument with an output device
* \param pDevice write to this device * \param pDevice write to this device
* \param eVersion the PDF version of the document to write.
* The PDF version can only be set in the constructor
* as it is the first item written to the document on
disk.
* \param pEncrypt pointer to an encryption object or NULL. If not NUL
L
* the PdfEncrypt object will be copied and used to en
crypt the
* created document.
*/ */
void Init( PdfOutputDevice* pDevice ); void Init( PdfOutputDevice* pDevice, EPdfVersion eVersion = ePdfVersion _1_5, PdfEncrypt* pEncrypt = NULL );
private: private:
PdfDocument m_doc;
PdfImmediateWriter* m_pWriter; PdfImmediateWriter* m_pWriter;
PdfOutputDevice* m_pDevice; PdfOutputDevice* m_pDevice;
}; PdfEncrypt* m_pEncrypt;
// -----------------------------------------------------
//
// -----------------------------------------------------
PdfInfo* PdfStreamedDocument::GetInfo() const
{
return m_doc.GetInfo();
}
// -----------------------------------------------------
//
// -----------------------------------------------------
PdfOutlines* PdfStreamedDocument::GetOutlines( bool bCreate )
{
return m_doc.GetOutlines( bCreate );
}
// -----------------------------------------------------
//
// -----------------------------------------------------
int PdfStreamedDocument::GetPageCount() const
{
return m_doc.GetPageCount();
}
// -----------------------------------------------------
//
// -----------------------------------------------------
PdfFont* PdfStreamedDocument::CreateFont( const char* pszFontName, bool bEm
bedd )
{
return m_doc.CreateFont( pszFontName, bEmbedd );
}
// -----------------------------------------------------
//
// -----------------------------------------------------
PdfFont* PdfStreamedDocument::CreateFont( FT_Face face, bool bEmbedd )
{
return m_doc.CreateFont( face, bEmbedd );
}
// -----------------------------------------------------
//
// -----------------------------------------------------
PdfPage* PdfStreamedDocument::CreatePage( const PdfRect & rSize )
{
return m_doc.CreatePage( rSize );
}
// -----------------------------------------------------
//
// -----------------------------------------------------
const PdfDocument & PdfStreamedDocument::Append( const PdfDocument & rDoc )
{
return m_doc.Append( rDoc );
}
// ----------------------------------------------------- bool m_bOwnDevice; ///< If true m_pDevice is owned by th
// is object and has to be deleted
// ----------------------------------------------------- };
void PdfStreamedDocument::AttachFile( const PdfFileSpec & rFileSpec )
{
m_doc.AttachFile( rFileSpec );
}
// -----------------------------------------------------
//
// -----------------------------------------------------
void PdfStreamedDocument::SetPageMode( EPdfPageMode inMode ) const
{
m_doc.SetPageMode( inMode );
}
// -----------------------------------------------------
//
// -----------------------------------------------------
EPdfPageMode PdfStreamedDocument::GetPageMode() const
{
return m_doc.GetPageMode();
}
// -----------------------------------------------------
//
// -----------------------------------------------------
void PdfStreamedDocument::SetUseFullScreen( void ) const
{
m_doc.SetUseFullScreen();
}
// -----------------------------------------------------
//
// -----------------------------------------------------
void PdfStreamedDocument::SetPageLayout( EPdfPageLayout inLayout )
{
m_doc.SetPageLayout( inLayout );
}
// -----------------------------------------------------
//
// -----------------------------------------------------
void PdfStreamedDocument::SetHideToolbar( void )
{
m_doc.SetHideToolbar();
}
// ----------------------------------------------------- // -----------------------------------------------------
// //
// ----------------------------------------------------- // -----------------------------------------------------
void PdfStreamedDocument::SetHideMenubar( void ) EPdfVersion PdfStreamedDocument::GetPdfVersion() const
{ {
m_doc.SetHideMenubar(); return m_pWriter->GetPdfVersion();
} }
// ----------------------------------------------------- // -----------------------------------------------------
// //
// ----------------------------------------------------- // -----------------------------------------------------
void PdfStreamedDocument::SetHideWindowUI( void ) bool PdfStreamedDocument::IsLinearized() const
{ {
m_doc.SetHideWindowUI(); // Linearization is currently not supported by PdfStreamedDocument
return false;
} }
// ----------------------------------------------------- // -----------------------------------------------------
// //
// ----------------------------------------------------- // -----------------------------------------------------
void PdfStreamedDocument::SetFitWindow( void ) bool PdfStreamedDocument::IsPrintAllowed() const
{ {
m_doc.SetFitWindow(); return m_pEncrypt ? m_pEncrypt->IsPrintAllowed() : true;
} }
// ----------------------------------------------------- // -----------------------------------------------------
// //
// ----------------------------------------------------- // -----------------------------------------------------
void PdfStreamedDocument::SetCenterWindow( void ) bool PdfStreamedDocument::IsEditAllowed() const
{ {
m_doc.SetCenterWindow(); return m_pEncrypt ? m_pEncrypt->IsEditAllowed() : true;
} }
// ----------------------------------------------------- // -----------------------------------------------------
// //
// ----------------------------------------------------- // -----------------------------------------------------
void PdfStreamedDocument::SetDisplayDocTitle( void ) bool PdfStreamedDocument::IsCopyAllowed() const
{ {
m_doc.SetDisplayDocTitle(); return m_pEncrypt ? m_pEncrypt->IsCopyAllowed() : true;
} }
// ----------------------------------------------------- // -----------------------------------------------------
// //
// ----------------------------------------------------- // -----------------------------------------------------
void PdfStreamedDocument::SetPrintScaling( PdfName& inScalingType ) bool PdfStreamedDocument::IsEditNotesAllowed() const
{ {
m_doc.SetPrintScaling( inScalingType ); return m_pEncrypt ? m_pEncrypt->IsEditNotesAllowed() : true;
} }
// ----------------------------------------------------- // -----------------------------------------------------
// //
// ----------------------------------------------------- // -----------------------------------------------------
void PdfStreamedDocument::SetBaseURI( const std::string& inBaseURI ) bool PdfStreamedDocument::IsFillAndSignAllowed() const
{ {
m_doc.SetBaseURI( inBaseURI ); return m_pEncrypt ? m_pEncrypt->IsFillAndSignAllowed() : true;
} }
// ----------------------------------------------------- // -----------------------------------------------------
// //
// ----------------------------------------------------- // -----------------------------------------------------
void PdfStreamedDocument::SetLanguage( const std::string& inLanguage ) bool PdfStreamedDocument::IsAccessibilityAllowed() const
{ {
m_doc.SetLanguage( inLanguage ); return m_pEncrypt ? m_pEncrypt->IsAccessibilityAllowed() : true;
} }
// ----------------------------------------------------- // -----------------------------------------------------
// //
// ----------------------------------------------------- // -----------------------------------------------------
void PdfStreamedDocument::SetBindingDirection( PdfName& inDirection ) bool PdfStreamedDocument::IsDocAssemblyAllowed() const
{ {
m_doc.SetBindingDirection( inDirection ); return m_pEncrypt ? m_pEncrypt->IsDocAssemblyAllowed() : true;
} }
// ----------------------------------------------------- // -----------------------------------------------------
// //
// ----------------------------------------------------- // -----------------------------------------------------
PdfAcroForm* PdfStreamedDocument::GetAcroForm( bool bCreate ) bool PdfStreamedDocument::IsHighPrintAllowed() const
{ {
return m_doc.GetAcroForm( bCreate ); return m_pEncrypt ? m_pEncrypt->IsHighPrintAllowed() : true;
} }
}; };
#endif /* _PDF_STREAMED_DOCUMENT_H_ */ #endif /* _PDF_STREAMED_DOCUMENT_H_ */
 End of changes. 57 change blocks. 
246 lines changed or deleted 151 lines changed or added


 PdfString.h   PdfString.h 
skipping to change at line 34 skipping to change at line 34
#include "PdfDefines.h" #include "PdfDefines.h"
#include "PdfDataType.h" #include "PdfDataType.h"
#include "PdfRefCountedBuffer.h" #include "PdfRefCountedBuffer.h"
namespace PoDoFo { namespace PoDoFo {
#define PDF_STRING_BUFFER_SIZE 24 #define PDF_STRING_BUFFER_SIZE 24
class PdfOutputDevice; class PdfOutputDevice;
typedef enum EPdfStringConversion { enum EPdfStringConversion {
ePdfStringConversion_Strict, ePdfStringConversion_Strict,
ePdfStringConversion_Lenient ePdfStringConversion_Lenient
}; };
/** A string that can be written to a PDF document. /** A string that can be written to a PDF document.
* If it contains binary data it is automatically * If it contains binary data it is automatically
* converted into a hex string, otherwise a normal PDF * converted into a hex string, otherwise a normal PDF
* string is written to the document. * string is written to the document.
* *
* PdfStrings representing text are either in PDFDocEncoding * PdfStrings representing text are either in PDFDocEncoding
skipping to change at line 60 skipping to change at line 60
* always stored as UTF-16BE or ISO Latin1 (PdfDocEncoding) * always stored as UTF-16BE or ISO Latin1 (PdfDocEncoding)
* in the PDF file. * in the PDF file.
* *
* UTF-16BE strings have to start with the byts 0xFE 0xFF * UTF-16BE strings have to start with the byts 0xFE 0xFF
* to be recognized by PoDoFo as unicode strings. * to be recognized by PoDoFo as unicode strings.
* *
* *
* PdfStrings is an implicitly shared class. As a reason * PdfStrings is an implicitly shared class. As a reason
* it is very fast to copy PdfString objects. * it is very fast to copy PdfString objects.
* *
* The internal string buffer is guaranteed to be always terminated
* by 2 zeros.
*/ */
class PODOFO_API PdfString : public PdfDataType{ class PODOFO_API PdfString : public PdfDataType{
public: public:
/** Create an empty and invalid string /** Create an empty and invalid string
*/ */
PdfString(); PdfString();
/** Construct a new PdfString from a std::string. /** Construct a new PdfString from a std::string.
* The input string will be copied. * The input string will be copied.
skipping to change at line 93 skipping to change at line 95
PdfString( const char* pszString ); PdfString( const char* pszString );
/** Construct a new PdfString from a string. /** Construct a new PdfString from a string.
* The input string will be copied. * The input string will be copied.
* If the first to bytes of the string are 0xFE and 0xFF * If the first to bytes of the string are 0xFE and 0xFF
* this string is treated as UTF-16BE encoded unicode string. * this string is treated as UTF-16BE encoded unicode string.
* *
* \param pszString the string to copy * \param pszString the string to copy
* \param lLen length of the string data to encode * \param lLen length of the string data to encode
* \param bHex if true the data will be * \param bHex if true the data will be
* hex encoded and IsHex() will return true. * hex encoded during writeout of the string and IsHex() w ill return true.
*/ */
PdfString( const char* pszString, long lLen, bool bHex = false ); PdfString( const char* pszString, long lLen, bool bHex = false );
/** Construct a new PdfString from an UTF-8 encoded string. /** Construct a new PdfString from an UTF-8 encoded string.
* *
* The string is converted to UTF-16BE internally. * The string is converted to UTF-16BE internally.
* *
* \param pszStringUtf8 a UTF-8 encoded string. * \param pszStringUtf8 a UTF-8 encoded string.
*/ */
PdfString( const pdf_utf8* pszStringUtf8 ); PdfString( const pdf_utf8* pszStringUtf8 );
/** Construct a new PdfString from an UTF-16be encoded zero terminated
string.
*
* \param pszStringUtf16 a UTF-16BE encoded string.
*/
PdfString( const pdf_utf16be* pszStringUtf16 );
/** Construct a new PdfString from an UTF-8 encoded string. /** Construct a new PdfString from an UTF-8 encoded string.
* *
* The string is converted to UTF-16BE internally. * The string is converted to UTF-16BE internally.
* *
* \param pszStringUtf8 a UTF-8 encoded string. * \param pszStringUtf8 a UTF-8 encoded string.
* \param lLen number of bytes to convert * \param lLen number of bytes to convert
*/ */
PdfString( const pdf_utf8* pszStringUtf8, long lLen ); PdfString( const pdf_utf8* pszStringUtf8, long lLen );
/** Copy an existing PdfString /** Copy an existing PdfString
skipping to change at line 127 skipping to change at line 135
PdfString( const PdfString & rhs ); PdfString( const PdfString & rhs );
~PdfString(); ~PdfString();
/** Set hex encoded data as the strings data. /** Set hex encoded data as the strings data.
* \param pszHex must be hex encoded data. * \param pszHex must be hex encoded data.
* \param lLen length of the hex encoded data. * \param lLen length of the hex encoded data.
* if lLen == -1 then strlen( pszHex ) will * if lLen == -1 then strlen( pszHex ) will
* be used as length of the hex data. * be used as length of the hex data.
* pszHex has to be zero terminated in this case. * pszHex has to be zero terminated in this case.
* \param pEncrypt if !NULL assume the hex data is encrypted and shoul d be decrypted after hexdecoding
*/ */
void SetHexData( const char* pszHex, long lLen = -1 ); void SetHexData( const char* pszHex, long lLen = -1, PdfEncrypt* pEncry pt = NULL );
/** The string is valid if no error in the constructor has occurred. /** The string is valid if no error in the constructor has occurred.
* If it is valid it is safe to call all the other member functions. * If it is valid it is safe to call all the other member functions.
* \returns true if this is a valid initialized PdfString * \returns true if this is a valid initialized PdfString
*/ */
inline bool IsValid() const; inline bool IsValid() const;
/** Check if this is a hex string or a text string. /** Check if this is a hex string.
* *
* If true the data returned by GetString() will be hexencoded. * If true the data will be hex encoded when the string is written to
* You to decode the hex data by yourself or you can use * a PDF file.
* HexDecode().
* *
* \returns true if this is a hex string. * \returns true if this is a hex string.
* \see GetString() * \see GetString() will return the raw string contents (not hex encod
* \see HexDecode ed)
*/ */
inline bool IsHex () const; inline bool IsHex () const;
/** /**
* PdfStrings are either Latin1 encoded or UTF-16BE * PdfStrings are either Latin1 encoded or UTF-16BE
* encoded unicode strings. * encoded unicode strings.
* This functions returns true if this is a unicode * This functions returns true if this is a unicode
* string object. * string object.
* *
* \returns true if this is a unicode string. * \returns true if this is a unicode string.
*/ */
inline bool IsUnicode () const; inline bool IsUnicode () const;
/** The contents of the strings can be read /** The contents of the strings can be read
* by this function. * by this function.
* *
* If IsHex() returns true the returned data is * The returned data is never hex encoded may contain 0 bytes.
* hex encoded. You can converted it to plain text
* using HexDecode()
* *
* if IsUnicode() returns true, the return value * if IsUnicode() returns true, the return value
* points to a UTF-16BE string buffer with Length() * points to a UTF-16BE string buffer with Length()
* characters. Better use GetUnicode() in this case. * characters. Better use GetUnicode() in this case.
* *
* \returns the strings contents * \returns the strings contents which is guaranteed to be zero termin
ated
* but might also contain 0 bytes in the string.
* \see IsHex * \see IsHex
* \see IsUnicode * \see IsUnicode
* \see Length * \see Length
* \see HexDecode
*/ */
inline const char* GetString() const; inline const char* GetString() const;
/** The contents of the strings can be read /** The contents of the strings can be read
* by this function. * by this function.
* *
* If IsHex() returns true the returned data is * The returned data is never hex encoded any maycontain 0 bytes.
* hex encoded.
* *
* if IsUnicode() returns true, the return value * if IsUnicode() returns true, the return value
* points to a UTF-16BE string buffer with Length() * points to a UTF-16BE string buffer with Length()
* characters. Better use GetUnicode() in this case. * characters. Better use GetUnicode() in this case.
* *
* \returns the strings contents * \returns the strings contents which is guaranteed to be zero termin
ated
* but might also contain 0 bytes in the string.
*
* \see IsHex * \see IsHex
* \see IsUnicode * \see IsUnicode
* \see Length * \see Length
*/ */
inline const pdf_utf16be* GetUnicode() const; inline const pdf_utf16be* GetUnicode() const;
/** The contents of the string as UTF8 string.
*
* The strings contents are always returned as
* UTF8 by this function. Works for unicode strings
* and for non unicode strings.
*
* This is the prefered way to access the strings contents.
*
* \returns the string contents always as UTF8.
*/
inline const std::string & GetStringUtf8() const;
/** The length of the string data returned by GetString() /** The length of the string data returned by GetString()
* in bytes including the terminating zero (or two * in bytes not including terminating zeros.
* terminating zeros for unicode strings)
* *
* \returns the length of the string. * \returns the length of the string.
*
* \see GetCharacterLength to determine the number of characters in th
e string
*/ */
inline long GetLength() const; inline long GetLength() const;
/** The length of the string data returned by GetUnicode() /** The length of the string data returned by GetUnicode()
* in characters including the terminating zero * in characters not including the terminating zero
* *
* \returns the length of the string. * \returns the length of the string.
*
* \see GetCharacterLength to determine the number of characters in th
e string
*/ */
inline long GetUnicodeLength() const; inline long GetUnicodeLength() const;
/** Get the number of characters in the string.
*
* This function returns the correct number of characters in the strin
g
* for unicode and ansi strings. Always use this method if you want to
* know the number of characters in the string
* as GetLength() will returns the number of bytes used for unicode st
rings!
*
*
* \returngs the number of characters in the string
*/
inline long GetCharacterLength() const;
/** Write this PdfString in PDF format to a PdfOutputDevice /** Write this PdfString in PDF format to a PdfOutputDevice
*
* \param pDevice the output device. * \param pDevice the output device.
* \param pEncrypt an encryption object which is used to encrypt this
object
* or NULL to not encrypt this object
*/ */
void Write ( PdfOutputDevice* pDevice ) const; void Write ( PdfOutputDevice* pDevice, const PdfEncrypt* pEncrypt = NUL L ) const;
/** Copy an existing PdfString /** Copy an existing PdfString
* \param rhs another PdfString to copy * \param rhs another PdfString to copy
* \returns this object * \returns this object
*/ */
const PdfString & operator=( const PdfString & rhs ); const PdfString & operator=( const PdfString & rhs );
/** Compare two PdfString objects /** Compare two PdfString objects
* \param rhs another PdfString to compare * \param rhs another PdfString to compare
* \returns this object * \returns this object
*/ */
bool operator>( const PdfString & rhs ) const; bool operator>( const PdfString & rhs ) const;
/** Compare two PdfString objects /** Compare two PdfString objects
* \param rhs another PdfString to compare * \param rhs another PdfString to compare
* \returns this object * \returns this object
*/ */
bool operator<( const PdfString & rhs ) const; bool operator<( const PdfString & rhs ) const;
/** Comparison operator /** Comparison operator
*
* UTF-8 and UTF-16BE encoded strings of the same data compare equal.
Whether
* the string will be written out as hex is not considered - only the
real "text"
* is tested for equality.
*
* \param rhs compare to this string object * \param rhs compare to this string object
* \returns true if both strings have the same contents * \returns true if both strings have the same contents
*/ */
bool operator==( const PdfString & rhs ) const; bool operator==( const PdfString & rhs ) const;
/** Comparison operator
* \param rhs compare to this string object
* \returns true if strings have different contents
*/
bool operator!=(const PdfString& rhs) const { return !operator==(rhs);
}
/** Converts this string to a hex encoded string. /** Converts this string to a hex encoded string.
* *
* If IsHex returns true, a copy of this string is returned * If IsHex returns true, a copy of this string is returned
* otherwise the strings data is hex encoded and returned. * otherwise the strings data is hex encoded and returned.
* *
* \returns a hex encoded version of this string or this string * \returns a hex encoded version of this string or this string
* if it is already hex ecoded. * if it is already hex ecoded.
* *
* \see IsHex * \see IsHex
*/ */
PdfString HexEncode() const; //PdfString HexEncode() const;
/** Converts this string to a ascii string (not hex encoded) /** Converts this string to a ascii string (not hex encoded)
* *
* If IsHex returns false, a copy of this string is returned * If IsHex returns false, a copy of this string is returned
* otherwise the strings data is hex decoded and returned. * otherwise the strings data is hex decoded and returned.
* *
* \returns a plain version of this string which is not hex encoded * \returns a plain version of this string which is not hex encoded
* or this string if it is already a plain not hex encoded st ring. * or this string if it is already a plain not hex encoded st ring.
* *
* \see IsHex * \see IsHex
*/ */
PdfString HexDecode() const; //PdfString HexDecode() const;
/** Converts this string to a unicode string /** Converts this string to a unicode string
* *
* If IsUnicode() returns true a copy of this string is returned * If IsUnicode() returns true a copy of this string is returned
* otherwise the string data is converted to UTF-16be and returned. * otherwise the string data is converted to UTF-16be and returned.
* *
* \returns a unicode version of this string * \returns a unicode version of this string
*/ */
PdfString ToUnicode() const; PdfString ToUnicode() const;
skipping to change at line 323 skipping to change at line 370
* *
*/ */
void InitFromUtf8( const pdf_utf8* pszStringUtf8, long lLen ); void InitFromUtf8( const pdf_utf8* pszStringUtf8, long lLen );
/** Swap the bytes in the buffer (UTF16be -> UTF16le) /** Swap the bytes in the buffer (UTF16be -> UTF16le)
* \param pBuf buffer * \param pBuf buffer
* \param lLen length of buffer * \param lLen length of buffer
*/ */
static void SwapBytes( char* pBuf, long lLen ); static void SwapBytes( char* pBuf, long lLen );
/** Initialise the data member containing a
* UTF8 version of this string.
*
* This is only done once and only if necessary.
*/
void InitUtf8();
private: private:
static const char s_pszUnicodeMarker[]; static const char s_pszUnicodeMarker[]; ///< The unicode marke
r used to indicate unicode strings in PDF
static const char* s_pszUnicodeMarkerHex; ///< The unicode marke
r converted to HEX
static const pdf_utf16be s_cPdfDocEncoding[256]; ///< conversion table from PDFDocEncoding to UTF16 static const pdf_utf16be s_cPdfDocEncoding[256]; ///< conversion table from PDFDocEncoding to UTF16
private: private:
PdfRefCountedBuffer m_buffer; PdfRefCountedBuffer m_buffer; ///< String data (alwa ys binary), may contain 0 bytes
bool m_bHex; bool m_bHex; ///< This string is co
bool m_bUnicode; nverted to hex during write out
bool m_bUnicode; ///< This string conta
ins unicode data
std::string m_sUtf8; ///< The UTF8 version
of the strings contents.
}; };
// -----------------------------------------------------
//
// -----------------------------------------------------
bool PdfString::IsValid() const bool PdfString::IsValid() const
{ {
return (m_buffer.GetBuffer() != NULL); return (m_buffer.GetBuffer() != NULL);
} }
// -----------------------------------------------------
//
// -----------------------------------------------------
bool PdfString::IsHex () const bool PdfString::IsHex () const
{ {
return m_bHex; return m_bHex;
} }
// -----------------------------------------------------
//
// -----------------------------------------------------
bool PdfString::IsUnicode () const bool PdfString::IsUnicode () const
{ {
return m_bUnicode; return m_bUnicode;
} }
// -----------------------------------------------------
//
// -----------------------------------------------------
const char* PdfString::GetString() const const char* PdfString::GetString() const
{ {
return m_buffer.GetBuffer(); return m_buffer.GetBuffer();
} }
// -----------------------------------------------------
//
// -----------------------------------------------------
const pdf_utf16be* PdfString::GetUnicode() const const pdf_utf16be* PdfString::GetUnicode() const
{ {
return reinterpret_cast<pdf_utf16be*>(m_buffer.GetBuffer()); return reinterpret_cast<pdf_utf16be*>(m_buffer.GetBuffer());
} }
// -----------------------------------------------------
//
// -----------------------------------------------------
const std::string & PdfString::GetStringUtf8() const
{
if( this->IsValid() && !m_sUtf8.length() && m_buffer.GetSize() - 2)
const_cast<PdfString*>(this)->InitUtf8();
return m_sUtf8;
}
// -----------------------------------------------------
//
// -----------------------------------------------------
long PdfString::GetLength() const long PdfString::GetLength() const
{ {
return m_buffer.GetSize(); return m_buffer.GetSize() - 2;
}
// -----------------------------------------------------
//
// -----------------------------------------------------
long PdfString::GetCharacterLength() const
{
return this->IsUnicode() ? this->GetUnicodeLength() : this->GetLength()
;
} }
// -----------------------------------------------------
//
// -----------------------------------------------------
long PdfString::GetUnicodeLength() const long PdfString::GetUnicodeLength() const
{ {
return m_buffer.GetSize() / sizeof(pdf_utf16be); return (m_buffer.GetSize() / sizeof(pdf_utf16be)) - 1;
} }
}; };
#endif // _PDF_STRING_H_ #endif // _PDF_STRING_H_
 End of changes. 40 change blocks. 
29 lines changed or deleted 144 lines changed or added


 PdfTokenizer.h   PdfTokenizer.h 
skipping to change at line 32 skipping to change at line 32
#define _PDF_TOKENIZER_H_ #define _PDF_TOKENIZER_H_
#include "PdfDefines.h" #include "PdfDefines.h"
#include "PdfRefCountedBuffer.h" #include "PdfRefCountedBuffer.h"
#include "PdfRefCountedInputDevice.h" #include "PdfRefCountedInputDevice.h"
#include <deque> #include <deque>
namespace PoDoFo { namespace PoDoFo {
class PdfEncrypt;
class PdfVariant; class PdfVariant;
typedef enum EPdfTokenType { enum EPdfTokenType {
ePdfTokenType_Delimiter, ePdfTokenType_Delimiter,
ePdfTokenType_Token, ePdfTokenType_Token,
ePdfTokenType_Unknown = 0xFF ePdfTokenType_Unknown = 0xFF
}; };
typedef std::pair<std::string,EPdfTokenType> TTokenizerPair; typedef std::pair<std::string,EPdfTokenType> TTokenizerPair;
typedef std::deque<TTokenizerPair> TTokenizerQueque; typedef std::deque<TTokenizerPair> TTokenizerQueque;
typedef TTokenizerQueque::iterator TITokenizerQueque; typedef TTokenizerQueque::iterator TITokenizerQueque;
typedef TTokenizerQueque::const_iterator TCITokenizerQueque; typedef TTokenizerQueque::const_iterator TCITokenizerQueque;
skipping to change at line 56 skipping to change at line 57
/** /**
* A simple tokenizer for PDF files and PDF content streams * A simple tokenizer for PDF files and PDF content streams
*/ */
class PODOFO_API PdfTokenizer { class PODOFO_API PdfTokenizer {
public: public:
PdfTokenizer(); PdfTokenizer();
PdfTokenizer( const char* pBuffer, long lLen ); PdfTokenizer( const char* pBuffer, long lLen );
PdfTokenizer( const PdfRefCountedInputDevice & rDevice, const PdfRefCou ntedBuffer & rBuffer ); PdfTokenizer( const PdfRefCountedInputDevice & rDevice, const PdfRefCou ntedBuffer & rBuffer );
~PdfTokenizer(); virtual ~PdfTokenizer();
/** Reads the next token from the current file position /** Reads the next token from the current file position
* ignoring all comments. * ignoring all comments.
* *
* \param peType if not NULL the type of the read token * \param[out] pszBuf On true return, set to a pointer to the read
* will be stored into this parameter * token (a NULL-terminated C string). The pointer
is
* to memory owned by PdfTokenizer and must NOT be
* freed. The contents are invalidated on the next
* call to GetNextToken(..) and by the destruction
of
* the PdfTokenizer. Undefined on false return.
*
* \param[out] peType On true return, if not NULL the type of the read
token
* will be stored into this parameter. Undefined on
false
* return.
* *
* \returns a pointer to the internal buffer * \returns True if a token was read, false if there are no
* where the result is stored * more tokens to read.
* *
* \see GetBuffer * \see GetBuffer
*/ */
const char* GetNextToken( EPdfTokenType* peType = NULL); bool GetNextToken( const char *& pszToken, EPdfTokenType* peType = NULL );
/** Reads the next token from the current file position /** Reads the next token from the current file position
* ignoring all comments and compare the passed token * ignoring all comments and compare the passed token
* to the read token. * to the read token.
* *
* If there is no next token available, throws UnexpectedEOF.
*
* \param pszToken a token that is compared to the * \param pszToken a token that is compared to the
* read token * read token
* *
* \returns true if the read token equals the passed token. * \returns true if the read token equals the passed token.
*/ */
bool IsNextToken( const char* pszToken ); bool IsNextToken( const char* pszToken );
/** Read the next number from the current file position /** Read the next number from the current file position
* ignoring all comments. * ignoring all comments.
* *
* Raises an exception if the next token is no number. * Raises NoNumber exception if the next token is no number, and
* UnexpectedEOF if no token could be read. No token is consumed if
* NoNumber is thrown.
* *
* \returns a number read from the input device. * \returns a number read from the input device.
*/ */
long GetNextNumber(); long GetNextNumber();
/** Read the next variant from the current file position /** Read the next variant from the current file position
* ignoring all comments. * ignoring all comments.
* *
* Raises an exception if there is no variant left in the file. * Raises an UnexpectedEOF exception if there is no variant left in th
e
* file.
* *
* \param rVariant write the read variant to this value * \param rVariant write the read variant to this value
* \param pEncrypt an encryption object which is used to decrypt strin gs during parsing
*/ */
void GetNextVariant( PdfVariant& rVariant ); void GetNextVariant( PdfVariant& rVariant, PdfEncrypt* pEncrypt );
/** Returns true if the given character is a whitespace /** Returns true if the given character is a whitespace
* according to the pdf reference * according to the pdf reference
* *
* \returns true if it is a whitespace character otherwise false * \returns true if it is a whitespace character otherwise false
*/ */
PODOFO_NOTHROW inline static bool IsWhitespace(const unsigned char ch); PODOFO_NOTHROW inline static bool IsWhitespace(const unsigned char ch);
/** Returns true if the given character is a delimiter /** Returns true if the given character is a delimiter
* according to the pdf reference * according to the pdf reference
skipping to change at line 122 skipping to change at line 137
PODOFO_NOTHROW inline static bool IsDelimiter(const unsigned char ch); PODOFO_NOTHROW inline static bool IsDelimiter(const unsigned char ch);
/** /**
* True if the passed character is a regular character according to the PDF * True if the passed character is a regular character according to the PDF
* reference (Section 3.1.1, Character Set); ie it is neither a white-s pace * reference (Section 3.1.1, Character Set); ie it is neither a white-s pace
* nor a delimeter character. * nor a delimeter character.
*/ */
PODOFO_NOTHROW inline static bool IsRegular(const unsigned char ch); PODOFO_NOTHROW inline static bool IsRegular(const unsigned char ch);
/** /**
* True iff the passed character is within the generally accepted "prin table" * True if the passed character is within the generally accepted "print able"
* ASCII range. * ASCII range.
*/ */
PODOFO_NOTHROW inline static bool IsPrintable(const unsigned char ch); PODOFO_NOTHROW inline static bool IsPrintable(const unsigned char ch);
private: protected:
/** Read the next variant from the current file position /** Read the next variant from the current file position
* ignoring all comments. * ignoring all comments.
* *
* Raises an exception if there is no variant left in the file. * Raises an exception if there is no variant left in the file.
* *
* \param pszToken a token that has already been read * \param pszToken a token that has already been read
* \param eType type of the passed token * \param eType type of the passed token
* \param rVariant write the read variant to this value * \param rVariant write the read variant to this value
* \param pEncrypt an encryption object which is used to decrypt strin gs during parsing
*/ */
void GetNextVariant( const char* pszToken, EPdfTokenType eType, PdfVari ant& rVariant ); void GetNextVariant( const char* pszToken, EPdfTokenType eType, PdfVari ant& rVariant, PdfEncrypt* pEncrypt );
/** Determine the possible datatype of a token.
* Numbers, reals, bools or NULL values are parsed directly by this fu
nction
* and saved to a variant.
*
* \returns the expected datatype
*/
EPdfDataType DetermineDataType( const char* pszToken, EPdfTokenType eTy pe, PdfVariant& rVariant ); EPdfDataType DetermineDataType( const char* pszToken, EPdfTokenType eTy pe, PdfVariant& rVariant );
void ReadDataType( EPdfDataType eDataType, PdfVariant& rVariant ); void ReadDataType( EPdfDataType eDataType, PdfVariant& rVariant, PdfEnc rypt* pEncrypt );
/** Read a dictionary from the input device /** Read a dictionary from the input device
* and store it into a variant. * and store it into a variant.
* *
* \param rVariant store the dictionary into this variable * \param rVariant store the dictionary into this variable
* \param pEncrypt an encryption object which is used to decrypt strin gs during parsing
*/ */
void ReadDictionary( PdfVariant& rVariant ); void ReadDictionary( PdfVariant& rVariant, PdfEncrypt* pEncrypt );
/** Read an array from the input device /** Read an array from the input device
* and store it into a variant. * and store it into a variant.
* *
* \param rVariant store the array into this variable * \param rVariant store the array into this variable
* \param pEncrypt an encryption object which is used to decrypt strin gs during parsing
*/ */
void ReadArray( PdfVariant& rVariant ); void ReadArray( PdfVariant& rVariant, PdfEncrypt* pEncrypt );
/** Read a string from the input device /** Read a string from the input device
* and store it into a variant. * and store it into a variant.
* *
* \param rVariant store the string into this variable * \param rVariant store the string into this variable
* \param pEncrypt an encryption object which is used to decrypt strin gs during parsing
*/ */
void ReadString( PdfVariant& rVariant ); void ReadString( PdfVariant& rVariant, PdfEncrypt* pEncrypt );
/** Read a hex string from the input device /** Read a hex string from the input device
* and store it into a variant. * and store it into a variant.
* *
* \param rVariant store the hex string into this variable * \param rVariant store the hex string into this variable
* \param pEncrypt an encryption object which is used to decrypt strin gs during parsing
*/ */
void ReadHexString( PdfVariant& rVariant ); void ReadHexString( PdfVariant& rVariant, PdfEncrypt* pEncrypt );
/** Read a name from the input device /** Read a name from the input device
* and store it into a variant. * and store it into a variant.
* *
* Throws UnexpectedEOF if there is nothing to read.
*
* \param rVariant store the name into this variable * \param rVariant store the name into this variable
*/ */
void ReadName( PdfVariant& rVariant ); void ReadName( PdfVariant& rVariant );
/** Add a token to the queque of tokens. /** Add a token to the queque of tokens.
* GetNextToken() will return all quequed tokens first before * GetNextToken() will return all quequed tokens first before
* reading new tokens from the input device. * reading new tokens from the input device.
* *
* \param pszToken string of the token * \param pszToken string of the token
* \param eType type of the token * \param eType type of the token
skipping to change at line 199 skipping to change at line 227
protected: protected:
PdfRefCountedInputDevice m_device; PdfRefCountedInputDevice m_device;
PdfRefCountedBuffer m_buffer; PdfRefCountedBuffer m_buffer;
private: private:
// 256-byte array mapping character ordinal values to a truth value // 256-byte array mapping character ordinal values to a truth value
// indicating whether or not they are whitespace according to the PDF // indicating whether or not they are whitespace according to the PDF
// standard. // standard.
static const char * const m_delimiterMap; static const char * const m_delimiterMap;
static const char * const m_whitespaceMap; static const char * const m_whitespaceMap;
static const char m_octMap[];
TTokenizerQueque m_deqQueque; TTokenizerQueque m_deqQueque;
// A vector which is used as a buffer to read strings.
// It is a member of the class to avoid reallocations while parsing.
std::vector<char> m_vecBuffer; // we use a vector instead of a string
// because we might read a unicode
// string which is allowed to contain 0
bytes.
}; };
// ----------------------------------------------------- // -----------------------------------------------------
// //
// ----------------------------------------------------- // -----------------------------------------------------
inline bool PdfTokenizer::IsWhitespace(const unsigned char ch) inline bool PdfTokenizer::IsWhitespace(const unsigned char ch)
{ {
return ( PdfTokenizer::m_whitespaceMap[ch] != 0 ); return ( PdfTokenizer::m_whitespaceMap[ch] != 0 );
} }
 End of changes. 28 change blocks. 
18 lines changed or deleted 61 lines changed or added


 PdfVariant.h   PdfVariant.h 
skipping to change at line 29 skipping to change at line 29
************************************************************************** */ ************************************************************************** */
#ifndef _PDF_VARIANT_H_ #ifndef _PDF_VARIANT_H_
#define _PDF_VARIANT_H_ #define _PDF_VARIANT_H_
#include <cmath> #include <cmath>
#include "PdfDefines.h" #include "PdfDefines.h"
#include "PdfRefCountedBuffer.h" #include "PdfRefCountedBuffer.h"
#include "PdfString.h"
namespace PoDoFo { namespace PoDoFo {
class PdfArray; class PdfArray;
class PdfData; class PdfData;
class PdfDataType; class PdfDataType;
class PdfDictionary; class PdfDictionary;
class PdfEncrypt;
class PdfName; class PdfName;
class PdfOutputDevice; class PdfOutputDevice;
class PdfString; class PdfString;
class PdfReference; class PdfReference;
/** /**
* A variant data type which supports all data types supported by the PDF s tandard. * A variant data type which supports all data types supported by the PDF s tandard.
* The data can be parsed directly from a string or set by one of the membe rs. * The data can be parsed directly from a string or set by one of the membe rs.
* One can also convert the variant back to a string after setting the valu es. * One can also convert the variant back to a string after setting the valu es.
* *
skipping to change at line 137 skipping to change at line 140
/** Clear all internal member variables and free the memory /** Clear all internal member variables and free the memory
* they have allocated. * they have allocated.
* Sets the datatype to ePdfDataType_Null * Sets the datatype to ePdfDataType_Null
*/ */
void Clear(); void Clear();
/** \returns the datatype of this object or ePdfDataType_Unknown /** \returns the datatype of this object or ePdfDataType_Unknown
* if it does not have a value. * if it does not have a value.
*/ */
inline const EPdfDataType GetDataType() const; inline EPdfDataType GetDataType() const;
/** \returns a human readable string representation of GetDataType() /** \returns a human readable string representation of GetDataType()
* The returned string must not be free'd. * The returned string must not be free'd.
*/ */
const char * GetDataTypeString() const; const char * GetDataTypeString() const;
/** \returns true if this variant is a bool (i.e. GetDataType() == ePdf DataType_Bool) /** \returns true if this variant is a bool (i.e. GetDataType() == ePdf DataType_Bool)
*/ */
inline bool IsBool() const { return GetDataType() == ePdfDataType_Bool; } inline bool IsBool() const { return GetDataType() == ePdfDataType_Bool; }
skipping to change at line 192 skipping to change at line 195
inline bool IsNull() const { return GetDataType() == ePdfDataType_Null; } inline bool IsNull() const { return GetDataType() == ePdfDataType_Null; }
/** \returns true if this variant is a reference (i.e. GetDataType() == ePdfDataType_Reference) /** \returns true if this variant is a reference (i.e. GetDataType() == ePdfDataType_Reference)
*/ */
inline bool IsReference() const { return GetDataType() == ePdfDataType_ Reference; } inline bool IsReference() const { return GetDataType() == ePdfDataType_ Reference; }
/** Write the complete variant to an output device. /** Write the complete variant to an output device.
* This is an overloaded member function. * This is an overloaded member function.
* *
* \param pDevice write the object to this device * \param pDevice write the object to this device
* \param pEncrypt an encryption object which is used to encrypt this
object
* or NULL to not encrypt this object
*/ */
void Write( PdfOutputDevice* pDevice ) const; void Write( PdfOutputDevice* pDevice, const PdfEncrypt* pEncrypt = NULL ) const;
/** Write the complete variant to an output device. /** Write the complete variant to an output device.
* \param pDevice write the object to this device * \param pDevice write the object to this device
* \param pEncrypt an encryption object which is used to encrypt this
object
* or NULL to not encrypt this object
* \param keyStop if not KeyNull and a key == keyStop is found * \param keyStop if not KeyNull and a key == keyStop is found
* writing will stop right before this key! * writing will stop right before this key!
* if IsDictionary returns true. * if IsDictionary returns true.
*/ */
virtual void Write( PdfOutputDevice* pDevice, const PdfName & keyStop ) const; virtual void Write( PdfOutputDevice* pDevice, const PdfEncrypt* pEncryp t, const PdfName & keyStop ) const;
/** Converts the current object into a string representation /** Converts the current object into a string representation
* which can be written directly to a PDF file on disc. * which can be written directly to a PDF file on disc.
* \param rsData the object string is returned in this object. * \param rsData the object string is returned in this object.
*/ */
void ToString( std::string & rsData ) const; void ToString( std::string & rsData ) const;
/** Set the value of this object as bool /** Set the value of this object as bool
* \param b the value as bool. * \param b the value as bool.
*/ */
skipping to change at line 282 skipping to change at line 289
/** Get the reference values of this object. /** Get the reference values of this object.
* \returns a PdfReference * \returns a PdfReference
*/ */
inline PdfReference & GetReference(); inline PdfReference & GetReference();
/** Assign the values of another PdfVariant to this one. /** Assign the values of another PdfVariant to this one.
* \param rhs an existing variant which is copied. * \param rhs an existing variant which is copied.
*/ */
const PdfVariant & operator=( const PdfVariant & rhs ); const PdfVariant & operator=( const PdfVariant & rhs );
/**
* Test to see if the value contained by this variant is the same
* as the value of the other variant.
*/
bool operator==( const PdfVariant & rhs ) const;
/**
* \see operator==
*/
inline bool operator!=( const PdfVariant & rhs) const;
protected: protected:
/** /**
* Dynamically load the contents of this object from a PDF file by call ing * Dynamically load the contents of this object from a PDF file by call ing
* the virtual method DelayedLoadImpl() if the object is not already lo aded. * the virtual method DelayedLoadImpl() if the object is not already lo aded.
* *
* For objects complete created in memory and those that do not support * For objects complete created in memory and those that do not support
* deferred loading this function does nothing, since deferred loading * deferred loading this function does nothing, since deferred loading
* will not be enabled. * will not be enabled.
*/ */
skipping to change at line 457 skipping to change at line 475
bool PdfVariant::IsEmpty() const bool PdfVariant::IsEmpty() const
{ {
DelayedLoad(); DelayedLoad();
return (m_eDataType == ePdfDataType_Null); return (m_eDataType == ePdfDataType_Null);
} }
// ----------------------------------------------------- // -----------------------------------------------------
// //
// ----------------------------------------------------- // -----------------------------------------------------
const EPdfDataType PdfVariant::GetDataType() const EPdfDataType PdfVariant::GetDataType() const
{ {
DelayedLoad(); DelayedLoad();
return m_eDataType; return m_eDataType;
} }
// ----------------------------------------------------- // -----------------------------------------------------
// //
// ----------------------------------------------------- // -----------------------------------------------------
void PdfVariant::SetBool( bool b ) void PdfVariant::SetBool( bool b )
skipping to change at line 573 skipping to change at line 591
return static_cast<double>(m_Data.nNumber); return static_cast<double>(m_Data.nNumber);
} }
// ----------------------------------------------------- // -----------------------------------------------------
// //
// ----------------------------------------------------- // -----------------------------------------------------
const PdfString & PdfVariant::GetString() const const PdfString & PdfVariant::GetString() const
{ {
DelayedLoad(); DelayedLoad();
if( !IsString() ) if( !IsString() && !IsHexString() )
{ {
PODOFO_RAISE_ERROR( ePdfError_InvalidDataType ); PODOFO_RAISE_ERROR( ePdfError_InvalidDataType );
} }
return *(reinterpret_cast<PdfString* const>(m_Data.pData)); return *(reinterpret_cast<PdfString* const>(m_Data.pData));
} }
// ----------------------------------------------------- // -----------------------------------------------------
// //
// ----------------------------------------------------- // -----------------------------------------------------
skipping to change at line 740 skipping to change at line 758
// ----------------------------------------------------- // -----------------------------------------------------
// //
// ----------------------------------------------------- // -----------------------------------------------------
void PdfVariant::DelayedLoadImpl() void PdfVariant::DelayedLoadImpl()
{ {
// Default implementation of virtual void DelayedLoadImpl() throws, sin ce delayed // Default implementation of virtual void DelayedLoadImpl() throws, sin ce delayed
// loading should not be enabled except by types that support it. // loading should not be enabled except by types that support it.
PODOFO_RAISE_ERROR( ePdfError_InternalLogic ); PODOFO_RAISE_ERROR( ePdfError_InternalLogic );
} }
// -----------------------------------------------------
//
// -----------------------------------------------------
bool PdfVariant::operator!=( const PdfVariant & rhs) const
{
return !(*this == rhs);
}
}; };
#endif // _PDF_VARIANT_H_ #endif // _PDF_VARIANT_H_
 End of changes. 11 change blocks. 
5 lines changed or deleted 33 lines changed or added


 PdfVecObjects.h   PdfVecObjects.h 
skipping to change at line 86 skipping to change at line 86
public: public:
// An incomplete set of container typedefs, just enough to handle // An incomplete set of container typedefs, just enough to handle
// the begin() and end() methods we wrap from the internal vector. // the begin() and end() methods we wrap from the internal vector.
// TODO: proper wrapper iterator class. // TODO: proper wrapper iterator class.
typedef TVecObjects::iterator iterator; typedef TVecObjects::iterator iterator;
typedef TVecObjects::const_iterator const_iterator; typedef TVecObjects::const_iterator const_iterator;
/** Every observer of PdfVecObjects has to implement this interface. /** Every observer of PdfVecObjects has to implement this interface.
*/ */
class Observer { class PODOFO_API Observer {
friend class PdfVecObjects; friend class PdfVecObjects;
public: public:
virtual ~Observer() virtual ~Observer()
{ {
} }
virtual void WriteObject( const PdfObject* pObject ) = 0; virtual void WriteObject( const PdfObject* pObject ) = 0;
/** /**
skipping to change at line 119 skipping to change at line 119
/** Called whenever appending to a stream has ended. /** Called whenever appending to a stream has ended.
* \param pStream the stream object the user currently writes to. * \param pStream the stream object the user currently writes to.
*/ */
virtual void EndAppendStream( const PdfStream* pStream ) = 0; virtual void EndAppendStream( const PdfStream* pStream ) = 0;
virtual void Finish() = 0; virtual void Finish() = 0;
}; };
/** This class is used to implement stream factories in PoDoFo. /** This class is used to implement stream factories in PoDoFo.
*/ */
class StreamFactory { class PODOFO_API StreamFactory {
public: public:
virtual ~StreamFactory() virtual ~StreamFactory()
{ {
} }
/** Creates a stream object /** Creates a stream object
* *
* \param pParent parent object * \param pParent parent object
* *
* \returns a new stream object * \returns a new stream object
*/ */
virtual PdfStream* CreateStream( PdfObject* pParent ) = 0; virtual PdfStream* CreateStream( PdfObject* pParent ) = 0;
}; };
private: private:
typedef std::vector<Observer*> TVecObservers; typedef std::vector<Observer*> TVecObservers;
typedef TVecObservers::iterator TIVecObservers; typedef TVecObservers::iterator TIVecObservers;
typedef TVecObservers::const_iterator TCIVecObservers; typedef TVecObservers::const_iterator TCIVecObservers;
enum EObjectState {
eObjectState_Object,
eObjectState_Free,
eObjectState_Written,
eObjectState_Invalid = 0xff
};
public: public:
/** Default constuctor /** Default constuctor
*/ */
PdfVecObjects(); PdfVecObjects();
virtual ~PdfVecObjects(); virtual ~PdfVecObjects();
/** \returns a pointer to a PdfDocument that is the /** \returns a pointer to a PdfDocument that is the
* parent of this vector. * parent of this vector.
* Might be NULL if the vector has no parent. * Might be NULL if the vector has no parent.
 End of changes. 3 change blocks. 
10 lines changed or deleted 2 lines changed or added


 PdfWriter.h   PdfWriter.h 
skipping to change at line 28 skipping to change at line 28
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
************************************************************************** */ ************************************************************************** */
#ifndef _PDF_WRITER_H_ #ifndef _PDF_WRITER_H_
#define _PDF_WRITER_H_ #define _PDF_WRITER_H_
#include "PdfDefines.h" #include "PdfDefines.h"
#include "PdfOutputDevice.h" #include "PdfOutputDevice.h"
#include "PdfVecObjects.h" #include "PdfVecObjects.h"
#include "PdfEncrypt.h"
namespace PoDoFo { namespace PoDoFo {
class PdfDictionary; class PdfDictionary;
class PdfDocument; class PdfDocument;
class PdfHintStream;
class PdfName; class PdfName;
class PdfObject; class PdfObject;
class PdfPage; class PdfPage;
class PdfPagesTree; class PdfPagesTree;
class PdfParser; class PdfParser;
class PdfVecObjects; class PdfVecObjects;
class PdfXRef; class PdfXRef;
namespace NonPublic { class PdfHintStream; }
/** The PdfWriter class writes a list of PdfObjects as PDF file. /** The PdfWriter class writes a list of PdfObjects as PDF file.
* The XRef section (which is the required table of contents for any * The XRef section (which is the required table of contents for any
* PDF file) is created automatically. * PDF file) is created automatically.
* *
* It does not know about pages but only about PdfObjects. * It does not know about pages but only about PdfObjects.
* *
* Most users will want to use PdfDocument. * Most users will want to use PdfDocument.
*/ */
class PODOFO_API PdfWriter { class PODOFO_API PdfWriter {
public: public:
skipping to change at line 121 skipping to change at line 124
/** /**
* \returns wether a XRef stream is used or not * \returns wether a XRef stream is used or not
*/ */
inline bool GetUseXRefStream() const; inline bool GetUseXRefStream() const;
/** Get the file format version of the pdf /** Get the file format version of the pdf
* \returns the file format version as string * \returns the file format version as string
*/ */
const char* GetPdfVersionString() const { return s_szPdfVersionNums[sta tic_cast<int>(m_eVersion)]; } const char* GetPdfVersionString() const { return s_szPdfVersionNums[sta tic_cast<int>(m_eVersion)]; }
/** Set wether all streams in the pdf document should /** Set the written document to be encrypted using a PdfEncrypt object
* be compress using the FlateDecode algorithm. *
* Only streams that are already JPEG compressed are not affected * \param rEncrypt an encryption object which is used to encrypt the w
* by this flag. ritten PDF file
* By default all streams are compressed using FlateDecode.
* You can set this value to false if you want to disable
* compression, for example for debugging purposes.
*
* \param bCompress enable/disable compression
*/
void SetPdfCompression( bool bCompress ) { m_bCompress = bCompress; }
/** Get wether PDF compression is enabled.
* \see SetPdfCompression
* \returns true if all streams will be compressed using
* the FlateDecode algorithm.
*/ */
bool GetPdfCompression() const { return m_bCompress; } void SetEncrypted( const PdfEncrypt & rEncrypt ) { if( m_pEncrypt ) del
ete m_pEncrypt; m_pEncrypt = PdfEncrypt::CreatePdfEncrypt( rEncrypt ); };
/**
* \returns true if this PdfWriter creates an encrypted PDF file
*/
bool GetEncrypted() const { return (m_pEncrypt != NULL); }
/** Calculate the byte offset of the object pObject in the PDF file /** Calculate the byte offset of the object pObject in the PDF file
* if the file was written to disk at the moment of calling this funct ion. * if the file was written to disk at the moment of calling this funct ion.
* *
* This function is very calculation intensive! * This function is very calculation intensive!
* *
* \param pObject object to calculate the byte offset (has to be a * \param pObject object to calculate the byte offset (has to be a
* child of this PdfWriter) * child of this PdfWriter)
* \param pulOffset pointer to an unsigned long to save the offset * \param pulOffset pointer to an unsigned long to save the offset
*/ */
void GetByteOffset( PdfObject* pObject, unsigned long* pulOffset ); void GetByteOffset( PdfObject* pObject, unsigned long* pulOffset );
/** Make sure the all objects are flate decoded if the user enabled fla
te decoding
* This might be necessary to call before calculating the length of ob
jects.
* It is called automatically before writing.
*
* \param vecObjects compress all objects in this vector
*/
void CompressObjects( const PdfVecObjects& vecObjects );
/** Write the whole document to a buffer in memory. /** Write the whole document to a buffer in memory.
* *
* Better use a PdfOutputDevice that writes to a PdfRefCountedBuffer.
*
* \param ppBuffer will be malloc'ed and the document * \param ppBuffer will be malloc'ed and the document
* will be written to this buffer. * will be written to this buffer.
* \param pulLen the length of the buffer will be returned in this par ameter * \param pulLen the length of the buffer will be returned in this par ameter
* \returns ErrOk on success * \returns ErrOk on success
* *
* \see Write * \see Write
*/ */
void WriteToBuffer( char** ppBuffer, unsigned long* pulLen ); void WriteToBuffer( char** ppBuffer, unsigned long* pulLen );
/** Add required keys to a trailer object /** Add required keys to a trailer object
skipping to change at line 196 skipping to change at line 185
*/ */
void PODOFO_LOCAL WritePdfHeader( PdfOutputDevice* pDevice ); void PODOFO_LOCAL WritePdfHeader( PdfOutputDevice* pDevice );
/** Write pdf objects to file /** Write pdf objects to file
* \param pDevice write to this output device * \param pDevice write to this output device
* \param vecObjects write all objects in this vector to the file * \param vecObjects write all objects in this vector to the file
* \param pXref add all written objects to this XRefTable * \param pXref add all written objects to this XRefTable
*/ */
void WritePdfObjects( PdfOutputDevice* pDevice, const PdfVecObjects& ve cObjects, PdfXRef* pXref ) PODOFO_LOCAL; void WritePdfObjects( PdfOutputDevice* pDevice, const PdfVecObjects& ve cObjects, PdfXRef* pXref ) PODOFO_LOCAL;
/** Creates a file identifier which is required in several
* PDF workflows.
* All values from the files document information dictionary are
* used to create a unique MD5 key which is added to the trailer dicti
onary.
*
* \param identifier write the identifier to this string
* \param pTrailer trailer object
*/
void CreateFileIdentifier( PdfString & identifier, const PdfObject* pTr
ailer ) const PODOFO_LOCAL;
private: private:
/** Writes a linearized PDF file /** Writes a linearized PDF file
* \param pDevice write to this output device * \param pDevice write to this output device
*/ */
void PODOFO_LOCAL WriteLinearized( PdfOutputDevice* pDevice ); void PODOFO_LOCAL WriteLinearized( PdfOutputDevice* pDevice );
/** Create a linearization dictionary for the current /** Create a linearization dictionary for the current
* document and return a pointer to it after inserting * document and return a pointer to it after inserting
* it into the vector of PdfObjects * it into the vector of PdfObjects
* *
skipping to change at line 219 skipping to change at line 218
/** Reorder and renumber all object as required for linearized PDF file s. /** Reorder and renumber all object as required for linearized PDF file s.
* This function is very slow. * This function is very slow.
* *
* \param pLinearize linearization dictionary * \param pLinearize linearization dictionary
* \param pHint primary hint stream dictionary * \param pHint primary hint stream dictionary
* \param pPage first page to display in the document * \param pPage first page to display in the document
* \param ppLast the pointer will be initialized to the last object * \param ppLast the pointer will be initialized to the last object
* belonging to the first page * belonging to the first page
*/ */
void ReorderObjectsLinearized( PdfObject* pLinearize, PdfHintStream* pH int, PdfPage* pPage, PdfObject** ppLast ) PODOFO_LOCAL; void ReorderObjectsLinearized( PdfObject* pLinearize, NonPublic::PdfHin tStream* pHint, PdfPage* pPage, PdfObject** ppLast ) PODOFO_LOCAL;
/** Initialize m_pPagesTree with its correct value /** Initialize m_pPagesTree with its correct value
* Always call this function befre accessing the pages tree. * Always call this function befre accessing the pages tree.
*/ */
void FetchPagesTree(); void FetchPagesTree();
/** Find dependencies required for creating a linearized PDF of the cat alog dictionary. /** Find dependencies required for creating a linearized PDF of the cat alog dictionary.
*/ */
void FindCatalogDependencies( PdfObject* pCatalog, const PdfName & rNam e, TPdfReferenceList* pList, bool bWithDependencies ) PODOFO_LOCAL; void FindCatalogDependencies( PdfObject* pCatalog, const PdfName & rNam e, TPdfReferenceList* pList, bool bWithDependencies ) PODOFO_LOCAL;
/** Fill all keys in the linearization dictionary with their values /** Fill all keys in the linearization dictionary with their values
* \param pLinearize a linearization dictionary * \param pLinearize a linearization dictionary
* \param pHint the hint stream * \param pHint the hint stream
* \param pPage the first page in the linerarized PDF file * \param pPage the first page in the linerarized PDF file
* \param pLast pointer of the last object belonging to the first page * \param pLast pointer of the last object belonging to the first page
* \param pVecXRefOffset xref table entries for previous entry * \param pVecXRefOffset xref table entries for previous entry
*/ */
// void FillLinearizationDictionary( PdfObject* pLinearize, PdfOutputDe // void FillLinearizationDictionary( PdfObject* pLinearize, PdfOutputDe
vice* pDevice, PdfPage* pPage, PdfObject* pLast, PdfHintStream* pHint, TVec vice* pDevice, PdfPage* pPage, PdfObject* pLast, NonPublic::PdfHintStream*
XRefOffset* pVecXRefOffset ) PODOFO_LOCAL; pHint, TVecXRefOffset* pVecXRefOffset ) PODOFO_LOCAL;
/** Creates a file identifier which is required in several
* PDF workflows.
* All values from the files document information dictionary are
* used to create a unique MD5 key which is added to the trailer dicti
onary.
*
* \param pTrailer add the file identifier to this trailer dictionary
*/
void CreateFileIdentifier( PdfObject* pTrailer ) const PODOFO_LOCAL;
protected: protected:
PdfVecObjects* m_vecObjects; PdfVecObjects* m_vecObjects;
PdfObject* m_pTrailer; PdfObject* m_pTrailer;
bool m_bCompress;
bool m_bXRefStream; bool m_bXRefStream;
PdfEncrypt* m_pEncrypt; ///< If not NULL encrypt all strings and
streams and create an encryption dictionary in the trailer
PdfObject* m_pEncryptObj; ///< Used to temporarly store the encryp
tion dictionary
PdfString m_identifier;
private: private:
EPdfVersion m_eVersion; EPdfVersion m_eVersion;
PdfPagesTree* m_pPagesTree; PdfPagesTree* m_pPagesTree;
bool m_bLinearized; bool m_bLinearized;
/** /**
* This value is required when writing * This value is required when writing
* a linearized PDF file. * a linearized PDF file.
* It represents the offset of the whitespace * It represents the offset of the whitespace
 End of changes. 12 change blocks. 
42 lines changed or deleted 40 lines changed or added


 PdfXObject.h   PdfXObject.h 
skipping to change at line 35 skipping to change at line 35
#include "PdfArray.h" #include "PdfArray.h"
#include "PdfCanvas.h" #include "PdfCanvas.h"
#include "PdfElement.h" #include "PdfElement.h"
#include "PdfRect.h" #include "PdfRect.h"
namespace PoDoFo { namespace PoDoFo {
class PdfDictionary; class PdfDictionary;
class PdfImageRef; class PdfImageRef;
class PdfObject; class PdfObject;
class PdfMemDocument;
/** A XObject is a content stream with several drawing commands and data /** A XObject is a content stream with several drawing commands and data
* which can be used throughout a PDF document. * which can be used throughout a PDF document.
* *
* You can draw on a XObject like you would draw onto a page and can draw * You can draw on a XObject like you would draw onto a page and can draw
* this XObject later again using a PdfPainter. * this XObject later again using a PdfPainter.
* *
* \see PdfPainter * \see PdfPainter
*/ */
class PODOFO_API PdfXObject : public PdfElement, public PdfCanvas { class PODOFO_API PdfXObject : public PdfElement, public PdfCanvas {
public: public:
/** Create a new XObject with a specified dimension /** Create a new XObject with a specified dimension
* in a given document
*
* \param rRect the size of the XObject
* \param pParent the parent document of the XObject
*/
PdfXObject( const PdfRect & rRect, PdfDocument* pParent );
/** Create a new XObject with a specified dimension
* in a given vector of PdfObjects * in a given vector of PdfObjects
* *
* \param rRect the size of the XObject * \param rRect the size of the XObject
* \param pParent the parent vector of the XObject * \param pParent the parent vector of the XObject
*/ */
PdfXObject( const PdfRect & rRect, PdfVecObjects* pParent ); PdfXObject( const PdfRect & rRect, PdfVecObjects* pParent );
/** Create a new XObject from a page of another document
* in a given document
*
* \param rDoc the document to create the XObject from
* \param nPage the page-number in rDoc to create the XObject from
* \param pParent the parent document of the XObject
*/
PdfXObject( const PdfMemDocument & rSourceDoc, int nPage, PdfDocument*
pParent );
/** Create a XObject from an existing PdfObject /** Create a XObject from an existing PdfObject
* *
* \param pObject an existing object which has to be * \param pObject an existing object which has to be
* a XObject * a XObject
*/ */
PdfXObject( PdfObject* pObject ); PdfXObject( PdfObject* pObject );
virtual ~PdfXObject() { } virtual ~PdfXObject() { }
/** Get access to the contents object of this page. /** Get access to the contents object of this page.
skipping to change at line 110 skipping to change at line 128
* without having to access the PdfObject. * without having to access the PdfObject.
* *
* This allows to work with XObjects which have been * This allows to work with XObjects which have been
* written to disk already. * written to disk already.
* *
* \returns the reference of the PdfObject for this XObject * \returns the reference of the PdfObject for this XObject
*/ */
inline const PdfReference & GetObjectReference() const; inline const PdfReference & GetObjectReference() const;
protected: protected:
void InitXObject( const PdfRect & rRect );
PdfXObject( const char* pszSubType, PdfDocument* pParent );
PdfXObject( const char* pszSubType, PdfVecObjects* pParent ); PdfXObject( const char* pszSubType, PdfVecObjects* pParent );
PdfXObject( const char* pszSubType, PdfObject* pObject ); PdfXObject( const char* pszSubType, PdfObject* pObject );
protected: protected:
PdfRect m_rRect; PdfRect m_rRect;
private: private:
static PdfArray s_matrix; static PdfArray s_matrix;
PdfObject* m_pResources; PdfObject* m_pResources;
 End of changes. 4 change blocks. 
0 lines changed or deleted 22 lines changed or added


 PdfXRef.h   PdfXRef.h 
skipping to change at line 41 skipping to change at line 41
class PdfOutputDevice; class PdfOutputDevice;
/** /**
* Creates an XRef table. * Creates an XRef table.
* *
* This is an internal class of PoDoFo used by PdfWriter. * This is an internal class of PoDoFo used by PdfWriter.
*/ */
class PdfXRef { class PdfXRef {
protected: protected:
typedef struct TXRefItem { struct TXRefItem{
TXRefItem( const PdfReference & rRef, const long & rlOff ) TXRefItem( const PdfReference & rRef, const long & rlOff )
: reference( rRef ), lOffset( rlOff ) : reference( rRef ), lOffset( rlOff )
{ {
} }
PdfReference reference; PdfReference reference;
long lOffset; long lOffset;
bool operator<( const TXRefItem & rhs ) const bool operator<( const TXRefItem & rhs ) const
{ {
skipping to change at line 71 skipping to change at line 71
typedef TVecReferences::iterator TIVecReferences; typedef TVecReferences::iterator TIVecReferences;
typedef TVecReferences::const_iterator TCIVecReferences; typedef TVecReferences::const_iterator TCIVecReferences;
class PdfXRefBlock { class PdfXRefBlock {
public: public:
PdfXRefBlock() PdfXRefBlock()
: m_nFirst( 0 ), m_nCount( 0 ) : m_nFirst( 0 ), m_nCount( 0 )
{ {
} }
PdfXRefBlock( const PdfXRefBlock & rhs )
: m_nFirst( 0 ), m_nCount( 0 )
{
this->operator=( rhs );
}
bool InsertItem( const TXRefItem & rItem, bool bUsed ); bool InsertItem( const TXRefItem & rItem, bool bUsed );
bool operator<( const PdfXRefBlock & rhs ) const bool operator<( const PdfXRefBlock & rhs ) const
{ {
return m_nFirst < rhs.m_nFirst; return m_nFirst < rhs.m_nFirst;
} }
const PdfXRefBlock & operator=( const PdfXRefBlock & rhs )
{
m_nFirst = rhs.m_nFirst;
m_nCount = rhs.m_nCount;
items = rhs.items;
freeItems = rhs.freeItems;
return *this;
}
unsigned long m_nFirst; unsigned long m_nFirst;
unsigned long m_nCount; unsigned long m_nCount;
TVecXRefItems items; TVecXRefItems items;
TVecReferences freeItems; TVecReferences freeItems;
}; };
typedef std::vector<PdfXRefBlock> TVecXRefBlock; typedef std::vector<PdfXRefBlock> TVecXRefBlock;
typedef TVecXRefBlock::iterator TIVecXRefBlock; typedef TVecXRefBlock::iterator TIVecXRefBlock;
typedef TVecXRefBlock::const_iterator TCIVecXRefBlock; typedef TVecXRefBlock::const_iterator TCIVecXRefBlock;
 End of changes. 3 change blocks. 
1 lines changed or deleted 18 lines changed or added


 podofo.h   podofo.h 
skipping to change at line 24 skipping to change at line 24
* * * *
* You should have received a copy of the GNU Library General Public * * You should have received a copy of the GNU Library General Public *
* License along with this program; if not, write to the * * License along with this program; if not, write to the *
* Free Software Foundation, Inc., * * Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
************************************************************************** */ ************************************************************************** */
#ifndef _PODOFO_H_ #ifndef _PODOFO_H_
#define _PODOFO_H_ #define _PODOFO_H_
/** This file can be used in client applications to include /**
* all files required by PoDoFo at once. * This file can be used in client applications to include
* all files required by PoDoFo at once.
* *
* Some symbols may be declared in the PoDoFo::NonPublic namespace.
* Client applications must never rely on or use these symbols directly.
* On supporting platforms they will be excluded from the DLL interface,
* and they are not guaranteed to continue to exist.
*/ */
#include "PdfVersion.h"
#include "PdfDefines.h" #include "PdfDefines.h"
/**
* Version number of this release
*/
#define PODOFO_MAJOR 0
#define PODOFO_MINOR 5
#define PODOFO_REVISION 0
#include "PdfAction.h" #include "PdfAction.h"
#include "PdfAcroForm.h" #include "PdfAcroForm.h"
#include "PdfAnnotation.h" #include "PdfAnnotation.h"
#include "PdfArray.h" #include "PdfArray.h"
#include "PdfCanvas.h" #include "PdfCanvas.h"
#include "PdfColor.h"
#include "PdfContentsTokenizer.h"
#include "PdfData.h" #include "PdfData.h"
#include "PdfDataType.h" #include "PdfDataType.h"
#include "PdfDate.h" #include "PdfDate.h"
#include "PdfDestination.h" #include "PdfDestination.h"
#include "PdfDocument.h" #include "PdfDocument.h"
#include "PdfElement.h" #include "PdfElement.h"
#include "PdfEncoding.h"
#include "PdfEncrypt.h"
#include "PdfError.h" #include "PdfError.h"
#include "PdfExtGState.h" #include "PdfExtGState.h"
#include "PdfField.h" #include "PdfField.h"
#include "PdfFileSpec.h" #include "PdfFileSpec.h"
#include "PdfFilter.h" #include "PdfFilter.h"
#include "PdfFont.h" #include "PdfFont.h"
#include "PdfFontCache.h" #include "PdfFontCache.h"
#include "PdfFontFactory.h"
#include "PdfFontMetrics.h" #include "PdfFontMetrics.h"
#include "PdfFunction.h"
// Not considereed to be part of the public API
#include "PdfHintStream.h"
// --
#include "PdfImage.h" #include "PdfImage.h"
#include "PdfInfo.h" #include "PdfInfo.h"
#include "PdfInputDevice.h" #include "PdfInputDevice.h"
#include "PdfMemDocument.h"
#include "PdfMemStream.h" #include "PdfMemStream.h"
#include "PdfName.h" #include "PdfName.h"
#include "PdfNamesTree.h" #include "PdfNamesTree.h"
#include "PdfObject.h" #include "PdfObject.h"
#include "PdfOutlines.h" #include "PdfOutlines.h"
#include "PdfOutputDevice.h" #include "PdfOutputDevice.h"
#include "PdfPage.h" #include "PdfPage.h"
#include "PdfPagesTree.h" #include "PdfPagesTree.h"
#include "PdfPainter.h" #include "PdfPainter.h"
#include "PdfPainterMM.h" #include "PdfPainterMM.h"
#include "PdfParser.h" #include "PdfParser.h"
#include "PdfParserObject.h" #include "PdfParserObject.h"
#include "PdfRect.h" #include "PdfRect.h"
#include "PdfRefCountedBuffer.h" #include "PdfRefCountedBuffer.h"
#include "PdfRefCountedInputDevice.h" #include "PdfRefCountedInputDevice.h"
#include "PdfShadingPattern.h"
#include "PdfStream.h" #include "PdfStream.h"
#include "PdfStreamedDocument.h" #include "PdfStreamedDocument.h"
#include "PdfString.h" #include "PdfString.h"
#include "PdfTable.h"
#include "PdfTokenizer.h" #include "PdfTokenizer.h"
#include "PdfVariant.h" #include "PdfVariant.h"
#include "PdfVecObjects.h" #include "PdfVecObjects.h"
#include "PdfWriter.h" #include "PdfWriter.h"
#include "PdfXObject.h" #include "PdfXObject.h"
#include "PdfXRef.h" #include "PdfXRef.h"
#include "PdfXRefStream.h" #include "PdfXRefStream.h"
#if 0 #if 0
#ifndef _PODOFO_NO_NAMESPACE_ #ifndef _PODOFO_NO_NAMESPACE_
 End of changes. 11 change blocks. 
15 lines changed or deleted 17 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/