I have the same problem if I use your source.zip. It's definitely a compiler problem. I tried compiling with JDK1.3.1 and JDK1.4. The problem persists.
I find that is a bit strange. I only get the problem when I compile with jdk1.3.
I will look into Matt Bensons suggestions and try to fix the problem. Otherwise we will be overwhelmed with similar remarks and questions.
When I compile CVS with jdk1.3, the call to the generated access method in PdfWriter is different. When listed with javap it can't find the access method signature.
(from the PdfBody.add(PdfObject) method):
39 getfield #14 <Field com.lowagie.text.pdf.PdfWriter writer> 42 invokestatic #18 <Method null> 45 invokevirtual #19 <Method void writeTo(java.io.OutputStream)>
When I compile with jdk1.4 the resulting code works with both jre1.3 and jre1.4 and the call to the access method looks more sane:
39 getfield #14 <Field com.lowagie.text.pdf.PdfWriter writer>
42 invokestatic #18 <Method com.lowagie.text.pdf.OutputStreamCounter access$001(com.lowagie.text.pdf.PdfWriter)>
45 invokevirtual #19 <Method void writeTo(java.io.OutputStream)>
The jdk1.3 compiler I used is: java version "1.3.1_03" Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_03-b03) Java HotSpot(TM) Client VM (build 1.3.1_03-b03, mixed mode)
And the jdk1.4 compiler was: java version "1.4.0" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92) Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)
The attached patch to PdfWriter allows at least Chap0101 to work for me when compiled and run jdk1.3.
regards, finn
Index: PdfWriter.java
===================================================================
RCS file: /cvsroot/itext/src/com/lowagie/text/pdf/PdfWriter.java,v
retrieving revision 1.63
diff -u -r1.63 PdfWriter.java
--- PdfWriter.java 25 Mar 2003 12:36:14 -0000 1.63
+++ PdfWriter.java 26 Mar 2003 09:50:01 -0000
@@ -93,6 +93,10 @@
* @see PdfIndirectObject
*/
+ private OutputStreamCounter getOs() {
+ return os;
+ }
+
public class PdfBody {
// inner classes
@@ -211,8 +215,8 @@
PdfIndirectObject add(PdfObject object) throws IOException {
PdfIndirectObject indirect = new PdfIndirectObject(size(), object,
writer);
xrefs.add(new PdfCrossReference(position));
- indirect.writeTo(writer.os);
- position = writer.os.getCounter();
+ indirect.writeTo(writer.getOs());
+ position = writer.getOs().getCounter();
return indirect;
}
@@ -249,16 +253,16 @@
PdfIndirectObject add(PdfObject object, PdfIndirectReference ref) throws
IOException {
PdfIndirectObject indirect = new PdfIndirectObject(ref.getNumber(),
object, writer);
xrefs.set(ref.getNumber(), new PdfCrossReference(position));
- indirect.writeTo(writer.os);
- position = writer.os.getCounter();
+ indirect.writeTo(writer.getOs());
+ position = writer.getOs().getCounter();
return indirect;
}
PdfIndirectObject add(PdfObject object, int refNumber) throws IOException {
PdfIndirectObject indirect = new PdfIndirectObject(refNumber, object,
writer);
xrefs.set(refNumber, new PdfCrossReference(position));
- indirect.writeTo(writer.os);
- position = writer.os.getCounter();
+ indirect.writeTo(writer.getOs());
+ position = writer.getOs().getCounter();
return indirect;
}
@@ -283,8 +287,8 @@
PdfIndirectObject add(PdfPages object) throws IOException {
PdfIndirectObject indirect = new PdfIndirectObject(PdfWriter.ROOT,
object, writer);
rootOffset = position;
- indirect.writeTo(writer.os);
- position = writer.os.getCounter();
+ indirect.writeTo(writer.getOs());
+ position = writer.getOs().getCounter();
return indirect;
}
@@ -1666,4 +1670,4 @@
this.extraCatalog = extraCatalog;
}
-}
\ No newline at end of file
+}
