| PdfDocument.h | | PdfDocument.h | |
| | | | |
| skipping to change at line 40 | | skipping to change at line 40 | |
| #include "PdfAcroForm.h" | | #include "PdfAcroForm.h" | |
| #include "PdfFontCache.h" | | #include "PdfFontCache.h" | |
| #include "PdfInfo.h" | | #include "PdfInfo.h" | |
| | | | |
| namespace PoDoFo { | | namespace PoDoFo { | |
| | | | |
| class PdfDestination; | | class PdfDestination; | |
| class PdfDictionary; | | class PdfDictionary; | |
| class PdfFileSpec; | | class PdfFileSpec; | |
| class PdfFont; | | class PdfFont; | |
|
| | | class PdfFontConfigWrapper; | |
| class PdfInfo; | | class PdfInfo; | |
| class PdfMemDocument; | | class PdfMemDocument; | |
| class PdfNamesTree; | | class PdfNamesTree; | |
| class PdfOutlines; | | class PdfOutlines; | |
| class PdfPage; | | class PdfPage; | |
| class PdfPagesTree; | | class PdfPagesTree; | |
| class PdfRect; | | class PdfRect; | |
| class PdfXObject; | | class PdfXObject; | |
| | | | |
| /** PdfDocument is the core interface for working with PDF documents. | | /** PdfDocument is the core interface for working with PDF documents. | |
| | | | |
| skipping to change at line 294 | | skipping to change at line 295 | |
| /** 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 ); | |
| | | | |
|
| | | /** Creates several new page objects and inserts them into the internal | |
| | | * page tree. | |
| | | * The created pages are owned by the PdfDocument | |
| | | * and will get deleted along with it! | |
| | | * | |
| | | * \param vecSizes a vector PdfRect's specifying the size of the pages | |
| | | (i.e the /MediaBox key) in PDF Units | |
| | | */ | |
| | | void CreatePages( const std::vector<PdfRect>& vecSizes ); | |
| | | | |
| /** 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 | | * \param bAppendAll specifies whether pages and outlines are appended
too | |
| * \returns this document | | * \returns this document | |
| */ | | */ | |
| const PdfDocument & Append( const PdfMemDocument & rDoc, bool bAppendAl
l = true ); | | const PdfDocument & Append( const PdfMemDocument & rDoc, bool bAppendAl
l = true ); | |
| | | | |
| /** Fill an existing empty XObject from a page of another document | | /** Fill an existing empty XObject from a page of another document | |
|
| | | * This will append the other document with this one | |
| * \param pXObj pointer to the XOject | | * \param pXObj pointer to the XOject | |
| * \param rDoc the document to embedd into XObject | | * \param rDoc the document to embedd into XObject | |
| * \param nPage page-number to embedd into XObject | | * \param nPage page-number to embedd into XObject | |
|
| * \param bUseTrimBox if true try to use trimbox for size of xo
bject | | * \param bUseTrimBox if true try to use trimbox for size of xobject | |
| * \returns the bounding box | | * \returns the bounding box | |
| */ | | */ | |
| PdfRect FillXObjectFromDocumentPage( PdfXObject * pXObj, const PdfMemDo
cument & rDoc, int nPage, bool bUseTrimBox ); | | PdfRect FillXObjectFromDocumentPage( PdfXObject * pXObj, const PdfMemDo
cument & rDoc, int nPage, bool bUseTrimBox ); | |
| | | | |
|
| | | /** Fill an existing empty XObject from an existing page from the curre | |
| | | nt document | |
| | | * If you need a page from another document use FillXObjectFromDocumen | |
| | | tPage, or append the documents manually | |
| | | * \param pXObj pointer to the XOject | |
| | | * \param nPage page-number to embedd into XObject | |
| | | * \param bUseTrimBox if true try to use trimbox for size of xobject | |
| | | * \returns the bounding box | |
| | | */ | |
| | | PdfRect FillXObjectFromExistingPage( PdfXObject * pXObj, int nPage, boo | |
| | | l bUseTrimBox ); | |
| | | | |
| | | /** Fill an existing empty XObject from an existing page pointer from t | |
| | | he current document | |
| | | * This is the implementation for FillXObjectFromDocumentPage and Fill | |
| | | XObjectFromExistingPage, you should use those directly instead of this | |
| | | * \param pXObj pointer to the XOject | |
| | | * \param pPage pointer to the page to embedd into XObject | |
| | | * \param bUseTrimBox if true try to use trimbox for size of xobject | |
| | | * \returns the bounding box | |
| | | */ | |
| | | PdfRect FillXObjectFromPage( PdfXObject * pXObj, const PdfPage * pPage, | |
| | | bool bUseTrimBox, unsigned int difference ); | |
| | | | |
| /** 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 ); | |
| | | | |
| /** 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 | |
| */ | | */ | |
| | | | |
| skipping to change at line 485 | | skipping to change at line 514 | |
| inline PdfVecObjects* GetObjects(); | | inline PdfVecObjects* GetObjects(); | |
| | | | |
| // Peter Petrov 26 April 2008 | | // Peter Petrov 26 April 2008 | |
| /** Get access to the internal vector of objects | | /** Get access to the internal vector of objects | |
| * or root object. | | * or root object. | |
| * | | * | |
| * \returns the vector of objects | | * \returns the vector of objects | |
| */ | | */ | |
| inline const PdfVecObjects* GetObjects() const; | | inline const PdfVecObjects* GetObjects() const; | |
| | | | |
|
| | | /** | |
| | | * Set wrapper for the fontconfig library. | |
| | | * Useful to avoid initializing Fontconfig multiple times. | |
| | | * | |
| | | * This setter can be called until first use of Fontconfig | |
| | | * as the library is initialized at first use. | |
| | | */ | |
| | | inline void SetFontConfigWrapper(const PdfFontConfigWrapper & rFontConf | |
| | | ig); | |
| | | | |
| protected: | | protected: | |
| /** Construct a new (empty) PdfDocument | | /** Construct a new (empty) PdfDocument | |
| */ | | */ | |
| PdfDocument(); | | PdfDocument(); | |
| | | | |
| /** Set the info object containing meta information. | | /** Set the info object containing meta information. | |
| * Deletes any old info object. | | * Deletes any old info object. | |
| * | | * | |
| * @param pInfo the new info object (will be owned by PdfDocument) | | * @param pInfo the new info object (will be owned by PdfDocument) | |
| */ | | */ | |
| | | | |
| skipping to change at line 678 | | skipping to change at line 716 | |
| | | | |
| // Peter Petrov 26 April 2008 | | // Peter Petrov 26 April 2008 | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| // | | // | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| inline FT_Library PdfDocument::GetFontLibrary() const | | inline FT_Library PdfDocument::GetFontLibrary() const | |
| { | | { | |
| return this->m_fontCache.GetFontLibrary(); | | return this->m_fontCache.GetFontLibrary(); | |
| } | | } | |
| | | | |
|
| | | // ----------------------------------------------------- | |
| | | // | |
| | | // ----------------------------------------------------- | |
| | | inline void PdfDocument::SetFontConfigWrapper(const PdfFontConfigWrapper & | |
| | | rFontConfig) | |
| | | { | |
| | | m_fontCache.SetFontConfigWrapper(rFontConfig); | |
| | | } | |
| | | | |
| }; | | }; | |
| | | | |
| #endif // _PDF_DOCUMENT_H_ | | #endif // _PDF_DOCUMENT_H_ | |
| | | | |
End of changes. 7 change blocks. |
| 1 lines changed or deleted | | 56 lines changed or added | |
|
| PdfEncrypt.h | | PdfEncrypt.h | |
| | | | |
| skipping to change at line 32 | | skipping to change at line 32 | |
| #define _PDFENCRYPT_H_ | | #define _PDFENCRYPT_H_ | |
| | | | |
| #include "PdfDefines.h" | | #include "PdfDefines.h" | |
| #include "PdfString.h" | | #include "PdfString.h" | |
| #include "PdfReference.h" | | #include "PdfReference.h" | |
| | | | |
| namespace PoDoFo { | | namespace PoDoFo { | |
| | | | |
| class PdfDictionary; | | class PdfDictionary; | |
| class PdfInputStream; | | class PdfInputStream; | |
|
| class PdfRijndael; | | | |
| class PdfObject; | | class PdfObject; | |
| class PdfOutputStream; | | class PdfOutputStream; | |
|
| | | class AESCryptoEngine; | |
| | | class RC4CryptoEngine; | |
| | | | |
| /// 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: | | /// Original Copyright header: | |
| ///////////////////////////////////////////////////////////////////////////
//// | | ///////////////////////////////////////////////////////////////////////////
//// | |
| // Name: pdfencrypt.h | | // Name: pdfencrypt.h | |
| // Purpose: | | // Purpose: | |
| // Author: Ulrich Telle | | // Author: Ulrich Telle | |
| // Modified by: | | // Modified by: | |
| // Created: 2005-08-16 | | // Created: 2005-08-16 | |
| | | | |
| skipping to change at line 67 | | skipping to change at line 68 | |
| * | | * | |
| */ | | */ | |
| class PODOFO_API PdfEncrypt | | class PODOFO_API PdfEncrypt | |
| { | | { | |
| public: | | public: | |
| | | | |
| /** A enum specifying a valid keylength for a PDF encryption key. | | /** A enum specifying a valid keylength for a PDF encryption key. | |
| * Keys must be in the range 40 to 128 bit and have to be a | | * Keys must be in the range 40 to 128 bit and have to be a | |
| * multiple of 8. | | * multiple of 8. | |
| * | | * | |
|
| * Adobe Reader supports only keys with 40 or 128bit! | | * Adobe Reader supports only keys with 40, 128 or 256 bits! | |
| */ | | */ | |
| typedef enum { | | typedef enum { | |
| ePdfKeyLength_40 = 40, | | ePdfKeyLength_40 = 40, | |
| ePdfKeyLength_56 = 56, | | ePdfKeyLength_56 = 56, | |
| ePdfKeyLength_80 = 80, | | ePdfKeyLength_80 = 80, | |
| ePdfKeyLength_96 = 96, | | ePdfKeyLength_96 = 96, | |
| ePdfKeyLength_128 = 128 | | ePdfKeyLength_128 = 128 | |
|
| | | #ifdef PODOFO_HAVE_LIBIDN | |
| | | ,ePdfKeyLength_256 = 256 | |
| | | #endif //PODOFO_HAVE_LIBIDN | |
| } EPdfKeyLength; | | } EPdfKeyLength; | |
| | | | |
| /** Set user permissions/restrictions on a document | | /** Set user permissions/restrictions on a document | |
| */ | | */ | |
| typedef enum { | | typedef enum { | |
| ePdfPermissions_Print = 0x00000004, ///< Allow printing t
he document | | ePdfPermissions_Print = 0x00000004, ///< Allow printing t
he document | |
| ePdfPermissions_Edit = 0x00000008, ///< Allow modifying
the document besides annotations, form fields or chaning pages | | ePdfPermissions_Edit = 0x00000008, ///< Allow modifying
the document besides annotations, form fields or chaning pages | |
| ePdfPermissions_Copy = 0x00000010, ///< Allow text and g
raphic extraction | | 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_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_FillAndSign = 0x00000100, ///< Fill in existing
form or signature fields | |
| | | | |
| skipping to change at line 96 | | skipping to change at line 100 | |
| ePdfPermissions_DocAssembly = 0x00000400, ///< Assemble the doc
ument: insert, create, rotate delete pages or add bookmarks | | 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_HighPrint = 0x00000800 ///< Print a high res
olution version of the document | |
| } EPdfPermissions; | | } EPdfPermissions; | |
| | | | |
| /** | | /** | |
| * The encryption algorithm. | | * The encryption algorithm. | |
| */ | | */ | |
| typedef enum { | | typedef enum { | |
| ePdfEncryptAlgorithm_RC4V1 = 1, ///< RC4 Version 1 encryption using
a 40bit key | | ePdfEncryptAlgorithm_RC4V1 = 1, ///< RC4 Version 1 encryption using
a 40bit key | |
| ePdfEncryptAlgorithm_RC4V2 = 2, ///< RC4 Version 2 encryption using
a key with 40-128bit | | ePdfEncryptAlgorithm_RC4V2 = 2, ///< RC4 Version 2 encryption using
a key with 40-128bit | |
|
| ePdfEncryptAlgorithm_AESV2 = 4 ///< AES encryption with an 128 bit | | ePdfEncryptAlgorithm_AESV2 = 4 ///< AES encryption with a 128 bit | |
| key (PDF1.6) | | key (PDF1.6) | |
| | | #ifdef PODOFO_HAVE_LIBIDN | |
| | | ,ePdfEncryptAlgorithm_AESV3 = 8 ///< AES encryption with a 256 bit | |
| | | key (PDF1.7 extension 3) - Support added by P. Zent | |
| | | #endif //PODOFO_HAVE_LIBIDN | |
| } EPdfEncryptAlgorithm; | | } EPdfEncryptAlgorithm; | |
| | | | |
| /** Create a PdfEncrypt object which can be used to encrypt a PDF file. | | /** 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 | | * \param userPassword the user password (if empty the user does not h
ave | |
| * to enter a password to open the document) | | * to enter a password to open the document) | |
| * \param ownerPassword the owner password | | * \param ownerPassword the owner password | |
| * \param protection several EPdfPermissions values or'ed together to
set | | * \param protection several EPdfPermissions values or'ed together to
set | |
| * the users permissions for this document | | * the users permissions for this document | |
| * \param eAlgorithm the revision of the encryption algorithm to be us
ed | | * \param eAlgorithm the revision of the encryption algorithm to be us
ed | |
| | | | |
| skipping to change at line 181 | | skipping to change at line 188 | |
| * Test if a certain encryption algorithm is enabled for loading PDF do
cuments. | | * Test if a certain encryption algorithm is enabled for loading PDF do
cuments. | |
| * | | * | |
| * \returns ture if the encryption algorithm is enabled | | * \returns ture if the encryption algorithm is enabled | |
| * \see GetEnabledEncryptionAlgorithms | | * \see GetEnabledEncryptionAlgorithms | |
| * \see SetEnabledEncryptionAlgorithms | | * \see SetEnabledEncryptionAlgorithms | |
| */ | | */ | |
| static bool IsEncryptionEnabled(EPdfEncryptAlgorithm eAlgorithm); | | static bool IsEncryptionEnabled(EPdfEncryptAlgorithm eAlgorithm); | |
| | | | |
| /** Destruct the PdfEncrypt object | | /** Destruct the PdfEncrypt object | |
| */ | | */ | |
|
| virtual ~PdfEncrypt(); | | virtual ~PdfEncrypt() = 0; | |
| | | | |
| /** 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 | | /** Generate encryption key from user and owner passwords and protectio
n key | |
| * | | * | |
| * \param documentId the documentId of the current document | | * \param documentId the documentId of the current document | |
| */ | | */ | |
|
| void GenerateEncryptionKey(const PdfString & documentId); | | virtual void GenerateEncryptionKey(const PdfString & documentId) = 0; | |
| | | | |
| /** Fill all keys into a encryption dictionary. | | /** Fill all keys into a encryption dictionary. | |
| * This dictionary is usually added to the PDF files trailer | | * This dictionary is usually added to the PDF files trailer | |
| * under the /Encryption key. | | * under the /Encryption key. | |
| * | | * | |
| * \param rDictionary an empty dictionary which is filled with informa
tion about | | * \param rDictionary an empty dictionary which is filled with informa
tion about | |
| * the used encryption algorithm | | * the used encryption algorithm | |
| */ | | */ | |
| virtual void CreateEncryptionDictionary( PdfDictionary & rDictionary )
const = 0; | | virtual void CreateEncryptionDictionary( PdfDictionary & rDictionary )
const = 0; | |
| | | | |
| | | | |
| skipping to change at line 236 | | skipping to change at line 237 | |
| virtual PdfInputStream* CreateEncryptionInputStream( PdfInputStream* pI
nputStream ) = 0; | | virtual PdfInputStream* CreateEncryptionInputStream( PdfInputStream* pI
nputStream ) = 0; | |
| | | | |
| /** | | /** | |
| * Tries to authenticate a user using either the user or owner password | | * Tries to authenticate a user using either the user or owner password | |
| * | | * | |
| * \param password owner or user password | | * \param password owner or user password | |
| * \param documentId the documentId of the PDF file | | * \param documentId the documentId of the PDF file | |
| * | | * | |
| * \returns true if either the owner or user password matches password | | * \returns true if either the owner or user password matches password | |
| */ | | */ | |
|
| bool Authenticate( const std::string & password, const PdfString & docu
mentId ); | | virtual bool Authenticate( const std::string & password, const PdfStrin
g & documentId ) = 0; | |
| | | | |
| /** Get the encryption algorithm of this object. | | /** Get the encryption algorithm of this object. | |
| * \returns the EPdfEncryptAlgorithm of this object | | * \returns the EPdfEncryptAlgorithm of this object | |
| */ | | */ | |
| inline EPdfEncryptAlgorithm GetEncryptAlgorithm() const; | | inline EPdfEncryptAlgorithm GetEncryptAlgorithm() const; | |
| | | | |
| /** Checks if printing this document is allowed. | | /** Checks if printing this document is allowed. | |
| * Every PDF consuming applications has to adhere this value! | | * Every PDF consuming applications has to adhere this value! | |
| * | | * | |
| * \returns true if you are allowed to print this document | | * \returns true if you are allowed to print this document | |
| | | | |
| skipping to change at line 315 | | skipping to change at line 316 | |
| | | | |
| /** Checks if it is allowed to print a high quality version of this doc
ument | | /** Checks if it is allowed to print a high quality version of this doc
ument | |
| * Every PDF consuming applications has to adhere this value! | | * Every PDF consuming applications has to adhere this value! | |
| * | | * | |
| * \returns true if you are allowed to print a high quality version of
this document | | * \returns true if you are allowed to print a high quality version of
this document | |
| * | | * | |
| * \see PdfEncrypt to set own document permissions. | | * \see PdfEncrypt to set own document permissions. | |
| */ | | */ | |
| inline bool IsHighPrintAllowed() const; | | 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) | |
| const unsigned char* GetUValue() const { return m_uValue; } | | const unsigned char* GetUValue() const { return m_uValue; } | |
| | | | |
| /// Get the O object value (owner) | | /// Get the O object value (owner) | |
| const unsigned char* GetOValue() const { return m_oValue; } | | const unsigned char* GetOValue() const { return m_oValue; } | |
| | | | |
|
| | | /// Get the encryption key value (owner) | |
| | | const unsigned char* GetEncryptionKey() const { return m_encryptionKey; | |
| | | } | |
| | | | |
| /// Get the P object value (protection) | | /// Get the P object value (protection) | |
|
| int GetPValue() const { return m_pValue; } | | pdf_int32 GetPValue() const { return m_pValue; } | |
| | | | |
| /// Get the revision number of the encryption method | | /// Get the revision number of the encryption method | |
| int GetRevision() const { return m_rValue; } | | int GetRevision() const { return m_rValue; } | |
| | | | |
| /// Get the key length of the encryption key in bits | | /// Get the key length of the encryption key in bits | |
| int GetKeyLength() const { return m_keyLength*8; } | | int GetKeyLength() const { return m_keyLength*8; } | |
| | | | |
| /// Encrypt a wxString | | /// Encrypt a wxString | |
|
| void Encrypt( std::string & str, pdf_long inputLen ) const; | | //void Encrypt( std::string & str, pdf_long inputLen ) const; | |
| | | | |
| /// Encrypt a character string | | /// Encrypt a character string | |
|
| virtual void Encrypt(unsigned char* str, pdf_long len) const = 0; | | // inStr: the input buffer | |
| | | // inLen: length of the input buffer | |
| | | // outStr: the output buffer | |
| | | // outLen: length of the output buffer | |
| | | virtual void Encrypt(const unsigned char* inStr, pdf_long inLen, | |
| | | unsigned char* outStr, pdf_long outLen) const = 0; | |
| | | | |
| | | /// Decrypt a character string | |
| | | // inStr: the input buffer | |
| | | // inLen: length of the input buffer | |
| | | // outStr: the output buffer | |
| | | // outLen: length of the output buffer | |
| | | virtual void Decrypt(const unsigned char* inStr, pdf_long inLen, | |
| | | unsigned char* outStr, pdf_long outLen) const = 0; | |
| | | | |
| /// Calculate stream size | | /// Calculate stream size | |
|
| virtual pdf_long CalculateStreamLength(pdf_long length) const; | | virtual pdf_long CalculateStreamLength(pdf_long length) const = 0; | |
| | | | |
| /// Calculate stream offset | | /// Calculate stream offset | |
|
| virtual pdf_long CalculateStreamOffset() const; | | virtual pdf_long CalculateStreamOffset() const = 0; | |
| | | | |
| /** Create a PdfString of MD5 data generated from a buffer in memory. | | | |
| * \param pBuffer the buffer of which to calculate the MD5 sum | | | |
| * \param nLength the length of the buffer | | | |
| * | | | |
| * \returns an MD5 sum as PdfString | | | |
| */ | | | |
| static PdfString GetMD5String( const unsigned char* pBuffer, int nLengt | | | |
| h ); | | | |
| | | | |
| /** Set the reference of the object that is currently encrypted. | | /** Set the reference of the object that is currently encrypted. | |
| * | | * | |
| * This value will be used in following calls of Encrypt | | * This value will be used in following calls of Encrypt | |
| * to encrypt the object. | | * to encrypt the object. | |
| * | | * | |
| * \see Encrypt | | * \see Encrypt | |
| */ | | */ | |
| inline void SetCurrentReference( const PdfReference & rRef ); | | inline void SetCurrentReference( const PdfReference & rRef ); | |
| | | | |
| protected: | | protected: | |
| PdfEncrypt() {}; | | PdfEncrypt() {}; | |
|
| | | PdfEncrypt( const PdfEncrypt & rhs ); | |
| | | | |
| | | /// Check two keys for equality | |
| | | bool CheckKey(unsigned char key1[32], unsigned char key2[32]); | |
| | | | |
|
| | | EPdfEncryptAlgorithm m_eAlgorithm; ///< The used encryption algorithm | |
| | | int m_keyLength; ///< Length of encryption key | |
| | | int m_rValue; ///< Revision | |
| | | pdf_int32 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_uValue[48]; ///< U entry in pdf document | |
| | | unsigned char m_oValue[48]; ///< O entry in pdf document | |
| | | unsigned char m_encryptionKey[32]; ///< Encryption key | |
| | | PdfReference m_curReference; ///< Reference of the current PdfO | |
| | | bject | |
| | | std::string m_documentId; ///< DocumentID of the current doc | |
| | | ument | |
| | | | |
| | | private: | |
| | | static int s_nEnabledEncryptionAlgorithms; ///< Or'ed int containin | |
| | | g the enabled encryption algorithms | |
| | | }; | |
| | | | |
| | | #ifdef PODOFO_HAVE_LIBIDN | |
| | | /** A pure virtual class that is used to encrypt a PDF file (AES-256) | |
| | | * This class is the base for classes that implement algorithms based on S | |
| | | HA hashes | |
| | | * | |
| | | * Client code is working only with PdfEncrypt class and knows nothing | |
| | | * about PdfEncrypt*, it is created through CreatePdfEncrypt factory me | |
| | | thod | |
| | | * | |
| | | */ | |
| | | | |
| | | class PdfEncryptSHABase : public PdfEncrypt { | |
| | | public: | |
| | | | |
| | | PdfEncryptSHABase() {}; | |
| // copy constructor | | // copy constructor | |
|
| PdfEncrypt( const PdfEncrypt & rhs ); | | PdfEncryptSHABase(const PdfEncrypt &rhs); | |
| | | | |
|
| /// Pad a password to 32 characters | | /* | |
| void PadPassword(const std::string& password, unsigned char pswd[32]); | | * Destruct PdfEncryptAESV2 object | |
| | | */ | |
| | | virtual ~PdfEncryptSHABase() {}; | |
| | | | |
| | | virtual PdfInputStream* CreateEncryptionInputStream( PdfInputStream* pI | |
| | | nputStream ) = 0; | |
| | | virtual PdfOutputStream* CreateEncryptionOutputStream( PdfOutputStream* | |
| | | pOutputStream ) = 0; | |
| | | | |
| | | virtual void CreateEncryptionDictionary( PdfDictionary & rDictionary ) | |
| | | const; | |
| | | | |
| | | virtual bool Authenticate( const std::string & password, const PdfStrin | |
| | | g & documentId ) = 0; | |
| | | | |
| | | /// Encrypt a character string | |
| | | virtual void Encrypt(const unsigned char* inStr, pdf_long inLen, | |
| | | unsigned char* outStr, pdf_long outLen) const = 0; | |
| | | | |
| | | virtual void GenerateEncryptionKey(const PdfString & documentId) = 0; | |
| | | | |
| | | /// Get the UE object value (user) | |
| | | const unsigned char* GetUEValue() const { return m_ueValue; } | |
| | | | |
| | | /// Get the OE object value (owner) | |
| | | const unsigned char* GetOEValue() const { return m_oeValue; } | |
| | | | |
| | | /// Get the Perms object value (encrypted protection) | |
| | | const unsigned char* GetPermsValue() const { return m_permsValue; } | |
| | | | |
| | | virtual pdf_long CalculateStreamOffset() const = 0; | |
| | | | |
| | | virtual pdf_long CalculateStreamLength(pdf_long length) const = 0; | |
| | | | |
| | | bool Authenticate(const std::string & documentID, const std::string & p | |
| | | assword, | |
| | | const std::string & uValue, const std::string & ueVal | |
| | | ue, | |
| | | const std::string & oValue, const std::string & oeVal | |
| | | ue, | |
| | | int pValue, const std::string & permsValue, | |
| | | int lengthValue, int rValue); | |
| | | | |
| | | protected: | |
| | | | |
| | | /// Generate initial vector | |
| | | virtual void GenerateInitialVector(unsigned char iv[16]); | |
| | | | |
| | | /// Compute encryption key to be used with AES-256 | |
| | | void ComputeEncryptionKey(); | |
| | | | |
| | | /// Generate the U and UE entries | |
| | | void ComputeUserKey(const unsigned char * userpswd, int len); | |
| | | | |
| | | /// Generate the O and OE entries | |
| | | void ComputeOwnerKey(const unsigned char * userpswd, int len); | |
| | | | |
| | | /// Preprocess password for use in EAS-256 Algorithm | |
| | | /// outBuf needs to be at least 127 bytes long | |
| | | void PreprocessPassword( const std::string &password, unsigned char* ou | |
| | | tBuf, int &len); | |
| | | | |
| | | unsigned char m_ueValue[32]; ///< UE entry in pdf document | |
| | | unsigned char m_oeValue[32]; ///< OE entry in pdf document | |
| | | unsigned char m_permsValue[16]; ///< Perms entry in pdf document | |
| | | }; | |
| | | | |
| | | /** A pure virtual class that is used to encrypt a PDF file (RC4, AES-128) | |
| | | * This class is the base for classes that implement algorithms based on M | |
| | | D5 hashes | |
| | | * | |
| | | * Client code is working only with PdfEncrypt class and knows nothing | |
| | | * about PdfEncrypt*, it is created through CreatePdfEncrypt factory me | |
| | | thod | |
| | | * | |
| | | */ | |
| | | #endif // PODOFO_HAVE_LIBIDN | |
| | | | |
| | | /** A pure virtual class that is used to encrypt a PDF file (AES-128/256) | |
| | | * This class is the base for classes that implement algorithms based on A | |
| | | ES | |
| | | * | |
| | | * Client code is working only with PdfEncrypt class and knows nothing | |
| | | * about PdfEncrypt*, it is created through CreatePdfEncrypt factory me | |
| | | thod | |
| | | * | |
| | | */ | |
| | | | |
| | | class PdfEncryptAESBase { | |
| | | public: | |
| | | ~PdfEncryptAESBase(); | |
| | | | |
| | | protected: | |
| | | PdfEncryptAESBase(); | |
| | | | |
| | | /// AES encryption | |
| | | void AES(const unsigned char* key, int keylen, const unsigned char* iv, | |
| | | const unsigned char* textin, pdf_long textlen, | |
| | | unsigned char* textout, pdf_long textoutlen); | |
| | | | |
| | | AESCryptoEngine* m_aes; ///< AES encryptor | |
| | | }; | |
| | | | |
| | | /** A pure virtual class that is used to encrypt a PDF file (RC4-40..128) | |
| | | * This class is the base for classes that implement algorithms based on R | |
| | | C4 | |
| | | * | |
| | | * Client code is working only with PdfEncrypt class and knows nothing | |
| | | * about PdfEncrypt*, it is created through CreatePdfEncrypt factory me | |
| | | thod | |
| | | * | |
| | | */ | |
| | | | |
| | | class PdfEncryptRC4Base { | |
| | | public: | |
| | | ~PdfEncryptRC4Base(); | |
| | | | |
| | | protected: | |
| | | PdfEncryptRC4Base(); | |
| | | | |
| | | /// AES encryption | |
| | | void RC4(const unsigned char* key, int keylen, | |
| | | const unsigned char* textin, pdf_long textlen, | |
| | | unsigned char* textout, pdf_long textoutlen); | |
| | | | |
| | | RC4CryptoEngine* m_rc4; ///< AES encryptor | |
| | | }; | |
| | | | |
| | | class PdfEncryptMD5Base : public PdfEncrypt, public PdfEncryptRC4Base { | |
| | | public: | |
| | | | |
| | | PdfEncryptMD5Base() {}; | |
| | | // copy constructor | |
| | | PdfEncryptMD5Base(const PdfEncrypt &rhs); | |
| | | | |
| | | /* | |
| | | * Destruct PdfEncryptAESV2 object | |
| | | */ | |
| | | virtual ~PdfEncryptMD5Base() {}; | |
| | | | |
| | | virtual PdfInputStream* CreateEncryptionInputStream( PdfInputStream* pI | |
| | | nputStream ) = 0; | |
| | | virtual PdfOutputStream* CreateEncryptionOutputStream( PdfOutputStream* | |
| | | pOutputStream ) = 0; | |
| | | | |
| | | virtual void CreateEncryptionDictionary( PdfDictionary & rDictionary ) | |
| | | const; | |
| | | | |
| | | virtual bool Authenticate( const std::string & password, const PdfStrin | |
| | | g & documentId ) = 0; | |
| | | | |
| | | /// Encrypt a character string | |
| | | virtual void Encrypt(const unsigned char* inStr, pdf_long inLen, | |
| | | unsigned char* outStr, pdf_long outLen) const = 0; | |
| | | | |
| | | virtual void GenerateEncryptionKey(const PdfString & documentId) = 0; | |
| | | | |
| | | /** Create a PdfString of MD5 data generated from a buffer in memory. | |
| | | * \param pBuffer the buffer of which to calculate the MD5 sum | |
| | | * \param nLength the length of the buffer | |
| | | * | |
| | | * \returns an MD5 sum as PdfString | |
| | | */ | |
| | | static PdfString GetMD5String( const unsigned char* pBuffer, int nLengt | |
| | | h ); | |
| | | | |
| | | virtual pdf_long CalculateStreamOffset() const = 0; | |
| | | | |
| | | virtual pdf_long CalculateStreamLength(pdf_long length) const = 0; | |
| | | | |
| | | /// Calculate the binary MD5 message digest of the given data | |
| | | static void GetMD5Binary(const unsigned char* data, int length, unsigne | |
| | | d char* digest); | |
| | | | |
| | | 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); | |
| | | | |
| | | protected: | |
| | | | |
| | | /// Generate initial vector | |
| | | virtual void GenerateInitialVector(unsigned char iv[16]); | |
| | | | |
| /// Compute owner key | | /// Compute owner key | |
| void ComputeOwnerKey(unsigned char userPad[32], unsigned char ownerPad[
32], | | void ComputeOwnerKey(unsigned char userPad[32], unsigned char ownerPad[
32], | |
| int keylength, int revision, bool authenticate, | | int keylength, int revision, bool authenticate, | |
| unsigned char ownerKey[32]); | | unsigned char ownerKey[32]); | |
| | | | |
|
| | | /// Pad a password to 32 characters | |
| | | void PadPassword(const std::string& password, unsigned char pswd[32]); | |
| | | | |
| /// Compute encryption key and user key | | /// Compute encryption key and user key | |
| void ComputeEncryptionKey(const std::string & documentID, | | void ComputeEncryptionKey(const std::string & documentID, | |
| unsigned char userPad[32], unsigned char owne
rKey[32], | | unsigned char userPad[32], unsigned char owne
rKey[32], | |
| int pValue, int keyLength, int revision, | | int pValue, int keyLength, int revision, | |
| unsigned char userKey[32]); | | unsigned char userKey[32]); | |
| | | | |
|
| /// Check two keys for equality | | | |
| bool CheckKey(unsigned char key1[32], unsigned char key2[32]); | | | |
| | | | |
| /// RC4 encryption | | | |
| void RC4(unsigned char* key, int keylen, | | | |
| unsigned char* textin, pdf_long textlen, | | | |
| unsigned char* textout); | | | |
| | | | |
| /// Calculate the binary MD5 message digest of the given data | | | |
| static void GetMD5Binary(const unsigned char* data, int length, unsigne | | | |
| d char* digest); | | | |
| | | | |
| /// Generate initial vector | | | |
| void GenerateInitialVector(unsigned char iv[16]); | | | |
| | | | |
| /** Create the encryption key for the current object. | | /** Create the encryption key for the current object. | |
| * | | * | |
| * \param objkey pointer to an array of at least MD5_HASHBYTES (=16) b
ytes length | | * \param objkey pointer to an array of at least MD5_HASHBYTES (=16) b
ytes length | |
| * \param pnKeyLen pointer to an integer where the actual keylength is
stored. | | * \param pnKeyLen pointer to an integer where the actual keylength is
stored. | |
| */ | | */ | |
|
| void CreateObjKey( unsigned char objkey[16], int* pnKeyLen ) const; | | virtual void CreateObjKey( unsigned char objkey[16], int* pnKeyLen ) co
nst; | |
| | | | |
|
| EPdfEncryptAlgorithm m_eAlgorithm; ///< The used encryption algorith | | | |
| m | | | |
| 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_rc4key[16]; ///< last RC4 key | |
| unsigned char m_rc4last[256]; ///< last RC4 state table | | 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: | | | |
| static int s_nEnabledEncryptionAlgorithms; ///< Or'ed int containin | | | |
| g the enabled encryption algorithms | | | |
| | | | |
|
| unsigned char m_encryptionKey[16]; ///< Encryption key | | | |
| | | | |
| PdfReference m_curReference; ///< Reference of the current PdfO | | | |
| bject | | | |
| | | | |
| std::string m_documentId; ///< DocumentID of the current doc | | | |
| ument | | | |
| }; | | }; | |
| | | | |
| /** A class that is used to encrypt a PDF file (AES-128) | | /** A class that is used to encrypt a PDF file (AES-128) | |
| * | | * | |
| * Client code is working only with PdfEncrypt class and knows nothing | | * Client code is working only with PdfEncrypt class and knows nothing | |
|
| * about PdfEncryptAES, it is created through CreatePdfEncrypt factory
method | | * about PdfEncryptAES*, it is created through CreatePdfEncrypt factory
method | |
| * | | * | |
| */ | | */ | |
| | | | |
|
| class PdfEncryptAES : public PdfEncrypt { | | class PdfEncryptAESV2 : public PdfEncryptMD5Base, public PdfEncryptAESBase
{ | |
| public: | | public: | |
| /* | | /* | |
|
| * Constructors of PdfEncryptAES | | * Constructors of PdfEncryptAESV2 | |
| */ | | */ | |
|
| PdfEncryptAES(PdfString oValue, PdfString uValue, int pValue); | | PdfEncryptAESV2(PdfString oValue, PdfString uValue, int pValue); | |
| PdfEncryptAES(const PdfEncrypt & rhs); | | PdfEncryptAESV2( const PdfEncrypt & rhs ) : PdfEncryptMD5Base(rhs) {} | |
| PdfEncryptAES( const std::string & userPassword, | | PdfEncryptAESV2( const std::string & userPassword, | |
| const std::string & ownerPassword, | | const std::string & ownerPassword, | |
| int protection = ePdfPermissions_Print | | | int protection = ePdfPermissions_Print | | |
| ePdfPermissions_Edit | | | ePdfPermissions_Edit | | |
| ePdfPermissions_Copy | | | ePdfPermissions_Copy | | |
| ePdfPermissions_EditNotes | | | ePdfPermissions_EditNotes | | |
| ePdfPermissions_FillAndSign | | | ePdfPermissions_FillAndSign | | |
| ePdfPermissions_Accessible | | | ePdfPermissions_Accessible | | |
| ePdfPermissions_DocAssembly | | | ePdfPermissions_DocAssembly | | |
| ePdfPermissions_HighPrint | | ePdfPermissions_HighPrint | |
| ); | | ); | |
| | | | |
| /* | | /* | |
|
| * Destruct PdfEncryptAES object | | * Destruct PdfEncryptAESV2 object | |
| */ | | */ | |
|
| ~PdfEncryptAES(); | | virtual ~PdfEncryptAESV2() {}; | |
| | | | |
|
| void Encrypt(unsigned char* str, pdf_long len) const; | | virtual PdfInputStream* CreateEncryptionInputStream( PdfInputStream* | |
| | | pInputStream ); | |
| | | virtual PdfOutputStream* CreateEncryptionOutputStream( PdfOutputStre | |
| | | am* pOutputStream ); | |
| | | | |
|
| /// Calculate stream offset | | virtual bool Authenticate( const std::string & password, const PdfStrin | |
| pdf_long CalculateStreamOffset() const; | | g & documentId ); | |
| | | | |
|
| PdfInputStream* CreateEncryptionInputStream( PdfInputStream* pInputS | | /// Encrypt a character string | |
| tream ); | | virtual void Encrypt(const unsigned char* inStr, pdf_long inLen, | |
| PdfOutputStream* CreateEncryptionOutputStream( PdfOutputStream* pOut | | unsigned char* outStr, pdf_long outLen) const; | |
| putStream ); | | virtual void Decrypt(const unsigned char* inStr, pdf_long inLen, | |
| | | unsigned char* outStr, pdf_long outLen) const; | |
| | | | |
|
| pdf_long CalculateStreamLength(pdf_long length) const; | | virtual void GenerateEncryptionKey(const PdfString & documentId); | |
| | | | |
|
| void CreateEncryptionDictionary( PdfDictionary & rDictionary ) const
; | | virtual pdf_long CalculateStreamOffset() const; | |
| | | | |
|
| private: | | virtual pdf_long CalculateStreamLength(pdf_long length) const; | |
| /// AES encryption | | }; | |
| void AES(unsigned char* key, int keylen, | | | |
| unsigned char* textin, pdf_long textlen, | | #ifdef PODOFO_HAVE_LIBIDN | |
| unsigned char* textout); | | /** A class that is used to encrypt a PDF file (AES-256) | |
| | | * | |
| | | * Client code is working only with PdfEncrypt class and knows nothing | |
| | | * about PdfEncryptAES*, it is created through CreatePdfEncrypt factory | |
| | | method | |
| | | * | |
| | | */ | |
| | | | |
| | | class PdfEncryptAESV3 : public PdfEncryptSHABase, public PdfEncryptAESBase | |
| | | { | |
| | | public: | |
| | | /* | |
| | | * Constructors of PdfEncryptAESV3 | |
| | | */ | |
| | | PdfEncryptAESV3(PdfString oValue, PdfString oeValue, PdfString uValue, | |
| | | PdfString ueValue, int pValue, PdfString permsValue); | |
| | | PdfEncryptAESV3( const PdfEncrypt & rhs ) : PdfEncryptSHABase(rhs) {} | |
| | | PdfEncryptAESV3( 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 PdfEncryptAESV3 object | |
| | | */ | |
| | | virtual ~PdfEncryptAESV3() {}; | |
| | | | |
| | | virtual PdfInputStream* CreateEncryptionInputStream( PdfInputStream* pI | |
| | | nputStream ); | |
| | | virtual PdfOutputStream* CreateEncryptionOutputStream( PdfOutputStream* | |
| | | pOutputStream ); | |
| | | | |
| | | virtual bool Authenticate( const std::string & password, const PdfStrin | |
| | | g & documentId ); | |
| | | | |
|
| PdfRijndael* m_aes; ///< AES encryptor | | /// Encrypt a character string | |
| | | virtual void Encrypt(const unsigned char* inStr, pdf_long inLen, | |
| | | unsigned char* outStr, pdf_long outLen) const; | |
| | | virtual void Decrypt(const unsigned char* inStr, pdf_long inLen, | |
| | | unsigned char* outStr, pdf_long outLen) const; | |
| | | | |
| | | virtual void GenerateEncryptionKey(const PdfString & documentId); | |
| | | | |
|
| | | virtual pdf_long CalculateStreamOffset() const; | |
| | | | |
| | | virtual pdf_long CalculateStreamLength(pdf_long length) const; | |
| }; | | }; | |
| | | | |
|
| | | #endif // PODOFO_HAVE_LIBIDN | |
| | | | |
| /** A class that is used to encrypt a PDF file (RC4 40-bit and 128-bit) | | /** 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 | | * Client code is working only with PdfEncrypt class and knows nothing | |
| * about PdfEncryptRC4, it is created through CreatePdfEncrypt factory
method | | * about PdfEncryptRC4, it is created through CreatePdfEncrypt factory
method | |
| * | | * | |
| */ | | */ | |
| | | | |
|
| class PdfEncryptRC4 : public PdfEncrypt { | | class PdfEncryptRC4 : public PdfEncryptMD5Base { | |
| public: | | public: | |
| /* | | /* | |
| * Constructors of PdfEncryptRC4 objects | | * Constructors of PdfEncryptRC4 objects | |
| */ | | */ | |
| PdfEncryptRC4(PdfString oValue, PdfString uValue, | | PdfEncryptRC4(PdfString oValue, PdfString uValue, | |
| int pValue, int rValue, EPdfEncryptAlgorithm eAlgorithm, lon
g length); | | int pValue, int rValue, EPdfEncryptAlgorithm eAlgorithm, lon
g length); | |
|
| | | PdfEncryptRC4( const PdfEncrypt & rhs ) : PdfEncryptMD5Base(rhs) {} | |
| PdfEncryptRC4( const std::string & userPassword, | | PdfEncryptRC4( const std::string & userPassword, | |
| const std::string & ownerPassword, | | const std::string & ownerPassword, | |
| int protection = ePdfPermissions_Print | | | int protection = ePdfPermissions_Print | | |
| ePdfPermissions_Edit | | | ePdfPermissions_Edit | | |
| ePdfPermissions_Copy | | | ePdfPermissions_Copy | | |
| ePdfPermissions_EditNotes | | | ePdfPermissions_EditNotes | | |
| ePdfPermissions_FillAndSign | | | ePdfPermissions_FillAndSign | | |
| ePdfPermissions_Accessible | | | ePdfPermissions_Accessible | | |
| ePdfPermissions_DocAssembly | | | ePdfPermissions_DocAssembly | | |
| ePdfPermissions_HighPrint, | | ePdfPermissions_HighPrint, | |
| EPdfEncryptAlgorithm eAlgorithm = ePdfEncryptAlgorithm_RC
4V1, | | EPdfEncryptAlgorithm eAlgorithm = ePdfEncryptAlgorithm_RC
4V1, | |
| EPdfKeyLength eKeyLength = ePdfKeyLength_40 ); | | EPdfKeyLength eKeyLength = ePdfKeyLength_40 ); | |
|
| PdfEncryptRC4(const PdfEncrypt & rhs) : PdfEncrypt(rhs) {} | | | |
| | | | |
|
| void Encrypt(unsigned char* str, pdf_long len) const; | | /* | |
| | | * Destruct PdfEncryptRC4 object | |
| | | */ | |
| | | virtual ~PdfEncryptRC4() {} | |
| | | | |
| | | virtual bool Authenticate( const std::string & password, const PdfStrin | |
| | | g & documentId ); | |
| | | | |
|
| PdfInputStream* CreateEncryptionInputStream( PdfInputStream* pInputS | | /// Encrypt a character string | |
| tream ); | | virtual void Encrypt(const unsigned char* inStr, pdf_long inLen, | |
| PdfOutputStream* CreateEncryptionOutputStream( PdfOutputStream* pOut | | unsigned char* outStr, pdf_long outLen) const; | |
| putStream ); | | virtual void Decrypt(const unsigned char* inStr, pdf_long inLen, | |
| | | unsigned char* outStr, pdf_long outLen) const; | |
| | | | |
|
| void CreateEncryptionDictionary( PdfDictionary & rDictionary ) const | | virtual PdfInputStream* CreateEncryptionInputStream( PdfInputStream* | |
| ; | | pInputStream ); | |
| | | virtual PdfOutputStream* CreateEncryptionOutputStream( PdfOutputStre | |
| | | am* pOutputStream ); | |
| | | | |
| | | virtual void GenerateEncryptionKey(const PdfString & documentId); | |
| | | | |
| | | virtual pdf_long CalculateStreamOffset() const; | |
| | | | |
| | | virtual pdf_long CalculateStreamLength(pdf_long length) const; | |
| }; | | }; | |
| | | | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| // | | // | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| PdfEncrypt::EPdfEncryptAlgorithm PdfEncrypt::GetEncryptAlgorithm() const | | PdfEncrypt::EPdfEncryptAlgorithm PdfEncrypt::GetEncryptAlgorithm() const | |
| { | | { | |
| return m_eAlgorithm; | | return m_eAlgorithm; | |
| } | | } | |
| | | | |
| | | | |
| skipping to change at line 536 | | skipping to change at line 771 | |
| void PdfEncrypt::SetCurrentReference( const PdfReference & rRef ) | | void PdfEncrypt::SetCurrentReference( const PdfReference & rRef ) | |
| { | | { | |
| m_curReference = rRef; | | m_curReference = rRef; | |
| } | | } | |
| | | | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| // | | // | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| bool PdfEncrypt::IsPrintAllowed() const | | bool PdfEncrypt::IsPrintAllowed() const | |
| { | | { | |
|
| // TODO: Check is this is correct (+/- 1 required ???) | | | |
| return (m_pValue & ePdfPermissions_Print) == ePdfPermissions_Print; | | return (m_pValue & ePdfPermissions_Print) == ePdfPermissions_Print; | |
| } | | } | |
| | | | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| // | | // | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| bool PdfEncrypt::IsEditAllowed() const | | bool PdfEncrypt::IsEditAllowed() const | |
| { | | { | |
| return (m_pValue & ePdfPermissions_Edit) == ePdfPermissions_Edit; | | return (m_pValue & ePdfPermissions_Edit) == ePdfPermissions_Edit; | |
| } | | } | |
| | | | |
End of changes. 47 change blocks. |
| 106 lines changed or deleted | | 368 lines changed or added | |
|
| PdfFont.h | | PdfFont.h | |
| | | | |
| skipping to change at line 59 | | skipping to change at line 59 | |
| public: | | public: | |
| | | | |
| /** 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 pEncoding the encoding of this font. The font will not take | | * \param pEncoding the encoding of this font. The font will take owne | |
| ownership of this object. | | rship of this object | |
| | | * depending on pEncoding->IsAutoDelete() | |
| * \param pParent parent of the font object | | * \param pParent parent of the font object | |
| * | | * | |
| */ | | */ | |
| PdfFont( PdfFontMetrics* pMetrics, const PdfEncoding* const pEncoding,
PdfVecObjects* pParent ); | | PdfFont( PdfFontMetrics* pMetrics, const PdfEncoding* const pEncoding,
PdfVecObjects* pParent ); | |
| | | | |
| /** Create a PdfFont based on an existing PdfObject | | /** Create a PdfFont based on an existing PdfObject | |
| * \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 pEncoding the encoding of this font. The font will not take | | * \param pEncoding the encoding of this font. The font will take owne | |
| ownership of this object. | | rship of this object | |
| | | * depending on pEncoding->IsAutoDelete() | |
| * \param pObject an existing PdfObject | | * \param pObject an existing PdfObject | |
| */ | | */ | |
| PdfFont( PdfFontMetrics* pMetrics, const PdfEncoding* const pEncoding,
PdfObject* pObject ); | | PdfFont( PdfFontMetrics* pMetrics, const PdfEncoding* const pEncoding,
PdfObject* pObject ); | |
| | | | |
| 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 | |
| */ | | */ | |
| inline void SetFontSize( float fSize ); | | inline void SetFontSize( float fSize ); | |
| | | | |
| skipping to change at line 106 | | skipping to change at line 108 | |
| /** Set the character spacing of the font | | /** Set the character spacing of the font | |
| * \param fCharSpace character spacing in percent | | * \param fCharSpace character spacing in percent | |
| */ | | */ | |
| inline void SetFontCharSpace( float fCharSpace ); | | inline void SetFontCharSpace( float fCharSpace ); | |
| | | | |
| /** Retrieve the current character spacing of this font object | | /** Retrieve the current character spacing of this font object | |
| * \returns the current font character spacing | | * \returns the current font character spacing | |
| */ | | */ | |
| inline float GetFontCharSpace() const; | | inline float GetFontCharSpace() const; | |
| | | | |
|
| | | /** Set the word spacing of the font | |
| | | * \param fWordSpace word spacing in PDF units | |
| | | */ | |
| | | inline void SetWordSpace( float fWordSpace ); | |
| | | | |
| | | /** Retrieve the current word spacing of this font object | |
| | | * \returns the current font word spacing in PDF units | |
| | | */ | |
| | | inline float GetWordSpace() 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 IsBold | |
| * \see IsItalic | | * \see IsItalic | |
| | | | |
| skipping to change at line 185 | | skipping to change at line 197 | |
| * or following whitespaces. | | * or following whitespaces. | |
| */ | | */ | |
| virtual void WriteStringToStream( const PdfString & rsString, PdfStream
* pStream ); | | virtual void WriteStringToStream( const PdfString & rsString, PdfStream
* pStream ); | |
| | | | |
| // Peter Petrov 24 September 2008 | | // Peter Petrov 24 September 2008 | |
| /** Embeds the font into PDF page | | /** Embeds the font into PDF page | |
| * | | * | |
| */ | | */ | |
| virtual void EmbedFont(); | | virtual void EmbedFont(); | |
| | | | |
|
| /** Remember the glyphs used in the string in case of subsetting | | /** Remember the glyphs used in the string in case of subsetting | |
| * | | * | |
| * \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 lStringLen draw only lLen characters of pszText | | * \param lStringLen draw only lLen characters of pszText | |
| * | | * | |
| * Only call if IsSubsetting() returns true. Might throw an exception
otherwise. | | * Only call if IsSubsetting() returns true. Might throw an exception
otherwise. | |
| * | | * | |
| * \see IsSubsetting | | * \see IsSubsetting | |
|
| */ | | */ | |
| virtual void AddUsedSubsettingGlyphs( const PdfString & sText, long | | virtual void AddUsedSubsettingGlyphs( const PdfString & sText, long lSt | |
| lStringLen ); | | ringLen ); | |
| | | | |
|
| /** Remember the glyphname in case of subsetting | | /** Remember the glyphname in case of subsetting | |
| * | | * | |
| * \param pszGlyphName Name of the glyph to remember | | * \param pszGlyphName Name of the glyph to remember | |
|
| */ | | */ | |
| virtual void AddUsedGlyphname( const char * pszGlyphName ); | | virtual void AddUsedGlyphname( const char * pszGlyphName ); | |
| | | | |
| /** Embeds pending subset-font into PDF page | | /** Embeds pending subset-font into PDF page | |
| * Only call if IsSubsetting() returns true. Might throw an exception
otherwise. | | * Only call if IsSubsetting() returns true. Might throw an exception
otherwise. | |
| * | | * | |
| * \see IsSubsetting | | * \see IsSubsetting | |
| */ | | */ | |
| virtual void EmbedSubsetFont(); | | virtual void EmbedSubsetFont(); | |
| | | | |
| /** Check if this is a subsetting font. | | /** Check if this is a subsetting font. | |
| * \returns true if this is a subsetting font | | * \returns true if this is a subsetting font | |
| */ | | */ | |
| inline bool IsSubsetting() const; | | inline bool IsSubsetting() const; | |
| | | | |
| protected: | | protected: | |
| /** Get the base font name of this font | | /** Get the base font name of this font | |
| * | | * | |
| * \returns the base font name | | * \returns the base font name | |
| */ | | */ | |
| inline const PdfName& GetBaseFont() const; | | inline const PdfName& GetBaseFont() const; | |
| | | | |
|
| void InitBase14Font(); | | void InitBase14Font(); | |
| | | | |
| const PdfEncoding* const m_pEncoding; | | const PdfEncoding* const m_pEncoding; | |
| PdfFontMetrics* m_pMetrics; | | PdfFontMetrics* m_pMetrics; | |
| | | | |
| bool m_bBold; | | bool m_bBold; | |
| bool m_bItalic; | | bool m_bItalic; | |
| bool m_bUnderlined; | | bool m_bUnderlined; | |
| bool m_bStrikedOut; | | bool m_bStrikedOut; | |
| | | | |
| bool m_bWasEmbedded; | | bool m_bWasEmbedded; | |
|
| bool m_isBase14; | | bool m_isBase14; | |
| bool m_bIsSubsetting; | | bool m_bIsSubsetting; | |
| PdfName m_Identifier; | | PdfName m_Identifier; | |
| | | | |
| private: | | private: | |
| /** default constructor, not implemented | | /** default constructor, not implemented | |
| */ | | */ | |
| PdfFont(void); | | PdfFont(void); | |
| /** copy constructor, not implemented | | /** copy constructor, not implemented | |
| */ | | */ | |
| PdfFont(const PdfFont& rhs); | | PdfFont(const PdfFont& rhs); | |
| /** assignment operator, not implemented | | /** assignment operator, not implemented | |
| | | | |
| skipping to change at line 359 | | skipping to change at line 371 | |
| // | | // | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| float PdfFont::GetFontCharSpace() const | | float PdfFont::GetFontCharSpace() const | |
| { | | { | |
| return m_pMetrics->GetFontCharSpace(); | | return m_pMetrics->GetFontCharSpace(); | |
| } | | } | |
| | | | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| // | | // | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
|
| | | inline void PdfFont::SetWordSpace( float fWordSpace ) | |
| | | { | |
| | | m_pMetrics->SetWordSpace( fWordSpace ); | |
| | | } | |
| | | | |
| | | // ----------------------------------------------------- | |
| | | // | |
| | | // ----------------------------------------------------- | |
| | | inline float PdfFont::GetWordSpace() const | |
| | | { | |
| | | return m_pMetrics->GetWordSpace(); | |
| | | } | |
| | | | |
| | | // ----------------------------------------------------- | |
| | | // | |
| | | // ----------------------------------------------------- | |
| const PdfEncoding* PdfFont::GetEncoding() const | | const PdfEncoding* PdfFont::GetEncoding() const | |
| { | | { | |
| return m_pEncoding; | | return m_pEncoding; | |
| | | | |
| } | | } | |
| | | | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| // | | // | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| PdfFontMetrics* PdfFont::GetFontMetrics2() | | PdfFontMetrics* PdfFont::GetFontMetrics2() | |
| | | | |
| skipping to change at line 418 | | skipping to change at line 446 | |
| bool PdfFont::IsStrikeOut() const | | bool PdfFont::IsStrikeOut() const | |
| { | | { | |
| return m_bStrikedOut; | | return m_bStrikedOut; | |
| } | | } | |
| | | | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| // | | // | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| bool PdfFont::IsBold() const | | bool PdfFont::IsBold() const | |
| { | | { | |
|
| return m_bBold; | | return m_bBold; | |
| } | | } | |
| | | | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| // | | // | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| bool PdfFont::IsItalic() const | | bool PdfFont::IsItalic() const | |
| { | | { | |
|
| return m_bItalic; | | return m_bItalic; | |
| } | | } | |
| | | | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| // | | // | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| bool PdfFont::IsSubsetting() const | | bool PdfFont::IsSubsetting() const | |
| { | | { | |
| return m_bIsSubsetting; | | return m_bIsSubsetting; | |
| } | | } | |
| | | | |
| | | | |
End of changes. 12 change blocks. |
| 18 lines changed or deleted | | 46 lines changed or added | |
|
| PdfFontCache.h | | PdfFontCache.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_FONT_CACHE_H_ | | #ifndef _PDF_FONT_CACHE_H_ | |
| #define _PDF_FONT_CACHE_H_ | | #define _PDF_FONT_CACHE_H_ | |
| | | | |
| #include "podofo/base/PdfDefines.h" | | #include "podofo/base/PdfDefines.h" | |
| #include "podofo/base/Pdf3rdPtyForwardDecl.h" | | #include "podofo/base/Pdf3rdPtyForwardDecl.h" | |
| #include "podofo/base/PdfEncoding.h" | | #include "podofo/base/PdfEncoding.h" | |
| #include "podofo/base/PdfEncodingFactory.h" | | #include "podofo/base/PdfEncodingFactory.h" | |
|
| #include "podofo/base/util/PdfMutex.h" | | | |
| #include "PdfFont.h" | | #include "PdfFont.h" | |
|
| | | #include "PdfFontConfigWrapper.h" | |
| | | | |
| namespace PoDoFo { | | namespace PoDoFo { | |
| | | | |
| class PdfFontMetrics; | | class PdfFontMetrics; | |
| class PdfVecObjects; | | class PdfVecObjects; | |
| | | | |
| /** A private structure, | | /** A private structure, | |
| * which represents a font in the cache. | | * which represents a font in the cache. | |
| */ | | */ | |
| struct TFontCacheElement { | | struct TFontCacheElement { | |
| | | | |
| skipping to change at line 132 | | skipping to change at line 133 | |
| * 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_DOC_API PdfFontCache { | | class PODOFO_DOC_API PdfFontCache { | |
| typedef std::vector<TFontCacheElement> TSortedFontList; | | typedef std::vector<TFontCacheElement> TSortedFontList; | |
| typedef TSortedFontList::iterator TISortedFontList; | | typedef TSortedFontList::iterator TISortedFontList; | |
| typedef TSortedFontList::const_iterator TCISortedFontList; | | typedef TSortedFontList::const_iterator TCISortedFontList; | |
| | | | |
|
| #if defined(PODOFO_HAVE_FONTCONFIG) | | | |
| static Util::PdfMutex m_FcMutex; | | | |
| #endif | | | |
| | | | |
| public: | | public: | |
| | | | |
| /** | | /** | |
| * Flags to control font creation. | | * Flags to control font creation. | |
| */ | | */ | |
| enum EFontCreationFlags { | | enum EFontCreationFlags { | |
| eFontCreationFlags_None = 0, ///< No spec
ial settings | | eFontCreationFlags_None = 0, ///< No spec
ial settings | |
| eFontCreationFlags_AutoSelectBase14 = 1, ///< Create automati
cally a base14 font if the fontname matches one of them | | eFontCreationFlags_AutoSelectBase14 = 1, ///< Create automati
cally a base14 font if the fontname matches one of them | |
| eFontCreationFlags_Type1Subsetting = 2 ///< Create subsette
d type1-font, which includes only used characters | | eFontCreationFlags_Type1Subsetting = 2 ///< Create subsette
d type1-font, which includes only used characters | |
| }; | | }; | |
| | | | |
| /** Create an empty font cache | | /** Create an empty font cache | |
| * | | * | |
| * \param pParent a PdfVecObjects which is required | | * \param pParent a PdfVecObjects which is required | |
| * to create new font objects | | * to create new font objects | |
| */ | | */ | |
| PdfFontCache( PdfVecObjects* pParent ); | | PdfFontCache( PdfVecObjects* pParent ); | |
| | | | |
|
| | | /** Create an empty font cache | |
| | | * | |
| | | * \param rFontConfig provide a handle to fontconfig, as initializing | |
| | | a | |
| | | * new fontconfig intance might be time consuming. | |
| | | * \param pParent a PdfVecObjects which is required | |
| | | * to create new font objects | |
| | | */ | |
| | | PdfFontCache( const PdfFontConfigWrapper & rFontConfig, PdfVecObjects* | |
| | | pParent ); | |
| | | | |
| /** Destroy and empty the font cache | | /** Destroy and empty the font cache | |
| */ | | */ | |
| ~PdfFontCache(); | | ~PdfFontCache(); | |
| | | | |
| /** | | /** | |
| * 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(); | |
| | | | |
| skipping to change at line 269 | | skipping to change at line 275 | |
| | | | |
| /** Embeds all pending subset-fonts | | /** Embeds all pending subset-fonts | |
| * | | * | |
| */ | | */ | |
| void EmbedSubsetFonts(); | | void EmbedSubsetFonts(); | |
| | | | |
| #if defined(PODOFO_HAVE_FONTCONFIG) | | #if defined(PODOFO_HAVE_FONTCONFIG) | |
| /** Get the path of a font file on a Unix system using fontconfig | | /** Get the path of a font file on a Unix system using fontconfig | |
| * | | * | |
| * This method is only available if PoDoFo was compiled with | | * This method is only available if PoDoFo was compiled with | |
|
| * fontconfig support. | | * fontconfig support. Make sure to lock any FontConfig mutexes before | |
| | | * calling this method by yourself! | |
| * | | * | |
| * \param pConfig a handle to an initialized fontconfig library | | * \param pConfig a handle to an initialized fontconfig library | |
| * \param pszFontName name of the requested font | | * \param pszFontName name of the requested font | |
| * \param bBold if true find a bold font | | * \param bBold if true find a bold font | |
| * \param bItalic if true find an italic font | | * \param bItalic if true find an italic font | |
| * \returns the path to the fontfile or an empty string | | * \returns the path to the fontfile or an empty string | |
| */ | | */ | |
| static std::string GetFontConfigFontPath( FcConfig* pConfig, const char
* pszFontName, bool bBold, bool bItalic ); | | static std::string GetFontConfigFontPath( FcConfig* pConfig, const char
* pszFontName, bool bBold, bool bItalic ); | |
| #endif // defined(PODOFO_HAVE_FONTCONFIG) | | #endif // defined(PODOFO_HAVE_FONTCONFIG) | |
| | | | |
| // Peter Petrov: 26 April 2008 | | // Peter Petrov: 26 April 2008 | |
| /** Returns the font library from font cache | | /** Returns the font library from font cache | |
| * | | * | |
| * \returns the internal handle to the freetype library | | * \returns the internal handle to the freetype library | |
| */ | | */ | |
| inline FT_Library GetFontLibrary() const; | | inline FT_Library GetFontLibrary() const; | |
| | | | |
|
| | | /** | |
| | | * Set wrapper for the fontconfig library. | |
| | | * Useful to avoid initializing Fontconfig multiple times. | |
| | | * | |
| | | * This setter can be called until first use of Fontconfig | |
| | | * as the library is initialized at first use. | |
| | | */ | |
| | | inline void SetFontConfigWrapper(const PdfFontConfigWrapper & rFontConf | |
| | | ig); | |
| | | | |
| 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 bBold if true search for a bold font | |
| * \param bItalic if true search for an italic 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. | |
| */ | | */ | |
| | | | |
| skipping to change at line 360 | | skipping to change at line 376 | |
| | | | |
| PdfFont* GetWin32Font( TISortedFontList itSorted, TSortedFontList & vec
Container, const wchar_t* pszFontName, | | PdfFont* GetWin32Font( TISortedFontList itSorted, TSortedFontList & vec
Container, const wchar_t* pszFontName, | |
| bool bBold, bool bItalic, bool bEmbed
d, const PdfEncoding * const pEncoding ); | | bool bBold, bool bItalic, bool bEmbed
d, const PdfEncoding * const pEncoding ); | |
| #endif // _WIN32 | | #endif // _WIN32 | |
| | | | |
| private: | | private: | |
| TSortedFontList m_vecFonts; ///< Sorted list of all fonts,
currently in the cache | | TSortedFontList m_vecFonts; ///< Sorted list of all fonts,
currently in the cache | |
| TSortedFontList m_vecFontSubsets; | | TSortedFontList m_vecFontSubsets; | |
| FT_Library m_ftLibrary; ///< Handle to the freetype li
brary | | FT_Library m_ftLibrary; ///< Handle to the freetype li
brary | |
| | | | |
|
| void* m_pFcConfig; ///< Handle to fontconfig on u | | | |
| nix systems | | | |
| | | | |
| PdfVecObjects* m_pParent; ///< Handle to parent for crea
ting new fonts and objects | | PdfVecObjects* m_pParent; ///< Handle to parent for crea
ting new fonts and objects | |
|
| | | | |
| | | PdfFontConfigWrapper m_fontConfig; ///< Handle to the fontconfig | |
| | | library | |
| }; | | }; | |
| | | | |
| // Peter Petrov: 26 April 2008 | | // Peter Petrov: 26 April 2008 | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| // | | // | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| FT_Library PdfFontCache::GetFontLibrary() const | | FT_Library PdfFontCache::GetFontLibrary() const | |
| { | | { | |
| return this->m_ftLibrary; | | return this->m_ftLibrary; | |
| } | | } | |
| | | | |
|
| | | // ----------------------------------------------------- | |
| | | // | |
| | | // ----------------------------------------------------- | |
| | | inline void PdfFontCache::SetFontConfigWrapper(const PdfFontConfigWrapper & | |
| | | rFontConfig) | |
| | | { | |
| | | m_fontConfig = rFontConfig; | |
| | | } | |
| | | | |
| }; | | }; | |
| | | | |
| #endif /* _PDF_FONT_CACHE_H_ */ | | #endif /* _PDF_FONT_CACHE_H_ */ | |
| | | | |
End of changes. 9 change blocks. |
| 9 lines changed or deleted | | 37 lines changed or added | |
|
| PdfFontMetrics.h | | PdfFontMetrics.h | |
| | | | |
| skipping to change at line 64 | | skipping to change at line 64 | |
| * \param nGlyphId id of the glyph | | * \param nGlyphId id of the glyph | |
| * \returns the width of a single glyph id | | * \returns the width of a single glyph id | |
| */ | | */ | |
| virtual double GetGlyphWidth( int nGlyphId ) const = 0; | | virtual double GetGlyphWidth( int nGlyphId ) const = 0; | |
| | | | |
| /** Get the width of a single named glyph | | /** Get the width of a single named glyph | |
| * | | * | |
| * \param pszGlyphname name of the glyph | | * \param pszGlyphname name of the glyph | |
| * \returns the width of a single named glyph | | * \returns the width of a single named glyph | |
| */ | | */ | |
|
| virtual double GetGlyphWidth( const char* pszGlyphname ) const = 0; | | virtual double GetGlyphWidth( const char* pszGlyphname ) const = 0; | |
| | | | |
| /** 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. | |
| */ | | */ | |
| virtual void GetBoundingBox( PdfArray & array ) const = 0; | | virtual void GetBoundingBox( PdfArray & array ) const = 0; | |
| | | | |
| /** 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 | |
| | | | |
| skipping to change at line 325 | | skipping to change at line 325 | |
| /** Set the character spacing of this metrics object | | /** Set the character spacing of this metrics object | |
| * \param fCharSpace character spacing in percent | | * \param fCharSpace character spacing in percent | |
| */ | | */ | |
| inline void SetFontCharSpace( float fCharSpace ); | | inline void SetFontCharSpace( float fCharSpace ); | |
| | | | |
| /** Retrieve the current character spacing of this metrics object | | /** Retrieve the current character spacing of this metrics object | |
| * \returns the current font character spacing | | * \returns the current font character spacing | |
| */ | | */ | |
| inline float GetFontCharSpace() const; | | inline float GetFontCharSpace() const; | |
| | | | |
|
| | | /** Set the word spacing of this metrics object | |
| | | * \param fWordSpace word spacing in PDF units | |
| | | */ | |
| | | inline void SetWordSpace( float fWordSpace ); | |
| | | | |
| | | /** Retrieve the current word spacing of this metrics object | |
| | | * \returns the current font word spacing in PDF units | |
| | | */ | |
| | | inline float GetWordSpace() const; | |
| | | | |
| /** | | /** | |
| * \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 | | /** Get the glyph id for a unicode character | |
| * in the current font. | | * in the current font. | |
| * | | * | |
| * \param lUnicode the unicode character value | | * \param lUnicode the unicode character value | |
| * \returns the glyhph id for the character or 0 if the glyph was not
found. | | * \returns the glyhph id for the character or 0 if the glyph was not
found. | |
| | | | |
| skipping to change at line 368 | | skipping to change at line 378 | |
| * Set the fonttype. | | * Set the fonttype. | |
| * \param eFontType fonttype | | * \param eFontType fonttype | |
| */ | | */ | |
| inline void SetFontType(EPdfFontType eFontType); | | inline void SetFontType(EPdfFontType eFontType); | |
| | | | |
| protected: | | protected: | |
| std::string m_sFilename; | | std::string m_sFilename; | |
| float m_fFontSize; | | float m_fFontSize; | |
| float m_fFontScale; | | float m_fFontScale; | |
| float m_fFontCharSpace; | | float m_fFontCharSpace; | |
|
| | | float m_fWordSpace; | |
| | | | |
| std::vector<double> m_vecWidth; | | std::vector<double> m_vecWidth; | |
| | | | |
| EPdfFontType m_eFontType; | | EPdfFontType m_eFontType; | |
| std::string m_sFontSubsetPrefix; | | std::string m_sFontSubsetPrefix; | |
| }; | | }; | |
| | | | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| // | | // | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| | | | |
| skipping to change at line 441 | | skipping to change at line 452 | |
| long PdfFontMetrics::GetUnderlinePositionMM() const | | long PdfFontMetrics::GetUnderlinePositionMM() const | |
| { | | { | |
| return static_cast<long>(this->GetUnderlinePosition() / PODOFO_CONVERS
ION_CONSTANT); | | return static_cast<long>(this->GetUnderlinePosition() / PODOFO_CONVERS
ION_CONSTANT); | |
| } | | } | |
| | | | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| // | | // | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| unsigned long PdfFontMetrics::GetStrikeOutPositionMM() const | | unsigned long PdfFontMetrics::GetStrikeOutPositionMM() const | |
| { | | { | |
|
| return static_cast<long>(this->GetStrikeOutPosition() / PODOFO_CONV
ERSION_CONSTANT); | | return static_cast<long>(this->GetStrikeOutPosition() / PODOFO_CONVERS
ION_CONSTANT); | |
| } | | } | |
| | | | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| // | | // | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| unsigned long PdfFontMetrics::GetUnderlineThicknessMM() const | | unsigned long PdfFontMetrics::GetUnderlineThicknessMM() const | |
| { | | { | |
| return static_cast<unsigned long>(this->GetUnderlineThickness() / PODOF
O_CONVERSION_CONSTANT); | | return static_cast<unsigned long>(this->GetUnderlineThickness() / PODOF
O_CONVERSION_CONSTANT); | |
| } | | } | |
| | | | |
| | | | |
| skipping to change at line 519 | | skipping to change at line 530 | |
| // | | // | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| float PdfFontMetrics::GetFontCharSpace() const | | float PdfFontMetrics::GetFontCharSpace() const | |
| { | | { | |
| return m_fFontCharSpace; | | return m_fFontCharSpace; | |
| } | | } | |
| | | | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| // | | // | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
|
| | | inline float PdfFontMetrics::GetWordSpace() const | |
| | | { | |
| | | return m_fWordSpace; | |
| | | } | |
| | | | |
| | | // ----------------------------------------------------- | |
| | | // | |
| | | // ----------------------------------------------------- | |
| const char* PdfFontMetrics::GetSubsetFontnamePrefix() const | | const char* PdfFontMetrics::GetSubsetFontnamePrefix() const | |
| { | | { | |
| return m_sFontSubsetPrefix.c_str(); | | return m_sFontSubsetPrefix.c_str(); | |
| } | | } | |
| | | | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| // | | // | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| void PdfFontMetrics::SetFontScale( float fScale ) | | void PdfFontMetrics::SetFontScale( float fScale ) | |
| { | | { | |
| | | | |
| skipping to change at line 540 | | skipping to change at line 559 | |
| } | | } | |
| | | | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| // | | // | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| void PdfFontMetrics::SetFontCharSpace( float fCharSpace ) | | void PdfFontMetrics::SetFontCharSpace( float fCharSpace ) | |
| { | | { | |
| m_fFontCharSpace = fCharSpace; | | m_fFontCharSpace = fCharSpace; | |
| } | | } | |
| | | | |
|
| | | // ----------------------------------------------------- | |
| | | // | |
| | | // ----------------------------------------------------- | |
| | | inline void PdfFontMetrics::SetWordSpace( float fWordSpace ) | |
| | | { | |
| | | m_fWordSpace = fWordSpace; | |
| | | } | |
| | | | |
| }; | | }; | |
| | | | |
| #endif // _PDF_FONT_METRICS_H_ | | #endif // _PDF_FONT_METRICS_H_ | |
| | | | |
End of changes. 6 change blocks. |
| 2 lines changed or deleted | | 29 lines changed or added | |
|
| PdfVariant.h | | PdfVariant.h | |
| | | | |
| skipping to change at line 674 | | skipping to change at line 674 | |
| | | | |
| if ( IsReal() ) | | if ( IsReal() ) | |
| return m_Data.dNumber; | | return m_Data.dNumber; | |
| else | | else | |
| return static_cast<double>(m_Data.nNumber); | | return static_cast<double>(m_Data.nNumber); | |
| } | | } | |
| | | | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| // | | // | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
|
| | | #ifdef __GNUC__ | |
| | | #pragma GCC diagnostic push | |
| | | #pragma GCC diagnostic ignored "-Wold-style-cast" | |
| | | #endif // __GNUC__ | |
| const PdfData & PdfVariant::GetRawData() const | | const PdfData & PdfVariant::GetRawData() const | |
| { | | { | |
| DelayedLoad(); | | DelayedLoad(); | |
| | | | |
| if( !IsRawData() ) | | if( !IsRawData() ) | |
| { | | { | |
| PODOFO_RAISE_ERROR( ePdfError_InvalidDataType ); | | PODOFO_RAISE_ERROR( ePdfError_InvalidDataType ); | |
| } | | } | |
|
| return *(reinterpret_cast<PdfData* const>(m_Data.pData)); | | // Do not change this to an reinterpret_cast | |
| } | | // We need a c-style casts here to avoid crashes | |
| | | // because a reinterpret_cast might point to a different position. | |
| | | return *((PdfData*)m_Data.pData); | |
| | | } | |
| | | #ifdef __GNUC__ | |
| | | #pragma GCC diagnostic pop | |
| | | #endif // __GNUC__ | |
| | | | |
| PdfData & PdfVariant::GetRawData() | | PdfData & PdfVariant::GetRawData() | |
| { | | { | |
| DelayedLoad(); | | DelayedLoad(); | |
| | | | |
| if( !IsRawData() ) | | if( !IsRawData() ) | |
| { | | { | |
| PODOFO_RAISE_ERROR( ePdfError_InvalidDataType ); | | PODOFO_RAISE_ERROR( ePdfError_InvalidDataType ); | |
| } | | } | |
|
| return *(reinterpret_cast<PdfData* const>(m_Data.pData)); | | // Do not change this to an reinterpret_cast | |
| | | // We need a c-style casts here to avoid crashes | |
| | | // because a reinterpret_cast might point to a different position. | |
| | | return *((PdfData*)m_Data.pData); | |
| } | | } | |
| | | | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| // | | // | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| const PdfString & PdfVariant::GetString() const | | const PdfString & PdfVariant::GetString() const | |
| { | | { | |
| DelayedLoad(); | | DelayedLoad(); | |
| | | | |
| if( !IsString() && !IsHexString() ) | | if( !IsString() && !IsHexString() ) | |
| { | | { | |
| PODOFO_RAISE_ERROR( ePdfError_InvalidDataType ); | | PODOFO_RAISE_ERROR( ePdfError_InvalidDataType ); | |
| } | | } | |
|
| | | // Do not change this to an reinterpret_cast | |
| return *(reinterpret_cast<PdfString* const>(m_Data.pData)); | | // We need a c-style casts here to avoid crashes | |
| | | // because a reinterpret_cast might point to a different position. | |
| | | return *((PdfString*)m_Data.pData); | |
| } | | } | |
| | | | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| // | | // | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| const PdfName & PdfVariant::GetName() const | | const PdfName & PdfVariant::GetName() const | |
| { | | { | |
| DelayedLoad(); | | DelayedLoad(); | |
| | | | |
| if( !IsName() ) | | if( !IsName() ) | |
| { | | { | |
| PODOFO_RAISE_ERROR( ePdfError_InvalidDataType ); | | PODOFO_RAISE_ERROR( ePdfError_InvalidDataType ); | |
| } | | } | |
| | | | |
|
| return *(reinterpret_cast<PdfName*>(m_Data.pData)); | | // Do not change this to an reinterpret_cast | |
| | | // We need a c-style casts here to avoid crashes | |
| | | // because a reinterpret_cast might point to a different position. | |
| | | return *((PdfName*)m_Data.pData); | |
| } | | } | |
| | | | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| // | | // | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| const PdfArray & PdfVariant::GetArray() const | | const PdfArray & PdfVariant::GetArray() const | |
| { | | { | |
| DelayedLoad(); | | DelayedLoad(); | |
| return GetArray_NoDL(); | | return GetArray_NoDL(); | |
| } | | } | |
| | | | |
| skipping to change at line 748 | | skipping to change at line 766 | |
| const PdfArray & PdfVariant::GetArray_NoDL() const | | const PdfArray & PdfVariant::GetArray_NoDL() const | |
| { | | { | |
| // Test against eDataType directly not GetDataType() since | | // Test against eDataType directly not GetDataType() since | |
| // we don't want to trigger a delayed load (and if required one has | | // we don't want to trigger a delayed load (and if required one has | |
| // already been triggered). | | // already been triggered). | |
| if( m_eDataType != ePdfDataType_Array ) | | if( m_eDataType != ePdfDataType_Array ) | |
| { | | { | |
| PODOFO_RAISE_ERROR( ePdfError_InvalidDataType ); | | PODOFO_RAISE_ERROR( ePdfError_InvalidDataType ); | |
| } | | } | |
| | | | |
|
| return *(reinterpret_cast<PdfArray* const>(m_Data.pData)); | | // Do not change this to an reinterpret_cast | |
| | | // We need a c-style casts here to avoid crashes | |
| | | // because a reinterpret_cast might point to a different position. | |
| | | return *((PdfArray*)m_Data.pData); | |
| } | | } | |
| | | | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| // | | // | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| PdfArray & PdfVariant::GetArray() | | PdfArray & PdfVariant::GetArray() | |
| { | | { | |
| DelayedLoad(); | | DelayedLoad(); | |
| return GetArray_NoDL(); | | return GetArray_NoDL(); | |
| } | | } | |
| | | | |
| skipping to change at line 772 | | skipping to change at line 793 | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| PdfArray & PdfVariant::GetArray_NoDL() | | PdfArray & PdfVariant::GetArray_NoDL() | |
| { | | { | |
| // Test against eDataType directly not GetDataType() since | | // Test against eDataType directly not GetDataType() since | |
| // we don't want to trigger a delayed load (and if required one has | | // we don't want to trigger a delayed load (and if required one has | |
| // already been triggered). | | // already been triggered). | |
| if( m_eDataType != ePdfDataType_Array ) | | if( m_eDataType != ePdfDataType_Array ) | |
| { | | { | |
| PODOFO_RAISE_ERROR( ePdfError_InvalidDataType ); | | PODOFO_RAISE_ERROR( ePdfError_InvalidDataType ); | |
| } | | } | |
|
| return *(reinterpret_cast<PdfArray* const>(m_Data.pData)); | | | |
| | | // Do not change this to an reinterpret_cast | |
| | | // We need a c-style casts here to avoid crashes | |
| | | // because a reinterpret_cast might point to a different position. | |
| | | return *((PdfArray*)m_Data.pData); | |
| } | | } | |
| | | | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| // | | // | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| const PdfDictionary & PdfVariant::GetDictionary() const | | const PdfDictionary & PdfVariant::GetDictionary() const | |
| { | | { | |
| DelayedLoad(); | | DelayedLoad(); | |
| return GetDictionary_NoDL(); | | return GetDictionary_NoDL(); | |
| } | | } | |
| | | | |
| skipping to change at line 797 | | skipping to change at line 822 | |
| const PdfDictionary & PdfVariant::GetDictionary_NoDL() const | | const PdfDictionary & PdfVariant::GetDictionary_NoDL() const | |
| { | | { | |
| // Test against eDataType directly not GetDataType() since | | // Test against eDataType directly not GetDataType() since | |
| // we don't want to trigger a delayed load (and if required one has | | // we don't want to trigger a delayed load (and if required one has | |
| // already been triggered). | | // already been triggered). | |
| if( m_eDataType != ePdfDataType_Dictionary ) | | if( m_eDataType != ePdfDataType_Dictionary ) | |
| { | | { | |
| PODOFO_RAISE_ERROR( ePdfError_InvalidDataType ); | | PODOFO_RAISE_ERROR( ePdfError_InvalidDataType ); | |
| } | | } | |
| | | | |
|
| return *(reinterpret_cast<PdfDictionary* const>(m_Data.pData)); | | // Do not change this to an reinterpret_cast | |
| | | // We need a c-style casts here to avoid crashes | |
| | | // because a reinterpret_cast might point to a different position. | |
| | | return *((PdfDictionary*)m_Data.pData); | |
| } | | } | |
| | | | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| // | | // | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| PdfDictionary & PdfVariant::GetDictionary() | | PdfDictionary & PdfVariant::GetDictionary() | |
| { | | { | |
| DelayedLoad(); | | DelayedLoad(); | |
| return GetDictionary_NoDL(); | | return GetDictionary_NoDL(); | |
| } | | } | |
| | | | |
| skipping to change at line 822 | | skipping to change at line 850 | |
| PdfDictionary & PdfVariant::GetDictionary_NoDL() | | PdfDictionary & PdfVariant::GetDictionary_NoDL() | |
| { | | { | |
| // Test against eDataType directly not GetDataType() since | | // Test against eDataType directly not GetDataType() since | |
| // we don't want to trigger a delayed load (and if required one has | | // we don't want to trigger a delayed load (and if required one has | |
| // already been triggered). | | // already been triggered). | |
| if( m_eDataType != ePdfDataType_Dictionary ) | | if( m_eDataType != ePdfDataType_Dictionary ) | |
| { | | { | |
| PODOFO_RAISE_ERROR( ePdfError_InvalidDataType ); | | PODOFO_RAISE_ERROR( ePdfError_InvalidDataType ); | |
| } | | } | |
| | | | |
|
| return *(reinterpret_cast<PdfDictionary* const>(m_Data.pData)); | | // Do not change this to an reinterpret_cast | |
| | | // We need a c-style casts here to avoid crashes | |
| | | // because a reinterpret_cast might point to a different position. | |
| | | return *((PdfDictionary*)m_Data.pData); | |
| } | | } | |
| | | | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| // | | // | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| const PdfReference & PdfVariant::GetReference() const | | const PdfReference & PdfVariant::GetReference() const | |
| { | | { | |
| DelayedLoad(); | | DelayedLoad(); | |
| | | | |
| if( !IsReference() ) | | if( !IsReference() ) | |
| { | | { | |
| PODOFO_RAISE_ERROR( ePdfError_InvalidDataType ); | | PODOFO_RAISE_ERROR( ePdfError_InvalidDataType ); | |
| } | | } | |
| | | | |
|
| return *(reinterpret_cast<PdfReference* const>(m_Data.pData)); | | // Do not change this to an reinterpret_cast | |
| | | // We need a c-style casts here to avoid crashes | |
| | | // because a reinterpret_cast might point to a different position. | |
| | | return *((PdfReference*)m_Data.pData); | |
| } | | } | |
| | | | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| // | | // | |
| // ----------------------------------------------------- | | // ----------------------------------------------------- | |
| bool PdfVariant::DelayedLoadDone() const | | bool PdfVariant::DelayedLoadDone() const | |
| { | | { | |
| return m_bDelayedLoadDone; | | return m_bDelayedLoadDone; | |
| } | | } | |
| | | | |
| | | | |
End of changes. 10 change blocks. |
| 11 lines changed or deleted | | 45 lines changed or added | |
|