This is an Element that contains some meta information about the document.
An object of type Meta can not be constructed by the user. Userdefined meta information should be placed in a Header-object. Meta is reserved for: Subject, Keywords, Author, Title, Producer and Creationdate information.
Inheritance: IElement
Ejemplo n.º 1
0
 /**
 * 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;
 }
Ejemplo n.º 2
0
 /**
  * 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();
 }
Ejemplo n.º 3
0
 /// <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);
 }
Ejemplo n.º 4
0
 /* (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;
 }
Ejemplo n.º 5
0
 /**
 * 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);
     }
 }