[tex-k] libpoppler support in TeX Live source tree
The Thanh Han
hanthethanh at gmail.com
Tue May 5 23:22:32 CEST 2009
Hi Nobert,
many thanks for your work on this.
On Tue, May 05, 2009 at 03:55:42PM +0200, Norbert Preining wrote:
> On Di, 05 Mai 2009, Norbert Preining wrote:
> > objectStream *objStr = xref->getObjStr();
> > in texk/web2c/pdftexdir/pdftosrc.cc:167 does not compile with poppler,
> > warning is:
> > ../../../texk/web2c/pdftexdir/pdftosrc.cc:167: error: ‘class XRef’ has no member named ‘getObjStr’
> > ../../../texk/web2c/pdftexdir/pdftosrc.cc:169: error: invalid use of incomplete type ‘struct ObjectStream’
> > /usr/include/poppler/XRef.h:39: error: forward declaration of ‘struct ObjectStream’
> > ../../../texk/web2c/pdftexdir/pdftosrc.cc:174: error: invalid use of incomplete type ‘struct ObjectStream’
> > /usr/include/poppler/XRef.h:39: error: forward declaration of ‘struct ObjectStream’
>
>
> Ok, googling found one hit, and that is a patch from redhat for poppler
> 0.6.2 that seems to not have been included:
>
> It moves the declaration of ObjectStream form XRef.cc to XRef.h and
> defines getObjStr.
> https://www.redhat.com/archives/fedora-extras-commits/2007-November/msg08712.html
this sounds very similar to a patch I made to xpdf, to
support object stream for pdftosrc. Below I copied the
relevant text I sent in a previous mail to Peter and others.
I suggested to remove support for object stream from
pdftosrc (or remove pdftosrc), so that we can get rid of
this patch. But Peter and Karl don't think it's a good idea.
So we need to maintain this patch for both xpdf and poppler
it seems.
Another workaround is to maintain a separate tree for
pdftosrc; this patch would be applied to a (temporary)
XRef.cc & XRef.h during compilation of pdftosrc. Sounds a
bit awkward, but IMO better than changing the original
XRef.{cc,h}.
Regards,
Thanh
,--------
| diff -ur xpdf-3.02.orig/xpdf/XRef.cc xpdf-3.02/xpdf/XRef.cc
| --- xpdf-3.02.orig/xpdf/XRef.cc 2007-02-27 23:05:52.000000000 +0100
| +++ xpdf-3.02/xpdf/XRef.cc 2008-05-08 15:40:41.000000000 +0200
| @@ -45,34 +96,9 @@
| // ObjectStream
| //------------------------------------------------------------------------
|
| -class ObjectStream {
| -public:
| -
| - // Create an object stream, using object number <objStrNum>,
| - // generation 0.
| - ObjectStream(XRef *xref, int objStrNumA);
| -
| - ~ObjectStream();
| -
| - // Return the object number of this object stream.
| - int getObjStrNum() { return objStrNum; }
| -
| - // Get the <objIdx>th object from this stream, which should be
| - // object number <objNum>, 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)
| -};
| -
| ObjectStream::ObjectStream(XRef *xref, int objStrNumA) {
| Stream *str;
| Parser *parser;
| - int *offsets;
| Object objStr, obj1, obj2;
| int first, i;
|
| @@ -80,6 +106,7 @@
| nObjects = 0;
| objs = NULL;
| objNums = NULL;
| + offsets = NULL;
|
| if (!xref->fetch(objStrNum, 0, &objStr)->isStream()) {
| goto err1;
| @@ -100,6 +127,7 @@
| goto err1;
| }
| first = obj1.getInt();
| + firstOffset = objStr.getStream()->getBaseStream()->getStart() + first;
| obj1.free();
| if (first < 0) {
| goto err1;
| @@ -121,7 +149,7 @@
| obj1.free();
| obj2.free();
| delete parser;
| - gfree(offsets);
| +// gfree(offsets);
| goto err1;
| }
| objNums[i] = obj1.getInt();
| @@ -131,7 +159,7 @@
| if (objNums[i] < 0 || offsets[i] < 0 ||
| (i > 0 && offsets[i] < offsets[i-1])) {
| delete parser;
| - gfree(offsets);
| +// gfree(offsets);
| goto err1;
| }
| }
| @@ -160,7 +188,7 @@
| delete parser;
| }
|
| - gfree(offsets);
| +// gfree(offsets);
|
| err1:
| objStr.free();
| @@ -177,6 +205,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 2008-05-08 15:40:41.000000000 +0200
| @@ -21,7 +60,36 @@
| class Dict;
| class Stream;
| class Parser;
| -class ObjectStream;
| +
| +class ObjectStream {
| +public:
| +
| + // Create an object stream, using object number <objStrNum>,
| + // generation 0.
| + ObjectStream(XRef *xref, int objStrNumA);
| +
| + ~ObjectStream();
| +
| + // Return the object number of this object stream.
| + int getObjStrNum() { return objStrNum; }
| +
| + // Get the <objIdx>th object from this stream, which should be
| + // object number <objNum>, 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;
| +};
| +
|
| //------------------------------------------------------------------------
| // XRef
| @@ -96,6 +164,7 @@
| int getSize() { return size; }
| XRefEntry *getEntry(int i) { return &entries[i]; }
| Object *getTrailerDict() { return &trailerDict; }
| + ObjectStream *getObjStr() { return objStr; }
|
| private:
`--------
Thanh's comment: Took me a while before I could recall where
it comes from. This is the relevant mail I sent to Derek
some time ago:
,--------
| Hi Derek,
|
| a user of pdftosrc (a tiny program that uses xpdf code to
| dump a stream from a pdf file) asked for a way to dump the
| xref table from a pdf file that has the xref table inside an
| object stream. I took a close look and it seems that to make
| it works, a few changes in xpdf codes are required. In short
| these changes are:
|
| - move ObjectStream declaration to XRef.h
| - add 2 following fields to ObjectStream:
|
| ,--------
| | int *offsets; // the object offsets (length = nObjects)
| | Guint firstOffset;
| `--------
|
| so one can keep track of offset of objects inside an object
| stream.
|
| I wonder whether there is a chance that you could adapt
| those changes to xpdf codes? They would not change anything
| apart from providing read access the offsets of individual
| objects inside a objects stream (write access should be
| disabled, but I haven't done that yet).
|
| If you think it makes sense, I will send a patch then.
|
| Best regards,
| Thanh
`--------
This change is "nice-to-have", but not a critical one.
More information about the tex-k
mailing list