001: /*
002: * $Id: PdfPageEventHelper.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: * Helps the use of <CODE>PdfPageEvent</CODE> by implementing all the interface methods.
059: * A class can extend <CODE>PdfPageEventHelper</CODE> and only implement the
060: * needed methods.
061: *<p>
062: * Note: do not use Document.add() inside a page event.
063: * @author Paulo Soares (psoares@consiste.pt)
064: */
065:
066: public class PdfPageEventHelper implements PdfPageEvent {
067:
068: /**
069: * Called when the document is opened.
070: *
071: * @param writer the <CODE>PdfWriter</CODE> for this document
072: * @param document the document
073: */
074: public void onOpenDocument(PdfWriter writer, Document document) {
075: }
076:
077: /**
078: * Called when a page is initialized.
079: * <P>
080: * Note that if even if a page is not written this method is still
081: * called. It is preferable to use <CODE>onEndPage</CODE> to avoid
082: * infinite loops.
083: *
084: * @param writer the <CODE>PdfWriter</CODE> for this document
085: * @param document the document
086: */
087: public void onStartPage(PdfWriter writer, Document document) {
088: }
089:
090: /**
091: * Called when a page is finished, just before being written to the document.
092: *
093: * @param writer the <CODE>PdfWriter</CODE> for this document
094: * @param document the document
095: */
096: public void onEndPage(PdfWriter writer, Document document) {
097: }
098:
099: /**
100: * Called when the document is closed.
101: * <P>
102: * Note that this method is called with the page number equal
103: * to the last page plus one.
104: *
105: * @param writer the <CODE>PdfWriter</CODE> for this document
106: * @param document the document
107: */
108: public void onCloseDocument(PdfWriter writer, Document document) {
109: }
110:
111: /**
112: * Called when a Paragraph is written.
113: * <P>
114: * <CODE>paragraphPosition</CODE> will hold the height at which the
115: * paragraph will be written to. This is useful to insert bookmarks with
116: * more control.
117: *
118: * @param writer the <CODE>PdfWriter</CODE> for this document
119: * @param document the document
120: * @param paragraphPosition the position the paragraph will be written to
121: */
122: public void onParagraph(PdfWriter writer, Document document,
123: float paragraphPosition) {
124: }
125:
126: /**
127: * Called when a Paragraph is written.
128: * <P>
129: * <CODE>paragraphPosition</CODE> will hold the height of the end of the paragraph.
130: *
131: * @param writer the <CODE>PdfWriter</CODE> for this document
132: * @param document the document
133: * @param paragraphPosition the position of the end of the paragraph
134: */
135: public void onParagraphEnd(PdfWriter writer, Document document,
136: float paragraphPosition) {
137: }
138:
139: /**
140: * Called when a Chapter is written.
141: * <P>
142: * <CODE>position</CODE> will hold the height at which the
143: * chapter will be written to.
144: *
145: * @param writer the <CODE>PdfWriter</CODE> for this document
146: * @param document the document
147: * @param paragraphPosition the position the chapter will be written to
148: * @param title the title of the Chapter
149: */
150: public void onChapter(PdfWriter writer, Document document,
151: float paragraphPosition, Paragraph title) {
152: }
153:
154: /**
155: * Called when the end of a Chapter is reached.
156: * <P>
157: * <CODE>position</CODE> will hold the height of the end of the chapter.
158: *
159: * @param writer the <CODE>PdfWriter</CODE> for this document
160: * @param document the document
161: * @param position the position of the end of the chapter.
162: */
163: public void onChapterEnd(PdfWriter writer, Document document,
164: float position) {
165: }
166:
167: /**
168: * Called when a Section is written.
169: * <P>
170: * <CODE>position</CODE> will hold the height at which the
171: * section will be written to.
172: *
173: * @param writer the <CODE>PdfWriter</CODE> for this document
174: * @param document the document
175: * @param paragraphPosition the position the section will be written to
176: * @param depth the number depth of the Section
177: * @param title the title of the section
178: */
179: public void onSection(PdfWriter writer, Document document,
180: float paragraphPosition, int depth, Paragraph title) {
181: }
182:
183: /**
184: * Called when the end of a Section is reached.
185: * <P>
186: * <CODE>position</CODE> will hold the height of the section end.
187: *
188: * @param writer the <CODE>PdfWriter</CODE> for this document
189: * @param document the document
190: * @param position the position of the end of the section
191: */
192: public void onSectionEnd(PdfWriter writer, Document document,
193: float position) {
194: }
195:
196: /**
197: * Called when a <CODE>Chunk</CODE> with a generic tag is written.
198: * <P>
199: * It is usefull to pinpoint the <CODE>Chunk</CODE> location to generate
200: * bookmarks, for example.
201: *
202: * @param writer the <CODE>PdfWriter</CODE> for this document
203: * @param document the document
204: * @param rect the <CODE>Rectangle</CODE> containing the <CODE>Chunk</CODE>
205: * @param text the text of the tag
206: */
207: public void onGenericTag(PdfWriter writer, Document document,
208: Rectangle rect, String text) {
209: }
210: }
|