From a0768e419064b66ea6eb3e06a4398806b24311e8 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Thu, 21 Jun 2012 23:06:48 -0400 Subject: Add QPDF::emptyPDF() and pdf_from_scratch test code --- libqpdf/QPDF.cc | 24 ++++++++++++++++++++++++ libqpdf/QPDF_optimization.cc | 2 +- libqpdf/QPDF_pages.cc | 2 +- 3 files changed, 26 insertions(+), 2 deletions(-) (limited to 'libqpdf') 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) { @@ -349,6 +367,12 @@ QPDF::processMemoryFile(char const* description, parse(password); } +void +QPDF::emptyPDF() +{ + processMemoryFile("empty file", EMPTY_PDF, strlen(EMPTY_PDF)); +} + void QPDF::setIgnoreXRefStreams(bool 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"); } } -- cgit v1.2.3-54-g00ecf