Patches for pdfTeX / luaTeX / XeTeX Object stream support for pdftosrc from: Han The Thanh diff -ur xpdf-3.02.orig/xpdf/XRef.cc xpdf-3.02/xpdf/XRef.cc --- xpdf-3.02.orig/xpdf/XRef.cc 2009-08-14 23:05:08.000000000 +0200 +++ xpdf-3.02/xpdf/XRef.cc 2009-10-15 14:32:25.000000000 +0200 @@ -5,6 +5,9 @@ // Copyright 1996-2003 Glyph & Cog, LLC // //======================================================================== +// Modified for TeX Live by Peter Breitenlohner +// See top-level ChangeLog for a list of all modifications +//======================================================================== #include @@ -45,37 +48,9 @@ // ObjectStream //------------------------------------------------------------------------ -class ObjectStream { -public: - - // Create an object stream, using object number , - // generation 0. - ObjectStream(XRef *xref, int objStrNumA); - - GBool isOk() { return ok; } - - ~ObjectStream(); - - // Return the object number of this object stream. - int getObjStrNum() { return objStrNum; } - - // Get the th object from this stream, which should be - // object number , generation 0. - Object *getObject(int objIdx, int objNum, Object *obj); - -private: - - int objStrNum; // object number of the object stream - int nObjects; // number of objects in the stream - Object *objs; // the objects (length = nObjects) - int *objNums; // the object numbers (length = nObjects) - GBool ok; -}; - ObjectStream::ObjectStream(XRef *xref, int objStrNumA) { Stream *str; Parser *parser; - int *offsets; Object objStr, obj1, obj2; int first, i; @@ -83,6 +58,7 @@ nObjects = 0; objs = NULL; objNums = NULL; + offsets = NULL; ok = gFalse; if (!xref->fetch(objStrNum, 0, &objStr)->isStream()) { @@ -104,6 +80,7 @@ goto err1; } first = obj1.getInt(); + firstOffset = objStr.getStream()->getBaseStream()->getStart() + first; obj1.free(); if (first < 0) { goto err1; @@ -132,7 +109,7 @@ obj1.free(); obj2.free(); delete parser; - gfree(offsets); +// gfree(offsets); goto err1; } objNums[i] = obj1.getInt(); @@ -142,7 +119,7 @@ if (objNums[i] < 0 || offsets[i] < 0 || (i > 0 && offsets[i] < offsets[i-1])) { delete parser; - gfree(offsets); +// gfree(offsets); goto err1; } } @@ -171,7 +148,7 @@ delete parser; } - gfree(offsets); +//gfree(offsets); ok = gTrue; err1: @@ -188,6 +165,7 @@ delete[] objs; } gfree(objNums); + gfree(offsets); } Object *ObjectStream::getObject(int objIdx, int objNum, Object *obj) { diff -ur xpdf-3.02.orig/xpdf/XRef.h xpdf-3.02/xpdf/XRef.h --- xpdf-3.02.orig/xpdf/XRef.h 2007-02-27 23:05:52.000000000 +0100 +++ xpdf-3.02/xpdf/XRef.h 2009-10-15 14:32:30.000000000 +0200 @@ -5,6 +5,9 @@ // Copyright 1996-2003 Glyph & Cog, LLC // //======================================================================== +// Modified for TeX Live by Peter Breitenlohner +// See top-level ChangeLog for a list of all modifications +//======================================================================== #ifndef XREF_H #define XREF_H @@ -21,7 +24,39 @@ class Dict; class Stream; class Parser; -class ObjectStream; + +class ObjectStream { +public: + + // Create an object stream, using object number , + // generation 0. + ObjectStream(XRef *xref, int objStrNumA); + + GBool isOk() { return ok; } + + ~ObjectStream(); + + // Return the object number of this object stream. + int getObjStrNum() { return objStrNum; } + + // Get the th object from this stream, which should be + // object number , generation 0. + Object *getObject(int objIdx, int objNum, Object *obj); + + int *getOffsets() { return offsets; } + Guint getFirstOffset() { return firstOffset; } + +private: + + int objStrNum; // object number of the object stream + int nObjects; // number of objects in the stream + Object *objs; // the objects (length = nObjects) + int *objNums; // the object numbers (length = nObjects) + int *offsets; // the object offsets (length = nObjects) + Guint firstOffset; + GBool ok; +}; + //------------------------------------------------------------------------ // XRef @@ -96,6 +131,7 @@ int getSize() { return size; } XRefEntry *getEntry(int i) { return &entries[i]; } Object *getTrailerDict() { return &trailerDict; } + ObjectStream *getObjStr() { return objStr; } private: