/** * Constructs a RtfInfoElement based on the given Meta object * * @param doc The RtfDocument this RtfInfoElement belongs to * @param meta The Meta object this RtfInfoElement is based on */ public RtfInfoElement(RtfDocument doc, Meta meta) : base(doc) { infoType = meta.Type; content = meta.Content; }
/** * Writes a Metatag in the header. * * @param meta the element that has to be written * @throws IOException */ protected void WriteHeader(Meta meta) { AddTabs(2); WriteStart(HtmlTags.META); switch (meta.Type) { case Element.HEADER: Write(HtmlTags.NAME, ((Header) meta).Name); break; case Element.SUBJECT: Write(HtmlTags.NAME, HtmlTags.SUBJECT); break; case Element.KEYWORDS: Write(HtmlTags.NAME, HtmlTags.KEYWORDS); break; case Element.AUTHOR: Write(HtmlTags.NAME, HtmlTags.AUTHOR); break; } Write(HtmlTags.CONTENT, HtmlEncoder.Encode(meta.Content)); WriteEnd(); }
/// <summary> /// Constructs a Meta. /// </summary> /// <param name="tag">the tagname of the meta-information</param> /// <param name="content">the content</param> public Meta(string tag, string content) { this.type = Meta.GetType(tag); this.content = new StringBuilder(content); }
/* (non-Javadoc) * @see com.lowagie.text.rtf.direct.RtfDestination#handleGroupEnd() */ public override bool HandleCloseGroup() { if (this.text.Length > 0) { Document doc = this.rtfParser.GetDocument(); if (doc != null) { if (this.elementName.Equals("author")){ doc.AddAuthor(this.text); } if (this.elementName.Equals("title")){ doc.AddTitle(this.text); } if (this.elementName.Equals("subject")){ doc.AddSubject(this.text); } } else { RtfDocument rtfDoc = this.rtfParser.GetRtfDocument(); if (rtfDoc != null) { if (this.elementName.Equals("author")){ Meta meta = new Meta(this.elementName, this.text); RtfInfoElement elem = new RtfInfoElement(rtfDoc, meta); rtfDoc.GetDocumentHeader().AddInfoElement(elem); } if (this.elementName.Equals("title")){ Meta meta = new Meta(this.elementName, this.text); RtfInfoElement elem = new RtfInfoElement(rtfDoc, meta); rtfDoc.GetDocumentHeader().AddInfoElement(elem); } if (this.elementName.Equals("subject")){ Meta meta = new Meta(this.elementName, this.text); RtfInfoElement elem = new RtfInfoElement(rtfDoc, meta); rtfDoc.GetDocumentHeader().AddInfoElement(elem); } } } this.SetToDefaults(); } return true; }
/** * Add a <code>Meta</code> element. It is written to the Inforamtion Group * and merged with the main <code>MemoryStream</code> when the * Document is closed. * * @param metaName The type of <code>Meta</code> element to be added * @param meta The <code>Meta</code> element to be added * * Currently only the Meta Elements Author, Subject, Keywords, Title, Producer and CreationDate are supported. * * @throws IOException */ private void WriteMeta(byte[] metaName, Meta meta) { info.WriteByte(openGroup); try { info.WriteByte(escape); info.Write(metaName, 0, metaName.Length); info.WriteByte(delimiter); if (meta.Type == Element.CREATIONDATE) { WriteFormatedDateTime(meta.Content); } else { byte[] t = DocWriter.GetISOBytes(meta.Content); info.Write(t, 0, t.Length); } } finally { info.WriteByte(closeGroup); } }