Porting update.
git-svn-id: svn://svn.code.sf.net/p/itextsharp/code/trunk@20 820d3149-562b-4f88-9aa4-a8e61a3485cfmaster
parent
9e5c88451d
commit
b972119de6
|
@ -56,6 +56,12 @@ namespace iTextSharp.text {
|
|||
*/
|
||||
public class ChapterAutoNumber : Chapter {
|
||||
|
||||
/**
|
||||
* Is the chapter number already set?
|
||||
* @since 2.1.4
|
||||
*/
|
||||
protected bool numberSet = false;
|
||||
|
||||
/**
|
||||
* Create a new object.
|
||||
*
|
||||
|
@ -97,5 +103,19 @@ namespace iTextSharp.text {
|
|||
}
|
||||
return AddSection(title, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the Chapter number.
|
||||
* @param number the new chapter number
|
||||
* @since 2.1.4
|
||||
*/
|
||||
public int SetAutomaticNumber(int number) {
|
||||
if (!numberSet) {
|
||||
number++;
|
||||
base.SetChapterNumber(number);
|
||||
numberSet = true;
|
||||
}
|
||||
return number;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -412,5 +412,13 @@ namespace iTextSharp.text {
|
|||
public virtual bool SetMarginMirroring(bool marginMirroring) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.lowagie.text.DocListener#setMarginMirroring(boolean)
|
||||
* @since 2.1.6
|
||||
*/
|
||||
public virtual bool SetMarginMirroringTopBottom(bool MarginMirroring) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -100,9 +100,18 @@ namespace iTextSharp.text {
|
|||
public class Document : IDocListener {
|
||||
|
||||
// membervariables
|
||||
|
||||
///<summary> This constant may only be changed by Paulo Soares and/or Bruno Lowagie. </summary>
|
||||
private const string ITEXT_VERSION = "iTextSharp 4.1.2 (based on iText 2.1.2u)";
|
||||
/**
|
||||
* This constant may only be changed by Paulo Soares and/or Bruno Lowagie.
|
||||
* @since 2.1.6
|
||||
*/
|
||||
private const String ITEXT = "iText";
|
||||
/**
|
||||
* This constant may only be changed by Paulo Soares and/or Bruno Lowagie.
|
||||
* @since 2.1.6
|
||||
*/
|
||||
private const String RELEASE = "2.1.6_SNAPSHOT";
|
||||
/** This constant may only be changed by Paulo Soares and/or Bruno Lowagie. */
|
||||
private const String ITEXT_VERSION = ITEXT + " " + RELEASE + " by 1T3XT";
|
||||
|
||||
///<summary> Allows the pdf documents to be produced without compression for debugging purposes. </summary>
|
||||
public static bool Compress = true;
|
||||
|
@ -137,6 +146,13 @@ namespace iTextSharp.text {
|
|||
protected float marginBottom = 0;
|
||||
|
||||
protected bool marginMirroring = false;
|
||||
|
||||
/**
|
||||
* mirroring of the top/bottom margins
|
||||
* @since 2.1.6
|
||||
*/
|
||||
protected bool marginMirroringTopBottom = false;
|
||||
|
||||
///<summary> Content of JavaScript onLoad function </summary>
|
||||
protected string javaScript_onLoad = null;
|
||||
|
||||
|
@ -157,6 +173,9 @@ namespace iTextSharp.text {
|
|||
///<summary> This is the textual part of the footer </summary>
|
||||
protected HeaderFooter footer = null;
|
||||
|
||||
/** This is a chapter number in case ChapterAutoNumber is used. */
|
||||
protected int chapternumber = 0;
|
||||
|
||||
// constructor
|
||||
|
||||
/// <summary>
|
||||
|
@ -222,6 +241,9 @@ namespace iTextSharp.text {
|
|||
throw new DocumentException("The document is not open yet; you can only add Meta information.");
|
||||
}
|
||||
bool success = false;
|
||||
if (element is ChapterAutoNumber) {
|
||||
chapternumber = ((ChapterAutoNumber)element).SetAutomaticNumber(chapternumber);
|
||||
}
|
||||
foreach (IDocListener listener in listeners) {
|
||||
success |= listener.Add(element);
|
||||
}
|
||||
|
@ -603,6 +625,30 @@ namespace iTextSharp.text {
|
|||
return open;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the product name.
|
||||
* This method may only be changed by Paulo Soares and/or Bruno Lowagie.
|
||||
* @return the product name
|
||||
* @since 2.1.6
|
||||
*/
|
||||
public static String Product {
|
||||
get {
|
||||
return ITEXT;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the release number.
|
||||
* This method may only be changed by Paulo Soares and/or Bruno Lowagie.
|
||||
* @return the product name
|
||||
* @since 2.1.6
|
||||
*/
|
||||
public static String Release {
|
||||
get {
|
||||
return RELEASE;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the iText version.
|
||||
/// </summary>
|
||||
|
@ -656,7 +702,7 @@ namespace iTextSharp.text {
|
|||
}
|
||||
|
||||
/**
|
||||
* Set the margin mirroring. It will mirror margins for odd/even pages.
|
||||
* Set the margin mirroring. It will mirror right/left margins for odd/even pages.
|
||||
* <p>
|
||||
* Note: it will not work with {@link Table}.
|
||||
*
|
||||
|
@ -672,6 +718,24 @@ namespace iTextSharp.text {
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the margin mirroring. It will mirror top/bottom margins for odd/even pages.
|
||||
* <p>
|
||||
* Note: it will not work with {@link Table}.
|
||||
*
|
||||
* @param marginMirroringTopBottom
|
||||
* <CODE>true</CODE> to mirror the margins
|
||||
* @return always <CODE>true</CODE>
|
||||
* @since 2.1.6
|
||||
*/
|
||||
public virtual bool SetMarginMirroringTopBottom(bool marginMirroringTopBottom) {
|
||||
this.marginMirroringTopBottom = marginMirroringTopBottom;
|
||||
foreach (IDocListener listener in listeners) {
|
||||
listener.SetMarginMirroringTopBottom(marginMirroringTopBottom);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the margin mirroring flag.
|
||||
*
|
||||
|
|
|
@ -165,6 +165,12 @@ namespace iTextSharp.text
|
|||
/// <summary> This is a possible type of Element. </summary>
|
||||
public const int IMGTEMPLATE = 35;
|
||||
|
||||
/**
|
||||
* This is a possible type of <CODE>Element</CODE>.
|
||||
* @since 2.1.5
|
||||
*/
|
||||
public const int JBIG2 = 36;
|
||||
|
||||
/// <summary> This is a possible type of <CODE>Element</CODE>. </summary>
|
||||
public const int MULTI_COLUMN_TEXT = 40;
|
||||
|
||||
|
|
|
@ -479,8 +479,7 @@ namespace iTextSharp.text {
|
|||
*/
|
||||
|
||||
public virtual void SetStyle(int style) {
|
||||
if (this.style == UNDEFINED) this.style = NORMAL;
|
||||
this.style |= style;
|
||||
this.style = style;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -107,6 +107,14 @@ namespace iTextSharp.text {
|
|||
*/
|
||||
bool SetMarginMirroring(bool marginMirroring);
|
||||
|
||||
/**
|
||||
* Parameter that allows you to do top/bottom margin mirroring (odd/even pages)
|
||||
* @param marginMirroringTopBottom
|
||||
* @return true if successful
|
||||
* @since 2.1.6
|
||||
*/
|
||||
bool SetMarginMirroringTopBottom(bool marginMirroringTopBottom); // [L6]
|
||||
|
||||
/// <summary>
|
||||
/// Sets the page number.
|
||||
/// </summary>
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
/*
|
||||
* $Id: BadPasswordException.java 3665 2009-01-26 22:32:15Z xlv $
|
||||
*
|
||||
* Copyright 2007 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, 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.exceptions {
|
||||
|
||||
/**
|
||||
* Typed exception used when opening an existing PDF document.
|
||||
* Gets thrown when the document isn't a valid PDF document.
|
||||
* @since 2.1.5 It was written for iText 2.0.8, but moved to another package
|
||||
*/
|
||||
public class BadPasswordException : IOException {
|
||||
|
||||
/**
|
||||
* Creates an exception saying the user password was incorrect.
|
||||
*/
|
||||
public BadPasswordException(String message) : base(message) {
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
using System;
|
||||
/*
|
||||
* $Id: IllegalPdfSyntaxException.java 3820 2009-03-25 10:30:01Z blowagie $
|
||||
*
|
||||
* Copyright 2009 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-2009 by Bruno Lowagie.
|
||||
* All Rights Reserved.
|
||||
* Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
|
||||
* are Copyright (C) 2000-2009 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.exceptions {
|
||||
|
||||
/**
|
||||
* Typed exception used when creating PDF syntax that isn't valid.
|
||||
* @since 2.1.6
|
||||
*/
|
||||
public class IllegalPdfSyntaxException : ArgumentException {
|
||||
|
||||
/**
|
||||
* Creates an exception saying the PDF syntax isn't correct.
|
||||
* @param message some extra info about the exception
|
||||
*/
|
||||
public IllegalPdfSyntaxException(String message) : base(message) {
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
/*
|
||||
* $Id: InvalidPdfException.java 3665 2009-01-26 22:32:15Z xlv $
|
||||
*
|
||||
* Copyright 2009 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-2009 by Bruno Lowagie.
|
||||
* All Rights Reserved.
|
||||
* Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
|
||||
* are Copyright (C) 2000-2009 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.exceptions {
|
||||
|
||||
/**
|
||||
* Typed exception used when opening an existing PDF document.
|
||||
* Gets thrown when the document isn't a valid PDF document.
|
||||
* @since 2.1.5
|
||||
*/
|
||||
public class InvalidPdfException : IOException {
|
||||
|
||||
/**
|
||||
* Creates an instance of a NoPdfException.
|
||||
* @param message the reason why the document isn't a PDF document according to iText.
|
||||
*/
|
||||
public InvalidPdfException(String message) : base(message) {
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
using System;
|
||||
/*
|
||||
* $Id: UnsupportedPdfException.java 3665 2009-01-26 22:32:15Z xlv $
|
||||
*
|
||||
* Copyright 2009 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-2009 by Bruno Lowagie.
|
||||
* All Rights Reserved.
|
||||
* Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
|
||||
* are Copyright (C) 2000-2009 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.exceptions {
|
||||
/**
|
||||
* Typed exception used when opening an existing PDF document.
|
||||
* Gets thrown when the document isn't a valid PDF document according to iText,
|
||||
* but it's different from the InvalidPdfException in the sense that it may
|
||||
* be an iText limitation (most of the times it isn't but you might have
|
||||
* bumped into something that has been added to the PDF specs, but that isn't
|
||||
* supported in iText yet).
|
||||
* @since 2.1.5
|
||||
*/
|
||||
public class UnsupportedPdfException : InvalidPdfException {
|
||||
|
||||
/**
|
||||
* Creates an instance of an UnsupportedPdfException.
|
||||
* @param message the reason why the document isn't a PDF document according to iText.
|
||||
*/
|
||||
public UnsupportedPdfException(String message) : base(message) {
|
||||
}
|
||||
}
|
||||
}
|
|
@ -408,41 +408,8 @@ namespace iTextSharp.text.html {
|
|||
if (s == null)
|
||||
return null;
|
||||
s = s.ToLower(CultureInfo.InvariantCulture).Trim();
|
||||
Color c = (Color)WebColors.GetRGBColor(s);
|
||||
if (c != null)
|
||||
return c;
|
||||
try {
|
||||
if (s.StartsWith("#")) {
|
||||
if (s.Length == 4)
|
||||
s = "#" + s.Substring(1, 1) + s.Substring(1, 1)
|
||||
+ s.Substring(2, 1) + s.Substring(2, 1)
|
||||
+ s.Substring(3, 1) + s.Substring(3, 1);
|
||||
if (s.Length == 7)
|
||||
return new Color(int.Parse(s.Substring(1), NumberStyles.HexNumber));
|
||||
}
|
||||
else if (s.StartsWith("rgb")) {
|
||||
StringTokenizer tk = new StringTokenizer(s.Substring(3), " \t\r\n\f(),");
|
||||
int[] cc = new int [3];
|
||||
for (int k = 0; k < 3; ++k) {
|
||||
if (!tk.HasMoreTokens())
|
||||
return null;
|
||||
String t = tk.NextToken();
|
||||
float n;
|
||||
if (t.EndsWith("%")) {
|
||||
n = float.Parse(t.Substring(0, t.Length - 1), System.Globalization.NumberFormatInfo.InvariantInfo);
|
||||
n = n * 255f / 100f;
|
||||
}
|
||||
else
|
||||
n = float.Parse(t, System.Globalization.NumberFormatInfo.InvariantInfo);
|
||||
int ni = (int)n;
|
||||
if (ni > 255)
|
||||
ni = 255;
|
||||
else if (ni < 0)
|
||||
ni = 0;
|
||||
cc[k] = ni;
|
||||
}
|
||||
return new Color(cc[0], cc[1], cc[2]);
|
||||
}
|
||||
return WebColors.GetRGBColor(s);
|
||||
}
|
||||
catch {
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ public class ChainedProperties {
|
|||
// adjust the font size
|
||||
String value = (String)prop[ElementTags.SIZE];
|
||||
if (value != null) {
|
||||
if (value.EndsWith("px")) {
|
||||
if (value.EndsWith("pt")) {
|
||||
prop[ElementTags.SIZE] = value.Substring(0, value.Length - 2);
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -3,8 +3,8 @@ using System.Collections;
|
|||
using System.Globalization;
|
||||
using System.util;
|
||||
using iTextSharp.text;
|
||||
using iTextSharp.text.pdf;
|
||||
using iTextSharp.text.html;
|
||||
using iTextSharp.text.pdf;
|
||||
/*
|
||||
* Copyright 2004 Paulo Soares
|
||||
*
|
||||
|
@ -102,22 +102,6 @@ namespace iTextSharp.text.html.simpleparser {
|
|||
|
||||
}
|
||||
|
||||
public static Paragraph CreateParagraph(Hashtable props) {
|
||||
Paragraph p = new Paragraph();
|
||||
String value = (String)props["align"];
|
||||
if (value != null) {
|
||||
if (Util.EqualsIgnoreCase(value, "center"))
|
||||
p.Alignment = Element.ALIGN_CENTER;
|
||||
else if (Util.EqualsIgnoreCase(value, "right"))
|
||||
p.Alignment = Element.ALIGN_RIGHT;
|
||||
else if (Util.EqualsIgnoreCase(value, "justify"))
|
||||
p.Alignment = Element.ALIGN_JUSTIFIED;
|
||||
}
|
||||
SetParagraphLeading(p, (String)props["leading"]);
|
||||
p.Hyphenation = GetHyphenation(props);
|
||||
return p;
|
||||
}
|
||||
|
||||
public static void CreateParagraph(Paragraph p, ChainedProperties props) {
|
||||
String value = props["align"];
|
||||
if (value != null) {
|
||||
|
@ -166,7 +150,7 @@ namespace iTextSharp.text.html.simpleparser {
|
|||
}
|
||||
|
||||
public Font GetFont(ChainedProperties props) {
|
||||
String face = props["face"];
|
||||
String face = props[ElementTags.FACE];
|
||||
if (face != null) {
|
||||
StringTokenizer tok = new StringTokenizer(face, ",");
|
||||
while (tok.HasMoreTokens()) {
|
||||
|
@ -180,16 +164,16 @@ namespace iTextSharp.text.html.simpleparser {
|
|||
}
|
||||
}
|
||||
int style = 0;
|
||||
if (props.HasProperty("i"))
|
||||
if (props.HasProperty(HtmlTags.I))
|
||||
style |= Font.ITALIC;
|
||||
if (props.HasProperty("b"))
|
||||
if (props.HasProperty(HtmlTags.B))
|
||||
style |= Font.BOLD;
|
||||
if (props.HasProperty("u"))
|
||||
if (props.HasProperty(HtmlTags.U))
|
||||
style |= Font.UNDERLINE;
|
||||
if (props.HasProperty("s"))
|
||||
if (props.HasProperty(HtmlTags.S))
|
||||
style |= Font.STRIKETHRU ;
|
||||
|
||||
String value = props["size"];
|
||||
String value = props[ElementTags.SIZE];
|
||||
float size = 12;
|
||||
if (value != null)
|
||||
size = float.Parse(value, System.Globalization.NumberFormatInfo.InvariantInfo);
|
||||
|
@ -259,6 +243,14 @@ namespace iTextSharp.text.html.simpleparser {
|
|||
return new HyphenationAuto(lang, country, leftMin, rightMin);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method isn't used by iText, but you can use it to analyze
|
||||
* the value of a style attribute inside a HashMap.
|
||||
* The different elements of the style attribute are added to the
|
||||
* HashMap as key-value pairs.
|
||||
* @param h a HashMap that should have at least a key named
|
||||
* style. After this method is invoked, more keys could be added.
|
||||
*/
|
||||
public static void InsertStyle(Hashtable h) {
|
||||
String style = (String)h["style"];
|
||||
if (style == null)
|
||||
|
@ -269,7 +261,7 @@ namespace iTextSharp.text.html.simpleparser {
|
|||
h["face"] = prop[key];
|
||||
}
|
||||
else if (key.Equals(Markup.CSS_KEY_FONTSIZE)) {
|
||||
h["size"] = Markup.ParseLength(prop[key]).ToString(NumberFormatInfo.InvariantInfo) + "px";
|
||||
h["size"] = Markup.ParseLength(prop[key]).ToString(NumberFormatInfo.InvariantInfo) + "pt";
|
||||
}
|
||||
else if (key.Equals(Markup.CSS_KEY_FONTSTYLE)) {
|
||||
String ss = prop[key].Trim().ToLower(CultureInfo.InvariantCulture);
|
||||
|
@ -281,9 +273,9 @@ namespace iTextSharp.text.html.simpleparser {
|
|||
if (ss.Equals("bold") || ss.Equals("700") || ss.Equals("800") || ss.Equals("900"))
|
||||
h["b"] = null;
|
||||
}
|
||||
else if (key.Equals(Markup.CSS_KEY_FONTWEIGHT)) {
|
||||
else if (key.Equals(Markup.CSS_KEY_TEXTDECORATION)) {
|
||||
String ss = prop[key].Trim().ToLower(CultureInfo.InvariantCulture);
|
||||
if (ss.Equals("underline"))
|
||||
if (ss.Equals(Markup.CSS_VALUE_UNDERLINE))
|
||||
h["u"] = null;
|
||||
}
|
||||
else if (key.Equals(Markup.CSS_KEY_COLOR)) {
|
||||
|
@ -301,6 +293,77 @@ namespace iTextSharp.text.html.simpleparser {
|
|||
v /= 100;
|
||||
h["leading"] = "0," + v.ToString(NumberFormatInfo.InvariantInfo);
|
||||
}
|
||||
else if (Util.EqualsIgnoreCase("normal", ss)) {
|
||||
h["leading"] = "0,1.5";
|
||||
}
|
||||
else {
|
||||
h["leading"] = v.ToString(NumberFormatInfo.InvariantInfo) + ",0";
|
||||
}
|
||||
}
|
||||
else if (key.Equals(Markup.CSS_KEY_TEXTALIGN)) {
|
||||
String ss = prop[key].Trim().ToLower(System.Globalization.CultureInfo.InvariantCulture);
|
||||
h["align"] = ss;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* New method contributed by Lubos Strapko
|
||||
* @param h
|
||||
* @param cprops
|
||||
* @since 2.1.3
|
||||
*/
|
||||
public static void InsertStyle(Hashtable h, ChainedProperties cprops) {
|
||||
String style = (String)h["style"];
|
||||
if (style == null)
|
||||
return;
|
||||
Properties prop = Markup.ParseAttributes(style);
|
||||
foreach (String key in prop.Keys) {
|
||||
if (key.Equals(Markup.CSS_KEY_FONTFAMILY)) {
|
||||
h["face"] = prop[key];
|
||||
}
|
||||
else if (key.Equals(Markup.CSS_KEY_FONTSIZE)) {
|
||||
float actualFontSize = Markup.ParseLength(cprops[ElementTags.SIZE], Markup.DEFAULT_FONT_SIZE);
|
||||
if (actualFontSize <= 0f)
|
||||
actualFontSize = Markup.DEFAULT_FONT_SIZE;
|
||||
h[ElementTags.SIZE] = Markup.ParseLength(prop[key], actualFontSize).ToString(NumberFormatInfo.InvariantInfo) + "pt";
|
||||
}
|
||||
else if (key.Equals(Markup.CSS_KEY_FONTSTYLE)) {
|
||||
String ss = prop[key].Trim().ToLower(CultureInfo.InvariantCulture);
|
||||
if (ss.Equals("italic") || ss.Equals("oblique"))
|
||||
h["i"] = null;
|
||||
}
|
||||
else if (key.Equals(Markup.CSS_KEY_FONTWEIGHT)) {
|
||||
String ss = prop[key].Trim().ToLower(CultureInfo.InvariantCulture);
|
||||
if (ss.Equals("bold") || ss.Equals("700") || ss.Equals("800") || ss.Equals("900"))
|
||||
h["b"] = null;
|
||||
}
|
||||
else if (key.Equals(Markup.CSS_KEY_TEXTDECORATION)) {
|
||||
String ss = prop[key].Trim().ToLower(CultureInfo.InvariantCulture);
|
||||
if (ss.Equals(Markup.CSS_VALUE_UNDERLINE))
|
||||
h["u"] = null;
|
||||
}
|
||||
else if (key.Equals(Markup.CSS_KEY_COLOR)) {
|
||||
Color c = Markup.DecodeColor(prop[key]);
|
||||
if (c != null) {
|
||||
int hh = c.ToArgb() & 0xffffff;
|
||||
String hs = "#" + hh.ToString("X06", NumberFormatInfo.InvariantInfo);
|
||||
h["color"] = hs;
|
||||
}
|
||||
}
|
||||
else if (key.Equals(Markup.CSS_KEY_LINEHEIGHT)) {
|
||||
String ss = prop[key].Trim();
|
||||
float actualFontSize = Markup.ParseLength(cprops[ElementTags.SIZE], Markup.DEFAULT_FONT_SIZE);
|
||||
if (actualFontSize <= 0f)
|
||||
actualFontSize = Markup.DEFAULT_FONT_SIZE;
|
||||
float v = Markup.ParseLength(prop[key], actualFontSize);
|
||||
if (ss.EndsWith("%")) {
|
||||
v /= 100;
|
||||
h["leading"] = "0," + v.ToString(NumberFormatInfo.InvariantInfo);
|
||||
}
|
||||
else if (Util.EqualsIgnoreCase("normal", ss)) {
|
||||
h["leading"] = "0,1.5";
|
||||
}
|
||||
else {
|
||||
h["leading"] = v.ToString(NumberFormatInfo.InvariantInfo) + ",0";
|
||||
}
|
||||
|
|
|
@ -5,7 +5,9 @@ using System.Collections;
|
|||
using System.Globalization;
|
||||
using System.util;
|
||||
using iTextSharp.text;
|
||||
using iTextSharp.text.html;
|
||||
using iTextSharp.text.pdf;
|
||||
using iTextSharp.text.pdf.draw;
|
||||
using iTextSharp.text.xml.simpleparser;
|
||||
/*
|
||||
* Copyright 2004 Paulo Soares
|
||||
|
@ -145,8 +147,8 @@ namespace iTextSharp.text.html.simpleparser {
|
|||
cprops.AddToChain(follow, prop);
|
||||
return;
|
||||
}
|
||||
FactoryProperties.InsertStyle(h);
|
||||
if (tag.Equals("a")) {
|
||||
FactoryProperties.InsertStyle(h, cprops);
|
||||
if (tag.Equals(HtmlTags.ANCHOR)) {
|
||||
cprops.AddToChain(tag, h);
|
||||
if (currentParagraph == null)
|
||||
currentParagraph = new Paragraph();
|
||||
|
@ -154,18 +156,63 @@ namespace iTextSharp.text.html.simpleparser {
|
|||
currentParagraph = new Paragraph();
|
||||
return;
|
||||
}
|
||||
if (tag.Equals("br")) {
|
||||
if (tag.Equals(HtmlTags.NEWLINE)) {
|
||||
if (currentParagraph == null)
|
||||
currentParagraph = new Paragraph();
|
||||
currentParagraph.Add(factoryProperties.CreateChunk("\n", cprops));
|
||||
return;
|
||||
}
|
||||
if (tag.Equals("font") || tag.Equals("span")) {
|
||||
if (tag.Equals(HtmlTags.HORIZONTALRULE)) {
|
||||
// Attempting to duplicate the behavior seen on Firefox with
|
||||
// http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_hr_test
|
||||
// where an initial break is only inserted when the preceding element doesn't
|
||||
// end with a break, but a trailing break is always inserted.
|
||||
bool addLeadingBreak = true;
|
||||
if (currentParagraph == null) {
|
||||
currentParagraph = new Paragraph();
|
||||
addLeadingBreak = false;
|
||||
}
|
||||
if (addLeadingBreak) { // Not a new paragraph
|
||||
int numChunks = currentParagraph.Chunks.Count;
|
||||
if (numChunks == 0 ||
|
||||
((Chunk)currentParagraph.Chunks[numChunks - 1]).Content.EndsWith("\n"))
|
||||
addLeadingBreak = false;
|
||||
}
|
||||
String align = (String)h["align"];
|
||||
int hrAlign = Element.ALIGN_CENTER;
|
||||
if (align != null) {
|
||||
if (Util.EqualsIgnoreCase(align, "left"))
|
||||
hrAlign = Element.ALIGN_LEFT;
|
||||
if (Util.EqualsIgnoreCase(align, "right"))
|
||||
hrAlign = Element.ALIGN_RIGHT;
|
||||
}
|
||||
String width = (String)h["width"];
|
||||
float hrWidth = 1;
|
||||
if (width != null) {
|
||||
float tmpWidth = Markup.ParseLength(width, Markup.DEFAULT_FONT_SIZE);
|
||||
if (tmpWidth > 0) hrWidth = tmpWidth;
|
||||
if (!width.EndsWith("%"))
|
||||
hrWidth = 100; // Treat a pixel width as 100% for now.
|
||||
}
|
||||
String size = (String)h["size"];
|
||||
float hrSize = 1;
|
||||
if (size != null) {
|
||||
float tmpSize = Markup.ParseLength(size, Markup.DEFAULT_FONT_SIZE);
|
||||
if (tmpSize > 0)
|
||||
hrSize = tmpSize;
|
||||
}
|
||||
if (addLeadingBreak)
|
||||
currentParagraph.Add(Chunk.NEWLINE);
|
||||
currentParagraph.Add(new LineSeparator(hrSize, hrWidth, null, hrAlign, currentParagraph.Leading/2));
|
||||
currentParagraph.Add(Chunk.NEWLINE);
|
||||
return;
|
||||
}
|
||||
if (tag.Equals(HtmlTags.CHUNK) || tag.Equals(HtmlTags.SPAN)) {
|
||||
cprops.AddToChain(tag, h);
|
||||
return;
|
||||
}
|
||||
if (tag.Equals("img")) {
|
||||
String src = (String)h["src"];
|
||||
if (tag.Equals(HtmlTags.IMAGE)) {
|
||||
String src = (String)h[ElementTags.SRC];
|
||||
if (src == null)
|
||||
return;
|
||||
cprops.AddToChain(tag, h);
|
||||
|
@ -209,14 +256,20 @@ namespace iTextSharp.text.html.simpleparser {
|
|||
img.SpacingBefore = float.Parse(before, System.Globalization.NumberFormatInfo.InvariantInfo);
|
||||
if (after != null)
|
||||
img.SpacingAfter = float.Parse(after, System.Globalization.NumberFormatInfo.InvariantInfo);
|
||||
float wp = LengthParse(width, (int)img.Width);
|
||||
float lp = LengthParse(height, (int)img.Height);
|
||||
if (wp > 0 && lp > 0)
|
||||
img.ScalePercent(wp > lp ? lp : wp);
|
||||
else if (wp > 0)
|
||||
img.ScalePercent(wp);
|
||||
else if (lp > 0)
|
||||
img.ScalePercent(lp);
|
||||
float actualFontSize = Markup.ParseLength(cprops[ElementTags.SIZE], Markup.DEFAULT_FONT_SIZE);
|
||||
if (actualFontSize <= 0f)
|
||||
actualFontSize = Markup.DEFAULT_FONT_SIZE;
|
||||
float widthInPoints = Markup.ParseLength(width, actualFontSize);
|
||||
float heightInPoints = Markup.ParseLength(height, actualFontSize);
|
||||
if (widthInPoints > 0 && heightInPoints > 0) {
|
||||
img.ScaleAbsolute(widthInPoints, heightInPoints);
|
||||
} else if (widthInPoints > 0) {
|
||||
heightInPoints = img.Height * widthInPoints / img.Width;
|
||||
img.ScaleAbsolute(widthInPoints, heightInPoints);
|
||||
} else if (heightInPoints > 0) {
|
||||
widthInPoints = img.Width * heightInPoints / img.Height;
|
||||
img.ScaleAbsolute(widthInPoints, heightInPoints);
|
||||
}
|
||||
img.WidthPercentage = 0;
|
||||
if (align != null) {
|
||||
EndElement("p");
|
||||
|
@ -248,16 +301,16 @@ namespace iTextSharp.text.html.simpleparser {
|
|||
|
||||
EndElement("p");
|
||||
if (tag.Equals("h1") || tag.Equals("h2") || tag.Equals("h3") || tag.Equals("h4") || tag.Equals("h5") || tag.Equals("h6")) {
|
||||
if (!h.ContainsKey("size")) {
|
||||
if (!h.ContainsKey(ElementTags.SIZE)) {
|
||||
int v = 7 - int.Parse(tag.Substring(1));
|
||||
h["size"] = v.ToString();
|
||||
h[ElementTags.SIZE] = v.ToString();
|
||||
}
|
||||
cprops.AddToChain(tag, h);
|
||||
return;
|
||||
}
|
||||
if (tag.Equals("ul")) {
|
||||
if (tag.Equals(HtmlTags.UNORDEREDLIST)) {
|
||||
if (pendingLI)
|
||||
EndElement("li");
|
||||
EndElement(HtmlTags.LISTITEM);
|
||||
skipText = true;
|
||||
cprops.AddToChain(tag, h);
|
||||
List list = new List(false, 10);
|
||||
|
@ -265,41 +318,36 @@ namespace iTextSharp.text.html.simpleparser {
|
|||
stack.Push(list);
|
||||
return;
|
||||
}
|
||||
if (tag.Equals("ol")) {
|
||||
if (tag.Equals(HtmlTags.ORDEREDLIST)) {
|
||||
if (pendingLI)
|
||||
EndElement("li");
|
||||
EndElement(HtmlTags.LISTITEM);
|
||||
skipText = true;
|
||||
cprops.AddToChain(tag, h);
|
||||
List list = new List(true, 10);
|
||||
stack.Push(list);
|
||||
return;
|
||||
}
|
||||
if (tag.Equals("li")) {
|
||||
if (tag.Equals(HtmlTags.LISTITEM)) {
|
||||
if (pendingLI)
|
||||
EndElement("li");
|
||||
EndElement(HtmlTags.LISTITEM);
|
||||
skipText = false;
|
||||
pendingLI = true;
|
||||
cprops.AddToChain(tag, h);
|
||||
stack.Push(FactoryProperties.CreateListItem(cprops));
|
||||
return;
|
||||
}
|
||||
if (tag.Equals("div") || tag.Equals("body")) {
|
||||
if (tag.Equals(HtmlTags.DIV) || tag.Equals(HtmlTags.BODY) || tag.Equals("p")) {
|
||||
cprops.AddToChain(tag, h);
|
||||
return;
|
||||
}
|
||||
if (tag.Equals("pre")) {
|
||||
if (!h.ContainsKey("face")) {
|
||||
h["face"] = "Courier";
|
||||
if (tag.Equals(HtmlTags.PRE)) {
|
||||
if (!h.ContainsKey(ElementTags.FACE)) {
|
||||
h[ElementTags.FACE] = "Courier";
|
||||
}
|
||||
cprops.AddToChain(tag, h);
|
||||
isPRE = true;
|
||||
return;
|
||||
}
|
||||
if (tag.Equals("p")) {
|
||||
cprops.AddToChain(tag, h);
|
||||
currentParagraph = FactoryProperties.CreateParagraph(h);
|
||||
return;
|
||||
}
|
||||
if (tag.Equals("tr")) {
|
||||
if (pendingTR)
|
||||
EndElement("tr");
|
||||
|
@ -384,9 +432,9 @@ namespace iTextSharp.text.html.simpleparser {
|
|||
}
|
||||
}
|
||||
currentParagraph = null;
|
||||
if (tag.Equals("ul") || tag.Equals("ol")) {
|
||||
if (tag.Equals(HtmlTags.UNORDEREDLIST) || tag.Equals(HtmlTags.ORDEREDLIST)) {
|
||||
if (pendingLI)
|
||||
EndElement("li");
|
||||
EndElement(HtmlTags.LISTITEM);
|
||||
skipText = false;
|
||||
cprops.RemoveChain(tag);
|
||||
if (stack.Count == 0)
|
||||
|
@ -402,7 +450,7 @@ namespace iTextSharp.text.html.simpleparser {
|
|||
((ITextElementArray)stack.Peek()).Add(obj);
|
||||
return;
|
||||
}
|
||||
if (tag.Equals("li")) {
|
||||
if (tag.Equals(HtmlTags.LISTITEM)) {
|
||||
pendingLI = false;
|
||||
skipText = true;
|
||||
cprops.RemoveChain(tag);
|
||||
|
@ -434,7 +482,7 @@ namespace iTextSharp.text.html.simpleparser {
|
|||
cprops.RemoveChain(tag);
|
||||
return;
|
||||
}
|
||||
if (tag.Equals("pre")) {
|
||||
if (tag.Equals(HtmlTags.PRE)) {
|
||||
cprops.RemoveChain(tag);
|
||||
isPRE = false;
|
||||
return;
|
||||
|
@ -569,7 +617,15 @@ namespace iTextSharp.text.html.simpleparser {
|
|||
}
|
||||
|
||||
public bool SetMarginMirroring(bool marginMirroring) {
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.lowagie.text.DocListener#setMarginMirroring(boolean)
|
||||
* @since 2.1.6
|
||||
*/
|
||||
public bool SetMarginMirroringTopBottom(bool marginMirroring) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool SetMargins(float marginLeft, float marginRight, float marginTop, float marginBottom) {
|
||||
|
@ -581,7 +637,7 @@ namespace iTextSharp.text.html.simpleparser {
|
|||
}
|
||||
|
||||
public const String tagsSupportedString = "ol ul li a pre font span br p div body table td th tr i b u sub sup em strong s strike"
|
||||
+ " h1 h2 h3 h4 h5 h6 img";
|
||||
+ " h1 h2 h3 h4 h5 h6 img hr";
|
||||
|
||||
public static Hashtable tagsSupported = new Hashtable();
|
||||
|
||||
|
@ -605,20 +661,5 @@ namespace iTextSharp.text.html.simpleparser {
|
|||
set {
|
||||
}
|
||||
}
|
||||
|
||||
private static float LengthParse(String txt, int c) {
|
||||
if (txt == null)
|
||||
return -1;
|
||||
if (txt.EndsWith("%")) {
|
||||
float vf = float.Parse(txt.Substring(0, txt.Length - 1), System.Globalization.NumberFormatInfo.InvariantInfo);
|
||||
return vf;
|
||||
}
|
||||
if (txt.EndsWith("px")) {
|
||||
float vf = float.Parse(txt.Substring(0, txt.Length - 2), System.Globalization.NumberFormatInfo.InvariantInfo);
|
||||
return vf;
|
||||
}
|
||||
int v = int.Parse(txt);
|
||||
return (float)v / c * 100f;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -274,10 +274,15 @@ namespace iTextSharp.text.pdf {
|
|||
js.Put(PdfName.JS, new PdfString(code));
|
||||
}
|
||||
else {
|
||||
byte[] b = PdfEncodings.ConvertToBytes(code, unicode ? PdfObject.TEXT_UNICODE : PdfObject.TEXT_PDFDOCENCODING);
|
||||
PdfStream stream = new PdfStream(b);
|
||||
stream.FlateCompress(writer.CompressionLevel);
|
||||
js.Put(PdfName.JS, writer.AddToBody(stream).IndirectReference);
|
||||
try {
|
||||
byte[] b = PdfEncodings.ConvertToBytes(code, unicode ? PdfObject.TEXT_UNICODE : PdfObject.TEXT_PDFDOCENCODING);
|
||||
PdfStream stream = new PdfStream(b);
|
||||
stream.FlateCompress(writer.CompressionLevel);
|
||||
js.Put(PdfName.JS, writer.AddToBody(stream).IndirectReference);
|
||||
}
|
||||
catch {
|
||||
js.Put(PdfName.JS, new PdfString(code));
|
||||
}
|
||||
}
|
||||
return js;
|
||||
}
|
||||
|
|
|
@ -124,7 +124,7 @@ public class PdfArray : PdfObject {
|
|||
*/
|
||||
|
||||
public PdfArray(PdfArray array) : base(ARRAY) {
|
||||
arrayList = new ArrayList(array.ArrayList);
|
||||
arrayList = new ArrayList(array.arrayList);
|
||||
}
|
||||
|
||||
// methods overriding some methods in PdfObject
|
||||
|
@ -152,6 +152,40 @@ public class PdfArray : PdfObject {
|
|||
|
||||
// methods concerning the ArrayList-membervalue
|
||||
|
||||
// ARRAY CONTENT METHODS
|
||||
|
||||
/**
|
||||
* Overwrites a specified location of the array, returning the previous
|
||||
* value
|
||||
*
|
||||
* @param idx The index of the element to be overwritten
|
||||
* @param obj new value for the specified index
|
||||
* @throws IndexOutOfBoundsException if the specified position doesn't exist
|
||||
* @return the previous value
|
||||
* @since 2.1.5
|
||||
*/
|
||||
public PdfObject SetPdfObject(int idx, PdfObject obj) {
|
||||
PdfObject tmp = (PdfObject)arrayList[idx];
|
||||
arrayList[idx] = obj;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the element at the specified position from the array.
|
||||
*
|
||||
* Shifts any subsequent elements to the left (subtracts one from their
|
||||
* indices).
|
||||
*
|
||||
* @param idx The index of the element to be removed.
|
||||
* @throws IndexOutOfBoundsException the specified position doesn't exist
|
||||
* @since 2.1.5
|
||||
*/
|
||||
public PdfObject Remove(int idx) {
|
||||
PdfObject tmp = (PdfObject)arrayList[idx];
|
||||
arrayList.RemoveAt(idx);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an ArrayList containing <CODE>PdfObject</CODE>s.
|
||||
*
|
||||
|
@ -176,6 +210,16 @@ public class PdfArray : PdfObject {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns <CODE>true</CODE> if the array is empty.
|
||||
*
|
||||
* @return <CODE>true</CODE> if the array is empty
|
||||
* @since 2.1.5
|
||||
*/
|
||||
public bool IsEmpty() {
|
||||
return arrayList.Count == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a <CODE>PdfObject</CODE> to the <CODE>PdfArray</CODE>.
|
||||
*
|
||||
|
@ -200,14 +244,31 @@ public class PdfArray : PdfObject {
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a <CODE>PdfObject</CODE> to the <CODE>PdfArray</CODE>.
|
||||
* <P>
|
||||
* The newly added object will be the first element in the <CODE>ArrayList</CODE>.
|
||||
*
|
||||
* @param object <CODE>PdfObject</CODE> to add
|
||||
*/
|
||||
/**
|
||||
* Inserts the specified element at the specified position.
|
||||
*
|
||||
* Shifts the element currently at that position (if any) and
|
||||
* any subsequent elements to the right (adds one to their indices).
|
||||
*
|
||||
* @param index The index at which the specified element is to be inserted
|
||||
* @param element The element to be inserted
|
||||
* @throws IndexOutOfBoundsException if the specified index is larger than the
|
||||
* last position currently set, plus 1.
|
||||
* @since 2.1.5
|
||||
*/
|
||||
public void Add(int index, PdfObject element) {
|
||||
arrayList.Insert(index, element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts a <CODE>PdfObject</CODE> at the beginning of the
|
||||
* <CODE>PdfArray</CODE>.
|
||||
*
|
||||
* The <CODE>PdfObject</CODE> will be the first element, any other elements
|
||||
* will be shifted to the right (adds one to their indices).
|
||||
*
|
||||
* @param object The <CODE>PdfObject</CODE> to add
|
||||
*/
|
||||
public void AddFirst(PdfObject obj) {
|
||||
arrayList.Insert(0, obj);
|
||||
}
|
||||
|
|
|
@ -367,6 +367,26 @@
|
|||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "iTextSharp\text\exceptions\BadPasswordException.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "iTextSharp\text\exceptions\IllegalPdfSyntaxException.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "iTextSharp\text\exceptions\InvalidPdfException.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "iTextSharp\text\exceptions\UnsupportedPdfException.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "iTextSharp\text\factories\ElementFactory.cs"
|
||||
SubType = "Code"
|
||||
|
|
Loading…
Reference in New Issue