diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/qpdf/DLL.h | 6 | ||||
-rw-r--r-- | include/qpdf/QPDFJob.hh | 27 | ||||
-rw-r--r-- | include/qpdf/QPDFWriter.hh | 89 |
3 files changed, 69 insertions, 53 deletions
diff --git a/include/qpdf/DLL.h b/include/qpdf/DLL.h index f6e17740..667a0cf5 100644 --- a/include/qpdf/DLL.h +++ b/include/qpdf/DLL.h @@ -25,9 +25,9 @@ /* The first version of qpdf to include the version constants is 10.6.0. */ #define QPDF_MAJOR_VERSION 11 -#define QPDF_MINOR_VERSION 3 -#define QPDF_PATCH_VERSION 1 -#define QPDF_VERSION "11.3.1" +#define QPDF_MINOR_VERSION 4 +#define QPDF_PATCH_VERSION 0 +#define QPDF_VERSION "11.4.0" /* * This file defines symbols that control the which functions, diff --git a/include/qpdf/QPDFJob.hh b/include/qpdf/QPDFJob.hh index 9bf81fcc..2a82d61c 100644 --- a/include/qpdf/QPDFJob.hh +++ b/include/qpdf/QPDFJob.hh @@ -397,6 +397,21 @@ class QPDFJob QPDF_DLL void run(); + // The following two methods allow a job to be run in two stages - creation + // of a QPDF object and writing of the QPDF object. This allows the QPDF + // object to be modified prior to writing it out. See + // examples/qpdfjob-remove-annotations for an illustration of its use. + + // Run the first stage of the job. Return a nullptr if the configuration is + // not valid. + QPDF_DLL + std::unique_ptr<QPDF> createQPDF(); + + // Run the second stage of the job. Do nothing if a nullptr is passed as + // parameter. + QPDF_DLL + void writeQPDF(QPDF& qpdf); + // CHECK STATUS -- these methods provide information known after // run() is called. @@ -474,7 +489,7 @@ class QPDFJob std::string to_nr; std::string from_nr; std::string repeat_nr; - std::shared_ptr<QPDF> pdf; + std::unique_ptr<QPDF> pdf; std::vector<int> to_pagenos; std::vector<int> from_pagenos; std::vector<int> repeat_pagenos; @@ -490,25 +505,25 @@ class QPDFJob // Basic file processing void processFile( - std::shared_ptr<QPDF>&, + std::unique_ptr<QPDF>&, char const* filename, char const* password, bool used_for_input, bool main_input); void processInputSource( - std::shared_ptr<QPDF>&, + std::unique_ptr<QPDF>&, std::shared_ptr<InputSource> is, char const* password, bool used_for_input); void doProcess( - std::shared_ptr<QPDF>&, + std::unique_ptr<QPDF>&, std::function<void(QPDF*, char const*)> fn, char const* password, bool empty, bool used_for_input, bool main_input); void doProcessOnce( - std::shared_ptr<QPDF>&, + std::unique_ptr<QPDF>&, std::function<void(QPDF*, char const*)> fn, char const* password, bool empty, @@ -518,7 +533,7 @@ class QPDFJob // Transformations void setQPDFOptions(QPDF& pdf); void - handlePageSpecs(QPDF& pdf, std::vector<std::shared_ptr<QPDF>>& page_heap); + handlePageSpecs(QPDF& pdf, std::vector<std::unique_ptr<QPDF>>& page_heap); bool shouldRemoveUnreferencedResources(QPDF& pdf); void handleRotations(QPDF& pdf); void diff --git a/include/qpdf/QPDFWriter.hh b/include/qpdf/QPDFWriter.hh index 464e20a0..c2896209 100644 --- a/include/qpdf/QPDFWriter.hh +++ b/include/qpdf/QPDFWriter.hh @@ -709,70 +709,71 @@ class QPDFWriter Members(Members const&) = delete; QPDF& pdf; - char const* filename; - FILE* file; - bool close_file; - Pl_Buffer* buffer_pipeline; - Buffer* output_buffer; - bool normalize_content_set; - bool normalize_content; - bool compress_streams; - bool compress_streams_set; - qpdf_stream_decode_level_e stream_decode_level; - bool stream_decode_level_set; - bool recompress_flate; - bool qdf_mode; - bool preserve_unreferenced_objects; - bool newline_before_endstream; - bool static_id; - bool suppress_original_object_ids; - bool direct_stream_lengths; - bool encrypted; - bool preserve_encryption; - bool linearized; - bool pclm; - qpdf_object_stream_e object_stream_mode; + QPDFObjGen root_og{-1, 0}; + char const* filename{"unspecified"}; + FILE* file{nullptr}; + bool close_file{false}; + Pl_Buffer* buffer_pipeline{nullptr}; + Buffer* output_buffer{nullptr}; + bool normalize_content_set{false}; + bool normalize_content{false}; + bool compress_streams{true}; + bool compress_streams_set{false}; + qpdf_stream_decode_level_e stream_decode_level{qpdf_dl_none}; + bool stream_decode_level_set{false}; + bool recompress_flate{false}; + bool qdf_mode{false}; + bool preserve_unreferenced_objects{false}; + bool newline_before_endstream{false}; + bool static_id{false}; + bool suppress_original_object_ids{false}; + bool direct_stream_lengths{true}; + bool encrypted{false}; + bool preserve_encryption{true}; + bool linearized{false}; + bool pclm{false}; + qpdf_object_stream_e object_stream_mode{qpdf_o_preserve}; std::string encryption_key; - bool encrypt_metadata; - bool encrypt_use_aes; + bool encrypt_metadata{true}; + bool encrypt_use_aes{false}; std::map<std::string, std::string> encryption_dictionary; - int encryption_V; - int encryption_R; + int encryption_V{0}; + int encryption_R{0}; std::string id1; // for /ID key of std::string id2; // trailer dictionary std::string final_pdf_version; - int final_extension_level; + int final_extension_level{0}; std::string min_pdf_version; - int min_extension_level; + int min_extension_level{0}; std::string forced_pdf_version; - int forced_extension_level; + int forced_extension_level{0}; std::string extra_header_text; - int encryption_dict_objid; + int encryption_dict_objid{0}; std::string cur_data_key; std::list<std::shared_ptr<Pipeline>> to_delete; - Pl_Count* pipeline; + Pl_Count* pipeline{nullptr}; std::vector<QPDFObjectHandle> object_queue; size_t object_queue_front{0}; std::map<QPDFObjGen, int> obj_renumber; std::map<int, QPDFXRefEntry> xref; std::map<int, qpdf_offset_t> lengths; - int next_objid; - int cur_stream_length_id; - size_t cur_stream_length; - bool added_newline; - int max_ostream_index; + int next_objid{1}; + int cur_stream_length_id{0}; + size_t cur_stream_length{0}; + bool added_newline{false}; + int max_ostream_index{0}; std::set<QPDFObjGen> normalized_streams; std::map<QPDFObjGen, int> page_object_to_seq; std::map<QPDFObjGen, int> contents_to_page_seq; std::map<QPDFObjGen, int> object_to_object_stream; std::map<int, std::set<QPDFObjGen>> object_stream_to_objects; std::list<Pipeline*> pipeline_stack; - unsigned long long next_stack_id; - bool deterministic_id; - Pl_MD5* md5_pipeline; + unsigned long long next_stack_id{0}; + bool deterministic_id{false}; + Pl_MD5* md5_pipeline{nullptr}; std::string deterministic_id_data; - bool did_write_setup; + bool did_write_setup{false}; // For linearization only std::string lin_pass1_filename; @@ -781,9 +782,9 @@ class QPDFWriter // For progress reporting std::shared_ptr<ProgressReporter> progress_reporter; - int events_expected; - int events_seen; - int next_progress_report; + int events_expected{0}; + int events_seen{0}; + int next_progress_report{0}; }; // Keep all member variables inside the Members object, which we |