Initial Commit

This commit is contained in:
2023-06-21 12:46:23 -04:00
commit c70248a520
1352 changed files with 336780 additions and 0 deletions

View File

@@ -0,0 +1,183 @@
using System;
using System.IO;
using System.Collections;
using iTextSharp.text;
using iTextSharp.text.pdf;
/*
* Copyright 2005 by Bruno Lowagie
*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the License.
*
* The Original Code is 'iText, a free JAVA-PDF library'.
*
* The Initial Developer of the Original Code is Bruno Lowagie. Portions created by
* the Initial Developer are Copyright (C) 1999-2005 by Bruno Lowagie.
* All Rights Reserved.
* Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
* are Copyright (C) 2000-2005 by Paulo Soares. All Rights Reserved.
*
* Contributor(s): all the names of the contributors are added in the source code
* where applicable.
*
* Alternatively, the contents of this file may be used under the terms of the
* LGPL license (the "GNU LIBRARY GENERAL PUBLIC LICENSE"), in which case the
* provisions of LGPL are applicable instead of those above. If you wish to
* allow use of your version of this file only under the terms of the LGPL
* License and not to allow others to use your version of this file under
* the MPL, indicate your decision by deleting the provisions above and
* replace them with the notice and other provisions required by the LGPL.
* If you do not delete the provisions above, a recipient may use your version
* of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE.
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the MPL as stated above or under the terms of the GNU
* Library General Public License as published by the Free Software Foundation;
* either version 2 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more
* details.
*
* If you didn't download this code from the following link, you should check if
* you aren't using an obsolete version:
* http://www.lowagie.com/iText/
*/
namespace iTextSharp.text.pdf.events {
/**
* Class for an index.
*
* @author Michael Niedermair
*/
public class FieldPositioningEvents : PdfPageEventHelper, IPdfPCellEvent {
/**
* Keeps a map with fields that are to be positioned in inGenericTag.
*/
protected Hashtable genericChunkFields = new Hashtable();
/**
* Keeps the form field that is to be positioned in a cellLayout event.
*/
protected PdfFormField cellField = null;
/**
* The PdfWriter to use when a field has to added in a cell event.
*/
protected PdfWriter fieldWriter = null;
/**
* The PdfFormField that is the parent of the field added in a cell event.
*/
protected PdfFormField parent = null;
/** Creates a new event. This constructor will be used if you need to position fields with Chunk objects. */
public FieldPositioningEvents() {}
/** Some extra padding that will be taken into account when defining the widget. */
public float padding;
/**
* Add a PdfFormField that has to be tied to a generic Chunk.
*/
public void AddField(String text, PdfFormField field) {
genericChunkFields[text] = field;
}
/** Creates a new event. This constructor will be used if you need to position fields with a Cell Event. */
public FieldPositioningEvents(PdfWriter writer, PdfFormField field) {
this.cellField = field;
this.fieldWriter = writer;
}
/** Creates a new event. This constructor will be used if you need to position fields with a Cell Event. */
public FieldPositioningEvents(PdfFormField parent, PdfFormField field) {
this.cellField = field;
this.parent = parent;
}
/** Creates a new event. This constructor will be used if you need to position fields with a Cell Event.
* @throws DocumentException
* @throws IOException*/
public FieldPositioningEvents(PdfWriter writer, String text) {
this.fieldWriter = writer;
TextField tf = new TextField(writer, new Rectangle(0, 0), text);
tf.FontSize = 14;
cellField = tf.GetTextField();
}
/** Creates a new event. This constructor will be used if you need to position fields with a Cell Event.
* @throws DocumentException
* @throws IOException*/
public FieldPositioningEvents(PdfWriter writer, PdfFormField parent, String text) {
this.parent = parent;
TextField tf = new TextField(writer, new Rectangle(0, 0), text);
tf.FontSize = 14;
cellField = tf.GetTextField();
}
/**
* @param padding The padding to set.
*/
public float Padding {
set {
padding = value;
}
get {
return padding;
}
}
/**
* @param parent The parent to set.
*/
public PdfFormField Parent {
set {
parent = value;
}
get {
return parent;
}
}
/**
* @see com.lowagie.text.pdf.PdfPageEvent#onGenericTag(com.lowagie.text.pdf.PdfWriter, com.lowagie.text.Document, com.lowagie.text.Rectangle, java.lang.String)
*/
public override void OnGenericTag(PdfWriter writer, Document document,
Rectangle rect, String text) {
rect.Bottom = rect.Bottom - 3;
PdfFormField field = (PdfFormField) genericChunkFields[text];
if (field == null) {
TextField tf = new TextField(writer, new Rectangle(rect.GetLeft(padding), rect.GetBottom(padding), rect.GetRight(padding), rect.GetTop(padding)), text);
tf.FontSize = 14;
field = tf.GetTextField();
}
else {
field.Put(PdfName.RECT, new PdfRectangle(rect.GetLeft(padding), rect.GetBottom(padding), rect.GetRight(padding), rect.GetTop(padding)));
}
if (parent == null)
writer.AddAnnotation(field);
else
parent.AddKid(field);
}
/**
* @see com.lowagie.text.pdf.PdfPCellEvent#cellLayout(com.lowagie.text.pdf.PdfPCell, com.lowagie.text.Rectangle, com.lowagie.text.pdf.PdfContentByte[])
*/
public void CellLayout(PdfPCell cell, Rectangle rect, PdfContentByte[] canvases) {
if (cellField == null || (fieldWriter == null && parent == null)) throw new ArgumentException("You have used the wrong constructor for this FieldPositioningEvents class.");
cellField.Put(PdfName.RECT, new PdfRectangle(rect.GetLeft(padding), rect.GetBottom(padding), rect.GetRight(padding), rect.GetTop(padding)));
if (parent == null)
fieldWriter.AddAnnotation(cellField);
else
parent.AddKid(cellField);
}
}
}

View File

@@ -0,0 +1,389 @@
using System;
using System.Collections;
using System.Text;
using System.util;
using iTextSharp.text;
/*
* Copyright 2005 by Michael Niedermair.
*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the License.
*
* The Original Code is 'iText, a free JAVA-PDF library'.
*
* The Initial Developer of the Original Code is Bruno Lowagie. Portions created by
* the Initial Developer are Copyright (C) 1999-2005 by Bruno Lowagie.
* All Rights Reserved.
* Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
* are Copyright (C) 2000-2005 by Paulo Soares. All Rights Reserved.
*
* Contributor(s): all the names of the contributors are added in the source code
* where applicable.
*
* Alternatively, the contents of this file may be used under the terms of the
* LGPL license (the "GNU LIBRARY GENERAL PUBLIC LICENSE"), in which case the
* provisions of LGPL are applicable instead of those above. If you wish to
* allow use of your version of this file only under the terms of the LGPL
* License and not to allow others to use your version of this file under
* the MPL, indicate your decision by deleting the provisions above and
* replace them with the notice and other provisions required by the LGPL.
* If you do not delete the provisions above, a recipient may use your version
* of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE.
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the MPL as stated above or under the terms of the GNU
* Library General Public License as published by the Free Software Foundation;
* either version 2 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more
* details.
*
* If you didn't download this code from the following link, you should check if
* you aren't using an obsolete version:
* http://www.lowagie.com/iText/
*/
namespace iTextSharp.text.pdf.events {
/**
* Class for an index.
*
* @author Michael Niedermair
*/
public class IndexEvents : PdfPageEventHelper {
/**
* keeps the indextag with the pagenumber
*/
private Hashtable indextag = new Hashtable();
/**
* All the text that is passed to this event, gets registered in the indexentry.
*
* @see com.lowagie.text.pdf.PdfPageEventHelper#onGenericTag(
* com.lowagie.text.pdf.PdfWriter, com.lowagie.text.Document,
* com.lowagie.text.Rectangle, java.lang.String)
*/
public override void OnGenericTag(PdfWriter writer, Document document,
Rectangle rect, String text) {
indextag[text] = writer.PageNumber;
}
// --------------------------------------------------------------------
/**
* indexcounter
*/
private long indexcounter = 0;
/**
* the list for the index entry
*/
private ArrayList indexentry = new ArrayList();
/**
* Create an index entry.
*
* @param text The text for the Chunk.
* @param in1 The first level.
* @param in2 The second level.
* @param in3 The third level.
* @return Returns the Chunk.
*/
public Chunk Create(String text, String in1, String in2,
String in3) {
Chunk chunk = new Chunk(text);
String tag = "idx_" + (indexcounter++);
chunk.SetGenericTag(tag);
chunk.SetLocalDestination(tag);
Entry entry = new Entry(in1, in2, in3, tag, this);
indexentry.Add(entry);
return chunk;
}
/**
* Create an index entry.
*
* @param text The text for the Chunk.
* @param in1 The first level.
* @return Returns the Chunk.
*/
public Chunk Create(String text, String in1) {
return Create(text, in1, "", "");
}
/**
* Create an index entry.
*
* @param text The text for the Chunk.
* @param in1 The first level.
* @param in2 The second level.
* @return Returns the Chunk.
*/
public Chunk Create(String text, String in1, String in2) {
return Create(text, in1, in2, "");
}
/**
* Create an index entry.
*
* @param text The text.
* @param in1 The first level.
* @param in2 The second level.
* @param in3 The third level.
*/
public void Create(Chunk text, String in1, String in2,
String in3) {
String tag = "idx_" + (indexcounter++);
text.SetGenericTag(tag);
text.SetLocalDestination(tag);
Entry entry = new Entry(in1, in2, in3, tag, this);
indexentry.Add(entry);
}
/**
* Create an index entry.
*
* @param text The text.
* @param in1 The first level.
*/
public void Create(Chunk text, String in1) {
Create(text, in1, "", "");
}
/**
* Create an index entry.
*
* @param text The text.
* @param in1 The first level.
* @param in2 The second level.
*/
public void Create(Chunk text, String in1, String in2) {
Create(text, in1, in2, "");
}
private class ISortIndex : IComparer {
public int Compare(object arg0, object arg1) {
Entry en1 = (Entry) arg0;
Entry en2 = (Entry) arg1;
int rt = 0;
if (en1.GetIn1() != null && en2.GetIn1() != null) {
if ((rt = Util.CompareToIgnoreCase(en1.GetIn1(),en2.GetIn1())) == 0) {
// in1 equals
if (en1.GetIn2() != null && en2.GetIn2() != null) {
if ((rt = Util.CompareToIgnoreCase(en1.GetIn2(), en2.GetIn2())) == 0) {
// in2 equals
if (en1.GetIn3() != null && en2.GetIn3() != null) {
rt = Util.CompareToIgnoreCase(en1.GetIn3(), en2.GetIn3());
}
}
}
}
}
return rt;
}
}
/**
* Comparator for sorting the index
*/
private IComparer comparator = new ISortIndex();
/**
* Set the comparator.
* @param aComparator The comparator to set.
*/
public void SetComparator(IComparer aComparator) {
comparator = aComparator;
}
/**
* Returns the sorted list with the entries and the collected page numbers.
* @return Returns the sorted list with the entries and teh collected page numbers.
*/
public ArrayList GetSortedEntries() {
Hashtable grouped = new Hashtable();
for (int i = 0; i < indexentry.Count; i++) {
Entry e = (Entry) indexentry[i];
String key = e.GetKey();
Entry master = (Entry) grouped[key];
if (master != null) {
master.AddPageNumberAndTag(e.GetPageNumber(), e.GetTag());
} else {
e.AddPageNumberAndTag(e.GetPageNumber(), e.GetTag());
grouped[key] = e;
}
}
// copy to a list and sort it
ArrayList sorted = new ArrayList(grouped.Values);
sorted.Sort(0, sorted.Count, comparator);
return sorted;
}
// --------------------------------------------------------------------
/**
* Class for an index entry.
* <p>
* In the first step, only in1, in2,in3 and tag are used.
* After the collections of the index entries, pagenumbers are used.
* </p>
*/
public class Entry {
/**
* first level
*/
private String in1;
/**
* second level
*/
private String in2;
/**
* third level
*/
private String in3;
/**
* the tag
*/
private String tag;
/**
* the lsit of all page numbers.
*/
private ArrayList pagenumbers = new ArrayList();
/**
* the lsit of all tags.
*/
private ArrayList tags = new ArrayList();
private IndexEvents parent;
/**
* Create a new object.
* @param aIn1 The first level.
* @param aIn2 The second level.
* @param aIn3 The third level.
* @param aTag The tag.
*/
public Entry(String aIn1, String aIn2, String aIn3,
String aTag, IndexEvents parent) {
in1 = aIn1;
in2 = aIn2;
in3 = aIn3;
tag = aTag;
this.parent = parent;
}
/**
* Returns the in1.
* @return Returns the in1.
*/
public String GetIn1() {
return in1;
}
/**
* Returns the in2.
* @return Returns the in2.
*/
public String GetIn2() {
return in2;
}
/**
* Returns the in3.
* @return Returns the in3.
*/
public String GetIn3() {
return in3;
}
/**
* Returns the tag.
* @return Returns the tag.
*/
public String GetTag() {
return tag;
}
/**
* Returns the pagenumer for this entry.
* @return Returns the pagenumer for this entry.
*/
public int GetPageNumber() {
int rt = -1;
object i = parent.indextag[tag];
if (i != null) {
rt = (int)i;
}
return rt;
}
/**
* Add a pagenumber.
* @param number The page number.
* @param tag
*/
public void AddPageNumberAndTag(int number, String tag) {
pagenumbers.Add(number);
tags.Add(tag);
}
/**
* Returns the key for the map-entry.
* @return Returns the key for the map-entry.
*/
public String GetKey() {
return in1 + "!" + in2 + "!" + in3;
}
/**
* Returns the pagenumbers.
* @return Returns the pagenumbers.
*/
public ArrayList GetPagenumbers() {
return pagenumbers;
}
/**
* Returns the tags.
* @return Returns the tags.
*/
public ArrayList GetTags() {
return tags;
}
/**
* print the entry (only for test)
* @return the toString implementation of the entry
*/
public override String ToString() {
StringBuilder buf = new StringBuilder();
buf.Append(in1).Append(' ');
buf.Append(in2).Append(' ');
buf.Append(in3).Append(' ');
for (int i = 0; i < pagenumbers.Count; i++) {
buf.Append(pagenumbers[i]).Append(' ');
}
return buf.ToString();
}
}
}
}

View File

@@ -0,0 +1,86 @@
using System;
using System.Collections;
using iTextSharp.text;
using iTextSharp.text.pdf;
/*
* $Id: PdfPCellEventForwarder.cs,v 1.2 2008/05/13 11:25:40 psoares33 Exp $
*
*
* Copyright 2005 Bruno Lowagie
*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the License.
*
* The Original Code is 'iText, a free JAVA-PDF library'.
*
* The Initial Developer of the Original Code is Bruno Lowagie. Portions created by
* the Initial Developer are Copyright (C) 1999, 2000, 2001, 2002 by Bruno Lowagie.
* All Rights Reserved.
* Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
* are Copyright (C) 2000, 2001, 2002 by Paulo Soares. All Rights Reserved.
*
* Contributor(s): all the names of the contributors are added in the source code
* where applicable.
*
* Alternatively, the contents of this file may be used under the terms of the
* LGPL license (the "GNU LIBRARY GENERAL PUBLIC LICENSE"), in which case the
* provisions of LGPL are applicable instead of those above. If you wish to
* allow use of your version of this file only under the terms of the LGPL
* License and not to allow others to use your version of this file under
* the MPL, indicate your decision by deleting the provisions above and
* replace them with the notice and other provisions required by the LGPL.
* If you do not delete the provisions above, a recipient may use your version
* of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE.
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the MPL as stated above or under the terms of the GNU
* Library General Public License as published by the Free Software Foundation;
* either version 2 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more
* details.
*
* If you didn't download this code from the following link, you should check if
* you aren't using an obsolete version:
* http://www.lowagie.com/iText/
*/
namespace iTextSharp.text.pdf.events {
/**
* If you want to add more than one event to a cell,
* you have to construct a PdfPCellEventForwarder, add the
* different events to this object and add the forwarder to
* the PdfPCell.
*/
public class PdfPCellEventForwarder : IPdfPCellEvent {
/** ArrayList containing all the PageEvents that have to be executed. */
protected ArrayList events = new ArrayList();
/**
* Add a page event to the forwarder.
* @param event an event that has to be added to the forwarder.
*/
public void AddCellEvent(IPdfPCellEvent eventa) {
events.Add(eventa);
}
/**
* @see com.lowagie.text.pdf.PdfPCellEvent#cellLayout(com.lowagie.text.pdf.PdfPCell, com.lowagie.text.Rectangle, com.lowagie.text.pdf.PdfContentByte[])
*/
public void CellLayout(PdfPCell cell, Rectangle position, PdfContentByte[] canvases) {
foreach (IPdfPCellEvent eventa in events) {
eventa.CellLayout(cell, position, canvases);
}
}
}
}

View File

@@ -0,0 +1,85 @@
using System;
using System.Collections;
using iTextSharp.text.pdf;
/*
* $Id: PdfPTableEventForwarder.cs,v 1.2 2008/05/13 11:25:40 psoares33 Exp $
*
*
* Copyright 2005 Bruno Lowagie
*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the License.
*
* The Original Code is 'iText, a free JAVA-PDF library'.
*
* The Initial Developer of the Original Code is Bruno Lowagie. Portions created by
* the Initial Developer are Copyright (C) 1999, 2000, 2001, 2002 by Bruno Lowagie.
* All Rights Reserved.
* Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
* are Copyright (C) 2000, 2001, 2002 by Paulo Soares. All Rights Reserved.
*
* Contributor(s): all the names of the contributors are added in the source code
* where applicable.
*
* Alternatively, the contents of this file may be used under the terms of the
* LGPL license (the "GNU LIBRARY GENERAL PUBLIC LICENSE"), in which case the
* provisions of LGPL are applicable instead of those above. If you wish to
* allow use of your version of this file only under the terms of the LGPL
* License and not to allow others to use your version of this file under
* the MPL, indicate your decision by deleting the provisions above and
* replace them with the notice and other provisions required by the LGPL.
* If you do not delete the provisions above, a recipient may use your version
* of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE.
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the MPL as stated above or under the terms of the GNU
* Library General Public License as published by the Free Software Foundation;
* either version 2 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more
* details.
*
* If you didn't download this code from the following link, you should check if
* you aren't using an obsolete version:
* http://www.lowagie.com/iText/
*/
namespace iTextSharp.text.pdf.events {
/**
* If you want to add more than one page event to a PdfPTable,
* you have to construct a PdfPTableEventForwarder, add the
* different events to this object and add the forwarder to
* the PdfWriter.
*/
public class PdfPTableEventForwarder : IPdfPTableEvent {
/** ArrayList containing all the PageEvents that have to be executed. */
protected ArrayList events = new ArrayList();
/**
* Add a page event to the forwarder.
* @param event an event that has to be added to the forwarder.
*/
public void AddTableEvent(IPdfPTableEvent eventa) {
events.Add(eventa);
}
/**
* @see com.lowagie.text.pdf.PdfPTableEvent#tableLayout(com.lowagie.text.pdf.PdfPTable, float[][], float[], int, int, com.lowagie.text.pdf.PdfContentByte[])
*/
public void TableLayout(PdfPTable table, float[][] widths, float[] heights, int headerRows, int rowStart, PdfContentByte[] canvases) {
foreach (IPdfPTableEvent eventa in events) {
eventa.TableLayout(table, widths, heights, headerRows, rowStart, canvases);
}
}
}
}

View File

@@ -0,0 +1,286 @@
using System;
using System.Collections;
using iTextSharp.text;
using iTextSharp.text.pdf;
/*
* $Id: PdfPageEventForwarder.cs,v 1.2 2008/05/13 11:25:40 psoares33 Exp $
*
*
* Copyright 2005 Bruno Lowagie
*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the License.
*
* The Original Code is 'iText, a free JAVA-PDF library'.
*
* The Initial Developer of the Original Code is Bruno Lowagie. Portions created by
* the Initial Developer are Copyright (C) 1999, 2000, 2001, 2002 by Bruno Lowagie.
* All Rights Reserved.
* Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
* are Copyright (C) 2000, 2001, 2002 by Paulo Soares. All Rights Reserved.
*
* Contributor(s): all the names of the contributors are added in the source code
* where applicable.
*
* Alternatively, the contents of this file may be used under the terms of the
* LGPL license (the "GNU LIBRARY GENERAL PUBLIC LICENSE"), in which case the
* provisions of LGPL are applicable instead of those above. If you wish to
* allow use of your version of this file only under the terms of the LGPL
* License and not to allow others to use your version of this file under
* the MPL, indicate your decision by deleting the provisions above and
* replace them with the notice and other provisions required by the LGPL.
* If you do not delete the provisions above, a recipient may use your version
* of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE.
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the MPL as stated above or under the terms of the GNU
* Library General Public License as published by the Free Software Foundation;
* either version 2 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more
* details.
*
* If you didn't download this code from the following link, you should check if
* you aren't using an obsolete version:
* http://www.lowagie.com/iText/
*/
namespace iTextSharp.text.pdf.events {
/**
* If you want to add more than one page eventa to a PdfWriter,
* you have to construct a PdfPageEventForwarder, add the
* different events to this object and add the forwarder to
* the PdfWriter.
*/
public class PdfPageEventForwarder : IPdfPageEvent {
/** ArrayList containing all the PageEvents that have to be executed. */
protected ArrayList events = new ArrayList();
/**
* Add a page eventa to the forwarder.
* @param eventa an eventa that has to be added to the forwarder.
*/
public void AddPageEvent(IPdfPageEvent eventa) {
events.Add(eventa);
}
/**
* Called when the document is opened.
*
* @param writer
* the <CODE>PdfWriter</CODE> for this document
* @param document
* the document
*/
public virtual void OnOpenDocument(PdfWriter writer, Document document) {
foreach (IPdfPageEvent eventa in events) {
eventa.OnOpenDocument(writer, document);
}
}
/**
* Called when a page is initialized.
* <P>
* Note that if even if a page is not written this method is still called.
* It is preferable to use <CODE>onEndPage</CODE> to avoid infinite loops.
*
* @param writer
* the <CODE>PdfWriter</CODE> for this document
* @param document
* the document
*/
public virtual void OnStartPage(PdfWriter writer, Document document) {
foreach (IPdfPageEvent eventa in events) {
eventa.OnStartPage(writer, document);
}
}
/**
* Called when a page is finished, just before being written to the
* document.
*
* @param writer
* the <CODE>PdfWriter</CODE> for this document
* @param document
* the document
*/
public virtual void OnEndPage(PdfWriter writer, Document document) {
foreach (IPdfPageEvent eventa in events) {
eventa.OnEndPage(writer, document);
}
}
/**
* Called when the document is closed.
* <P>
* Note that this method is called with the page number equal to the last
* page plus one.
*
* @param writer
* the <CODE>PdfWriter</CODE> for this document
* @param document
* the document
*/
public virtual void OnCloseDocument(PdfWriter writer, Document document) {
foreach (IPdfPageEvent eventa in events) {
eventa.OnCloseDocument(writer, document);
}
}
/**
* Called when a Paragraph is written.
* <P>
* <CODE>paragraphPosition</CODE> will hold the height at which the
* paragraph will be written to. This is useful to insert bookmarks with
* more control.
*
* @param writer
* the <CODE>PdfWriter</CODE> for this document
* @param document
* the document
* @param paragraphPosition
* the position the paragraph will be written to
*/
public virtual void OnParagraph(PdfWriter writer, Document document,
float paragraphPosition) {
foreach (IPdfPageEvent eventa in events) {
eventa.OnParagraph(writer, document, paragraphPosition);
}
}
/**
* Called when a Paragraph is written.
* <P>
* <CODE>paragraphPosition</CODE> will hold the height of the end of the
* paragraph.
*
* @param writer
* the <CODE>PdfWriter</CODE> for this document
* @param document
* the document
* @param paragraphPosition
* the position of the end of the paragraph
*/
public virtual void OnParagraphEnd(PdfWriter writer, Document document,
float paragraphPosition) {
foreach (IPdfPageEvent eventa in events) {
eventa.OnParagraphEnd(writer, document, paragraphPosition);
}
}
/**
* Called when a Chapter is written.
* <P>
* <CODE>position</CODE> will hold the height at which the chapter will be
* written to.
*
* @param writer
* the <CODE>PdfWriter</CODE> for this document
* @param document
* the document
* @param paragraphPosition
* the position the chapter will be written to
* @param title
* the title of the Chapter
*/
public virtual void OnChapter(PdfWriter writer, Document document,
float paragraphPosition, Paragraph title) {
foreach (IPdfPageEvent eventa in events) {
eventa.OnChapter(writer, document, paragraphPosition, title);
}
}
/**
* Called when the end of a Chapter is reached.
* <P>
* <CODE>position</CODE> will hold the height of the end of the chapter.
*
* @param writer
* the <CODE>PdfWriter</CODE> for this document
* @param document
* the document
* @param position
* the position of the end of the chapter.
*/
public virtual void OnChapterEnd(PdfWriter writer, Document document, float position) {
foreach (IPdfPageEvent eventa in events) {
eventa.OnChapterEnd(writer, document, position);
}
}
/**
* Called when a Section is written.
* <P>
* <CODE>position</CODE> will hold the height at which the section will be
* written to.
*
* @param writer
* the <CODE>PdfWriter</CODE> for this document
* @param document
* the document
* @param paragraphPosition
* the position the section will be written to
* @param depth
* the number depth of the Section
* @param title
* the title of the section
*/
public virtual void OnSection(PdfWriter writer, Document document,
float paragraphPosition, int depth, Paragraph title) {
foreach (IPdfPageEvent eventa in events) {
eventa.OnSection(writer, document, paragraphPosition, depth, title);
}
}
/**
* Called when the end of a Section is reached.
* <P>
* <CODE>position</CODE> will hold the height of the section end.
*
* @param writer
* the <CODE>PdfWriter</CODE> for this document
* @param document
* the document
* @param position
* the position of the end of the section
*/
public virtual void OnSectionEnd(PdfWriter writer, Document document, float position) {
foreach (IPdfPageEvent eventa in events) {
eventa.OnSectionEnd(writer, document, position);
}
}
/**
* Called when a <CODE>Chunk</CODE> with a generic tag is written.
* <P>
* It is usefull to pinpoint the <CODE>Chunk</CODE> location to generate
* bookmarks, for example.
*
* @param writer
* the <CODE>PdfWriter</CODE> for this document
* @param document
* the document
* @param rect
* the <CODE>Rectangle</CODE> containing the <CODE>Chunk
* </CODE>
* @param text
* the text of the tag
*/
public virtual void OnGenericTag(PdfWriter writer, Document document,
Rectangle rect, String text) {
foreach (IPdfPageEvent eventa in events) {
eventa.OnGenericTag(writer, document, rect, text);
}
}
}
}