virtual public void AddDocInfoProperty(Object key, String value) { if (key is String) { key = new PdfName((String)key); } if (PdfName.TITLE.Equals(key)) { xmpMeta.SetLocalizedText(XmpConst.NS_DC, DublinCoreProperties.TITLE, XmpConst.X_DEFAULT, XmpConst.X_DEFAULT, value); } else if (PdfName.AUTHOR.Equals(key)) { xmpMeta.AppendArrayItem(XmpConst.NS_DC, DublinCoreProperties.CREATOR, new PropertyOptions(PropertyOptions.ARRAY_ORDERED), value, null); } else if (PdfName.SUBJECT.Equals(key)) { xmpMeta.SetLocalizedText(XmpConst.NS_DC, DublinCoreProperties.DESCRIPTION, XmpConst.X_DEFAULT, XmpConst.X_DEFAULT, value); } else if (PdfName.KEYWORDS.Equals(key)) { foreach (String v in value.Split(',', ';')) { if (v.Trim().Length > 0) { xmpMeta.AppendArrayItem(XmpConst.NS_DC, DublinCoreProperties.SUBJECT, new PropertyOptions(PropertyOptions.ARRAY), v.Trim(), null); } } xmpMeta.SetProperty(XmpConst.NS_PDF, PdfProperties.KEYWORDS, value); } else if (PdfName.PRODUCER.Equals(key)) { xmpMeta.SetProperty(XmpConst.NS_PDF, PdfProperties.PRODUCER, value); } else if (PdfName.CREATOR.Equals(key)) { xmpMeta.SetProperty(XmpConst.NS_XMP, XmpBasicProperties.CREATORTOOL, value); } else if (PdfName.CREATIONDATE.Equals(key)) { xmpMeta.SetProperty(XmpConst.NS_XMP, XmpBasicProperties.CREATEDATE, PdfDate.GetW3CDate(value)); } else if (PdfName.MODDATE.Equals(key)) { xmpMeta.SetProperty(XmpConst.NS_XMP, XmpBasicProperties.MODIFYDATE, PdfDate.GetW3CDate(value)); } }
/** * @param os * @param info * @throws IOException */ public XmpWriter(Stream os, IDictionary <string, string> info) : this(os) { if (info != null) { DublinCoreSchema dc = new DublinCoreSchema(); PdfSchema p = new PdfSchema(); XmpBasicSchema basic = new XmpBasicSchema(); String value; foreach (KeyValuePair <string, string> entry in info) { String key = entry.Key; value = 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); } } }
/** * @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; String value; foreach (PdfName key in info.Keys) { obj = info.Get(key); if (obj == null) { continue; } value = ((PdfString)obj).ToUnicodeString(); if (PdfName.TITLE.Equals(key)) { dc.AddTitle(value); } if (PdfName.AUTHOR.Equals(key)) { dc.AddAuthor(value); } if (PdfName.SUBJECT.Equals(key)) { dc.AddSubject(value); dc.AddDescription(value); } if (PdfName.KEYWORDS.Equals(key)) { p.AddKeywords(value); } if (PdfName.CREATOR.Equals(key)) { basic.AddCreatorTool(value); } if (PdfName.PRODUCER.Equals(key)) { p.AddProducer(value); } if (PdfName.CREATIONDATE.Equals(key)) { basic.AddCreateDate(PdfDate.GetW3CDate(obj.ToString())); } if (PdfName.MODDATE.Equals(key)) { basic.AddModDate(PdfDate.GetW3CDate(obj.ToString())); } } 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 (String key in info.Keys) { value = (String)info[key]; 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); } 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); } } }
/// <summary> /// @throws IOException /// </summary> /// <param name="os"></param> /// <param name="info"></param> public XmpWriter(Stream os, Hashtable info) : this(os) { if (info != null) { var dc = new DublinCoreSchema(); var p = new PdfSchema(); var basic = new XmpBasicSchema(); string value; foreach (DictionaryEntry entry in info) { var 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); } } }