001: /*
002: * $Id: PdfPageEvent.java 2366 2006-09-14 23:10:58Z xlv $
003: * $Name$
004: *
005: * Copyright 2001, 2002 Paulo Soares
006: *
007: * The contents of this file are subject to the Mozilla Public License Version 1.1
008: * (the "License"); you may not use this file except in compliance with the License.
009: * You may obtain a copy of the License at http://www.mozilla.org/MPL/
010: *
011: * Software distributed under the License is distributed on an "AS IS" basis,
012: * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
013: * for the specific language governing rights and limitations under the License.
014: *
015: * The Original Code is 'iText, a free JAVA-PDF library'.
016: *
017: * The Initial Developer of the Original Code is Bruno Lowagie. Portions created by
018: * the Initial Developer are Copyright (C) 1999, 2000, 2001, 2002 by Bruno Lowagie.
019: * All Rights Reserved.
020: * Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
021: * are Copyright (C) 2000, 2001, 2002 by Paulo Soares. All Rights Reserved.
022: *
023: * Contributor(s): all the names of the contributors are added in the source code
024: * where applicable.
025: *
026: * Alternatively, the contents of this file may be used under the terms of the
027: * LGPL license (the "GNU LIBRARY GENERAL PUBLIC LICENSE"), in which case the
028: * provisions of LGPL are applicable instead of those above. If you wish to
029: * allow use of your version of this file only under the terms of the LGPL
030: * License and not to allow others to use your version of this file under
031: * the MPL, indicate your decision by deleting the provisions above and
032: * replace them with the notice and other provisions required by the LGPL.
033: * If you do not delete the provisions above, a recipient may use your version
034: * of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE.
035: *
036: * This library is free software; you can redistribute it and/or modify it
037: * under the terms of the MPL as stated above or under the terms of the GNU
038: * Library General Public License as published by the Free Software Foundation;
039: * either version 2 of the License, or any later version.
040: *
041: * This library is distributed in the hope that it will be useful, but WITHOUT
042: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
043: * FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more
044: * details.
045: *
046: * If you didn't download this code from the following link, you should check if
047: * you aren't using an obsolete version:
048: * http://www.lowagie.com/iText/
049: */
050:
051: package com.lowagie.text.pdf;
052:
053: import com.lowagie.text.Document;
054: import com.lowagie.text.Paragraph;
055: import com.lowagie.text.Rectangle;
056:
057: /**
058: * Allows a class to catch several document events.
059: *<p>
060: * Note: do not use Document.add() inside a page event.
061: *
062: * @author Paulo Soares (psoares@consiste.pt)
063: */
064:
065: public interface PdfPageEvent {
066:
067: /**
068: * Called when the document is opened.
069: *
070: * @param writer the <CODE>PdfWriter</CODE> for this document
071: * @param document the document
072: */
073: public void onOpenDocument(PdfWriter writer, Document document);
074:
075: /**
076: * Called when a page is initialized.
077: * <P>
078: * Note that if even if a page is not written this method is still
079: * called. It is preferable to use <CODE>onEndPage</CODE> to avoid
080: * infinite loops.
081: *
082: * @param writer the <CODE>PdfWriter</CODE> for this document
083: * @param document the document
084: */
085: public void onStartPage(PdfWriter writer, Document document);
086:
087: /**
088: * Called when a page is finished, just before being written to the document.
089: *
090: * @param writer the <CODE>PdfWriter</CODE> for this document
091: * @param document the document
092: */
093: public void onEndPage(PdfWriter writer, Document document);
094:
095: /**
096: * Called when the document is closed.
097: * <P>
098: * Note that this method is called with the page number equal
099: * to the last page plus one.
100: *
101: * @param writer the <CODE>PdfWriter</CODE> for this document
102: * @param document the document
103: */
104: public void onCloseDocument(PdfWriter writer, Document document);
105:
106: /**
107: * Called when a Paragraph is written.
108: * <P>
109: * <CODE>paragraphPosition</CODE> will hold the height at which the
110: * paragraph will be written to. This is useful to insert bookmarks with
111: * more control.
112: *
113: * @param writer the <CODE>PdfWriter</CODE> for this document
114: * @param document the document
115: * @param paragraphPosition the position the paragraph will be written to
116: */
117: public void onParagraph(PdfWriter writer, Document document,
118: float paragraphPosition);
119:
120: /**
121: * Called when a Paragraph is written.
122: * <P>
123: * <CODE>paragraphPosition</CODE> will hold the height of the end of the paragraph.
124: *
125: * @param writer the <CODE>PdfWriter</CODE> for this document
126: * @param document the document
127: * @param paragraphPosition the position of the end of the paragraph
128: */
129: public void onParagraphEnd(PdfWriter writer, Document document,
130: float paragraphPosition);
131:
132: /**
133: * Called when a Chapter is written.
134: * <P>
135: * <CODE>position</CODE> will hold the height at which the
136: * chapter will be written to.
137: *
138: * @param writer the <CODE>PdfWriter</CODE> for this document
139: * @param document the document
140: * @param paragraphPosition the position the chapter will be written to
141: * @param title the title of the Chapter
142: */
143: public void onChapter(PdfWriter writer, Document document,
144: float paragraphPosition, Paragraph title);
145:
146: /**
147: * Called when the end of a Chapter is reached.
148: * <P>
149: * <CODE>position</CODE> will hold the height of the end of the chapter.
150: *
151: * @param writer the <CODE>PdfWriter</CODE> for this document
152: * @param document the document
153: * @param paragraphPosition the position the chapter will be written to
154: */
155: public void onChapterEnd(PdfWriter writer, Document document,
156: float paragraphPosition);
157:
158: /**
159: * Called when a Section is written.
160: * <P>
161: * <CODE>position</CODE> will hold the height at which the
162: * section will be written to.
163: *
164: * @param writer the <CODE>PdfWriter</CODE> for this document
165: * @param document the document
166: * @param paragraphPosition the position the section will be written to
167: * @param depth the number depth of the section
168: * @param title the title of the section
169: */
170: public void onSection(PdfWriter writer, Document document,
171: float paragraphPosition, int depth, Paragraph title);
172:
173: /**
174: * Called when the end of a Section is reached.
175: * <P>
176: * <CODE>position</CODE> will hold the height of the section end.
177: *
178: * @param writer the <CODE>PdfWriter</CODE> for this document
179: * @param document the document
180: * @param paragraphPosition the position the section will be written to
181: */
182: public void onSectionEnd(PdfWriter writer, Document document,
183: float paragraphPosition);
184:
185: /**
186: * Called when a <CODE>Chunk</CODE> with a generic tag is written.
187: * <P>
188: * It is usefull to pinpoint the <CODE>Chunk</CODE> location to generate
189: * bookmarks, for example.
190: *
191: * @param writer the <CODE>PdfWriter</CODE> for this document
192: * @param document the document
193: * @param rect the <CODE>Rectangle</CODE> containing the <CODE>Chunk</CODE>
194: * @param text the text of the tag
195: */
196: public void onGenericTag(PdfWriter writer, Document document,
197: Rectangle rect, String text);
198: }
|