From 57c01ef81ff11b208188bbdedc98b6ce20c786b3 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Sun, 26 Jan 2020 16:43:55 -0500 Subject: In qdf mode, don't write extra XRef streams (fixes #386) fix-qdf assumes there is exactly one XRef stream and that it is at the end of the file. --- libqpdf/QPDFWriter.cc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'libqpdf/QPDFWriter.cc') diff --git a/libqpdf/QPDFWriter.cc b/libqpdf/QPDFWriter.cc index 7b769ae4..5f97117d 100644 --- a/libqpdf/QPDFWriter.cc +++ b/libqpdf/QPDFWriter.cc @@ -1241,6 +1241,21 @@ QPDFWriter::enqueueObject(QPDFObjectHandle object) " another file."); } + if (this->m->qdf_mode && + object.isStream() && object.getDict().getKey("/Type").isName() && + (object.getDict().getKey("/Type").getName() == "/XRef")) + { + // As a special case, do not output any extraneous XRef + // streams in QDF mode. Doing so will confuse fix-qdf, + // which expects to see only one XRef stream at the end of + // the file. This case can occur when creating a QDF from + // a file with object streams when preserving unreferenced + // objects since the old cross reference streams are not + // actually referenced by object number. + QTC::TC("qpdf", "QPDFWriter ignore XRef in qdf mode"); + return; + } + QPDFObjGen og = object.getObjGen(); if (this->m->obj_renumber.count(og) == 0) -- cgit v1.2.3-54-g00ecf