com.lowagie.text.Meta Java Examples

The following examples show how to use com.lowagie.text.Meta. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HtmlWriter.java    From gcs with Mozilla Public License 2.0 6 votes vote down vote up
/**
 * Writes a Metatag in the header.
 *
 * @param meta the element that has to be written
 * @throws IOException
 */

protected void writeHeader(Meta meta) throws IOException {
	addTabs(2);
	writeStart(HtmlTags.META);
	switch (meta.type()) {
		case Element.HEADER:
			write(HtmlTags.NAME, ((Header) meta).getName());
			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.getContent()));
	writeEnd();
}
 
Example #2
Source File: HtmlWriter.java    From itext2 with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
* Writes a Metatag in the header.
*
* @param   meta   the element that has to be written
* @throws  IOException
*/
   
   protected void writeHeader(Meta meta) throws IOException {
       addTabs(2);
       writeStart(HtmlTags.META);
       switch(meta.type()) {
           case Element.HEADER:
               write(HtmlTags.NAME, ((Header) meta).getName());
               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.getContent()));
       writeEnd();
   }
 
Example #3
Source File: RtfInfoElement.java    From itext2 with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Writes the content of one RTF information element.
 */    
public void writeContent(final OutputStream result) throws IOException
{
    result.write(OPEN_GROUP);
    switch(infoType) {
        case Meta.AUTHOR:
            result.write(INFO_AUTHOR);
        	break;
        case Meta.SUBJECT:
            result.write(INFO_SUBJECT);
    		break;
        case Meta.KEYWORDS:
            result.write(INFO_KEYWORDS);
    		break;
        case Meta.TITLE:
            result.write(INFO_TITLE);
    		break;
        case Meta.PRODUCER:
            result.write(INFO_PRODUCER);
    		break;
        case Meta.CREATIONDATE:
            result.write(INFO_CREATION_DATE);
        	break;
        default:
            result.write(INFO_AUTHOR);
        	break;
    }
    result.write(DELIMITER);
    if(infoType == Meta.CREATIONDATE) {
        result.write(DocWriter.getISOBytes(convertDate(content)));
    } else {
        document.filterSpecialChar(result, content, false, false);
    }
    result.write(CLOSE_GROUP);
}
 
Example #4
Source File: PatchRtfDocument.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
public RtfBasicElement[] mapElement( Element element ) throws DocumentException {
  ArrayList<RtfBasicElement> rtfElements = new ArrayList<RtfBasicElement>();
  if ( element instanceof RtfBasicElement ) {
    RtfBasicElement rtfElement = (RtfBasicElement) element;
    rtfElement.setRtfDocument( rtfDoc );
    return new RtfBasicElement[] { rtfElement };
  }
  switch ( element.type() ) {
    case Element.CHUNK:
      Chunk chunk = (Chunk) element;
      if ( chunk.hasAttributes() ) {
        if ( chunk.getAttributes().containsKey( Chunk.IMAGE ) ) {
          rtfElements.add( new RtfImage( rtfDoc, chunk.getImage() ) );
        } else if ( chunk.getAttributes().containsKey( Chunk.NEWPAGE ) ) {
          rtfElements.add( new RtfNewPage( rtfDoc ) );
        } else if ( chunk.getAttributes().containsKey( Chunk.TAB ) ) {
          Float tabPos = (Float) ( (Object[]) chunk.getAttributes().get( Chunk.TAB ) )[1];
          RtfTab tab = new RtfTab( tabPos.floatValue(), RtfTab.TAB_LEFT_ALIGN );
          tab.setRtfDocument( rtfDoc );
          rtfElements.add( tab );
          rtfElements.add( new RtfChunk( rtfDoc, new Chunk( "\t" ) ) );
        } else {
          rtfElements.add( new RtfChunk( rtfDoc, (Chunk) element ) );
        }
      } else {
        rtfElements.add( new RtfChunk( rtfDoc, (Chunk) element ) );
      }
      break;
    case Element.PHRASE:
      rtfElements.add( new RtfPhrase( rtfDoc, (Phrase) element ) );
      break;
    case Element.PARAGRAPH:
      rtfElements.add( new RtfParagraph( rtfDoc, (Paragraph) element ) );
      break;
    case Element.ANCHOR:
      rtfElements.add( new RtfAnchor( rtfDoc, (Anchor) element ) );
      break;
    case Element.ANNOTATION:
      rtfElements.add( new RtfAnnotation( rtfDoc, (Annotation) element ) );
      break;
    case Element.IMGRAW:
    case Element.IMGTEMPLATE:
    case Element.JPEG:
      rtfElements.add( new RtfImage( rtfDoc, (Image) element ) );
      break;
    case Element.AUTHOR:
    case Element.SUBJECT:
    case Element.KEYWORDS:
    case Element.TITLE:
    case Element.PRODUCER:
    case Element.CREATIONDATE:
      rtfElements.add( new RtfInfoElement( rtfDoc, (Meta) element ) );
      break;
    case Element.LIST:
      rtfElements.add( new RtfList( rtfDoc, (List) element ) ); // TODO: Testing
      break;
    case Element.LISTITEM:
      rtfElements.add( new RtfListItem( rtfDoc, (ListItem) element ) ); // TODO: Testing
      break;
    case Element.SECTION:
      rtfElements.add( new RtfSection( rtfDoc, (Section) element ) );
      break;
    case Element.CHAPTER:
      rtfElements.add( new RtfChapter( rtfDoc, (Chapter) element ) );
      break;
    case Element.TABLE:
      if ( element instanceof Table ) {
        rtfElements.add( new PatchRtfTable( rtfDoc, (Table) element ) );
      } else {
        rtfElements.add( new PatchRtfTable( rtfDoc, ( (SimpleTable) element ).createTable() ) );
      }
      break;
    case Element.PTABLE:
      if ( element instanceof PdfPTable ) {
        rtfElements.add( new PatchRtfTable( rtfDoc, (PdfPTable) element ) );
      } else {
        rtfElements.add( new PatchRtfTable( rtfDoc, ( (SimpleTable) element ).createTable() ) );
      }
      break;
  }

  return rtfElements.toArray( new RtfBasicElement[rtfElements.size()] );
}
 
Example #5
Source File: RtfInfoElement.java    From itext2 with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * 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) {
    super(doc);
    infoType = meta.type();
    content = meta.getContent();
}