diff options
Diffstat (limited to 'include/qpdf')
-rw-r--r-- | include/qpdf/Buffer.hh | 10 | ||||
-rw-r--r-- | include/qpdf/Pipeline.hh | 7 | ||||
-rw-r--r-- | include/qpdf/Pl_Buffer.hh | 7 | ||||
-rw-r--r-- | include/qpdf/Pl_Count.hh | 9 | ||||
-rw-r--r-- | include/qpdf/Pl_Discard.hh | 6 | ||||
-rw-r--r-- | include/qpdf/Pl_Flate.hh | 6 | ||||
-rw-r--r-- | include/qpdf/Pl_StdioFile.hh | 6 | ||||
-rw-r--r-- | include/qpdf/QPDF.hh | 45 | ||||
-rw-r--r-- | include/qpdf/QPDFExc.hh | 9 | ||||
-rw-r--r-- | include/qpdf/QPDFObject.hh | 2 | ||||
-rw-r--r-- | include/qpdf/QPDFObjectHandle.hh | 50 | ||||
-rw-r--r-- | include/qpdf/QPDFTokenizer.hh | 8 | ||||
-rw-r--r-- | include/qpdf/QPDFWriter.hh | 22 | ||||
-rw-r--r-- | include/qpdf/QPDFXRefEntry.hh | 8 |
14 files changed, 181 insertions, 14 deletions
diff --git a/include/qpdf/Buffer.hh b/include/qpdf/Buffer.hh index 36f673ce..bcc210c4 100644 --- a/include/qpdf/Buffer.hh +++ b/include/qpdf/Buffer.hh @@ -10,16 +10,24 @@ #include <qpdf/DLL.h> -class DLL_EXPORT Buffer +class Buffer { public: + DLL_EXPORT Buffer(); + DLL_EXPORT Buffer(unsigned long size); + DLL_EXPORT Buffer(Buffer const&); + DLL_EXPORT Buffer& operator=(Buffer const&); + DLL_EXPORT ~Buffer(); + DLL_EXPORT unsigned long getSize() const; + DLL_EXPORT unsigned char const* getBuffer() const; + DLL_EXPORT unsigned char* getBuffer(); private: diff --git a/include/qpdf/Pipeline.hh b/include/qpdf/Pipeline.hh index aefb1b0b..7e248c1c 100644 --- a/include/qpdf/Pipeline.hh +++ b/include/qpdf/Pipeline.hh @@ -33,20 +33,25 @@ #include <qpdf/DLL.h> #include <string> -class DLL_EXPORT Pipeline +class Pipeline { public: + DLL_EXPORT Pipeline(char const* identifier, Pipeline* next); + DLL_EXPORT virtual ~Pipeline(); // Subclasses should implement write and finish to do their jobs // and then, if they are not end-of-line pipelines, call // getNext()->write or getNext()->finish. + DLL_EXPORT virtual void write(unsigned char* data, int len) = 0; + DLL_EXPORT virtual void finish() = 0; protected: + DLL_EXPORT Pipeline* getNext(bool allow_null = false); std::string identifier; diff --git a/include/qpdf/Pl_Buffer.hh b/include/qpdf/Pl_Buffer.hh index de376d1e..1e0bd8ac 100644 --- a/include/qpdf/Pl_Buffer.hh +++ b/include/qpdf/Pl_Buffer.hh @@ -24,17 +24,22 @@ #include <qpdf/Buffer.hh> #include <list> -class DLL_EXPORT Pl_Buffer: public Pipeline +class Pl_Buffer: public Pipeline { public: + DLL_EXPORT Pl_Buffer(char const* identifier, Pipeline* next = 0); + DLL_EXPORT virtual ~Pl_Buffer(); + DLL_EXPORT virtual void write(unsigned char*, int); + DLL_EXPORT virtual void finish(); // Each call to getBuffer() resets this object -- see notes above. // The caller is responsible for deleting the returned Buffer // object. + DLL_EXPORT Buffer* getBuffer(); private: diff --git a/include/qpdf/Pl_Count.hh b/include/qpdf/Pl_Count.hh index 0539bcbd..09b9dffa 100644 --- a/include/qpdf/Pl_Count.hh +++ b/include/qpdf/Pl_Count.hh @@ -13,17 +13,24 @@ #include <qpdf/Pipeline.hh> -class DLL_EXPORT Pl_Count: public Pipeline +class Pl_Count: public Pipeline { public: + DLL_EXPORT Pl_Count(char const* identifier, Pipeline* next); + DLL_EXPORT virtual ~Pl_Count(); + DLL_EXPORT virtual void write(unsigned char*, int); + DLL_EXPORT virtual void finish(); + DLL_EXPORT // Returns the number of bytes written + DLL_EXPORT int getCount() const; // Returns the last character written, or '\0' if no characters // have been written (in which case getCount() returns 0) + DLL_EXPORT unsigned char getLastChar() const; private: diff --git a/include/qpdf/Pl_Discard.hh b/include/qpdf/Pl_Discard.hh index 7565744e..f99112b2 100644 --- a/include/qpdf/Pl_Discard.hh +++ b/include/qpdf/Pl_Discard.hh @@ -16,12 +16,16 @@ #include <qpdf/Pipeline.hh> -class DLL_EXPORT Pl_Discard: public Pipeline +class Pl_Discard: public Pipeline { public: + DLL_EXPORT Pl_Discard(); + DLL_EXPORT virtual ~Pl_Discard(); + DLL_EXPORT virtual void write(unsigned char*, int); + DLL_EXPORT virtual void finish(); }; diff --git a/include/qpdf/Pl_Flate.hh b/include/qpdf/Pl_Flate.hh index 6cbd148f..286d80e8 100644 --- a/include/qpdf/Pl_Flate.hh +++ b/include/qpdf/Pl_Flate.hh @@ -12,18 +12,22 @@ #include <zlib.h> -class DLL_EXPORT Pl_Flate: public Pipeline +class Pl_Flate: public Pipeline { public: static int const def_bufsize = 65536; enum action_e { a_inflate, a_deflate }; + DLL_EXPORT Pl_Flate(char const* identifier, Pipeline* next, action_e action, int out_bufsize = def_bufsize); + DLL_EXPORT virtual ~Pl_Flate(); + DLL_EXPORT virtual void write(unsigned char* data, int len); + DLL_EXPORT virtual void finish(); private: diff --git a/include/qpdf/Pl_StdioFile.hh b/include/qpdf/Pl_StdioFile.hh index 2b60e664..3bb9f257 100644 --- a/include/qpdf/Pl_StdioFile.hh +++ b/include/qpdf/Pl_StdioFile.hh @@ -18,15 +18,19 @@ // This pipeline is reusable. // -class DLL_EXPORT Pl_StdioFile: public Pipeline +class Pl_StdioFile: public Pipeline { public: // f is externally maintained; this class just writes to and // flushes it. It does not close it. + DLL_EXPORT Pl_StdioFile(char const* identifier, FILE* f); + DLL_EXPORT virtual ~Pl_StdioFile(); + DLL_EXPORT virtual void write(unsigned char* buf, int len); + DLL_EXPORT virtual void finish(); private: diff --git a/include/qpdf/QPDF.hh b/include/qpdf/QPDF.hh index 3f66a5f9..5cbbe652 100644 --- a/include/qpdf/QPDF.hh +++ b/include/qpdf/QPDF.hh @@ -25,10 +25,12 @@ class BitStream; class BitWriter; class QPDFExc; -class DLL_EXPORT QPDF +class QPDF { public: + DLL_EXPORT QPDF(); + DLL_EXPORT ~QPDF(); // Associate a file with a QPDF object and do initial parsing of @@ -41,6 +43,7 @@ class DLL_EXPORT QPDF // encrypted,either a null password or an empty password can be // used. If the file is encrypted, either the user password or // the owner password may be supplied. + DLL_EXPORT void processFile(char const* filename, char const* password = 0); // Parameter settings @@ -49,18 +52,21 @@ class DLL_EXPORT QPDF // (one that contains both cross-reference streams and // cross-reference tables). This can be useful for testing to // ensure that a hybrid file would work with an older reader. + DLL_EXPORT void setIgnoreXRefStreams(bool); // By default, any warnings are issued to stderr as they are // encountered. If this is called with a true value, reporting of // warnings is suppressed. You may still retrieve warnings by // calling getWarnings. + DLL_EXPORT void setSuppressWarnings(bool); // By default, QPDF will try to recover if it finds certain types // of errors in PDF files. If turned off, it will throw an // exception on the first such problem it finds without attempting // recovery. + DLL_EXPORT void setAttemptRecovery(bool); // Other public methods @@ -70,19 +76,26 @@ class DLL_EXPORT QPDF // throws an exception. Note that if setSuppressWarnings was not // called or was called with a false value, any warnings retrieved // here will have already been issued to stderr. + DLL_EXPORT std::vector<QPDFExc> getWarnings(); + DLL_EXPORT std::string getFilename() const; + DLL_EXPORT std::string getPDFVersion() const; + DLL_EXPORT QPDFObjectHandle getTrailer(); + DLL_EXPORT QPDFObjectHandle getRoot(); // Install this object handle as an indirect object and return an // indirect reference to it. + DLL_EXPORT QPDFObjectHandle makeIndirectObject(QPDFObjectHandle); // Retrieve an object by object ID and generation. Returns an // indirect reference to it. + DLL_EXPORT QPDFObjectHandle getObjectByID(int objid, int generation); // Encryption support @@ -115,31 +128,46 @@ class DLL_EXPORT QPDF bool encrypt_metadata; }; + DLL_EXPORT bool isEncrypted() const; + DLL_EXPORT bool isEncrypted(int& R, int& P); // Encryption permissions -- not enforced by QPDF + DLL_EXPORT bool allowAccessibility(); + DLL_EXPORT bool allowExtractAll(); + DLL_EXPORT bool allowPrintLowRes(); + DLL_EXPORT bool allowPrintHighRes(); + DLL_EXPORT bool allowModifyAssembly(); + DLL_EXPORT bool allowModifyForm(); + DLL_EXPORT bool allowModifyAnnotation(); + DLL_EXPORT bool allowModifyOther(); + DLL_EXPORT bool allowModifyAll(); // Helper function to trim padding from user password. Calling // trim_user_password on the result of getPaddedUserPassword gives // getTrimmedUserPassword's result. + DLL_EXPORT static void trim_user_password(std::string& user_password); + DLL_EXPORT static std::string compute_data_key( std::string const& encryption_key, int objid, int generation, bool use_aes); + DLL_EXPORT static std::string compute_encryption_key( std::string const& password, EncryptionData const& data); + DLL_EXPORT static void compute_encryption_O_U( char const* user_password, char const* owner_password, int V, int R, int key_len, int P, bool encrypt_metadata, @@ -148,19 +176,23 @@ class DLL_EXPORT QPDF // Return the full user password as stored in the PDF file. If // you are attempting to recover the user password in a // user-presentable form, call getTrimmedUserPassword() instead. + DLL_EXPORT std::string const& getPaddedUserPassword() const; // Return human-readable form of user password. + DLL_EXPORT std::string getTrimmedUserPassword() const; // Linearization support // Returns true iff the file starts with a linearization parameter // dictionary. Does no additional validation. + DLL_EXPORT bool isLinearized(); // Performs various sanity checks on a linearized file. Return // true if no errors or warnings. Otherwise, return false and // output errors and warnings to stdout. + DLL_EXPORT bool checkLinearization(); // Calls checkLinearization() and, if possible, prints normalized @@ -168,9 +200,11 @@ class DLL_EXPORT QPDF // includes adding min values to delta values and adjusting // offsets based on the location and size of the primary hint // stream. + DLL_EXPORT void showLinearizationData(); // Shows the contents of the cross-reference table + DLL_EXPORT void showXRefTable(); // Optimization support -- see doc/optimization. Implemented in @@ -184,26 +218,31 @@ class DLL_EXPORT QPDF // This is available so that the test suite can make sure that a // linearized file is already optimized. When called in this way, // optimize() still populates the object <-> user maps + DLL_EXPORT void optimize(std::map<int, int> const& object_stream_data, bool allow_changes = true); // Replace all references to indirect objects that are "scalars" // (i.e., things that don't have children: not arrays, streams, or // dictionaries) with direct objects. + DLL_EXPORT void flattenScalarReferences(); // Decode all streams, discarding the output. Used to check // correctness of stream encoding. + DLL_EXPORT void decodeStreams(); // For QPDFWriter: // Remove /ID, /Encrypt, and /Prev keys from the trailer // dictionary since these are regenerated during write. + DLL_EXPORT void trimTrailerForWrite(); // Get lists of all objects in order according to the part of a // linearized file that they belong to. + DLL_EXPORT void getLinearizedParts( std::map<int, int> const& object_stream_data, std::vector<QPDFObjectHandle>& part4, @@ -212,6 +251,7 @@ class DLL_EXPORT QPDF std::vector<QPDFObjectHandle>& part8, std::vector<QPDFObjectHandle>& part9); + DLL_EXPORT void generateHintStream(std::map<int, QPDFXRefEntry> const& xref, std::map<int, size_t> const& lengths, std::map<int, int> const& obj_renumber, @@ -219,15 +259,18 @@ class DLL_EXPORT QPDF int& S, int& O); // Map object to object stream that contains it + DLL_EXPORT void getObjectStreamData(std::map<int, int>&); // Get a list of objects that would be permitted in an object // stream + DLL_EXPORT std::vector<int> getCompressibleObjects(); // Convenience routines for common functions. See also // QPDFObjectHandle.hh for additional convenience routines. // Traverse page tree return all /Page objects. + DLL_EXPORT std::vector<QPDFObjectHandle> const& getAllPages(); // Resolver class is restricted to QPDFObjectHandle so that only diff --git a/include/qpdf/QPDFExc.hh b/include/qpdf/QPDFExc.hh index 968cd049..8fa7fedc 100644 --- a/include/qpdf/QPDFExc.hh +++ b/include/qpdf/QPDFExc.hh @@ -12,14 +12,16 @@ #include <qpdf/Constants.h> #include <stdexcept> -class DLL_EXPORT QPDFExc: public std::runtime_error +class QPDFExc: public std::runtime_error { public: + DLL_EXPORT QPDFExc(qpdf_error_code_e error_code, std::string const& filename, std::string const& object, off_t offset, std::string const& message); + DLL_EXPORT virtual ~QPDFExc() throw (); // To get a complete error string, call what(), provided by @@ -32,10 +34,15 @@ class DLL_EXPORT QPDFExc: public std::runtime_error // the underlying issue, but it is more programmer-friendly than // trying to parse a string that is subject to change. + DLL_EXPORT qpdf_error_code_e getErrorCode() const; + DLL_EXPORT std::string const& getFilename() const; + DLL_EXPORT std::string const& getObject() const; + DLL_EXPORT off_t getFilePosition() const; + DLL_EXPORT std::string const& getMessageDetail() const; private: diff --git a/include/qpdf/QPDFObject.hh b/include/qpdf/QPDFObject.hh index ff31f9a9..0872caa1 100644 --- a/include/qpdf/QPDFObject.hh +++ b/include/qpdf/QPDFObject.hh @@ -12,7 +12,7 @@ #include <string> -class DLL_EXPORT QPDFObject +class QPDFObject { public: virtual ~QPDFObject() {} diff --git a/include/qpdf/QPDFObjectHandle.hh b/include/qpdf/QPDFObjectHandle.hh index 0948fefe..6fc9e5aa 100644 --- a/include/qpdf/QPDFObjectHandle.hh +++ b/include/qpdf/QPDFObjectHandle.hh @@ -23,40 +23,61 @@ class Pipeline; class QPDF; -class DLL_EXPORT QPDFObjectHandle +class QPDFObjectHandle { public: + DLL_EXPORT QPDFObjectHandle(); + DLL_EXPORT bool isInitialized() const; // Exactly one of these will return true for any object. + DLL_EXPORT bool isBool(); + DLL_EXPORT bool isNull(); + DLL_EXPORT bool isInteger(); + DLL_EXPORT bool isReal(); + DLL_EXPORT bool isName(); + DLL_EXPORT bool isString(); + DLL_EXPORT bool isArray(); + DLL_EXPORT bool isDictionary(); + DLL_EXPORT bool isStream(); // This returns true in addition to the query for the specific // type for indirect objects. + DLL_EXPORT bool isIndirect(); // True for everything except array, dictionary, and stream + DLL_EXPORT bool isScalar(); // Public factory methods + DLL_EXPORT static QPDFObjectHandle newNull(); + DLL_EXPORT static QPDFObjectHandle newBool(bool value); + DLL_EXPORT static QPDFObjectHandle newInteger(int value); + DLL_EXPORT static QPDFObjectHandle newReal(std::string const& value); + DLL_EXPORT static QPDFObjectHandle newName(std::string const& name); + DLL_EXPORT static QPDFObjectHandle newString(std::string const& str); + DLL_EXPORT static QPDFObjectHandle newArray( std::vector<QPDFObjectHandle> const& items); + DLL_EXPORT static QPDFObjectHandle newDictionary( std::map<std::string, QPDFObjectHandle> const& items); @@ -65,58 +86,78 @@ class DLL_EXPORT QPDFObjectHandle // type, an exception is thrown. // Methods for bool objects + DLL_EXPORT bool getBoolValue(); // Methods for integer objects + DLL_EXPORT int getIntValue(); // Methods for real objects + DLL_EXPORT std::string getRealValue(); // Methods that work for both integer and real objects + DLL_EXPORT bool isNumber(); + DLL_EXPORT double getNumericValue(); // Methods for name objects; see also name and array objects + DLL_EXPORT std::string getName(); // Methods for string objects + DLL_EXPORT std::string getStringValue(); + DLL_EXPORT std::string getUTF8Value(); // Methods for array objects; see also name and array objects + DLL_EXPORT int getArrayNItems(); + DLL_EXPORT QPDFObjectHandle getArrayItem(int n); // Methods for dictionary objects + DLL_EXPORT bool hasKey(std::string const&); + DLL_EXPORT QPDFObjectHandle getKey(std::string const&); + DLL_EXPORT std::set<std::string> getKeys(); // Methods for name and array objects + DLL_EXPORT bool isOrHasName(std::string const&); // Mutator methods. Use with caution. // Recursively copy this object, making it direct. Throws an // exception if a loop is detected or any sub-object is a stream. + DLL_EXPORT void makeDirect(); // Mutator methods for array objects + DLL_EXPORT void setArrayItem(int, QPDFObjectHandle const&); // Mutator methods for dictionary objects // Replace value of key, adding it if it does not exist + DLL_EXPORT void replaceKey(std::string const& key, QPDFObjectHandle const&); // Remove key, doing nothing if key does not exist + DLL_EXPORT void removeKey(std::string const& key); // Methods for stream objects + DLL_EXPORT QPDFObjectHandle getDict(); // Returns filtered (uncompressed) stream data. Throws an // exception if the stream is filtered and we can't decode it. + DLL_EXPORT PointerHolder<Buffer> getStreamData(); // Write stream data through the given pipeline. A null pipeline @@ -136,14 +177,19 @@ class DLL_EXPORT QPDFObjectHandle // value of this function to determine whether or not the /Filter // and /DecodeParms keys in the stream dictionary should be // replaced if writing a new stream object. + DLL_EXPORT bool pipeStreamData(Pipeline*, bool filter, bool normalize, bool compress); // return 0 for direct objects + DLL_EXPORT int getObjectID() const; + DLL_EXPORT int getGeneration() const; + DLL_EXPORT std::string unparse(); + DLL_EXPORT std::string unparseResolved(); // Convenience routines for commonly performed functions @@ -153,6 +199,7 @@ class DLL_EXPORT QPDFObjectHandle // function does not presently support inherited resources. See // comment in the source for details. Return value is a map from // XObject name to the image object, which is always a stream. + DLL_EXPORT std::map<std::string, QPDFObjectHandle> getPageImages(); // Throws an exception if this is not a Page object. Returns a @@ -160,6 +207,7 @@ class DLL_EXPORT QPDFObjectHandle // the given page. This routine allows the caller to not care // whether there are one or more than one content streams for a // page. + DLL_EXPORT std::vector<QPDFObjectHandle> getPageContents(); // Initializers for objects. This Factory class gives the QPDF diff --git a/include/qpdf/QPDFTokenizer.hh b/include/qpdf/QPDFTokenizer.hh index a48a78d6..b93df068 100644 --- a/include/qpdf/QPDFTokenizer.hh +++ b/include/qpdf/QPDFTokenizer.hh @@ -13,7 +13,7 @@ #include <string> #include <stdio.h> -class DLL_EXPORT QPDFTokenizer +class QPDFTokenizer { public: enum token_type_e @@ -84,6 +84,7 @@ class DLL_EXPORT QPDFTokenizer std::string error_message; }; + DLL_EXPORT QPDFTokenizer(); // PDF files with version < 1.2 allowed the pound character @@ -91,6 +92,7 @@ class DLL_EXPORT QPDFTokenizer // character was allowed only when followed by two hexadecimal // digits. This method should be called when parsing a PDF file // whose version is older than 1.2. + DLL_EXPORT void allowPoundAnywhereInName(); // Mode of operation: @@ -101,19 +103,23 @@ class DLL_EXPORT QPDFTokenizer // It these are called when a token is available, an exception // will be thrown. + DLL_EXPORT void presentCharacter(char ch); + DLL_EXPORT void presentEOF(); // If a token is available, return true and initialize token with // the token, unread_char with whether or not we have to unread // the last character, and if unread_char, ch with the character // to unread. + DLL_EXPORT bool getToken(Token& token, bool& unread_char, char& ch); // This function returns true of the current character is between // tokens (i.e., white space that is not part of a string) or is // part of a comment. A tokenizing filter can call this to // determine whether to output the character. + DLL_EXPORT bool betweenTokens(); private: diff --git a/include/qpdf/QPDFWriter.hh b/include/qpdf/QPDFWriter.hh index 15e9317b..651c8f61 100644 --- a/include/qpdf/QPDFWriter.hh +++ b/include/qpdf/QPDFWriter.hh @@ -32,7 +32,7 @@ class QPDF; class QPDFObjectHandle; class Pl_Count; -class DLL_EXPORT QPDFWriter +class QPDFWriter { public: // Passing null as filename means write to stdout. QPDFWriter @@ -42,7 +42,9 @@ class DLL_EXPORT QPDFWriter // useful for tracking down problems. If your application doesn't // want the partially written file to be left behind, you should // delete it the eventual call to write fails. + DLL_EXPORT QPDFWriter(QPDF& pdf, char const* filename); + DLL_EXPORT ~QPDFWriter(); // Set the value of object stream mode. In disable mode, we never @@ -52,6 +54,7 @@ class DLL_EXPORT QPDFWriter // generate a conventional cross-reference table if there are no // object streams and a cross-reference stream if there are object // streams. The default is o_preserve. + DLL_EXPORT void setObjectStreamMode(qpdf_object_stream_e); // Set value of stream data mode. In uncompress mode, we attempt @@ -59,6 +62,7 @@ class DLL_EXPORT QPDFWriter // preserve any filtering applied to streams. In compress mode, // if we can apply all filters and the stream is not already // optimally compressed, recompress the stream. + DLL_EXPORT void setStreamDataMode(qpdf_stream_data_e); // Set value of content stream normalization. The default is @@ -68,6 +72,7 @@ class DLL_EXPORT QPDFWriter // damage the content stream. This flag should be used only for // debugging and experimenting with PDF content streams. Never // use it for production files. + DLL_EXPORT void setContentNormalization(bool); // Set QDF mode. QDF mode causes special "pretty printing" of @@ -75,6 +80,7 @@ class DLL_EXPORT QPDFWriter // Resulting PDF files can be edited in a text editor and then run // through fix-qdf to update cross reference tables and stream // lengths. + DLL_EXPORT void setQDFMode(bool); // Set the minimum PDF version. If the PDF version of the input @@ -86,6 +92,7 @@ class DLL_EXPORT QPDFWriter // QPDFWriter automatically sets the minimum version to 1.4 when // R3 encryption parameters are used, and to 1.5 when object // streams are used. + DLL_EXPORT void setMinimumPDFVersion(std::string const&); // Force the PDF version of the output file to be a given version. @@ -103,27 +110,32 @@ class DLL_EXPORT QPDFWriter // that type of encryption will explicitly disable decryption. // Additionally, forcing to a version below 1.5 will disable // object streams. + DLL_EXPORT void forcePDFVersion(std::string const&); // Cause a static /ID value to be generated. Use only in test // suites. + DLL_EXPORT void setStaticID(bool); // Use a fixed initialization vector for AES-CBC encryption. This // is not secure. It should be used only in test suites for // creating predictable encrypted output. + DLL_EXPORT void setStaticAesIV(bool); // Suppress inclusion of comments indicating original object IDs // when writing QDF files. This can also be useful for testing, // particularly when using comparison of two qdf files to // determine whether two PDF files have identical content. + DLL_EXPORT void setSuppressOriginalObjectIDs(bool); // Preserve encryption. The default is true unless prefilering, // content normalization, or qdf mode has been selected in which // case encryption is never preserved. Encryption is also not // preserved if we explicitly set encryption parameters. + DLL_EXPORT void setPreserveEncryption(bool); // Set up for encrypted output. Disables stream prefiltering and @@ -132,14 +144,17 @@ class DLL_EXPORT QPDFWriter // encryption parameters pushes the PDF version number to at least // 1.4, and setting R4 parameters pushes the version to at least // 1.5, or if AES is used, 1.6. + DLL_EXPORT void setR2EncryptionParameters( char const* user_password, char const* owner_password, bool allow_print, bool allow_modify, bool allow_extract, bool allow_annotate); + DLL_EXPORT void setR3EncryptionParameters( char const* user_password, char const* owner_password, bool allow_accessibility, bool allow_extract, qpdf_r3_print_e print, qpdf_r3_modify_e modify); + DLL_EXPORT void setR4EncryptionParameters( char const* user_password, char const* owner_password, bool allow_accessibility, bool allow_extract, @@ -148,11 +163,16 @@ class DLL_EXPORT QPDFWriter // Create linearized output. Disables qdf mode, content // normalization, and stream prefiltering. + DLL_EXPORT void setLinearization(bool); + DLL_EXPORT void write(); private: + QPDFWriter(QPDFWriter const&); + QPDFWriter& operator=(QPDFWriter const&); + // flags used by unparseObject static int const f_stream = 1 << 0; static int const f_filtered = 1 << 1; diff --git a/include/qpdf/QPDFXRefEntry.hh b/include/qpdf/QPDFXRefEntry.hh index 05a3f21e..679bae5f 100644 --- a/include/qpdf/QPDFXRefEntry.hh +++ b/include/qpdf/QPDFXRefEntry.hh @@ -10,7 +10,7 @@ #include <qpdf/DLL.h> -class DLL_EXPORT QPDFXRefEntry +class QPDFXRefEntry { public: // Type constants are from the PDF spec section @@ -19,12 +19,18 @@ class DLL_EXPORT QPDFXRefEntry // 1 = "uncompressed"; field 1 = offset // 2 = "compressed"; field 1 = object stream number, field 2 = index + DLL_EXPORT QPDFXRefEntry(); + DLL_EXPORT QPDFXRefEntry(int type, int field1, int field2); + DLL_EXPORT int getType() const; + DLL_EXPORT int getOffset() const; // only for type 1 + DLL_EXPORT int getObjStreamNumber() const; // only for type 2 + DLL_EXPORT int getObjStreamIndex() const; // only for type 2 private: |