mirror of
https://github.com/qpdf/qpdf.git
synced 2025-01-02 22:50:20 +00:00
DLL.hh -> DLL.h, move public enumerated types into Constants.h and use them both for C and C++ interfaces
git-svn-id: svn+q:///qpdf/trunk@828 71b93d88-0707-0410-a8cf-f5a4172ac649
This commit is contained in:
parent
734ac1e1d2
commit
b67a3c15e7
@ -200,7 +200,7 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
}
|
||||
QPDFWriter w(file, fl_tmp.c_str());
|
||||
w.setStreamDataMode(QPDFWriter::s_preserve);
|
||||
w.setStreamDataMode(qpdf_s_preserve);
|
||||
w.setLinearization(true);
|
||||
w.setStaticID(static_id);
|
||||
w.write();
|
||||
|
@ -8,7 +8,7 @@
|
||||
#ifndef __BUFFER_HH__
|
||||
#define __BUFFER_HH__
|
||||
|
||||
#include <qpdf/DLL.hh>
|
||||
#include <qpdf/DLL.h>
|
||||
|
||||
class DLL_EXPORT Buffer
|
||||
{
|
||||
|
52
include/qpdf/Constants.h
Normal file
52
include/qpdf/Constants.h
Normal file
@ -0,0 +1,52 @@
|
||||
#ifndef __QPDFCONSTANTS_H__
|
||||
#define __QPDFCONSTANTS_H__
|
||||
|
||||
/* Keep this file 'C' compatible so it can be used from the C and C++
|
||||
* interfaces.
|
||||
*/
|
||||
|
||||
/* Error Codes */
|
||||
|
||||
enum qpdf_error_code_e
|
||||
{
|
||||
qpdf_e_success = 0,
|
||||
qpdf_e_internal, /* logic/programming error -- indicates bug */
|
||||
qpdf_e_system, /* I/O error, memory error, etc. */
|
||||
qpdf_e_unsupported, /* PDF feature not (yet) supported by qpdf */
|
||||
qpdf_e_password, /* incorrect password for encrypted file */
|
||||
qpdf_e_damaged_pdf /* syntax errors or other damage in PDF */
|
||||
};
|
||||
|
||||
/* Write Parameters */
|
||||
|
||||
enum qpdf_object_stream_e
|
||||
{
|
||||
qpdf_o_disable = 0, /* disable object streams */
|
||||
qpdf_o_preserve, /* preserve object streams */
|
||||
qpdf_o_generate /* generate object streams */
|
||||
};
|
||||
enum qpdf_stream_data_e
|
||||
{
|
||||
qpdf_s_uncompress = 0, /* uncompress stream data */
|
||||
qpdf_s_preserve, /* preserve stream data compression */
|
||||
qpdf_s_compress /* compress stream data */
|
||||
};
|
||||
|
||||
/* R3 Encryption Parameters */
|
||||
|
||||
enum qpdf_r3_print_e
|
||||
{
|
||||
qpdf_r3p_full = 0, /* allow all printing */
|
||||
qpdf_r3p_low, /* allow only low-resolution printing */
|
||||
qpdf_r3p_none /* allow no printing */
|
||||
};
|
||||
enum qpdf_r3_modify_e
|
||||
{
|
||||
qpdf_r3m_all = 0, /* allow all modification */
|
||||
qpdf_r3m_annotate, /* allow comment authoring and form operations */
|
||||
qpdf_r3m_form, /* allow form field fill-in or signing */
|
||||
qpdf_r3m_assembly, /* allow only document assembly */
|
||||
qpdf_r3m_none /* allow no modification */
|
||||
};
|
||||
|
||||
#endif /* __QPDFCONSTANTS_H__ */
|
@ -7,4 +7,4 @@
|
||||
# define DLL_EXPORT
|
||||
#endif
|
||||
|
||||
#endif // __QPDF_DLL_HH__
|
||||
#endif /* __QPDF_DLL_HH__ */
|
@ -30,7 +30,7 @@
|
||||
#ifndef __PIPELINE_HH__
|
||||
#define __PIPELINE_HH__
|
||||
|
||||
#include <qpdf/DLL.hh>
|
||||
#include <qpdf/DLL.h>
|
||||
#include <string>
|
||||
|
||||
class DLL_EXPORT Pipeline
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include <map>
|
||||
#include <list>
|
||||
|
||||
#include <qpdf/DLL.hh>
|
||||
#include <qpdf/DLL.h>
|
||||
|
||||
#include <qpdf/QPDFXRefEntry.hh>
|
||||
#include <qpdf/QPDFObjectHandle.hh>
|
||||
|
@ -8,7 +8,7 @@
|
||||
#ifndef __QPDFEXC_HH__
|
||||
#define __QPDFEXC_HH__
|
||||
|
||||
#include <qpdf/DLL.hh>
|
||||
#include <qpdf/DLL.h>
|
||||
#include <stdexcept>
|
||||
|
||||
class DLL_EXPORT QPDFExc: public std::runtime_error
|
||||
|
@ -8,7 +8,7 @@
|
||||
#ifndef __QPDFOBJECT_HH__
|
||||
#define __QPDFOBJECT_HH__
|
||||
|
||||
#include <qpdf/DLL.hh>
|
||||
#include <qpdf/DLL.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include <set>
|
||||
#include <map>
|
||||
|
||||
#include <qpdf/DLL.hh>
|
||||
#include <qpdf/DLL.h>
|
||||
|
||||
#include <qpdf/PointerHolder.hh>
|
||||
#include <qpdf/Buffer.hh>
|
||||
|
@ -8,7 +8,7 @@
|
||||
#ifndef __QPDFTOKENIZER_HH__
|
||||
#define __QPDFTOKENIZER_HH__
|
||||
|
||||
#include <qpdf/DLL.hh>
|
||||
#include <qpdf/DLL.h>
|
||||
|
||||
#include <string>
|
||||
#include <stdio.h>
|
||||
|
@ -19,7 +19,8 @@
|
||||
#include <set>
|
||||
#include <map>
|
||||
|
||||
#include <qpdf/DLL.hh>
|
||||
#include <qpdf/DLL.h>
|
||||
#include <qpdf/Constants.h>
|
||||
|
||||
#include <qpdf/QPDFXRefEntry.hh>
|
||||
|
||||
@ -51,16 +52,14 @@ 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.
|
||||
enum object_stream_e { o_disable, o_preserve, o_generate };
|
||||
void setObjectStreamMode(object_stream_e);
|
||||
void setObjectStreamMode(qpdf_object_stream_e);
|
||||
|
||||
// Set value of stream data mode. In uncompress mode, we attempt
|
||||
// to uncompress any stream that we can. In preserve mode, we
|
||||
// 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.
|
||||
enum stream_data_e { s_uncompress, s_preserve, s_compress };
|
||||
void setStreamDataMode(stream_data_e);
|
||||
void setStreamDataMode(qpdf_stream_data_e);
|
||||
|
||||
// Set value of content stream normalization. The default is
|
||||
// "false". If true, we attempt to normalize newlines inside of
|
||||
@ -137,28 +136,14 @@ class DLL_EXPORT QPDFWriter
|
||||
char const* user_password, char const* owner_password,
|
||||
bool allow_print, bool allow_modify,
|
||||
bool allow_extract, bool allow_annotate);
|
||||
enum r3_print_e
|
||||
{
|
||||
r3p_full, // allow all printing
|
||||
r3p_low, // allow only low-resolution printing
|
||||
r3p_none // allow no printing
|
||||
};
|
||||
enum r3_modify_e
|
||||
{
|
||||
r3m_all, // allow all modification
|
||||
r3m_annotate, // allow comment authoring and form operations
|
||||
r3m_form, // allow form field fill-in or signing
|
||||
r3m_assembly, // allow only document assembly
|
||||
r3m_none // allow no modification
|
||||
};
|
||||
void setR3EncryptionParameters(
|
||||
char const* user_password, char const* owner_password,
|
||||
bool allow_accessibility, bool allow_extract,
|
||||
r3_print_e print, r3_modify_e modify);
|
||||
qpdf_r3_print_e print, qpdf_r3_modify_e modify);
|
||||
void setR4EncryptionParameters(
|
||||
char const* user_password, char const* owner_password,
|
||||
bool allow_accessibility, bool allow_extract,
|
||||
r3_print_e print, r3_modify_e modify,
|
||||
qpdf_r3_print_e print, qpdf_r3_modify_e modify,
|
||||
bool encrypt_metadata, bool use_aes);
|
||||
|
||||
// Create linearized output. Disables qdf mode, content
|
||||
@ -203,7 +188,7 @@ class DLL_EXPORT QPDFWriter
|
||||
std::set<int>& bits_to_clear,
|
||||
char const* user_password, char const* owner_password,
|
||||
bool allow_accessibility, bool allow_extract,
|
||||
r3_print_e print, r3_modify_e modify);
|
||||
qpdf_r3_print_e print, qpdf_r3_modify_e modify);
|
||||
void disableIncompatbleEncryption(float v);
|
||||
void setEncryptionParameters(
|
||||
char const* user_password, char const* owner_password,
|
||||
@ -265,7 +250,7 @@ class DLL_EXPORT QPDFWriter
|
||||
bool normalize_content_set;
|
||||
bool normalize_content;
|
||||
bool stream_data_mode_set;
|
||||
stream_data_e stream_data_mode;
|
||||
qpdf_stream_data_e stream_data_mode;
|
||||
bool qdf_mode;
|
||||
bool static_id;
|
||||
bool suppress_original_object_ids;
|
||||
@ -273,7 +258,7 @@ class DLL_EXPORT QPDFWriter
|
||||
bool encrypted;
|
||||
bool preserve_encryption;
|
||||
bool linearized;
|
||||
object_stream_e object_stream_mode;
|
||||
qpdf_object_stream_e object_stream_mode;
|
||||
std::string encryption_key;
|
||||
bool encrypt_metadata;
|
||||
bool encrypt_use_aes;
|
||||
|
@ -8,7 +8,7 @@
|
||||
#ifndef __QPDFXREFENTRY_HH__
|
||||
#define __QPDFXREFENTRY_HH__
|
||||
|
||||
#include <qpdf/DLL.hh>
|
||||
#include <qpdf/DLL.h>
|
||||
|
||||
class DLL_EXPORT QPDFXRefEntry
|
||||
{
|
||||
|
@ -8,7 +8,7 @@
|
||||
#ifndef __QTC_HH__
|
||||
#define __QTC_HH__
|
||||
|
||||
#include <qpdf/DLL.hh>
|
||||
#include <qpdf/DLL.h>
|
||||
|
||||
namespace QTC
|
||||
{
|
||||
|
@ -8,7 +8,7 @@
|
||||
#ifndef __QUTIL_HH__
|
||||
#define __QUTIL_HH__
|
||||
|
||||
#include <qpdf/DLL.hh>
|
||||
#include <qpdf/DLL.h>
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <stdexcept>
|
||||
|
@ -61,7 +61,8 @@
|
||||
* primarily on differences between the C and C++ API.
|
||||
*/
|
||||
|
||||
#include <qpdf/DLL.hh>
|
||||
#include <qpdf/DLL.h>
|
||||
#include <qpdf/Constants.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -199,20 +200,13 @@ extern "C" {
|
||||
DLL_EXPORT
|
||||
QPDF_ERROR_CODE qpdf_init_write(qpdf_data qpdf, char const* filename);
|
||||
|
||||
# define QPDF_OBJECT_STREAM_DISABLE 0
|
||||
# define QPDF_OBJECT_STREAM_PRESERVE 1
|
||||
# define QPDF_OBJECT_STREAM_GENERATE 2
|
||||
|
||||
/* For mode, pass one of the QPDF_OBJECT_STREAM constants. */
|
||||
DLL_EXPORT
|
||||
void qpdf_set_object_stream_mode(qpdf_data qpdf, int mode);
|
||||
void qpdf_set_object_stream_mode(qpdf_data qpdf,
|
||||
enum qpdf_object_stream_e mode);
|
||||
|
||||
# define QPDF_STREAM_DATA_UNCOMPRESS 0
|
||||
# define QPDF_STREAM_DATA_PRESERVE 1
|
||||
# define QPDF_STREAM_DATA_COMPRESS 2
|
||||
/* For mode, pass one of the QPDF_STREAM_DATA constants. */
|
||||
DLL_EXPORT
|
||||
void qpdf_set_stream_data_mode(qpdf_data qpdf, int mode);
|
||||
void qpdf_set_stream_data_mode(qpdf_data qpdf,
|
||||
enum qpdf_stream_data_e mode);
|
||||
|
||||
DLL_EXPORT
|
||||
void qpdf_set_content_normalization(qpdf_data qpdf, QPDF_BOOL value);
|
||||
@ -245,30 +239,17 @@ extern "C" {
|
||||
QPDF_BOOL allow_print, QPDF_BOOL allow_modify,
|
||||
QPDF_BOOL allow_extract, QPDF_BOOL allow_annotate);
|
||||
|
||||
# define QPDF_R3_PRINT_FULL 0
|
||||
# define QPDF_R3_PRINT_LOW 1
|
||||
# define QPDF_R3_PRINT_NONE 2
|
||||
|
||||
# define QPDF_R3_MODIFY_ALL 0
|
||||
# define QPDF_R3_MODIFY_ANNOTATE 1
|
||||
# define QPDF_R3_MODIFY_FORM 2
|
||||
# define QPDF_R3_MODIFY_ASSEMBLY 3
|
||||
# define QPDF_R3_MODIFY_NONE 4
|
||||
|
||||
/* Value of print should be one of the QPDF_R3_PRINT constants.
|
||||
* Value of modify should be one of the QPDF_R3_MODIFY constants.
|
||||
*/
|
||||
DLL_EXPORT
|
||||
void qpdf_set_r3_encryption_parameters(
|
||||
qpdf_data qpdf, char const* user_password, char const* owner_password,
|
||||
QPDF_BOOL allow_accessibility, QPDF_BOOL allow_extract,
|
||||
int print, int modify);
|
||||
enum qpdf_r3_print_e print, enum qpdf_r3_modify_e modify);
|
||||
|
||||
DLL_EXPORT
|
||||
void qpdf_set_r4_encryption_parameters(
|
||||
qpdf_data qpdf, char const* user_password, char const* owner_password,
|
||||
QPDF_BOOL allow_accessibility, QPDF_BOOL allow_extract,
|
||||
int print, int modify,
|
||||
enum qpdf_r3_print_e print, enum qpdf_r3_modify_e modify,
|
||||
QPDF_BOOL encrypt_metadata, QPDF_BOOL use_aes);
|
||||
|
||||
DLL_EXPORT
|
||||
|
@ -29,7 +29,7 @@ QPDFWriter::QPDFWriter(QPDF& pdf, char const* filename) :
|
||||
normalize_content_set(false),
|
||||
normalize_content(false),
|
||||
stream_data_mode_set(false),
|
||||
stream_data_mode(s_compress),
|
||||
stream_data_mode(qpdf_s_compress),
|
||||
qdf_mode(false),
|
||||
static_id(false),
|
||||
suppress_original_object_ids(false),
|
||||
@ -37,7 +37,7 @@ QPDFWriter::QPDFWriter(QPDF& pdf, char const* filename) :
|
||||
encrypted(false),
|
||||
preserve_encryption(true),
|
||||
linearized(false),
|
||||
object_stream_mode(o_preserve),
|
||||
object_stream_mode(qpdf_o_preserve),
|
||||
encrypt_metadata(true),
|
||||
encrypt_use_aes(false),
|
||||
encryption_dict_objid(0),
|
||||
@ -77,13 +77,13 @@ QPDFWriter::~QPDFWriter()
|
||||
}
|
||||
|
||||
void
|
||||
QPDFWriter::setObjectStreamMode(object_stream_e mode)
|
||||
QPDFWriter::setObjectStreamMode(qpdf_object_stream_e mode)
|
||||
{
|
||||
this->object_stream_mode = mode;
|
||||
}
|
||||
|
||||
void
|
||||
QPDFWriter::setStreamDataMode(stream_data_e mode)
|
||||
QPDFWriter::setStreamDataMode(qpdf_stream_data_e mode)
|
||||
{
|
||||
this->stream_data_mode_set = true;
|
||||
this->stream_data_mode = mode;
|
||||
@ -198,7 +198,7 @@ void
|
||||
QPDFWriter::setR3EncryptionParameters(
|
||||
char const* user_password, char const* owner_password,
|
||||
bool allow_accessibility, bool allow_extract,
|
||||
r3_print_e print, r3_modify_e modify)
|
||||
qpdf_r3_print_e print, qpdf_r3_modify_e modify)
|
||||
{
|
||||
std::set<int> clear;
|
||||
interpretR3EncryptionParameters(
|
||||
@ -212,7 +212,7 @@ void
|
||||
QPDFWriter::setR4EncryptionParameters(
|
||||
char const* user_password, char const* owner_password,
|
||||
bool allow_accessibility, bool allow_extract,
|
||||
r3_print_e print, r3_modify_e modify,
|
||||
qpdf_r3_print_e print, qpdf_r3_modify_e modify,
|
||||
bool encrypt_metadata, bool use_aes)
|
||||
{
|
||||
std::set<int> clear;
|
||||
@ -230,7 +230,7 @@ QPDFWriter::interpretR3EncryptionParameters(
|
||||
std::set<int>& clear,
|
||||
char const* user_password, char const* owner_password,
|
||||
bool allow_accessibility, bool allow_extract,
|
||||
r3_print_e print, r3_modify_e modify)
|
||||
qpdf_r3_print_e print, qpdf_r3_modify_e modify)
|
||||
{
|
||||
// Acrobat 5 security options:
|
||||
|
||||
@ -263,13 +263,13 @@ QPDFWriter::interpretR3EncryptionParameters(
|
||||
// statements). Each option clears successively more access bits.
|
||||
switch (print)
|
||||
{
|
||||
case r3p_none:
|
||||
case qpdf_r3p_none:
|
||||
clear.insert(3); // any printing
|
||||
|
||||
case r3p_low:
|
||||
case qpdf_r3p_low:
|
||||
clear.insert(12); // high resolution printing
|
||||
|
||||
case r3p_full:
|
||||
case qpdf_r3p_full:
|
||||
break;
|
||||
|
||||
// no default so gcc warns for missing cases
|
||||
@ -277,19 +277,19 @@ QPDFWriter::interpretR3EncryptionParameters(
|
||||
|
||||
switch (modify)
|
||||
{
|
||||
case r3m_none:
|
||||
case qpdf_r3m_none:
|
||||
clear.insert(11); // document assembly
|
||||
|
||||
case r3m_assembly:
|
||||
case qpdf_r3m_assembly:
|
||||
clear.insert(9); // filling in form fields
|
||||
|
||||
case r3m_form:
|
||||
case qpdf_r3m_form:
|
||||
clear.insert(6); // modify annotations, fill in form fields
|
||||
|
||||
case r3m_annotate:
|
||||
case qpdf_r3m_annotate:
|
||||
clear.insert(4); // other modifications
|
||||
|
||||
case r3m_all:
|
||||
case qpdf_r3m_all:
|
||||
break;
|
||||
|
||||
// no default so gcc warns for missing cases
|
||||
@ -922,8 +922,8 @@ QPDFWriter::unparseObject(QPDFObjectHandle object, int level,
|
||||
{
|
||||
is_metadata = true;
|
||||
}
|
||||
bool filter = (this->stream_data_mode != s_preserve);
|
||||
if (this->stream_data_mode == s_compress)
|
||||
bool filter = (this->stream_data_mode != qpdf_s_preserve);
|
||||
if (this->stream_data_mode == qpdf_s_compress)
|
||||
{
|
||||
// Don't filter if the stream is already compressed with
|
||||
// FlateDecode. We don't want to make it worse by getting
|
||||
@ -952,7 +952,7 @@ QPDFWriter::unparseObject(QPDFObjectHandle object, int level,
|
||||
normalize = true;
|
||||
filter = true;
|
||||
}
|
||||
else if (filter && (this->stream_data_mode == s_compress))
|
||||
else if (filter && (this->stream_data_mode == qpdf_s_compress))
|
||||
{
|
||||
compress = true;
|
||||
QTC::TC("qpdf", "QPDFWriter compressing uncompressed stream");
|
||||
@ -1107,7 +1107,8 @@ QPDFWriter::writeObjectStream(QPDFObjectHandle object)
|
||||
|
||||
// Set up a stream to write the stream data into a buffer.
|
||||
Pipeline* next = pushPipeline(new Pl_Buffer("object stream"));
|
||||
if (! ((this->stream_data_mode == s_uncompress) || this->qdf_mode))
|
||||
if (! ((this->stream_data_mode == qpdf_s_uncompress) ||
|
||||
this->qdf_mode))
|
||||
{
|
||||
compressed = true;
|
||||
next = pushPipeline(
|
||||
@ -1455,7 +1456,7 @@ QPDFWriter::write()
|
||||
}
|
||||
if (! this->stream_data_mode_set)
|
||||
{
|
||||
this->stream_data_mode = s_uncompress;
|
||||
this->stream_data_mode = qpdf_s_uncompress;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1465,7 +1466,7 @@ QPDFWriter::write()
|
||||
this->preserve_encryption = false;
|
||||
}
|
||||
else if (this->normalize_content ||
|
||||
(this->stream_data_mode == s_uncompress) ||
|
||||
(this->stream_data_mode == qpdf_s_uncompress) ||
|
||||
this->qdf_mode)
|
||||
{
|
||||
// Encryption makes looking at contents pretty useless. If
|
||||
@ -1485,12 +1486,12 @@ QPDFWriter::write()
|
||||
if (v < 1.5)
|
||||
{
|
||||
QTC::TC("qpdf", "QPDFWriter forcing object stream disable");
|
||||
this->object_stream_mode = o_disable;
|
||||
this->object_stream_mode = qpdf_o_disable;
|
||||
}
|
||||
}
|
||||
|
||||
if (this->qdf_mode || this->normalize_content ||
|
||||
(this->stream_data_mode == s_uncompress))
|
||||
(this->stream_data_mode == qpdf_s_uncompress))
|
||||
{
|
||||
initializeSpecialStreams();
|
||||
}
|
||||
@ -1506,15 +1507,15 @@ QPDFWriter::write()
|
||||
|
||||
switch (this->object_stream_mode)
|
||||
{
|
||||
case o_disable:
|
||||
case qpdf_o_disable:
|
||||
// no action required
|
||||
break;
|
||||
|
||||
case o_preserve:
|
||||
case qpdf_o_preserve:
|
||||
preserveObjectStreams();
|
||||
break;
|
||||
|
||||
case o_generate:
|
||||
case qpdf_o_generate:
|
||||
generateObjectStreams();
|
||||
break;
|
||||
|
||||
@ -1760,7 +1761,7 @@ QPDFWriter::writeXRefStream(int xref_id, int max_id, int max_offset,
|
||||
|
||||
Pipeline* p = pushPipeline(new Pl_Buffer("xref stream"));
|
||||
bool compressed = false;
|
||||
if (! ((this->stream_data_mode == s_uncompress) || this->qdf_mode))
|
||||
if (! ((this->stream_data_mode == qpdf_s_uncompress) || this->qdf_mode))
|
||||
{
|
||||
compressed = true;
|
||||
p = pushPipeline(
|
||||
|
@ -1,4 +1,3 @@
|
||||
#include <qpdf/DLL.hh>
|
||||
#include <qpdf/QUtil.hh>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
@ -251,48 +251,16 @@ QPDF_ERROR_CODE qpdf_init_write(qpdf_data qpdf, char const* filename)
|
||||
return status;
|
||||
}
|
||||
|
||||
void qpdf_set_object_stream_mode(qpdf_data qpdf, int mode)
|
||||
void qpdf_set_object_stream_mode(qpdf_data qpdf, qpdf_object_stream_e mode)
|
||||
{
|
||||
QTC::TC("qpdf", "qpdf-c called qpdf_set_object_stream_mode");
|
||||
QPDFWriter::object_stream_e omode = QPDFWriter::o_preserve;
|
||||
switch (mode)
|
||||
{
|
||||
case QPDF_OBJECT_STREAM_DISABLE:
|
||||
omode = QPDFWriter::o_disable;
|
||||
break;
|
||||
|
||||
case QPDF_OBJECT_STREAM_GENERATE:
|
||||
omode = QPDFWriter::o_generate;
|
||||
break;
|
||||
|
||||
default:
|
||||
// already set to o_preserve; treate out of range values as
|
||||
// the default.
|
||||
break;
|
||||
}
|
||||
|
||||
qpdf->qpdf_writer->setObjectStreamMode(omode);
|
||||
qpdf->qpdf_writer->setObjectStreamMode(mode);
|
||||
}
|
||||
|
||||
void qpdf_set_stream_data_mode(qpdf_data qpdf, int mode)
|
||||
void qpdf_set_stream_data_mode(qpdf_data qpdf, qpdf_stream_data_e mode)
|
||||
{
|
||||
QTC::TC("qpdf", "qpdf-c called qpdf_set_stream_data_mode");
|
||||
QPDFWriter::stream_data_e smode = QPDFWriter::s_preserve;
|
||||
switch (mode)
|
||||
{
|
||||
case QPDF_STREAM_DATA_UNCOMPRESS:
|
||||
smode = QPDFWriter::s_uncompress;
|
||||
break;
|
||||
|
||||
case QPDF_STREAM_DATA_COMPRESS:
|
||||
smode = QPDFWriter::s_compress;
|
||||
break;
|
||||
|
||||
default:
|
||||
// Treat anything else as default
|
||||
break;
|
||||
}
|
||||
qpdf->qpdf_writer->setStreamDataMode(smode);
|
||||
qpdf->qpdf_writer->setStreamDataMode(mode);
|
||||
}
|
||||
|
||||
void qpdf_set_content_normalization(qpdf_data qpdf, QPDF_BOOL value)
|
||||
@ -346,39 +314,24 @@ void qpdf_set_r2_encryption_parameters(
|
||||
void qpdf_set_r3_encryption_parameters(
|
||||
qpdf_data qpdf, char const* user_password, char const* owner_password,
|
||||
QPDF_BOOL allow_accessibility, QPDF_BOOL allow_extract,
|
||||
int print, int modify)
|
||||
qpdf_r3_print_e print, qpdf_r3_modify_e modify)
|
||||
{
|
||||
QTC::TC("qpdf", "qpdf-c called qpdf_set_r3_encryption_parameters");
|
||||
qpdf->qpdf_writer->setR3EncryptionParameters(
|
||||
user_password, owner_password,
|
||||
allow_accessibility, allow_extract,
|
||||
((print == QPDF_R3_PRINT_LOW) ? QPDFWriter::r3p_low :
|
||||
(print == QPDF_R3_PRINT_NONE) ? QPDFWriter::r3p_none :
|
||||
QPDFWriter::r3p_full),
|
||||
((modify == QPDF_R3_MODIFY_ANNOTATE) ? QPDFWriter::r3m_annotate :
|
||||
(modify == QPDF_R3_MODIFY_FORM) ? QPDFWriter::r3m_form :
|
||||
(modify == QPDF_R3_MODIFY_ASSEMBLY) ? QPDFWriter::r3m_assembly :
|
||||
(modify == QPDF_R3_MODIFY_NONE) ? QPDFWriter::r3m_none :
|
||||
QPDFWriter::r3m_all));
|
||||
allow_accessibility, allow_extract, print, modify);
|
||||
}
|
||||
|
||||
void qpdf_set_r4_encryption_parameters(
|
||||
qpdf_data qpdf, char const* user_password, char const* owner_password,
|
||||
QPDF_BOOL allow_accessibility, QPDF_BOOL allow_extract,
|
||||
int print, int modify, QPDF_BOOL encrypt_metadata, QPDF_BOOL use_aes)
|
||||
qpdf_r3_print_e print, qpdf_r3_modify_e modify,
|
||||
QPDF_BOOL encrypt_metadata, QPDF_BOOL use_aes)
|
||||
{
|
||||
QTC::TC("qpdf", "qpdf-c called qpdf_set_r4_encryption_parameters");
|
||||
qpdf->qpdf_writer->setR4EncryptionParameters(
|
||||
user_password, owner_password,
|
||||
allow_accessibility, allow_extract,
|
||||
((print == QPDF_R3_PRINT_LOW) ? QPDFWriter::r3p_low :
|
||||
(print == QPDF_R3_PRINT_NONE) ? QPDFWriter::r3p_none :
|
||||
QPDFWriter::r3p_full),
|
||||
((modify == QPDF_R3_MODIFY_ANNOTATE) ? QPDFWriter::r3m_annotate :
|
||||
(modify == QPDF_R3_MODIFY_FORM) ? QPDFWriter::r3m_form :
|
||||
(modify == QPDF_R3_MODIFY_ASSEMBLY) ? QPDFWriter::r3m_assembly :
|
||||
(modify == QPDF_R3_MODIFY_NONE) ? QPDFWriter::r3m_none :
|
||||
QPDFWriter::r3m_all),
|
||||
allow_accessibility, allow_extract, print, modify,
|
||||
encrypt_metadata, use_aes);
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
#ifndef __BITSTREAM_HH__
|
||||
#define __BITSTREAM_HH__
|
||||
|
||||
#include <qpdf/DLL.hh>
|
||||
#include <qpdf/DLL.h>
|
||||
|
||||
class DLL_EXPORT BitStream
|
||||
{
|
||||
|
@ -3,7 +3,7 @@
|
||||
#ifndef __BITWRITER_HH__
|
||||
#define __BITWRITER_HH__
|
||||
|
||||
#include <qpdf/DLL.hh>
|
||||
#include <qpdf/DLL.h>
|
||||
|
||||
class Pipeline;
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
#define __MD5_HH__
|
||||
|
||||
#include <string>
|
||||
#include <qpdf/DLL.hh>
|
||||
#include <qpdf/DLL.h>
|
||||
#include <qpdf/qpdf-config.h>
|
||||
#ifdef HAVE_INTTYPES_H
|
||||
# include <inttypes.h>
|
||||
|
@ -12,7 +12,7 @@
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
|
||||
#include <qpdf/DLL.hh>
|
||||
#include <qpdf/DLL.h>
|
||||
|
||||
// Note: this class does not encapsulate all features of the PCRE
|
||||
// package -- only those that I actually need right now are here.
|
||||
|
@ -114,7 +114,7 @@ static void test06(char const* infile,
|
||||
qpdf_read(qpdf, infile, password);
|
||||
qpdf_init_write(qpdf, outfile);
|
||||
qpdf_set_static_ID(qpdf, QPDF_TRUE);
|
||||
qpdf_set_object_stream_mode(qpdf, QPDF_OBJECT_STREAM_GENERATE);
|
||||
qpdf_set_object_stream_mode(qpdf, qpdf_o_generate);
|
||||
qpdf_write(qpdf);
|
||||
report_errors();
|
||||
}
|
||||
@ -154,7 +154,7 @@ static void test09(char const* infile,
|
||||
qpdf_read(qpdf, infile, password);
|
||||
qpdf_init_write(qpdf, outfile);
|
||||
qpdf_set_static_ID(qpdf, QPDF_TRUE);
|
||||
qpdf_set_stream_data_mode(qpdf, QPDF_STREAM_DATA_UNCOMPRESS);
|
||||
qpdf_set_stream_data_mode(qpdf, qpdf_s_uncompress);
|
||||
qpdf_write(qpdf);
|
||||
report_errors();
|
||||
}
|
||||
@ -193,7 +193,7 @@ static void test12(char const* infile,
|
||||
qpdf_set_static_ID(qpdf, QPDF_TRUE);
|
||||
qpdf_set_r3_encryption_parameters(
|
||||
qpdf, "user2", "owner2", QPDF_TRUE, QPDF_TRUE,
|
||||
QPDF_R3_PRINT_LOW, QPDF_R3_MODIFY_ALL);
|
||||
qpdf_r3p_low, qpdf_r3m_all);
|
||||
qpdf_write(qpdf);
|
||||
report_errors();
|
||||
}
|
||||
@ -240,7 +240,7 @@ static void test15(char const* infile,
|
||||
qpdf_set_static_aes_IV(qpdf, QPDF_TRUE);
|
||||
qpdf_set_r4_encryption_parameters(
|
||||
qpdf, "user2", "owner2", QPDF_TRUE, QPDF_TRUE,
|
||||
QPDF_R3_PRINT_LOW, QPDF_R3_MODIFY_ALL, QPDF_TRUE, QPDF_TRUE);
|
||||
qpdf_r3p_low, qpdf_r3m_all, QPDF_TRUE, QPDF_TRUE);
|
||||
qpdf_write(qpdf);
|
||||
report_errors();
|
||||
}
|
||||
|
38
qpdf/qpdf.cc
38
qpdf/qpdf.cc
@ -233,7 +233,7 @@ parse_encrypt_options(
|
||||
std::string& user_password, std::string& owner_password, int& keylen,
|
||||
bool& r2_print, bool& r2_modify, bool& r2_extract, bool& r2_annotate,
|
||||
bool& r3_accessibility, bool& r3_extract,
|
||||
QPDFWriter::r3_print_e& r3_print, QPDFWriter::r3_modify_e& r3_modify,
|
||||
qpdf_r3_print_e& r3_print, qpdf_r3_modify_e& r3_modify,
|
||||
bool& force_V4, bool& cleartext_metadata, bool& use_aes)
|
||||
{
|
||||
if (cur_arg + 3 >= argc)
|
||||
@ -310,15 +310,15 @@ parse_encrypt_options(
|
||||
{
|
||||
if (val == "full")
|
||||
{
|
||||
r3_print = QPDFWriter::r3p_full;
|
||||
r3_print = qpdf_r3p_full;
|
||||
}
|
||||
else if (val == "low")
|
||||
{
|
||||
r3_print = QPDFWriter::r3p_low;
|
||||
r3_print = qpdf_r3p_low;
|
||||
}
|
||||
else if (val == "none")
|
||||
{
|
||||
r3_print = QPDFWriter::r3p_none;
|
||||
r3_print = qpdf_r3p_none;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -352,23 +352,23 @@ parse_encrypt_options(
|
||||
{
|
||||
if (val == "all")
|
||||
{
|
||||
r3_modify = QPDFWriter::r3m_all;
|
||||
r3_modify = qpdf_r3m_all;
|
||||
}
|
||||
else if (val == "annotate")
|
||||
{
|
||||
r3_modify = QPDFWriter::r3m_annotate;
|
||||
r3_modify = qpdf_r3m_annotate;
|
||||
}
|
||||
else if (val == "form")
|
||||
{
|
||||
r3_modify = QPDFWriter::r3m_form;
|
||||
r3_modify = qpdf_r3m_form;
|
||||
}
|
||||
else if (val == "assembly")
|
||||
{
|
||||
r3_modify = QPDFWriter::r3m_assembly;
|
||||
r3_modify = qpdf_r3m_assembly;
|
||||
}
|
||||
else if (val == "none")
|
||||
{
|
||||
r3_modify = QPDFWriter::r3m_none;
|
||||
r3_modify = qpdf_r3m_none;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -587,19 +587,19 @@ int main(int argc, char* argv[])
|
||||
bool r2_annotate = true;
|
||||
bool r3_accessibility = true;
|
||||
bool r3_extract = true;
|
||||
QPDFWriter::r3_print_e r3_print = QPDFWriter::r3p_full;
|
||||
QPDFWriter::r3_modify_e r3_modify = QPDFWriter::r3m_all;
|
||||
qpdf_r3_print_e r3_print = qpdf_r3p_full;
|
||||
qpdf_r3_modify_e r3_modify = qpdf_r3m_all;
|
||||
bool force_V4 = false;
|
||||
bool cleartext_metadata = false;
|
||||
bool use_aes = false;
|
||||
|
||||
bool stream_data_set = false;
|
||||
QPDFWriter::stream_data_e stream_data_mode = QPDFWriter::s_compress;
|
||||
qpdf_stream_data_e stream_data_mode = qpdf_s_compress;
|
||||
bool normalize_set = false;
|
||||
bool normalize = false;
|
||||
bool suppress_recovery = false;
|
||||
bool object_stream_set = false;
|
||||
QPDFWriter::object_stream_e object_stream_mode = QPDFWriter::o_preserve;
|
||||
qpdf_object_stream_e object_stream_mode = qpdf_o_preserve;
|
||||
bool ignore_xref_streams = false;
|
||||
bool qdf_mode = false;
|
||||
std::string min_version;
|
||||
@ -677,15 +677,15 @@ int main(int argc, char* argv[])
|
||||
stream_data_set = true;
|
||||
if (strcmp(parameter, "compress") == 0)
|
||||
{
|
||||
stream_data_mode = QPDFWriter::s_compress;
|
||||
stream_data_mode = qpdf_s_compress;
|
||||
}
|
||||
else if (strcmp(parameter, "preserve") == 0)
|
||||
{
|
||||
stream_data_mode = QPDFWriter::s_preserve;
|
||||
stream_data_mode = qpdf_s_preserve;
|
||||
}
|
||||
else if (strcmp(parameter, "uncompress") == 0)
|
||||
{
|
||||
stream_data_mode = QPDFWriter::s_uncompress;
|
||||
stream_data_mode = qpdf_s_uncompress;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -716,15 +716,15 @@ int main(int argc, char* argv[])
|
||||
object_stream_set = true;
|
||||
if (strcmp(parameter, "disable") == 0)
|
||||
{
|
||||
object_stream_mode = QPDFWriter::o_disable;
|
||||
object_stream_mode = qpdf_o_disable;
|
||||
}
|
||||
else if (strcmp(parameter, "preserve") == 0)
|
||||
{
|
||||
object_stream_mode = QPDFWriter::o_preserve;
|
||||
object_stream_mode = qpdf_o_preserve;
|
||||
}
|
||||
else if (strcmp(parameter, "generate") == 0)
|
||||
{
|
||||
object_stream_mode = QPDFWriter::o_generate;
|
||||
object_stream_mode = qpdf_o_generate;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user