01: /*
02: *
03: * $Id: PDFXref.java,v 1.1.1.1 2001/10/29 19:51:09 ezb Exp $
04: *
05: * $Date: 2001/10/29 19:51:09 $
06: *
07: *
08: *
09: * This library is free software; you can redistribute it and/or
10: * modify it under the terms of the GNU Lesser General Public
11: * License as published by the Free Software Foundation; either
12: * version 2.1 of the License, or (at your option) any later version.
13: *
14: * This library is distributed in the hope that it will be useful,
15: * but WITHOUT ANY WARRANTY; without even the implied warranty of
16: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17: * Lesser General Public License for more details.
18: *
19: * You should have received a copy of the GNU Lesser General Public
20: * License along with this library; if not, write to the Free Software
21: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22: *
23: */
24: package gnu.jpdf;
25:
26: /**
27: * <p>This class is used to hold the xref information in the PDF
28: * Trailer block.</p>
29: *
30: * <p>Basically, each object has an id, and an offset in the end file.</p>
31: *
32: * <p>See the Adobe PDF Manual for more information. This class will
33: * normally not be used directly by a developer</p>
34: *
35: * @author Peter T. Mount
36: * @author Eric Z. Beard, ericzbeard@hotmail.com
37: * @author $Author: ezb $
38: * @version $Revision: 1.1.1.1 $, $Date: 2001/10/29 19:51:09 $
39: *
40: */
41: public class PDFXref {
42:
43: /*
44: * NOTE: Originally an inner class in PDF.java (now PDFDocument) written
45: * by Peter Mount for uk.org.retep.pdf
46: */
47:
48: /**
49: * The id of a PDF Object
50: */
51: public int id;
52:
53: /**
54: * The offset within the PDF file
55: */
56: public int offset;
57:
58: /**
59: * The generation of the object, usually 0
60: */
61: public int generation;
62:
63: /**
64: * Creates a crossreference for a PDF Object
65: * @param id The object's ID
66: * @param offset The object's position in the file
67: */
68: public PDFXref(int id, int offset) {
69: this (id, offset, 0);
70: }
71:
72: /**
73: * Creates a crossreference for a PDF Object
74: *
75: * @param id The object's ID
76: * @param offset The object's position in the file
77: * @param generation The object's generation, usually 0
78: */
79: public PDFXref(int id, int offset, int generation) {
80: this .id = id;
81: this .offset = offset;
82: this .generation = generation;
83: }
84:
85: /**
86: * @return The xref in the format of the xref section in the PDF file
87: */
88: public String toString() {
89: String of = Integer.toString(offset);
90: String ge = Integer.toString(generation);
91: String rs = "0000000000".substring(0, 10 - of.length()) + of
92: + " " + "00000".substring(0, 5 - ge.length()) + ge;
93: if (generation == 65535)
94: return rs + " f ";
95: return rs + " n ";
96: }
97:
98: } // end class PDFXref
|