aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2012-06-22 05:06:48 +0200
committerJay Berkenbilt <ejb@ql.org>2012-06-22 05:09:05 +0200
commita0768e419064b66ea6eb3e06a4398806b24311e8 (patch)
tree6ecfa1f080bdab2ee4573d14dd71c06507b84bdd /libqpdf
parent9eb8c9159b97b500e0ecb36271b663cafc89d932 (diff)
downloadqpdf-a0768e419064b66ea6eb3e06a4398806b24311e8.tar.zst
Add QPDF::emptyPDF() and pdf_from_scratch test code
Diffstat (limited to 'libqpdf')
-rw-r--r--libqpdf/QPDF.cc24
-rw-r--r--libqpdf/QPDF_optimization.cc2
-rw-r--r--libqpdf/QPDF_pages.cc2
3 files changed, 26 insertions, 2 deletions
diff --git a/libqpdf/QPDF.cc b/libqpdf/QPDF.cc
index e97da295..b0a8741c 100644
--- a/libqpdf/QPDF.cc
+++ b/libqpdf/QPDF.cc
@@ -17,6 +17,24 @@
std::string QPDF::qpdf_version = "2.3.1";
+static char const* EMPTY_PDF =
+ "%PDF-1.3\n"
+ "1 0 obj\n"
+ "<< /Type /Catalog /Pages 2 0 R >>\n"
+ "endobj\n"
+ "2 0 obj\n"
+ "<< /Type /Pages /Kids [] /Count 0 >>\n"
+ "endobj\n"
+ "xref\n"
+ "0 3\n"
+ "0000000000 65535 f \n"
+ "0000000009 00000 n \n"
+ "0000000058 00000 n \n"
+ "trailer << /Size 3 /Root 1 0 R >>\n"
+ "startxref\n"
+ "110\n"
+ "%%EOF\n";
+
void
QPDF::InputSource::setLastOffset(qpdf_offset_t offset)
{
@@ -350,6 +368,12 @@ QPDF::processMemoryFile(char const* description,
}
void
+QPDF::emptyPDF()
+{
+ processMemoryFile("empty file", EMPTY_PDF, strlen(EMPTY_PDF));
+}
+
+void
QPDF::setIgnoreXRefStreams(bool val)
{
this->ignore_xref_streams = val;
diff --git a/libqpdf/QPDF_optimization.cc b/libqpdf/QPDF_optimization.cc
index 10b56b60..f2d33863 100644
--- a/libqpdf/QPDF_optimization.cc
+++ b/libqpdf/QPDF_optimization.cc
@@ -365,7 +365,7 @@ QPDF::optimizePagesTreeInternal(
throw QPDFExc(qpdf_e_damaged_pdf, this->file->getName(),
this->last_object_description,
this->file->getLastOffset(),
- "invalid Type in page tree");
+ "invalid Type " + type + " in page tree");
}
}
diff --git a/libqpdf/QPDF_pages.cc b/libqpdf/QPDF_pages.cc
index 2b8a831e..89f5f195 100644
--- a/libqpdf/QPDF_pages.cc
+++ b/libqpdf/QPDF_pages.cc
@@ -73,7 +73,7 @@ QPDF::getAllPagesInternal(QPDFObjectHandle cur_pages,
throw QPDFExc(qpdf_e_damaged_pdf, this->file->getName(),
this->last_object_description,
this->file->getLastOffset(),
- ": invalid Type in page tree");
+ "invalid Type " + type + " in page tree");
}
}