Source Code Cross Referenced for PdfPageEventForwarder.java in  » PDF » pdf-itext » com » lowagie » text » pdf » events » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » PDF » pdf itext » com.lowagie.text.pdf.events 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: PdfPageEventForwarder.java 2366 2006-09-14 23:10:58Z xlv $
003:         * $Name$
004:         *
005:         * Copyright 2005 Bruno Lowagie
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.events;
052:
053:        import java.util.ArrayList;
054:        import java.util.Iterator;
055:
056:        import com.lowagie.text.Document;
057:        import com.lowagie.text.Paragraph;
058:        import com.lowagie.text.Rectangle;
059:        import com.lowagie.text.pdf.PdfPageEvent;
060:        import com.lowagie.text.pdf.PdfWriter;
061:
062:        /**
063:         * If you want to add more than one page event to a PdfWriter,
064:         * you have to construct a PdfPageEventForwarder, add the
065:         * different events to this object and add the forwarder to
066:         * the PdfWriter.
067:         */
068:
069:        public class PdfPageEventForwarder implements  PdfPageEvent {
070:
071:            /** ArrayList containing all the PageEvents that have to be executed. */
072:            protected ArrayList events = new ArrayList();
073:
074:            /** 
075:             * Add a page event to the forwarder.
076:             * @param event an event that has to be added to the forwarder.
077:             */
078:            public void addPageEvent(PdfPageEvent event) {
079:                events.add(event);
080:            }
081:
082:            /**
083:             * Called when the document is opened.
084:             * 
085:             * @param writer
086:             *            the <CODE>PdfWriter</CODE> for this document
087:             * @param document
088:             *            the document
089:             */
090:            public void onOpenDocument(PdfWriter writer, Document document) {
091:                PdfPageEvent event;
092:                for (Iterator i = events.iterator(); i.hasNext();) {
093:                    event = (PdfPageEvent) i.next();
094:                    event.onOpenDocument(writer, document);
095:                }
096:            }
097:
098:            /**
099:             * Called when a page is initialized.
100:             * <P>
101:             * Note that if even if a page is not written this method is still called.
102:             * It is preferable to use <CODE>onEndPage</CODE> to avoid infinite loops.
103:             * 
104:             * @param writer
105:             *            the <CODE>PdfWriter</CODE> for this document
106:             * @param document
107:             *            the document
108:             */
109:            public void onStartPage(PdfWriter writer, Document document) {
110:                PdfPageEvent event;
111:                for (Iterator i = events.iterator(); i.hasNext();) {
112:                    event = (PdfPageEvent) i.next();
113:                    event.onStartPage(writer, document);
114:                }
115:            }
116:
117:            /**
118:             * Called when a page is finished, just before being written to the
119:             * document.
120:             * 
121:             * @param writer
122:             *            the <CODE>PdfWriter</CODE> for this document
123:             * @param document
124:             *            the document
125:             */
126:            public void onEndPage(PdfWriter writer, Document document) {
127:                PdfPageEvent event;
128:                for (Iterator i = events.iterator(); i.hasNext();) {
129:                    event = (PdfPageEvent) i.next();
130:                    event.onEndPage(writer, document);
131:                }
132:            }
133:
134:            /**
135:             * Called when the document is closed.
136:             * <P>
137:             * Note that this method is called with the page number equal to the last
138:             * page plus one.
139:             * 
140:             * @param writer
141:             *            the <CODE>PdfWriter</CODE> for this document
142:             * @param document
143:             *            the document
144:             */
145:            public void onCloseDocument(PdfWriter writer, Document document) {
146:                PdfPageEvent event;
147:                for (Iterator i = events.iterator(); i.hasNext();) {
148:                    event = (PdfPageEvent) i.next();
149:                    event.onCloseDocument(writer, document);
150:                }
151:            }
152:
153:            /**
154:             * Called when a Paragraph is written.
155:             * <P>
156:             * <CODE>paragraphPosition</CODE> will hold the height at which the
157:             * paragraph will be written to. This is useful to insert bookmarks with
158:             * more control.
159:             * 
160:             * @param writer
161:             *            the <CODE>PdfWriter</CODE> for this document
162:             * @param document
163:             *            the document
164:             * @param paragraphPosition
165:             *            the position the paragraph will be written to
166:             */
167:            public void onParagraph(PdfWriter writer, Document document,
168:                    float paragraphPosition) {
169:                PdfPageEvent event;
170:                for (Iterator i = events.iterator(); i.hasNext();) {
171:                    event = (PdfPageEvent) i.next();
172:                    event.onParagraph(writer, document, paragraphPosition);
173:                }
174:            }
175:
176:            /**
177:             * Called when a Paragraph is written.
178:             * <P>
179:             * <CODE>paragraphPosition</CODE> will hold the height of the end of the
180:             * paragraph.
181:             * 
182:             * @param writer
183:             *            the <CODE>PdfWriter</CODE> for this document
184:             * @param document
185:             *            the document
186:             * @param paragraphPosition
187:             *            the position of the end of the paragraph
188:             */
189:            public void onParagraphEnd(PdfWriter writer, Document document,
190:                    float paragraphPosition) {
191:                PdfPageEvent event;
192:                for (Iterator i = events.iterator(); i.hasNext();) {
193:                    event = (PdfPageEvent) i.next();
194:                    event.onParagraphEnd(writer, document, paragraphPosition);
195:                }
196:            }
197:
198:            /**
199:             * Called when a Chapter is written.
200:             * <P>
201:             * <CODE>position</CODE> will hold the height at which the chapter will be
202:             * written to.
203:             * 
204:             * @param writer
205:             *            the <CODE>PdfWriter</CODE> for this document
206:             * @param document
207:             *            the document
208:             * @param paragraphPosition
209:             *            the position the chapter will be written to
210:             * @param title
211:             *            the title of the Chapter
212:             */
213:            public void onChapter(PdfWriter writer, Document document,
214:                    float paragraphPosition, Paragraph title) {
215:                PdfPageEvent event;
216:                for (Iterator i = events.iterator(); i.hasNext();) {
217:                    event = (PdfPageEvent) i.next();
218:                    event.onChapter(writer, document, paragraphPosition, title);
219:                }
220:            }
221:
222:            /**
223:             * Called when the end of a Chapter is reached.
224:             * <P>
225:             * <CODE>position</CODE> will hold the height of the end of the chapter.
226:             * 
227:             * @param writer
228:             *            the <CODE>PdfWriter</CODE> for this document
229:             * @param document
230:             *            the document
231:             * @param position
232:             *            the position of the end of the chapter.
233:             */
234:            public void onChapterEnd(PdfWriter writer, Document document,
235:                    float position) {
236:                PdfPageEvent event;
237:                for (Iterator i = events.iterator(); i.hasNext();) {
238:                    event = (PdfPageEvent) i.next();
239:                    event.onChapterEnd(writer, document, position);
240:                }
241:            }
242:
243:            /**
244:             * Called when a Section is written.
245:             * <P>
246:             * <CODE>position</CODE> will hold the height at which the section will be
247:             * written to.
248:             * 
249:             * @param writer
250:             *            the <CODE>PdfWriter</CODE> for this document
251:             * @param document
252:             *            the document
253:             * @param paragraphPosition
254:             *            the position the section will be written to
255:             * @param depth
256:             *            the number depth of the Section
257:             * @param title
258:             *            the title of the section
259:             */
260:            public void onSection(PdfWriter writer, Document document,
261:                    float paragraphPosition, int depth, Paragraph title) {
262:                PdfPageEvent event;
263:                for (Iterator i = events.iterator(); i.hasNext();) {
264:                    event = (PdfPageEvent) i.next();
265:                    event.onSection(writer, document, paragraphPosition, depth,
266:                            title);
267:                }
268:            }
269:
270:            /**
271:             * Called when the end of a Section is reached.
272:             * <P>
273:             * <CODE>position</CODE> will hold the height of the section end.
274:             * 
275:             * @param writer
276:             *            the <CODE>PdfWriter</CODE> for this document
277:             * @param document
278:             *            the document
279:             * @param position
280:             *            the position of the end of the section
281:             */
282:            public void onSectionEnd(PdfWriter writer, Document document,
283:                    float position) {
284:                PdfPageEvent event;
285:                for (Iterator i = events.iterator(); i.hasNext();) {
286:                    event = (PdfPageEvent) i.next();
287:                    event.onSectionEnd(writer, document, position);
288:                }
289:            }
290:
291:            /**
292:             * Called when a <CODE>Chunk</CODE> with a generic tag is written.
293:             * <P>
294:             * It is usefull to pinpoint the <CODE>Chunk</CODE> location to generate
295:             * bookmarks, for example.
296:             * 
297:             * @param writer
298:             *            the <CODE>PdfWriter</CODE> for this document
299:             * @param document
300:             *            the document
301:             * @param rect
302:             *            the <CODE>Rectangle</CODE> containing the <CODE>Chunk
303:             *            </CODE>
304:             * @param text
305:             *            the text of the tag
306:             */
307:            public void onGenericTag(PdfWriter writer, Document document,
308:                    Rectangle rect, String text) {
309:                PdfPageEvent event;
310:                for (Iterator i = events.iterator(); i.hasNext();) {
311:                    event = (PdfPageEvent) i.next();
312:                    event.onGenericTag(writer, document, rect, text);
313:                }
314:            }
315:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.