KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > gnu > jpdf > PDFXref


1 /*
2  *
3  * $Id: PDFXref.java,v 1.1.1.1 2001/10/29 19:51:09 ezb Exp $
4  *
5  * $Date: 2001/10/29 19:51:09 $
6  *
7  *
8  *
9  * 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   /*
45    * NOTE: Originally an inner class in PDF.java (now PDFDocument) written
46    * by Peter Mount for uk.org.retep.pdf
47    */

48
49   /**
50    * The id of a PDF Object
51    */

52   public int id;
53
54   /**
55    * The offset within the PDF file
56    */

57   public int offset;
58         
59   /**
60    * The generation of the object, usually 0
61    */

62   public int generation;
63         
64   /**
65    * Creates a crossreference for a PDF Object
66    * @param id The object's ID
67    * @param offset The object's position in the file
68    */

69   public PDFXref(int id,int offset)
70   {
71     this(id,offset,0);
72   }
73         
74   /**
75    * Creates a crossreference for a PDF Object
76    *
77    * @param id The object's ID
78    * @param offset The object's position in the file
79    * @param generation The object's generation, usually 0
80    */

81   public PDFXref(int id,int offset,int generation)
82   {
83     this.id = id;
84     this.offset = offset;
85     this.generation = generation;
86   }
87         
88   /**
89    * @return The xref in the format of the xref section in the PDF file
90    */

91   public String JavaDoc toString()
92   {
93     String JavaDoc of = Integer.toString(offset);
94     String JavaDoc ge = Integer.toString(generation);
95     String JavaDoc rs = "0000000000".substring(0, 10-of.length()) +
96                 of +
97                 " " +
98                 "00000".substring(0,5-ge.length())+ge;
99     if(generation==65535)
100       return rs+" f ";
101     return rs+" n ";
102   }
103
104 } // end class PDFXref
105

106
Popular Tags