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,185 @@
using System;
/*
* $Id: DublinCoreSchema.cs,v 1.3 2008/05/13 11:26:16 psoares33 Exp $
*
*
* 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.xml.xmp {
/**
* An implementation of an XmpSchema.
*/
public class DublinCoreSchema : XmpSchema {
/** default namespace identifier*/
public const String DEFAULT_XPATH_ID = "dc";
/** default namespace uri*/
public const String DEFAULT_XPATH_URI = "http://purl.org/dc/elements/1.1/";
/** External Contributors to the resource (other than the authors). */
public const String CONTRIBUTOR = "dc:contributor";
/** The extent or scope of the resource. */
public const String COVERAGE = "dc:coverage";
/** The authors of the resource (listed in order of precedence, if significant). */
public const String CREATOR = "dc:creator";
/** Date(s) that something interesting happened to the resource. */
public const String DATE = "dc:date";
/** A textual description of the content of the resource. Multiple values may be present for different languages. */
public const String DESCRIPTION = "dc:description";
/** The file format used when saving the resource. Tools and applications should set this property to the save format of the data. It may include appropriate qualifiers. */
public const String FORMAT = "dc:format";
/** Unique identifier of the resource. */
public const String IDENTIFIER = "dc:identifier";
/** An unordered array specifying the languages used in the resource. */
public const String LANGUAGE = "dc:language";
/** Publishers. */
public const String PUBLISHER = "dc:publisher";
/** Relationships to other documents. */
public const String RELATION = "dc:relation";
/** Informal rights statement, selected by language. */
public const String RIGHTS = "dc:rights";
/** Unique identifier of the work from which this resource was derived. */
public const String SOURCE = "dc:source";
/** An unordered array of descriptive phrases or keywords that specify the topic of the content of the resource. */
public const String SUBJECT = "dc:subject";
/** The title of the document, or the name given to the resource. Typically, it will be a name by which the resource is formally known. */
public const String TITLE = "dc:title";
/** A document type; for example, novel, poem, or working paper. */
public const String TYPE = "dc:type";
/**
* @param shorthand
* @throws IOException
*/
public DublinCoreSchema() : base("xmlns:" + DEFAULT_XPATH_ID + "=\"" + DEFAULT_XPATH_URI + "\"") {
this[FORMAT] = "application/pdf";
}
/**
* Adds a title.
* @param title
*/
public void AddTitle(String title) {
this[TITLE] = title;
}
/**
* Adds a description.
* @param desc
*/
public void AddDescription(String desc) {
this[DESCRIPTION] = desc;
}
/**
* Adds a subject.
* @param subject
*/
public void AddSubject(String subject) {
XmpArray array = new XmpArray(XmpArray.UNORDERED);
array.Add(subject);
SetProperty(SUBJECT, array);
}
/**
* Adds a subject.
* @param subject array of subjects
*/
public void addSubject(String[] subject) {
XmpArray array = new XmpArray(XmpArray.UNORDERED);
for (int i = 0; i < subject.Length; i++) {
array.Add(subject[i]);
}
SetProperty(SUBJECT, array);
}
/**
* Adds a single author.
* @param author
*/
public void AddAuthor(String author) {
XmpArray array = new XmpArray(XmpArray.ORDERED);
array.Add(author);
SetProperty(CREATOR, array);
}
/**
* Adds an array of authors.
* @param author
*/
public void AddAuthor(String[] author) {
XmpArray array = new XmpArray(XmpArray.ORDERED);
for (int i = 0; i < author.Length; i++) {
array.Add(author[i]);
}
SetProperty(CREATOR, array);
}
/**
* Adds a single publisher.
* @param publisher
*/
public void AddPublisher(String publisher) {
XmpArray array = new XmpArray(XmpArray.ORDERED);
array.Add(publisher);
SetProperty(PUBLISHER, array);
}
/**
* Adds an array of publishers.
* @param publisher
*/
public void AddPublisher(String[] publisher) {
XmpArray array = new XmpArray(XmpArray.ORDERED);
for (int i = 0; i < publisher.Length; i++) {
array.Add(publisher[i]);
}
SetProperty(PUBLISHER, array);
}
}
}

View File

@@ -0,0 +1,163 @@
using System;
using System.Text;
/*
* $Id: EncodingNoPreamble.cs,v 1.2 2008/05/13 11:26:16 psoares33 Exp $
*
*
* Copyright 2007 Paulo Soares.
*
* 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.xml.xmp {
/// <summary>
/// A wrapper for an Encoding to suppress the preamble.
/// </summary>
public class EncodingNoPreamble : Encoding {
private Encoding encoding;
private static byte[] emptyPreamble = new byte[0];
public EncodingNoPreamble(Encoding encoding) {
this.encoding = encoding;
}
public override int GetByteCount(char[] chars, int index, int count) {
return encoding.GetByteCount(chars, index, count);
}
public override int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex) {
return encoding.GetBytes(chars, charIndex, charCount, bytes, byteIndex);
}
public override int GetCharCount(byte[] bytes, int index, int count) {
return encoding.GetCharCount(bytes, index, count);
}
public override int GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex) {
return encoding.GetChars(bytes, byteIndex, byteCount, chars, charIndex);
}
public override int GetMaxByteCount(int charCount) {
return encoding.GetMaxByteCount(charCount);
}
public override int GetMaxCharCount(int byteCount) {
return encoding.GetMaxCharCount(byteCount);
}
public override string BodyName {
get {
return encoding.BodyName;
}
}
public override int CodePage {
get {
return encoding.CodePage;
}
}
public override string EncodingName {
get {
return encoding.EncodingName;
}
}
public override string HeaderName {
get {
return encoding.HeaderName;
}
}
public override bool IsBrowserDisplay {
get {
return encoding.IsBrowserDisplay;
}
}
public override bool IsBrowserSave {
get {
return encoding.IsBrowserSave;
}
}
public override bool IsMailNewsDisplay {
get {
return encoding.IsMailNewsDisplay;
}
}
public override bool IsMailNewsSave {
get {
return encoding.IsMailNewsSave;
}
}
public override string WebName {
get {
return encoding.WebName;
}
}
public override int WindowsCodePage {
get {
return encoding.WindowsCodePage;
}
}
public override Decoder GetDecoder() {
return encoding.GetDecoder ();
}
public override Encoder GetEncoder() {
return encoding.GetEncoder ();
}
public override byte[] GetPreamble() {
return emptyPreamble;
}
}
}

View File

@@ -0,0 +1,100 @@
using System;
using System.Text;
using System.util;
/*
* $Id: LangAlt.cs,v 1.3 2008/05/13 11:26:16 psoares33 Exp $
*
*
* Copyright 2007 by Armin Haberling
*
* 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.xml.xmp {
public class LangAlt : Properties {
/** Key for the default language. */
public const String DEFAULT = "x-default";
/** Creates a Properties object that stores languages for use in an XmpSchema */
public LangAlt(String defaultValue) {
AddLanguage(DEFAULT, defaultValue);
}
/** Creates a Properties object that stores languages for use in an XmpSchema */
public LangAlt() {
}
/**
* Add a language.
*/
public void AddLanguage(String language, String value) {
this[language] = XmpSchema.Escape(value);
}
/**
* Process a property.
*/
protected internal void Process(StringBuilder buf, String lang) {
buf.Append("<rdf:li xml:lang=\"");
buf.Append(lang);
buf.Append("\" >");
buf.Append(this[lang]);
buf.Append("</rdf:li>");
}
/**
* Creates a String that can be used in an XmpSchema.
*/
public override String ToString() {
StringBuilder sb = new StringBuilder();
sb.Append("<rdf:Alt>");
foreach (String s in this.Keys)
Process(sb, s);
sb.Append("</rdf:Alt>");
return sb.ToString();
}
}
}

View File

@@ -0,0 +1,92 @@
using System;
/*
* $Id: PdfA1Schema.cs,v 1.3 2008/05/13 11:26:16 psoares33 Exp $
*
*
* Copyright 2007 Paulo Soares.
*
* 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.xml.xmp {
/**
* An implementation of an XmpSchema.
*/
public class PdfA1Schema : XmpSchema {
/** default namespace identifier*/
public const String DEFAULT_XPATH_ID = "pdfaid";
/** default namespace uri*/
public const String DEFAULT_XPATH_URI = "http://www.aiim.org/pdfa/ns/id/";
/** Part, always 1. */
public const String PART = "pdfaid:part";
/** Conformance, A or B. */
public const String CONFORMANCE = "pdfaid:conformance";
/**
* @throws IOException
*/
public PdfA1Schema() : base("xmlns:" + DEFAULT_XPATH_ID + "=\"" + DEFAULT_XPATH_URI + "\"") {
AddPart("1");
}
/**
* Adds part.
* @param part
*/
public void AddPart(String part) {
this[PART] = part;
}
/**
* Adds the conformance.
* @param conformance
*/
public void AddConformance(String conformance) {
this[CONFORMANCE] = conformance;
}
}
}

View File

@@ -0,0 +1,104 @@
using System;
using iTextSharp.text;
/*
* $Id: PdfSchema.cs,v 1.3 2008/05/13 11:26:16 psoares33 Exp $
*
*
* 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.xml.xmp {
/**
* An implementation of an XmpSchema.
*/
public class PdfSchema : XmpSchema {
/** default namespace identifier*/
public const String DEFAULT_XPATH_ID = "pdf";
/** default namespace uri*/
public const String DEFAULT_XPATH_URI = "http://ns.adobe.com/pdf/1.3/";
/** Keywords. */
public const String KEYWORDS = "pdf:Keywords";
/** The PDF file version (for example: 1.0, 1.3, and so on). */
public const String VERSION = "pdf:PDFVersion";
/** The Producer. */
public const String PRODUCER = "pdf:Producer";
/**
* @throws IOException
*/
public PdfSchema() : base("xmlns:" + DEFAULT_XPATH_ID + "=\"" + DEFAULT_XPATH_URI + "\"") {
AddProducer(Document.Version);
}
/**
* Adds keywords.
* @param keywords
*/
public void AddKeywords(String keywords) {
this[KEYWORDS] = keywords;
}
/**
* Adds the producer.
* @param producer
*/
public void AddProducer(String producer) {
this[PRODUCER] = producer;
}
/**
* Adds the version.
* @param version
*/
public void AddVersion(String version) {
this[VERSION] = version;
}
}
}

View File

@@ -0,0 +1,98 @@
using System;
using System.Collections;
using System.Text;
/*
* $Id: XmpArray.cs,v 1.3 2008/05/13 11:26:16 psoares33 Exp $
*
*
* 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.xml.xmp {
/**
* StringBuilder to construct an XMP array.
*/
public class XmpArray : ArrayList {
/** An array that is unordered. */
public const String UNORDERED = "rdf:Bag";
/** An array that is ordered. */
public const String ORDERED = "rdf:Seq";
/** An array with alternatives. */
public const String ALTERNATIVE = "rdf:Alt";
/** the type of array. */
protected String type;
/**
* Creates an XmpArray.
* @param type the type of array: UNORDERED, ORDERED or ALTERNATIVE.
*/
public XmpArray(String type) {
this.type = type;
}
/**
* Returns the String representation of the XmpArray.
* @return a String representation
*/
public override String ToString() {
StringBuilder buf = new StringBuilder("<");
buf.Append(type);
buf.Append('>');
foreach (String s in this) {
buf.Append("<rdf:li>");
buf.Append(XmpSchema.Escape(s));
buf.Append("</rdf:li>");
}
buf.Append("</");
buf.Append(type);
buf.Append('>');
return buf.ToString();
}
}
}

View File

@@ -0,0 +1,139 @@
using System;
/*
* $Id: XmpBasicSchema.cs,v 1.4 2008/05/13 11:26:16 psoares33 Exp $
*
*
* 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.xml.xmp {
/**
* An implementation of an XmpSchema.
*/
public class XmpBasicSchema : XmpSchema {
/** default namespace identifier*/
public const String DEFAULT_XPATH_ID = "xmp";
/** default namespace uri*/
public const String DEFAULT_XPATH_URI = "http://ns.adobe.com/xap/1.0/";
/** An unordered array specifying properties that were edited outside the authoring application. Each item should contain a single namespace and XPath separated by one ASCII space (U+0020). */
public const String ADVISORY = "xmp:Advisory";
/** The base URL for relative URLs in the document content. If this document contains Internet links, and those links are relative, they are relative to this base URL. This property provides a standard way for embedded relative URLs to be interpreted by tools. Web authoring tools should set the value based on their notion of where URLs will be interpreted. */
public const String BASEURL = "xmp:BaseURL";
/** The date and time the resource was originally created. */
public const String CREATEDATE = "xmp:CreateDate";
/** The name of the first known tool used to create the resource. If history is present in the metadata, this value should be equivalent to that of xmpMM:History<72>s softwareAgent property. */
public const String CREATORTOOL = "xmp:CreatorTool";
/** An unordered array of text strings that unambiguously identify the resource within a given context. */
public const String IDENTIFIER = "xmp:Identifier";
/** The date and time that any metadata for this resource was last changed. */
public const String METADATADATE = "xmp:MetadataDate";
/** The date and time the resource was last modified. */
public const String MODIFYDATE = "xmp:ModifyDate";
/** A short informal name for the resource. */
public const String NICKNAME = "xmp:Nickname";
/** An alternative array of thumbnail images for a file, which can differ in characteristics such as size or image encoding. */
public const String THUMBNAILS = "xmp:Thumbnails";
/**
* @param shorthand
* @throws IOException
*/
public XmpBasicSchema() : base("xmlns:" + DEFAULT_XPATH_ID + "=\"" + DEFAULT_XPATH_URI + "\"") {
}
/**
* Adds the creatortool.
* @param creator
*/
public void AddCreatorTool(String creator) {
this[CREATORTOOL] = creator;
}
/**
* Adds the creation date.
* @param date
*/
public void AddCreateDate(String date) {
this[CREATEDATE] = date;
}
/**
* Adds the modification date.
* @param date
*/
public void AddModDate(String date) {
this[MODIFYDATE] = date;
}
/**
* Adds the meta data date.
* @param date
*/
public void AddMetaDataDate(String date) {
this[METADATADATE] = date;
}
/** Adds the identifier.
* @param id
*/
public void AddIdentifiers(String[] id) {
XmpArray array = new XmpArray(XmpArray.UNORDERED);
for (int i = 0; i < id.Length; i++) {
array.Add(id[i]);
}
SetProperty(IDENTIFIER, array);
}
/** Adds the nickname.
* @param name
*/
public void AddNickname(String name) {
this[NICKNAME] = name;
}
}
}

View File

@@ -0,0 +1,94 @@
using System;
/*
* $Id: XmpMMSchema.cs,v 1.3 2008/05/13 11:26:16 psoares33 Exp $
*
*
* 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.xml.xmp {
/**
* An implementation of an XmpSchema.
*/
public class XmpMMSchema : XmpSchema {
/** default namespace identifier*/
public const String DEFAULT_XPATH_ID = "xmpMM";
/** default namespace uri*/
public const String DEFAULT_XPATH_URI = "http://ns.adobe.com/xap/1.0/mm/";
/** A reference to the original document from which this one is derived. It is a minimal reference; missing components can be assumed to be unchanged. For example, a new version might only need to specify the instance ID and version number of the previous version, or a rendition might only need to specify the instance ID and rendition class of the original. */
public const String DERIVEDFROM = "xmpMM:DerivedFrom";
/** The common identifier for all versions and renditions of a document. */
public const String DOCUMENTID = "xmpMM:DocumentID";
/** An ordered array of high-level user actions that resulted in this resource. It is intended to give human readers a general indication of the steps taken to make the changes from the previous version to this one. The list should be at an abstract level; it is not intended to be an exhaustive keystroke or other detailed history. */
public const String HISTORY = "xmpMM:History";
/** A reference to the document as it was prior to becoming managed. It is set when a managed document is introduced to an asset management system that does not currently own it. It may or may not include references to different management systems. */
public const String MANAGEDFROM = "xmpMM:ManagedFrom";
/** The name of the asset management system that manages this resource. */
public const String MANAGER = "xmpMM:Manager";
/** A URI identifying the managed resource to the asset management system; the presence of this property is the formal indication that this resource is managed. The form and content of this URI is private to the asset management system. */
public const String MANAGETO = "xmpMM:ManageTo";
/** A URI that can be used to access information about the managed resource through a web browser. It might require a custom browser plugin. */
public const String MANAGEUI = "xmpMM:ManageUI";
/** Specifies a particular variant of the asset management system. The format of this property is private to the specific asset management system. */
public const String MANAGERVARIANT = "xmpMM:ManagerVariant";
/** The rendition class name for this resource.*/
public const String RENDITIONCLASS = "xmpMM:RenditionClass";
/** Can be used to provide additional rendition parameters that are too complex or verbose to encode in xmpMM: RenditionClass. */
public const String RENDITIONPARAMS = "xmpMM:RenditionParams";
/** The document version identifier for this resource. */
public const String VERSIONID = "xmpMM:VersionID";
/** The version history associated with this resource.*/
public const String VERSIONS = "xmpMM:Versions";
/**
* @throws IOException
*/
public XmpMMSchema() : base("xmlns:" + DEFAULT_XPATH_ID + "=\"" + DEFAULT_XPATH_URI + "\"") {
}
}
}

View File

@@ -0,0 +1,165 @@
using System;
using System.Text;
using System.util;
/*
* $Id: XmpSchema.cs,v 1.5 2008/05/13 11:26:16 psoares33 Exp $
*
*
* 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.xml.xmp {
/**
* Abstract superclass of the XmpSchemas supported by iText.
*/
public abstract class XmpSchema : Properties {
/** the namesspace */
protected String xmlns;
/** Constructs an XMP schema.
* @param xmlns
*/
public XmpSchema(String xmlns) : base() {
this.xmlns = xmlns;
}
/**
* The String representation of the contents.
* @return a String representation.
*/
public override String ToString() {
StringBuilder buf = new StringBuilder();
foreach (object key in Keys) {
Process(buf, key);
}
return buf.ToString();
}
/**
* Processes a property
* @param buf
* @param p
*/
protected void Process(StringBuilder buf, Object p) {
buf.Append('<');
buf.Append(p);
buf.Append('>');
buf.Append(this[p.ToString()]);
buf.Append("</");
buf.Append(p);
buf.Append('>');
}
/**
* @return Returns the xmlns.
*/
public String Xmlns {
get {
return xmlns;
}
}
/**
* @param key
* @param value
* @return the previous property (null if there wasn't one)
*/
public void AddProperty(String key, String value) {
this[key] = value;
}
public override string this[string key] {
set {
base[key] = Escape(value);
}
}
public void SetProperty(string key, XmpArray value) {
base[key] = value.ToString();
}
/**
* @see java.util.Properties#setProperty(java.lang.String, java.lang.String)
*
* @param key
* @param value
* @return the previous property (null if there wasn't one)
*/
public void SetProperty(String key, LangAlt value) {
base[key] = value.ToString();
}
/**
* @param content
* @return
*/
public static String Escape(String content) {
StringBuilder buf = new StringBuilder();
for (int i = 0; i < content.Length; i++) {
switch (content[i]) {
case '<':
buf.Append("&lt;");
break;
case '>':
buf.Append("&gt;");
break;
case '\'':
buf.Append("&apos;");
break;
case '\"':
buf.Append("&quot;");
break;
case '&':
buf.Append("&amp;");
break;
default:
buf.Append(content[i]);
break;
}
}
return buf.ToString();
}
}
}

View File

@@ -0,0 +1,276 @@
using System;
using System.IO;
using System.Collections;
using iTextSharp.text.pdf;
using iTextSharp.text.xml.simpleparser;
/*
* $Id: XmpWriter.cs,v 1.10 2008/05/13 11:26:16 psoares33 Exp $
*
*
* 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.xml.xmp {
/**
* With this class you can create an Xmp Stream that can be used for adding
* Metadata to a PDF Dictionary. Remark that this class doesn't cover the
* complete XMP specification.
*/
public class XmpWriter {
/** A possible charset for the XMP. */
public const String UTF8 = "UTF-8";
/** A possible charset for the XMP. */
public const String UTF16 = "UTF-16";
/** A possible charset for the XMP. */
public const String UTF16BE = "UTF-16BE";
/** A possible charset for the XMP. */
public const String UTF16LE = "UTF-16LE";
/** String used to fill the extra space. */
public const String EXTRASPACE = " \n";
/** You can add some extra space in the XMP packet; 1 unit in this variable represents 100 spaces and a newline. */
protected int extraSpace;
/** The writer to which you can write bytes for the XMP stream. */
protected StreamWriter writer;
/** The about string that goes into the rdf:Description tags. */
protected String about;
/** The end attribute. */
protected char end = 'w';
/**
* Creates an XmpWriter.
* @param os
* @param utfEncoding
* @param extraSpace
* @throws IOException
*/
public XmpWriter(Stream os, string utfEncoding, int extraSpace) {
this.extraSpace = extraSpace;
writer = new StreamWriter(os, new EncodingNoPreamble(IanaEncodings.GetEncodingEncoding(utfEncoding)));
writer.Write("<?xpacket begin=\"\uFEFF\" id=\"W5M0MpCehiHzreSzNTczkc9d\"?>\n");
writer.Write("<x:xmpmeta xmlns:x=\"adobe:ns:meta/\">\n");
writer.Write("<rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n");
about = "";
}
/**
* Creates an XmpWriter.
* @param os
* @throws IOException
*/
public XmpWriter(Stream os) : this(os, UTF8, 20) {
}
/** Sets the XMP to read-only */
public void SetReadOnly() {
end = 'r';
}
/**
* @param about The about to set.
*/
public String About {
set {
this.about = value;
}
}
/**
* Adds an rdf:Description.
* @param xmlns
* @param content
* @throws IOException
*/
public void AddRdfDescription(String xmlns, String content) {
writer.Write("<rdf:Description rdf:about=\"");
writer.Write(about);
writer.Write("\" ");
writer.Write(xmlns);
writer.Write(">");
writer.Write(content);
writer.Write("</rdf:Description>\n");
}
/**
* Adds an rdf:Description.
* @param s
* @throws IOException
*/
public void AddRdfDescription(XmpSchema s) {
writer.Write("<rdf:Description rdf:about=\"");
writer.Write(about);
writer.Write("\" ");
writer.Write(s.Xmlns);
writer.Write(">");
writer.Write(s.ToString());
writer.Write("</rdf:Description>\n");
}
/**
* Flushes and closes the XmpWriter.
* @throws IOException
*/
public void Close() {
writer.Write("</rdf:RDF>");
writer.Write("</x:xmpmeta>\n");
for (int i = 0; i < extraSpace; i++) {
writer.Write(EXTRASPACE);
}
writer.Write("<?xpacket end=\"" + end + "\"?>");
writer.Flush();
writer.Close();
}
/**
* @param os
* @param info
* @throws IOException
*/
public XmpWriter(Stream os, PdfDictionary info, int PdfXConformance) : this(os) {
if (info != null) {
DublinCoreSchema dc = new DublinCoreSchema();
PdfSchema p = new PdfSchema();
XmpBasicSchema basic = new XmpBasicSchema();
PdfObject obj;
foreach (PdfName key in info.Keys) {
obj = info.Get(key);
if (obj == null)
continue;
if (PdfName.TITLE.Equals(key)) {
dc.AddTitle(((PdfString)obj).ToUnicodeString());
}
if (PdfName.AUTHOR.Equals(key)) {
dc.AddAuthor(((PdfString)obj).ToUnicodeString());
}
if (PdfName.SUBJECT.Equals(key)) {
dc.AddSubject(((PdfString)obj).ToUnicodeString());
dc.AddDescription(((PdfString)obj).ToUnicodeString());
}
if (PdfName.KEYWORDS.Equals(key)) {
p.AddKeywords(((PdfString)obj).ToUnicodeString());
}
if (PdfName.CREATOR.Equals(key)) {
basic.AddCreatorTool(((PdfString)obj).ToUnicodeString());
}
if (PdfName.PRODUCER.Equals(key)) {
p.AddProducer(((PdfString)obj).ToUnicodeString());
}
if (PdfName.CREATIONDATE.Equals(key)) {
basic.AddCreateDate(((PdfDate)obj).GetW3CDate());
}
if (PdfName.MODDATE.Equals(key)) {
basic.AddModDate(((PdfDate)obj).GetW3CDate());
}
}
if (dc.Count > 0) AddRdfDescription(dc);
if (p.Count > 0) AddRdfDescription(p);
if (basic.Count > 0) AddRdfDescription(basic);
if (PdfXConformance == PdfWriter.PDFA1A || PdfXConformance == PdfWriter.PDFA1B) {
PdfA1Schema a1 = new PdfA1Schema();
if (PdfXConformance == PdfWriter.PDFA1A)
a1.AddConformance("A");
else
a1.AddConformance("B");
AddRdfDescription(a1);
}
}
}
/**
* @param os
* @param info
* @throws IOException
*/
public XmpWriter(Stream os, Hashtable info) : this(os) {
if (info != null) {
DublinCoreSchema dc = new DublinCoreSchema();
PdfSchema p = new PdfSchema();
XmpBasicSchema basic = new XmpBasicSchema();
String value;
foreach (DictionaryEntry entry in info) {
String key = (String)entry.Key;
value = (String)entry.Value;
if (value == null)
continue;
if ("Title".Equals(key)) {
dc.AddTitle(value);
}
if ("Author".Equals(key)) {
dc.AddAuthor(value);
}
if ("Subject".Equals(key)) {
dc.AddSubject(value);
dc.AddDescription(value);
}
if ("Keywords".Equals(key)) {
p.AddKeywords(value);
}
if ("Creator".Equals(key)) {
basic.AddCreatorTool(value);
}
if ("Producer".Equals(key)) {
p.AddProducer(value);
}
if ("CreationDate".Equals(key)) {
basic.AddCreateDate(PdfDate.GetW3CDate(value));
}
if ("ModDate".Equals(key)) {
basic.AddModDate(PdfDate.GetW3CDate(value));
}
}
if (dc.Count > 0) AddRdfDescription(dc);
if (p.Count > 0) AddRdfDescription(p);
if (basic.Count > 0) AddRdfDescription(basic);
}
}
}
}