2
1
mirror of https://github.com/qpdf/qpdf.git synced 2025-01-22 22:58:33 +00:00

Add ExtensionLevel support to version handling

All version operations are now fully aware of extension levels.
This commit is contained in:
Jay Berkenbilt 2012-12-27 15:17:39 -05:00
parent 3101955ac0
commit 774584163f
92 changed files with 1423 additions and 30 deletions

View File

@ -144,6 +144,8 @@ class QPDF
QPDF_DLL QPDF_DLL
std::string getPDFVersion() const; std::string getPDFVersion() const;
QPDF_DLL QPDF_DLL
int getExtensionLevel();
QPDF_DLL
QPDFObjectHandle getTrailer(); QPDFObjectHandle getTrailer();
QPDF_DLL QPDF_DLL
QPDFObjectHandle getRoot(); QPDFObjectHandle getRoot();

View File

@ -153,6 +153,8 @@ class QPDFWriter
// streams are used. // streams are used.
QPDF_DLL QPDF_DLL
void setMinimumPDFVersion(std::string const&); void setMinimumPDFVersion(std::string const&);
QPDF_DLL
void setMinimumPDFVersion(std::string const&, int extension_level);
// Force the PDF version of the output file to be a given version. // Force the PDF version of the output file to be a given version.
// Use of this function may create PDF files that will not work // Use of this function may create PDF files that will not work
@ -171,6 +173,8 @@ class QPDFWriter
// object streams. // object streams.
QPDF_DLL QPDF_DLL
void forcePDFVersion(std::string const&); void forcePDFVersion(std::string const&);
QPDF_DLL
void forcePDFVersion(std::string const&, int extension_level);
// Provide additional text to insert in the PDF file somewhere // Provide additional text to insert in the PDF file somewhere
// near the beginning of the file. This can be used to add // near the beginning of the file. This can be used to add
@ -251,6 +255,7 @@ class QPDFWriter
static int const f_stream = 1 << 0; static int const f_stream = 1 << 0;
static int const f_filtered = 1 << 1; static int const f_filtered = 1 << 1;
static int const f_in_ostream = 1 << 2; static int const f_in_ostream = 1 << 2;
static int const f_in_extensions = 1 << 3;
enum trailer_e { t_normal, t_lin_first, t_lin_second }; enum trailer_e { t_normal, t_lin_first, t_lin_second };
@ -286,7 +291,8 @@ class QPDFWriter
char const* user_password, char const* owner_password, char const* user_password, char const* owner_password,
bool allow_accessibility, bool allow_extract, bool allow_accessibility, bool allow_extract,
qpdf_r3_print_e print, qpdf_r3_modify_e modify); qpdf_r3_print_e print, qpdf_r3_modify_e modify);
void disableIncompatibleEncryption(int major, int minor); void disableIncompatibleEncryption(int major, int minor,
int extension_level);
void parseVersion(std::string const& version, int& major, int& minor) const; void parseVersion(std::string const& version, int& major, int& minor) const;
int compareVersions(int major1, int minor1, int major2, int minor2) const; int compareVersions(int major1, int minor1, int major2, int minor2) const;
void setEncryptionParameters( void setEncryptionParameters(
@ -375,8 +381,12 @@ class QPDFWriter
std::string id1; // for /ID key of std::string id1; // for /ID key of
std::string id2; // trailer dictionary std::string id2; // trailer dictionary
std::string final_pdf_version;
int final_extension_level;
std::string min_pdf_version; std::string min_pdf_version;
int min_extension_level;
std::string forced_pdf_version; std::string forced_pdf_version;
int forced_extension_level;
std::string extra_header_text; std::string extra_header_text;
int encryption_dict_objid; int encryption_dict_objid;
std::string cur_data_key; std::string cur_data_key;

View File

@ -1872,6 +1872,30 @@ QPDF::getPDFVersion() const
return this->pdf_version; return this->pdf_version;
} }
int
QPDF::getExtensionLevel()
{
int result = 0;
QPDFObjectHandle obj = getRoot();
if (obj.hasKey("/Extensions"))
{
obj = obj.getKey("/Extensions");
if (obj.isDictionary() && obj.hasKey("/ADBE"))
{
obj = obj.getKey("/ADBE");
if (obj.isDictionary() && obj.hasKey("/ExtensionLevel"))
{
obj = obj.getKey("/ExtensionLevel");
if (obj.isInteger())
{
result = obj.getIntValue();
}
}
}
}
return result;
}
QPDFObjectHandle QPDFObjectHandle
QPDF::getTrailer() QPDF::getTrailer()
{ {

View File

@ -64,6 +64,9 @@ QPDFWriter::init()
object_stream_mode = qpdf_o_preserve; object_stream_mode = qpdf_o_preserve;
encrypt_metadata = true; encrypt_metadata = true;
encrypt_use_aes = false; encrypt_use_aes = false;
min_extension_level = 0;
final_extension_level = 0;
forced_extension_level = 0;
encryption_dict_objid = 0; encryption_dict_objid = 0;
next_objid = 1; next_objid = 1;
cur_stream_length_id = 0; cur_stream_length_id = 0;
@ -169,11 +172,20 @@ QPDFWriter::setQDFMode(bool val)
void void
QPDFWriter::setMinimumPDFVersion(std::string const& version) QPDFWriter::setMinimumPDFVersion(std::string const& version)
{
setMinimumPDFVersion(version, 0);
}
void
QPDFWriter::setMinimumPDFVersion(std::string const& version,
int extension_level)
{ {
bool set_version = false; bool set_version = false;
bool set_extension_level = false;
if (this->min_pdf_version.empty()) if (this->min_pdf_version.empty())
{ {
set_version = true; set_version = true;
set_extension_level = true;
} }
else else
{ {
@ -183,10 +195,22 @@ QPDFWriter::setMinimumPDFVersion(std::string const& version)
int min_minor = 0; int min_minor = 0;
parseVersion(version, old_major, old_minor); parseVersion(version, old_major, old_minor);
parseVersion(this->min_pdf_version, min_major, min_minor); parseVersion(this->min_pdf_version, min_major, min_minor);
if (compareVersions(old_major, old_minor, min_major, min_minor) > 0) int compare = compareVersions(
old_major, old_minor, min_major, min_minor);
if (compare > 0)
{ {
QTC::TC("qpdf", "QPDFWriter increasing minimum version"); QTC::TC("qpdf", "QPDFWriter increasing minimum version",
extension_level == 0 ? 0 : 1);
set_version = true; set_version = true;
set_extension_level = true;
}
else if (compare == 0)
{
if (extension_level > this->min_extension_level)
{
QTC::TC("qpdf", "QPDFWriter increasing extension level");
set_extension_level = true;
}
} }
} }
@ -194,12 +218,24 @@ QPDFWriter::setMinimumPDFVersion(std::string const& version)
{ {
this->min_pdf_version = version; this->min_pdf_version = version;
} }
if (set_extension_level)
{
this->min_extension_level = extension_level;
}
} }
void void
QPDFWriter::forcePDFVersion(std::string const& version) QPDFWriter::forcePDFVersion(std::string const& version)
{
forcePDFVersion(version, 0);
}
void
QPDFWriter::forcePDFVersion(std::string const& version,
int extension_level)
{ {
this->forced_pdf_version = version; this->forced_pdf_version = version;
this->forced_extension_level = extension_level;
} }
void void
@ -476,7 +512,8 @@ QPDFWriter::copyEncryptionParameters(QPDF& qpdf)
} }
void void
QPDFWriter::disableIncompatibleEncryption(int major, int minor) QPDFWriter::disableIncompatibleEncryption(int major, int minor,
int extension_level)
{ {
if (! this->encrypted) if (! this->encrypted)
{ {
@ -513,6 +550,15 @@ QPDFWriter::disableIncompatibleEncryption(int major, int minor)
disable = true; disable = true;
} }
} }
else if ((compareVersions(major, minor, 1, 7) < 0) ||
((compareVersions(major, minor, 1, 7) == 0) &&
extension_level < 3))
{
if ((V >= 5) || (R >= 5))
{
disable = true;
}
}
} }
if (disable) if (disable)
{ {
@ -584,15 +630,26 @@ QPDFWriter::setEncryptionParametersInternal(
encryption_dictionary["/P"] = QUtil::int_to_string(P); encryption_dictionary["/P"] = QUtil::int_to_string(P);
encryption_dictionary["/O"] = QPDF_String(O).unparse(true); encryption_dictionary["/O"] = QPDF_String(O).unparse(true);
encryption_dictionary["/U"] = QPDF_String(U).unparse(true); encryption_dictionary["/U"] = QPDF_String(U).unparse(true);
setMinimumPDFVersion("1.3"); if (V >= 5)
if (R == 3)
{ {
setMinimumPDFVersion("1.4"); setMinimumPDFVersion("1.4");
} }
else if (R >= 4) if (R >= 5)
{
setMinimumPDFVersion("1.7", 3);
}
else if (R == 4)
{ {
setMinimumPDFVersion(this->encrypt_use_aes ? "1.6" : "1.5"); setMinimumPDFVersion(this->encrypt_use_aes ? "1.6" : "1.5");
} }
else if (R == 3)
{
setMinimumPDFVersion("1.4");
}
else
{
setMinimumPDFVersion("1.3");
}
if ((R >= 4) && (! encrypt_metadata)) if ((R >= 4) && (! encrypt_metadata))
{ {
@ -1005,7 +1062,7 @@ QPDFWriter::unparseObject(QPDFObjectHandle object, int level,
unsigned int flags, size_t stream_length, unsigned int flags, size_t stream_length,
bool compress) bool compress)
{ {
unsigned int child_flags = flags & ~f_stream; unsigned int child_flags = flags & ~f_stream & ~f_in_extensions;
std::string indent; std::string indent;
for (int i = 0; i < level; ++i) for (int i = 0; i < level; ++i)
@ -1037,8 +1094,143 @@ QPDFWriter::unparseObject(QPDFObjectHandle object, int level,
} }
else if (object.isDictionary()) else if (object.isDictionary())
{ {
// Handle special cases for specific dictionaries.
// Extensions dictionaries are complicated. We have one of
// several cases:
//
// * We need ADBE
// - We already have Extensions
// - If it has the right ADBE, preserve it
// - Otherwise, replace ADBE
// - We don't have Extensions: create one from scratch
// * We don't want ADBE
// - We already have Extensions
// - If it only has ADBE, remove it
// - If it has other things, keep those and remove ADBE
// - We have no extensions: no action required
//
// We may be in the root dictionary, or we may be inside the
// extensions dictionary itself. The latter is determined by
// the presence of the f_in_extensions flag.
bool is_root = false;
bool have_extensions_other = false;
bool have_extensions_adbe = false;
QPDFObjectHandle extensions;
if (object.getObjectID() == pdf.getRoot().getObjectID())
{
is_root = true;
if (object.hasKey("/Extensions") &&
object.getKey("/Extensions").isDictionary())
{
extensions = object.getKey("/Extensions");
}
}
else if (flags & f_in_extensions)
{
extensions = object;
}
if (extensions.isInitialized())
{
std::set<std::string> keys = extensions.getKeys();
if (keys.count("/ADBE") > 0)
{
have_extensions_adbe = true;
keys.erase("/ADBE");
}
if (keys.size() > 0)
{
have_extensions_other = true;
}
}
bool need_extensions_adbe = (this->final_extension_level > 0);
bool write_new_extensions = false;
bool write_new_adbe = false;
bool suppress_existing_extensions = false;
bool suppress_existing_adbe = false;
if (is_root)
{
if (need_extensions_adbe)
{
if (! (have_extensions_other || have_extensions_adbe))
{
// We need Extensions and don't have it. Create
// it here.
QTC::TC("qpdf", "QPDFWriter create Extensions",
this->qdf_mode ? 0 : 1);
write_new_extensions = true;
suppress_existing_extensions = true;
}
else
{
// Preserve existing Extensions and do the work
// in the extensions dictionary.
}
}
else if (! have_extensions_other)
{
// We have Extensions dictionary and don't want one.
suppress_existing_extensions = true;
if (have_extensions_adbe)
{
QTC::TC("qpdf", "QPDFWriter remove existing Extensions");
}
}
}
else if (flags & f_in_extensions)
{
QTC::TC("qpdf", "QPDFWriter preserve Extensions");
QPDFObjectHandle adbe = extensions.getKey("/ADBE");
if (adbe.isDictionary() &&
adbe.hasKey("/BaseVersion") &&
adbe.getKey("/BaseVersion").isName() &&
(adbe.getKey("/BaseVersion").getName() ==
"/" + this->final_pdf_version) &&
adbe.hasKey("/ExtensionLevel") &&
adbe.getKey("/ExtensionLevel").isInteger() &&
(adbe.getKey("/ExtensionLevel").getIntValue() ==
this->final_extension_level))
{
QTC::TC("qpdf", "QPDFWriter preserve ADBE");
}
else
{
suppress_existing_adbe = true;
if (need_extensions_adbe)
{
write_new_adbe = true;
}
}
}
writeString("<<"); writeString("<<");
writeStringQDF("\n"); writeStringQDF("\n");
if (write_new_extensions || write_new_adbe)
{
writeStringQDF(indent);
writeStringQDF(" ");
writeStringNoQDF(" ");
if (write_new_extensions)
{
writeString("/Extensions << ");
}
writeString("/ADBE << /BaseVersion /");
writeString(this->final_pdf_version);
writeString(" /ExtensionLevel ");
writeString(QUtil::int_to_string(this->final_extension_level));
writeString(" >>");
if (write_new_extensions)
{
writeString(" >>");
}
writeStringQDF("\n");
}
std::set<std::string> keys = object.getKeys(); std::set<std::string> keys = object.getKeys();
for (std::set<std::string>::iterator iter = keys.begin(); for (std::set<std::string>::iterator iter = keys.begin();
iter != keys.end(); ++iter) iter != keys.end(); ++iter)
@ -1057,12 +1249,27 @@ QPDFWriter::unparseObject(QPDFObjectHandle object, int level,
{ {
continue; continue;
} }
bool is_extensions = (is_root && (key == "/Extensions"));
if (suppress_existing_extensions && is_extensions)
{
QTC::TC("qpdf", "QPDFWriter skip Extensions");
continue;
}
if (suppress_existing_adbe && (key == "/ADBE"))
{
QTC::TC("qpdf", "QPDFWriter skip ADBE");
continue;
}
writeStringQDF(indent); writeStringQDF(indent);
writeStringQDF(" "); writeStringQDF(" ");
writeStringNoQDF(" "); writeStringNoQDF(" ");
writeString(QPDF_Name::normalizeName(key)); writeString(QPDF_Name::normalizeName(key));
writeString(" "); writeString(" ");
unparseChild(object.getKey(key), level + 1, child_flags); unparseChild(object.getKey(key), level + 1,
child_flags | (is_extensions ? f_in_extensions : 0));
writeStringQDF("\n"); writeStringQDF("\n");
} }
@ -1706,12 +1913,17 @@ QPDFWriter::prepareFileForWrite()
else if (node.isDictionary() || node.isStream()) else if (node.isDictionary() || node.isStream())
{ {
bool is_stream = false; bool is_stream = false;
bool is_root = false;
QPDFObjectHandle dict = node; QPDFObjectHandle dict = node;
if (node.isStream()) if (node.isStream())
{ {
is_stream = true; is_stream = true;
dict = node.getDict(); dict = node.getDict();
} }
else if (pdf.getRoot().getObjectID() == node.getObjectID())
{
is_root = true;
}
std::set<std::string> keys = dict.getKeys(); std::set<std::string> keys = dict.getKeys();
for (std::set<std::string>::iterator iter = keys.begin(); for (std::set<std::string>::iterator iter = keys.begin();
@ -1720,19 +1932,43 @@ QPDFWriter::prepareFileForWrite()
std::string const& key = *iter; std::string const& key = *iter;
QPDFObjectHandle oh = dict.getKey(key); QPDFObjectHandle oh = dict.getKey(key);
bool add_to_queue = true; bool add_to_queue = true;
if (oh.isIndirect()) if (is_stream)
{ {
if (is_stream) if (oh.isIndirect() &&
((key == "/Length") ||
(key == "/Filter") ||
(key == "/DecodeParms")))
{ {
if ((key == "/Length") || QTC::TC("qpdf", "QPDFWriter make stream key direct");
(key == "/Filter") || add_to_queue = false;
(key == "/DecodeParms")) oh.makeDirect();
dict.replaceKey(key, oh);
}
}
else if (is_root)
{
if ((key == "/Extensions") && (oh.isDictionary()))
{
bool extensions_indirect = false;
if (oh.isIndirect())
{ {
QTC::TC("qpdf", "QPDF make stream key direct"); QTC::TC("qpdf", "QPDFWriter make Extensions direct");
extensions_indirect = true;
add_to_queue = false; add_to_queue = false;
oh.makeDirect(); oh = oh.shallowCopy();
dict.replaceKey(key, oh); dict.replaceKey(key, oh);
} }
if (oh.hasKey("/ADBE"))
{
QPDFObjectHandle adbe = oh.getKey("/ADBE");
if (adbe.isIndirect())
{
QTC::TC("qpdf", "QPDFWriter make ADBE direct",
extensions_indirect ? 0 : 1);
adbe.makeDirect();
oh.replaceKey("/ADBE", adbe);
}
}
} }
} }
@ -1791,7 +2027,8 @@ QPDFWriter::write()
int major = 0; int major = 0;
int minor = 0; int minor = 0;
parseVersion(this->forced_pdf_version, major, minor); parseVersion(this->forced_pdf_version, major, minor);
disableIncompatibleEncryption(major, minor); disableIncompatibleEncryption(major, minor,
this->forced_extension_level);
if (compareVersions(major, minor, 1, 5) < 0) if (compareVersions(major, minor, 1, 5) < 0)
{ {
QTC::TC("qpdf", "QPDFWriter forcing object stream disable"); QTC::TC("qpdf", "QPDFWriter forcing object stream disable");
@ -1938,16 +2175,18 @@ QPDFWriter::writeEncryptionDictionary()
void void
QPDFWriter::writeHeader() QPDFWriter::writeHeader()
{ {
setMinimumPDFVersion(pdf.getPDFVersion()); setMinimumPDFVersion(pdf.getPDFVersion(), pdf.getExtensionLevel());
std::string version = this->min_pdf_version; this->final_pdf_version = this->min_pdf_version;
this->final_extension_level = this->min_extension_level;
if (! this->forced_pdf_version.empty()) if (! this->forced_pdf_version.empty())
{ {
QTC::TC("qpdf", "QPDFWriter using forced PDF version"); QTC::TC("qpdf", "QPDFWriter using forced PDF version");
version = this->forced_pdf_version; this->final_pdf_version = this->forced_pdf_version;
this->final_extension_level = this->forced_extension_level;
} }
writeString("%PDF-"); writeString("%PDF-");
writeString(version); writeString(this->final_pdf_version);
// This string of binary characters would not be valid UTF-8, so // This string of binary characters would not be valid UTF-8, so
// it really should be treated as binary. // it really should be treated as binary.
writeString("\n%\xbf\xf7\xa2\xfe\n"); writeString("\n%\xbf\xf7\xa2\xfe\n");

View File

@ -189,6 +189,9 @@ familiar with the PDF file format or who are PDF developers.\n\
--min-version=version sets the minimum PDF version of the output file\n\ --min-version=version sets the minimum PDF version of the output file\n\
--force-version=version forces this to be the PDF version of the output file\n\ --force-version=version forces this to be the PDF version of the output file\n\
\n\ \n\
Version numbers may be expressed as major.minor.extension-level, so 1.7.3\n\
means PDF version 1.7 at extension level 3.\n\
\n\
Values for stream data options:\n\ Values for stream data options:\n\
\n\ \n\
compress recompress stream data when possible (default)\n\ compress recompress stream data when possible (default)\n\
@ -838,6 +841,21 @@ QPDFPageData::QPDFPageData(QPDF* qpdf, char const* range) :
this->selected_pages = parse_numrange(range, (int)this->orig_pages.size()); this->selected_pages = parse_numrange(range, (int)this->orig_pages.size());
} }
static void parse_version(std::string const& full_version_string,
std::string& version, int& extension_level)
{
PointerHolder<char> vp(true, QUtil::copy_string(full_version_string));
char* v = vp.getPointer();
char* p1 = strchr(v, '.');
char* p2 = (p1 ? strchr(1 + p1, '.') : 0);
if (p2 && *(p2 + 1))
{
*p2++ = '\0';
extension_level = atoi(p2);
}
version = v;
}
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
whoami = QUtil::getWhoami(argv[0]); whoami = QUtil::getWhoami(argv[0]);
@ -1370,8 +1388,14 @@ int main(int argc, char* argv[])
std::cout << "checking " << infilename << std::endl; std::cout << "checking " << infilename << std::endl;
try try
{ {
std::cout << "PDF Version: " << pdf.getPDFVersion() int extension_level = pdf.getExtensionLevel();
<< std::endl; std::cout << "PDF Version: " << pdf.getPDFVersion();
if (extension_level > 0)
{
std::cout << " extension level "
<< pdf.getExtensionLevel();
}
std::cout << std::endl;
::show_encryption(pdf); ::show_encryption(pdf);
if (pdf.isLinearized()) if (pdf.isLinearized())
{ {
@ -1603,11 +1627,17 @@ int main(int argc, char* argv[])
} }
if (! min_version.empty()) if (! min_version.empty())
{ {
w.setMinimumPDFVersion(min_version); std::string version;
int extension_level = 0;
parse_version(min_version, version, extension_level);
w.setMinimumPDFVersion(version, extension_level);
} }
if (! force_version.empty()) if (! force_version.empty())
{ {
w.forcePDFVersion(force_version); std::string version;
int extension_level = 0;
parse_version(force_version, version, extension_level);
w.forcePDFVersion(version, extension_level);
} }
w.write(); w.write();
} }

View File

@ -151,7 +151,7 @@ qpdf-c called qpdf_allow_modify_form 0
qpdf-c called qpdf_allow_modify_annotation 0 qpdf-c called qpdf_allow_modify_annotation 0
qpdf-c called qpdf_allow_modify_other 0 qpdf-c called qpdf_allow_modify_other 0
qpdf-c called qpdf_allow_modify_all 0 qpdf-c called qpdf_allow_modify_all 0
QPDFWriter increasing minimum version 0 QPDFWriter increasing minimum version 1
QPDFWriter using forced PDF version 0 QPDFWriter using forced PDF version 0
qpdf-c called qpdf_set_minimum_pdf_version 0 qpdf-c called qpdf_set_minimum_pdf_version 0
qpdf-c called qpdf_force_pdf_version 0 qpdf-c called qpdf_force_pdf_version 0
@ -243,4 +243,13 @@ QPDFWriter extra header text no newline 0
QPDFWriter extra header text add newline 0 QPDFWriter extra header text add newline 0
QPDF bogus 0 offset 0 QPDF bogus 0 offset 0
QPDF global offset 0 QPDF global offset 0
QPDF make stream key direct 0 QPDFWriter make stream key direct 0
QPDFWriter increasing extension level 0
QPDFWriter make Extensions direct 0
QPDFWriter make ADBE direct 1
QPDFWriter preserve Extensions 0
QPDFWriter create Extensions 1
QPDFWriter skip ADBE 0
QPDFWriter remove existing Extensions 0
QPDFWriter skip Extensions 0
QPDFWriter preserve ADBE 0

View File

@ -109,6 +109,55 @@ $td->runtest("new stream",
{$td->FILE => "a.pdf"}, {$td->FILE => "a.pdf"},
{$td->FILE => "add-contents.pdf"}); {$td->FILE => "add-contents.pdf"});
show_ntests();
# ----------
$td->notify("--- Extensions Dictionary Tests ---");
my @ext_inputs = ('minimal.pdf', 'extensions-adbe.pdf',
'extensions-other.pdf', 'extensions-adbe-other.pdf');
my @new_versions = ('1.3', '1.6', '1.7.1', '1.7.2', '1.7.3',
'1.8', '1.8.0', '1.8.2', '1.8.5');
$n_tests += (4 * @new_versions + 3) * @ext_inputs;
foreach my $input (@ext_inputs)
{
my $base = $input;
$base =~ s/\.pdf$//;
if ($base eq 'minimal')
{
$base = 'extensions-none';
}
foreach my $version (@new_versions)
{
foreach my $op (qw(min force))
{
$td->runtest("$input: $op version to $version",
{$td->COMMAND =>
"qpdf --static-id" .
" --$op-version=$version $input a.pdf"},
{$td->STRING => "", $td->EXIT_STATUS => 0});
$td->runtest("check version information",
{$td->COMMAND => "test_driver 34 a.pdf"},
{$td->FILE => "$base-$op-$version.out",
$td->EXIT_STATUS => 0},
$td->NORMALIZE_NEWLINES);
if (($op eq 'force') && ($version eq '1.8.5'))
{
# Look at the actual file for a few cases to make sure
# qdf and non-qdf output are okay
$td->runtest("check file",
{$td->FILE => "a.pdf"},
{$td->FILE => "$base-$op-$version.pdf"});
$td->runtest("$input: $op version to $version",
{$td->COMMAND =>
"qpdf --qdf --static-id" .
" --$op-version=$version $input a.qdf"},
{$td->STRING => "", $td->EXIT_STATUS => 0});
$td->runtest("check file",
{$td->FILE => "a.qdf"},
{$td->FILE => "$base-$op-$version.qdf"});
}
}
}
}
show_ntests(); show_ntests();
# ---------- # ----------
$td->notify("--- Page API Tests ---"); $td->notify("--- Page API Tests ---");
@ -147,6 +196,7 @@ $td->runtest("remove page we don't have",
{$td->COMMAND => "test_driver 22 page_api_1.pdf"}, {$td->COMMAND => "test_driver 22 page_api_1.pdf"},
{$td->FILE => "page_api_1.out2", $td->EXIT_STATUS => 2}, {$td->FILE => "page_api_1.out2", $td->EXIT_STATUS => 2},
$td->NORMALIZE_NEWLINES); $td->NORMALIZE_NEWLINES);
show_ntests();
# ---------- # ----------
$td->notify("--- Miscellaneous Tests ---"); $td->notify("--- Miscellaneous Tests ---");
$n_tests += 57; $n_tests += 57;
@ -466,6 +516,7 @@ foreach my $d (@nrange_tests)
$td->NORMALIZE_NEWLINES); $td->NORMALIZE_NEWLINES);
} }
show_ntests();
# ---------- # ----------
$td->notify("--- Merging and Splitting ---"); $td->notify("--- Merging and Splitting ---");
$n_tests += 6; $n_tests += 6;
@ -513,6 +564,7 @@ $td->runtest("avoid respecification of password",
$td->runtest("check output", $td->runtest("check output",
{$td->FILE => "a.pdf"}, {$td->FILE => "a.pdf"},
{$td->FILE => "pages-copy-encryption.pdf"}); {$td->FILE => "pages-copy-encryption.pdf"});
show_ntests();
# ---------- # ----------
$td->notify("--- PDF From Scratch ---"); $td->notify("--- PDF From Scratch ---");
$n_tests += 2; $n_tests += 2;
@ -524,6 +576,7 @@ $td->runtest("basic qpdf from scratch",
$td->runtest("check output", $td->runtest("check output",
{$td->FILE => "a.pdf"}, {$td->FILE => "a.pdf"},
{$td->FILE => "from-scratch-0.pdf"}); {$td->FILE => "from-scratch-0.pdf"});
show_ntests();
# ---------- # ----------
$td->notify("--- Copy Foreign Objects ---"); $td->notify("--- Copy Foreign Objects ---");
$n_tests += 7; $n_tests += 7;
@ -546,6 +599,7 @@ $td->runtest("copy objects error",
{$td->FILE => "copy-foreign-objects-errors.out", {$td->FILE => "copy-foreign-objects-errors.out",
$td->EXIT_STATUS => 0}, $td->EXIT_STATUS => 0},
$td->NORMALIZE_NEWLINES); $td->NORMALIZE_NEWLINES);
show_ntests();
# ---------- # ----------
$td->notify("--- Error Condition Tests ---"); $td->notify("--- Error Condition Tests ---");
# $n_tests incremented after initialization of badfiles below. # $n_tests incremented after initialization of badfiles below.

View File

@ -0,0 +1,4 @@
version: 1.3
extension level: 0
null
test 34 done

View File

@ -0,0 +1,4 @@
version: 1.6
extension level: 0
null
test 34 done

View File

@ -0,0 +1,4 @@
version: 1.7
extension level: 1
<< /ADBE << /BaseVersion /1.7 /ExtensionLevel 1 >> >>
test 34 done

View File

@ -0,0 +1,4 @@
version: 1.7
extension level: 2
<< /ADBE << /BaseVersion /1.7 /ExtensionLevel 2 /URL (http://something.adobe.com) >> >>
test 34 done

View File

@ -0,0 +1,4 @@
version: 1.7
extension level: 3
<< /ADBE << /BaseVersion /1.7 /ExtensionLevel 3 >> >>
test 34 done

View File

@ -0,0 +1,4 @@
version: 1.8
extension level: 0
null
test 34 done

View File

@ -0,0 +1,4 @@
version: 1.8
extension level: 2
<< /ADBE << /BaseVersion /1.8 /ExtensionLevel 2 >> >>
test 34 done

View File

@ -0,0 +1,4 @@
version: 1.8
extension level: 5
<< /ADBE << /BaseVersion /1.8 /ExtensionLevel 5 >> >>
test 34 done

Binary file not shown.

View File

@ -0,0 +1,104 @@
%PDF-1.8
%¿÷¢þ
%QDF-1.0
%% Original object ID: 1 0
1 0 obj
<<
/Extensions <<
/ADBE << /BaseVersion /1.8 /ExtensionLevel 5 >>
>>
/Pages 2 0 R
/Type /Catalog
>>
endobj
%% Original object ID: 2 0
2 0 obj
<<
/Count 1
/Kids [
3 0 R
]
/Type /Pages
>>
endobj
%% Page 1
%% Original object ID: 3 0
3 0 obj
<<
/Contents 4 0 R
/MediaBox [
0
0
612
792
]
/Parent 2 0 R
/Resources <<
/Font <<
/F1 6 0 R
>>
/ProcSet 7 0 R
>>
/Type /Page
>>
endobj
%% Contents for page 1
%% Original object ID: 4 0
4 0 obj
<<
/Length 5 0 R
>>
stream
BT
/F1 24 Tf
72 720 Td
(Potato) Tj
ET
endstream
endobj
5 0 obj
44
endobj
%% Original object ID: 6 0
6 0 obj
<<
/BaseFont /Helvetica
/Encoding /WinAnsiEncoding
/Name /F1
/Subtype /Type1
/Type /Font
>>
endobj
%% Original object ID: 7 0
7 0 obj
[
/PDF
/Text
]
endobj
xref
0 8
0000000000 65535 f
0000000052 00000 n
0000000207 00000 n
0000000316 00000 n
0000000558 00000 n
0000000657 00000 n
0000000703 00000 n
0000000848 00000 n
trailer <<
/Root 1 0 R
/Size 8
/ID [<e42c124696c09bd2cacaf7196e9c88a0><31415926535897932384626433832795>]
>>
startxref
883
%%EOF

View File

@ -0,0 +1,4 @@
version: 1.8
extension level: 0
null
test 34 done

View File

@ -0,0 +1,4 @@
version: 1.7
extension level: 2
<< /ADBE << /BaseVersion /1.7 /ExtensionLevel 2 /URL (http://something.adobe.com) >> >>
test 34 done

View File

@ -0,0 +1,4 @@
version: 1.7
extension level: 2
<< /ADBE << /BaseVersion /1.7 /ExtensionLevel 2 /URL (http://something.adobe.com) >> >>
test 34 done

View File

@ -0,0 +1,4 @@
version: 1.7
extension level: 2
<< /ADBE << /BaseVersion /1.7 /ExtensionLevel 2 /URL (http://something.adobe.com) >> >>
test 34 done

View File

@ -0,0 +1,4 @@
version: 1.7
extension level: 2
<< /ADBE << /BaseVersion /1.7 /ExtensionLevel 2 /URL (http://something.adobe.com) >> >>
test 34 done

View File

@ -0,0 +1,4 @@
version: 1.7
extension level: 3
<< /ADBE << /BaseVersion /1.7 /ExtensionLevel 3 >> >>
test 34 done

View File

@ -0,0 +1,4 @@
version: 1.8
extension level: 0
null
test 34 done

View File

@ -0,0 +1,4 @@
version: 1.8
extension level: 2
<< /ADBE << /BaseVersion /1.8 /ExtensionLevel 2 >> >>
test 34 done

View File

@ -0,0 +1,4 @@
version: 1.8
extension level: 5
<< /ADBE << /BaseVersion /1.8 /ExtensionLevel 5 >> >>
test 34 done

View File

@ -0,0 +1,4 @@
version: 1.8
extension level: 0
null
test 34 done

View File

@ -0,0 +1,4 @@
version: 1.3
extension level: 0
<< /Potato << /BaseVersion /3.14159 /ExtensionLevel 16059 >> >>
test 34 done

View File

@ -0,0 +1,4 @@
version: 1.6
extension level: 0
<< /Potato << /BaseVersion /3.14159 /ExtensionLevel 16059 >> >>
test 34 done

View File

@ -0,0 +1,4 @@
version: 1.7
extension level: 1
<< /ADBE << /BaseVersion /1.7 /ExtensionLevel 1 >> /Potato << /BaseVersion /3.14159 /ExtensionLevel 16059 >> >>
test 34 done

View File

@ -0,0 +1,4 @@
version: 1.7
extension level: 2
<< /ADBE << /BaseVersion /1.7 /ExtensionLevel 2 >> /Potato << /BaseVersion /3.14159 /ExtensionLevel 16059 >> >>
test 34 done

View File

@ -0,0 +1,4 @@
version: 1.7
extension level: 3
<< /ADBE << /BaseVersion /1.7 /ExtensionLevel 3 >> /Potato << /BaseVersion /3.14159 /ExtensionLevel 16059 >> >>
test 34 done

View File

@ -0,0 +1,4 @@
version: 1.8
extension level: 0
<< /Potato << /BaseVersion /3.14159 /ExtensionLevel 16059 >> >>
test 34 done

View File

@ -0,0 +1,4 @@
version: 1.8
extension level: 2
<< /ADBE << /BaseVersion /1.8 /ExtensionLevel 2 >> /Potato << /BaseVersion /3.14159 /ExtensionLevel 16059 >> >>
test 34 done

View File

@ -0,0 +1,4 @@
version: 1.8
extension level: 5
<< /ADBE << /BaseVersion /1.8 /ExtensionLevel 5 >> /Potato << /BaseVersion /3.14159 /ExtensionLevel 16059 >> >>
test 34 done

Binary file not shown.

View File

@ -0,0 +1,108 @@
%PDF-1.8
%¿÷¢þ
%QDF-1.0
%% Original object ID: 1 0
1 0 obj
<<
/Extensions <<
/ADBE << /BaseVersion /1.8 /ExtensionLevel 5 >>
/Potato <<
/BaseVersion /3.14159
/ExtensionLevel 16059
>>
>>
/Pages 2 0 R
/Type /Catalog
>>
endobj
%% Original object ID: 2 0
2 0 obj
<<
/Count 1
/Kids [
3 0 R
]
/Type /Pages
>>
endobj
%% Page 1
%% Original object ID: 3 0
3 0 obj
<<
/Contents 4 0 R
/MediaBox [
0
0
612
792
]
/Parent 2 0 R
/Resources <<
/Font <<
/F1 6 0 R
>>
/ProcSet 7 0 R
>>
/Type /Page
>>
endobj
%% Contents for page 1
%% Original object ID: 4 0
4 0 obj
<<
/Length 5 0 R
>>
stream
BT
/F1 24 Tf
72 720 Td
(Potato) Tj
ET
endstream
endobj
5 0 obj
44
endobj
%% Original object ID: 6 0
6 0 obj
<<
/BaseFont /Helvetica
/Encoding /WinAnsiEncoding
/Name /F1
/Subtype /Type1
/Type /Font
>>
endobj
%% Original object ID: 7 0
7 0 obj
[
/PDF
/Text
]
endobj
xref
0 8
0000000000 65535 f
0000000052 00000 n
0000000285 00000 n
0000000394 00000 n
0000000636 00000 n
0000000735 00000 n
0000000781 00000 n
0000000926 00000 n
trailer <<
/Root 1 0 R
/Size 8
/ID [<484577389048fa45fc00a1f5b434efa5><31415926535897932384626433832795>]
>>
startxref
961
%%EOF

View File

@ -0,0 +1,4 @@
version: 1.8
extension level: 0
<< /Potato << /BaseVersion /3.14159 /ExtensionLevel 16059 >> >>
test 34 done

View File

@ -0,0 +1,4 @@
version: 1.7
extension level: 2
<< /ADBE << /BaseVersion /1.7 /ExtensionLevel 2 >> /Potato << /BaseVersion /3.14159 /ExtensionLevel 16059 >> >>
test 34 done

View File

@ -0,0 +1,4 @@
version: 1.7
extension level: 2
<< /ADBE << /BaseVersion /1.7 /ExtensionLevel 2 >> /Potato << /BaseVersion /3.14159 /ExtensionLevel 16059 >> >>
test 34 done

View File

@ -0,0 +1,4 @@
version: 1.7
extension level: 2
<< /ADBE << /BaseVersion /1.7 /ExtensionLevel 2 >> /Potato << /BaseVersion /3.14159 /ExtensionLevel 16059 >> >>
test 34 done

View File

@ -0,0 +1,4 @@
version: 1.7
extension level: 2
<< /ADBE << /BaseVersion /1.7 /ExtensionLevel 2 >> /Potato << /BaseVersion /3.14159 /ExtensionLevel 16059 >> >>
test 34 done

View File

@ -0,0 +1,4 @@
version: 1.7
extension level: 3
<< /ADBE << /BaseVersion /1.7 /ExtensionLevel 3 >> /Potato << /BaseVersion /3.14159 /ExtensionLevel 16059 >> >>
test 34 done

View File

@ -0,0 +1,4 @@
version: 1.8
extension level: 0
<< /Potato << /BaseVersion /3.14159 /ExtensionLevel 16059 >> >>
test 34 done

View File

@ -0,0 +1,4 @@
version: 1.8
extension level: 2
<< /ADBE << /BaseVersion /1.8 /ExtensionLevel 2 >> /Potato << /BaseVersion /3.14159 /ExtensionLevel 16059 >> >>
test 34 done

View File

@ -0,0 +1,4 @@
version: 1.8
extension level: 5
<< /ADBE << /BaseVersion /1.8 /ExtensionLevel 5 >> /Potato << /BaseVersion /3.14159 /ExtensionLevel 16059 >> >>
test 34 done

View File

@ -0,0 +1,4 @@
version: 1.8
extension level: 0
<< /Potato << /BaseVersion /3.14159 /ExtensionLevel 16059 >> >>
test 34 done

View File

@ -0,0 +1,104 @@
%PDF-1.7
%¿÷¢þ
%QDF-1.0
1 0 obj
<<
/Pages 2 0 R
/Type /Catalog
/Extensions <<
/ADBE 8 0 R
/Potato << /BaseVersion /3.14159 /ExtensionLevel 16059 >>
>>
>>
endobj
2 0 obj
<<
/Count 1
/Kids [
3 0 R
]
/Type /Pages
>>
endobj
%% Page 1
3 0 obj
<<
/Contents 4 0 R
/MediaBox [
0
0
612
792
]
/Parent 2 0 R
/Resources <<
/Font <<
/F1 6 0 R
>>
/ProcSet 7 0 R
>>
/Type /Page
>>
endobj
%% Contents for page 1
4 0 obj
<<
/Length 5 0 R
>>
stream
BT
/F1 24 Tf
72 720 Td
(Potato) Tj
ET
endstream
endobj
5 0 obj
44
endobj
6 0 obj
<<
/BaseFont /Helvetica
/Encoding /WinAnsiEncoding
/Name /F1
/Subtype /Type1
/Type /Font
>>
endobj
7 0 obj
[
/PDF
/Text
]
endobj
8 0 obj
<< /BaseVersion /1.7 /ExtensionLevel 2 >>
endobj
xref
0 9
0000000000 65535 f
0000000025 00000 n
0000000179 00000 n
0000000261 00000 n
0000000476 00000 n
0000000575 00000 n
0000000594 00000 n
0000000712 00000 n
0000000747 00000 n
trailer <<
/Root 1 0 R
/Size 9
/ID [<484577389048fa45fc00a1f5b434efa5><484577389048fa45fc00a1f5b434efa5>]
>>
startxref
805
%%EOF

View File

@ -0,0 +1,106 @@
%PDF-1.7
%¿÷¢þ
%QDF-1.0
1 0 obj
<<
/Pages 2 0 R
/Type /Catalog
/Extensions 8 0 R
>>
endobj
2 0 obj
<<
/Count 1
/Kids [
3 0 R
]
/Type /Pages
>>
endobj
%% Page 1
3 0 obj
<<
/Contents 4 0 R
/MediaBox [
0
0
612
792
]
/Parent 2 0 R
/Resources <<
/Font <<
/F1 6 0 R
>>
/ProcSet 7 0 R
>>
/Type /Page
>>
endobj
%% Contents for page 1
4 0 obj
<<
/Length 5 0 R
>>
stream
BT
/F1 24 Tf
72 720 Td
(Potato) Tj
ET
endstream
endobj
5 0 obj
44
endobj
6 0 obj
<<
/BaseFont /Helvetica
/Encoding /WinAnsiEncoding
/Name /F1
/Subtype /Type1
/Type /Font
>>
endobj
7 0 obj
[
/PDF
/Text
]
endobj
8 0 obj
<< /ADBE 9 0 R >>
endobj
9 0 obj
<< /BaseVersion /1.7 /ExtensionLevel 2 /URL (http://something.adobe.com) >>
endobj
xref
0 10
0000000000 65535 f
0000000025 00000 n
0000000099 00000 n
0000000181 00000 n
0000000396 00000 n
0000000495 00000 n
0000000514 00000 n
0000000632 00000 n
0000000667 00000 n
0000000701 00000 n
trailer <<
/Root 1 0 R
/Size 10
/ID [<e42c124696c09bd2cacaf7196e9c88a0><e42c124696c09bd2cacaf7196e9c88a0>]
>>
startxref
793
%%EOF

View File

@ -0,0 +1,4 @@
version: 1.3
extension level: 0
null
test 34 done

View File

@ -0,0 +1,4 @@
version: 1.6
extension level: 0
null
test 34 done

View File

@ -0,0 +1,4 @@
version: 1.7
extension level: 1
<< /ADBE << /BaseVersion /1.7 /ExtensionLevel 1 >> >>
test 34 done

View File

@ -0,0 +1,4 @@
version: 1.7
extension level: 2
<< /ADBE << /BaseVersion /1.7 /ExtensionLevel 2 >> >>
test 34 done

View File

@ -0,0 +1,4 @@
version: 1.7
extension level: 3
<< /ADBE << /BaseVersion /1.7 /ExtensionLevel 3 >> >>
test 34 done

View File

@ -0,0 +1,4 @@
version: 1.8
extension level: 0
null
test 34 done

View File

@ -0,0 +1,4 @@
version: 1.8
extension level: 2
<< /ADBE << /BaseVersion /1.8 /ExtensionLevel 2 >> >>
test 34 done

View File

@ -0,0 +1,4 @@
version: 1.8
extension level: 5
<< /ADBE << /BaseVersion /1.8 /ExtensionLevel 5 >> >>
test 34 done

Binary file not shown.

View File

@ -0,0 +1,102 @@
%PDF-1.8
%¿÷¢þ
%QDF-1.0
%% Original object ID: 1 0
1 0 obj
<<
/Extensions << /ADBE << /BaseVersion /1.8 /ExtensionLevel 5 >> >>
/Pages 2 0 R
/Type /Catalog
>>
endobj
%% Original object ID: 2 0
2 0 obj
<<
/Count 1
/Kids [
3 0 R
]
/Type /Pages
>>
endobj
%% Page 1
%% Original object ID: 3 0
3 0 obj
<<
/Contents 4 0 R
/MediaBox [
0
0
612
792
]
/Parent 2 0 R
/Resources <<
/Font <<
/F1 6 0 R
>>
/ProcSet 7 0 R
>>
/Type /Page
>>
endobj
%% Contents for page 1
%% Original object ID: 4 0
4 0 obj
<<
/Length 5 0 R
>>
stream
BT
/F1 24 Tf
72 720 Td
(Potato) Tj
ET
endstream
endobj
5 0 obj
44
endobj
%% Original object ID: 6 0
6 0 obj
<<
/BaseFont /Helvetica
/Encoding /WinAnsiEncoding
/Name /F1
/Subtype /Type1
/Type /Font
>>
endobj
%% Original object ID: 5 0
7 0 obj
[
/PDF
/Text
]
endobj
xref
0 8
0000000000 65535 f
0000000052 00000 n
0000000201 00000 n
0000000310 00000 n
0000000552 00000 n
0000000651 00000 n
0000000697 00000 n
0000000842 00000 n
trailer <<
/Root 1 0 R
/Size 8
/ID [<31415926535897932384626433832795><31415926535897932384626433832795>]
>>
startxref
877
%%EOF

View File

@ -0,0 +1,4 @@
version: 1.8
extension level: 0
null
test 34 done

View File

@ -0,0 +1,4 @@
version: 1.3
extension level: 0
null
test 34 done

View File

@ -0,0 +1,4 @@
version: 1.6
extension level: 0
null
test 34 done

View File

@ -0,0 +1,4 @@
version: 1.7
extension level: 1
<< /ADBE << /BaseVersion /1.7 /ExtensionLevel 1 >> >>
test 34 done

View File

@ -0,0 +1,4 @@
version: 1.7
extension level: 2
<< /ADBE << /BaseVersion /1.7 /ExtensionLevel 2 >> >>
test 34 done

View File

@ -0,0 +1,4 @@
version: 1.7
extension level: 3
<< /ADBE << /BaseVersion /1.7 /ExtensionLevel 3 >> >>
test 34 done

View File

@ -0,0 +1,4 @@
version: 1.8
extension level: 0
null
test 34 done

View File

@ -0,0 +1,4 @@
version: 1.8
extension level: 2
<< /ADBE << /BaseVersion /1.8 /ExtensionLevel 2 >> >>
test 34 done

View File

@ -0,0 +1,4 @@
version: 1.8
extension level: 5
<< /ADBE << /BaseVersion /1.8 /ExtensionLevel 5 >> >>
test 34 done

View File

@ -0,0 +1,4 @@
version: 1.8
extension level: 0
null
test 34 done

View File

@ -0,0 +1,4 @@
version: 1.3
extension level: 0
<< /Potato << /BaseVersion /3.14159 /ExtensionLevel 16059 >> >>
test 34 done

View File

@ -0,0 +1,4 @@
version: 1.6
extension level: 0
<< /Potato << /BaseVersion /3.14159 /ExtensionLevel 16059 >> >>
test 34 done

View File

@ -0,0 +1,4 @@
version: 1.7
extension level: 1
<< /ADBE << /BaseVersion /1.7 /ExtensionLevel 1 >> /Potato << /BaseVersion /3.14159 /ExtensionLevel 16059 >> >>
test 34 done

View File

@ -0,0 +1,4 @@
version: 1.7
extension level: 2
<< /ADBE << /BaseVersion /1.7 /ExtensionLevel 2 >> /Potato << /BaseVersion /3.14159 /ExtensionLevel 16059 >> >>
test 34 done

View File

@ -0,0 +1,4 @@
version: 1.7
extension level: 3
<< /ADBE << /BaseVersion /1.7 /ExtensionLevel 3 >> /Potato << /BaseVersion /3.14159 /ExtensionLevel 16059 >> >>
test 34 done

View File

@ -0,0 +1,4 @@
version: 1.8
extension level: 0
<< /Potato << /BaseVersion /3.14159 /ExtensionLevel 16059 >> >>
test 34 done

View File

@ -0,0 +1,4 @@
version: 1.8
extension level: 2
<< /ADBE << /BaseVersion /1.8 /ExtensionLevel 2 >> /Potato << /BaseVersion /3.14159 /ExtensionLevel 16059 >> >>
test 34 done

View File

@ -0,0 +1,4 @@
version: 1.8
extension level: 5
<< /ADBE << /BaseVersion /1.8 /ExtensionLevel 5 >> /Potato << /BaseVersion /3.14159 /ExtensionLevel 16059 >> >>
test 34 done

Binary file not shown.

View File

@ -0,0 +1,108 @@
%PDF-1.8
%¿÷¢þ
%QDF-1.0
%% Original object ID: 1 0
1 0 obj
<<
/Extensions <<
/ADBE << /BaseVersion /1.8 /ExtensionLevel 5 >>
/Potato <<
/BaseVersion /3.14159
/ExtensionLevel 16059
>>
>>
/Pages 2 0 R
/Type /Catalog
>>
endobj
%% Original object ID: 2 0
2 0 obj
<<
/Count 1
/Kids [
3 0 R
]
/Type /Pages
>>
endobj
%% Page 1
%% Original object ID: 3 0
3 0 obj
<<
/Contents 4 0 R
/MediaBox [
0
0
612
792
]
/Parent 2 0 R
/Resources <<
/Font <<
/F1 6 0 R
>>
/ProcSet 7 0 R
>>
/Type /Page
>>
endobj
%% Contents for page 1
%% Original object ID: 4 0
4 0 obj
<<
/Length 5 0 R
>>
stream
BT
/F1 24 Tf
72 720 Td
(Potato) Tj
ET
endstream
endobj
5 0 obj
44
endobj
%% Original object ID: 6 0
6 0 obj
<<
/BaseFont /Helvetica
/Encoding /WinAnsiEncoding
/Name /F1
/Subtype /Type1
/Type /Font
>>
endobj
%% Original object ID: 7 0
7 0 obj
[
/PDF
/Text
]
endobj
xref
0 8
0000000000 65535 f
0000000052 00000 n
0000000285 00000 n
0000000394 00000 n
0000000636 00000 n
0000000735 00000 n
0000000781 00000 n
0000000926 00000 n
trailer <<
/Root 1 0 R
/Size 8
/ID [<369e89600ee1a6c4c7e73533610180c2><31415926535897932384626433832795>]
>>
startxref
961
%%EOF

View File

@ -0,0 +1,4 @@
version: 1.8
extension level: 0
<< /Potato << /BaseVersion /3.14159 /ExtensionLevel 16059 >> >>
test 34 done

View File

@ -0,0 +1,4 @@
version: 1.5
extension level: 0
<< /Potato << /BaseVersion /3.14159 /ExtensionLevel 16059 >> >>
test 34 done

View File

@ -0,0 +1,4 @@
version: 1.6
extension level: 0
<< /Potato << /BaseVersion /3.14159 /ExtensionLevel 16059 >> >>
test 34 done

View File

@ -0,0 +1,4 @@
version: 1.7
extension level: 1
<< /ADBE << /BaseVersion /1.7 /ExtensionLevel 1 >> /Potato << /BaseVersion /3.14159 /ExtensionLevel 16059 >> >>
test 34 done

View File

@ -0,0 +1,4 @@
version: 1.7
extension level: 2
<< /ADBE << /BaseVersion /1.7 /ExtensionLevel 2 >> /Potato << /BaseVersion /3.14159 /ExtensionLevel 16059 >> >>
test 34 done

View File

@ -0,0 +1,4 @@
version: 1.7
extension level: 3
<< /ADBE << /BaseVersion /1.7 /ExtensionLevel 3 >> /Potato << /BaseVersion /3.14159 /ExtensionLevel 16059 >> >>
test 34 done

View File

@ -0,0 +1,4 @@
version: 1.8
extension level: 0
<< /Potato << /BaseVersion /3.14159 /ExtensionLevel 16059 >> >>
test 34 done

View File

@ -0,0 +1,4 @@
version: 1.8
extension level: 2
<< /ADBE << /BaseVersion /1.8 /ExtensionLevel 2 >> /Potato << /BaseVersion /3.14159 /ExtensionLevel 16059 >> >>
test 34 done

View File

@ -0,0 +1,4 @@
version: 1.8
extension level: 5
<< /ADBE << /BaseVersion /1.8 /ExtensionLevel 5 >> /Potato << /BaseVersion /3.14159 /ExtensionLevel 16059 >> >>
test 34 done

View File

@ -0,0 +1,4 @@
version: 1.8
extension level: 0
<< /Potato << /BaseVersion /3.14159 /ExtensionLevel 16059 >> >>
test 34 done

View File

@ -0,0 +1,98 @@
%PDF-1.5
%¿÷¢þ
%QDF-1.0
1 0 obj
<<
/Pages 2 0 R
/Type /Catalog
/Extensions <<
/Potato << /BaseVersion /3.14159 /ExtensionLevel 16059 >>
>>
>>
endobj
2 0 obj
<<
/Count 1
/Kids [
3 0 R
]
/Type /Pages
>>
endobj
%% Page 1
3 0 obj
<<
/Contents 4 0 R
/MediaBox [
0
0
612
792
]
/Parent 2 0 R
/Resources <<
/Font <<
/F1 6 0 R
>>
/ProcSet 7 0 R
>>
/Type /Page
>>
endobj
%% Contents for page 1
4 0 obj
<<
/Length 5 0 R
>>
stream
BT
/F1 24 Tf
72 720 Td
(Potato) Tj
ET
endstream
endobj
5 0 obj
44
endobj
6 0 obj
<<
/BaseFont /Helvetica
/Encoding /WinAnsiEncoding
/Name /F1
/Subtype /Type1
/Type /Font
>>
endobj
7 0 obj
[
/PDF
/Text
]
endobj
xref
0 8
0000000000 65535 f
0000000025 00000 n
0000000163 00000 n
0000000245 00000 n
0000000460 00000 n
0000000559 00000 n
0000000578 00000 n
0000000696 00000 n
trailer <<
/Root 1 0 R
/Size 8
/ID [<369e89600ee1a6c4c7e73533610180c2><369e89600ee1a6c4c7e73533610180c2>]
>>
startxref
731
%%EOF

View File

@ -1,7 +1,7 @@
checking obj0.pdf checking obj0.pdf
PDF Version: 1.3
File is not encrypted
File is not linearized
WARNING: obj0.pdf: file is damaged WARNING: obj0.pdf: file is damaged
WARNING: obj0.pdf (object 1 0, file position 77): expected n n obj WARNING: obj0.pdf (object 1 0, file position 77): expected n n obj
WARNING: obj0.pdf: Attempting to reconstruct cross-reference table WARNING: obj0.pdf: Attempting to reconstruct cross-reference table
PDF Version: 1.3
File is not encrypted
File is not linearized

View File

@ -1126,6 +1126,13 @@ void runtest(int n, char const* filename1, char const* filename2)
fwrite(b->getBuffer(), b->getSize(), 1, f); fwrite(b->getBuffer(), b->getSize(), 1, f);
fclose(f); fclose(f);
} }
else if (n == 34)
{
// Look at Extensions dictionary
std::cout << "version: " << pdf.getPDFVersion() << std::endl
<< "extension level: " << pdf.getExtensionLevel() << std::endl
<< pdf.getRoot().getKey("/Extensions").unparse() << std::endl;
}
else else
{ {
throw std::runtime_error(std::string("invalid test ") + throw std::runtime_error(std::string("invalid test ") +