Example usage for com.lowagie.text ElementTags ALIGN_CENTER

List of usage examples for com.lowagie.text ElementTags ALIGN_CENTER

Introduction

In this page you can find the example usage for com.lowagie.text ElementTags ALIGN_CENTER.

Prototype

String ALIGN_CENTER

To view the source code for com.lowagie.text ElementTags ALIGN_CENTER.

Click Source Link

Document

the possible value of an alignment attribute

Usage

From source file:com.pureinfo.srm.patent.action.PatentPrintPdfAction.java

License:Open Source License

/**
 * @see com.pureinfo.ark.interaction.ActionBase#executeAction()
 *//*w w  w . j a v a  2s.c o m*/
public ActionForward executeAction() throws PureException {
    int nYear = request.getRequiredInt("year", "");

    Rectangle rectPageSize = new Rectangle(PageSize.A4);
    rectPageSize.setBackgroundColor(Color.WHITE);
    rectPageSize.setBorderColor(Color.BLACK);
    rectPageSize = rectPageSize.rotate();
    Document doc = new Document(rectPageSize, 10, 10, 10, 10);
    doc.addTitle(nYear + "");
    doc.addAuthor("PureInfo");
    try {
        BaseFont bfontTitle = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
        Font fontTitle = new Font(bfontTitle, 18, Font.NORMAL);
        Paragraph paraTitle = new Paragraph(nYear + "",
                fontTitle);
        paraTitle.setAlignment(ElementTags.ALIGN_CENTER);

        BaseFont bfontContent = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
        Font fontContent = new Font(bfontContent, 10, Font.NORMAL);

        FileFactory fileFactory = FileFactory.getInstance();
        String sPath = fileFactory.lookupPathConfigByFlag(FileFactory.FLAG_DOWNLOADTEMP, true).getLocalPath();

        FileUtil.insurePathExists(sPath);
        PdfWriter.getInstance(doc, new FileOutputStream(new File(sPath, "patent.pdf")));

        doc.open();
        doc.add(paraTitle);
        doc.add(new Paragraph("   "));

        String[] arrTitles = new String[] { "", "", "", "", "", "",
                "", "", "" };
        PdfPTable pTable = new PdfPTable(arrTitles.length);
        pTable.setWidths(new int[] { 5, 10, 9, 9, 20, 15, 12, 10, 10 });

        for (int i = 0; i < arrTitles.length; i++) {
            PdfPCell pCell = new PdfPCell();
            Paragraph para = new Paragraph(arrTitles[i], fontContent);
            para.setAlignment(ElementTags.ALIGN_CENTER);

            pCell.addElement(para);
            pTable.addCell(pCell);
        }

        /**
         * 
         */
        IPatentMgr mgr = (IPatentMgr) ArkContentHelper.getContentMgrOf(Patent.class);
        List patents = mgr.findAllAuthorizedOf(nYear);
        int i = 0;
        for (Iterator iter = patents.iterator(); iter.hasNext(); i++) {
            Patent patent = (Patent) iter.next();
            this.addPatentCell(pTable, String.valueOf(i + 1), fontContent);
            this.addPatentCell(pTable, patent.getPatentSid(), fontContent);
            this.addPatentCell(pTable, ForceConstants.DATE_FORMAT.format(patent.getApplyDate()), fontContent);
            this.addPatentCell(pTable, patent.getWarrantDate() == null ? ""
                    : ForceConstants.DATE_FORMAT.format(patent.getWarrantDate()), fontContent);
            this.addPatentCell(pTable, patent.getName(), fontContent);
            this.addPatentCell(pTable, patent.getAllAuthosName(), fontContent);
            this.addPatentCell(pTable, patent.getRightPerson(), fontContent);
            this.addPatentCell(pTable, getCollegeName(patent), fontContent);
            this.addPatentCell(pTable, patent.getPatentTypeName(), fontContent);
        }

        doc.add(pTable);
        doc.close();

    } catch (DocumentException ex) {
        // TODO Auto-generated catch block
        ex.printStackTrace(System.err);
    } catch (IOException ex) {
        // TODO Auto-generated catch block
        ex.printStackTrace(System.err);
    }

    List list = new ArrayList();
    list.add(new Pair("/download/patent.pdf", ""));
    request.setAttribute("forward", list);
    return mapping.findForward("success");
}

From source file:org.apache.maven.doxia.module.itext.ITextSink.java

License:Apache License

/** {@inheritDoc} */
public void body() {
    if (writeStart) {
        writeStartElement(ElementTags.ITEXT);
        writeAddAttribute(ElementTags.TITLE, header.getTitle());
        writeAddAttribute(ElementTags.AUTHOR, header.getAuthors());
        writeAddAttribute(ElementTags.CREATIONDATE, header.getDate());
        writeAddAttribute(ElementTags.SUBJECT, header.getTitle());
        writeAddAttribute(ElementTags.KEYWORDS, "");
        writeAddAttribute(ElementTags.PRODUCER, "Generated with Doxia by " + System.getProperty("user.name"));
        writeAddAttribute(ElementTags.PAGE_SIZE, ITextUtil.getPageSize(ITextUtil.getDefaultPageSize()));

        writeStartElement(ElementTags.CHAPTER);
        writeAddAttribute(ElementTags.NUMBERDEPTH, numberDepth);
        writeAddAttribute(ElementTags.DEPTH, depth);
        writeAddAttribute(ElementTags.INDENT, "0.0");

        writeStartElement(ElementTags.TITLE);
        writeAddAttribute(ElementTags.LEADING, DEFAULT_CHAPTER_TITLE_LEADING);
        writeAddAttribute(ElementTags.FONT, ITextFont.DEFAULT_FONT_NAME);
        writeAddAttribute(ElementTags.SIZE, ITextFont.getSectionFontSize(0));
        writeAddAttribute(ElementTags.STYLE, ITextFont.BOLD);
        writeAddAttribute(ElementTags.BLUE, ITextFont.DEFAULT_FONT_COLOR_BLUE);
        writeAddAttribute(ElementTags.GREEN, ITextFont.DEFAULT_FONT_COLOR_GREEN);
        writeAddAttribute(ElementTags.RED, ITextFont.DEFAULT_FONT_COLOR_RED);
        writeAddAttribute(ElementTags.ALIGN, ElementTags.ALIGN_CENTER);

        //            startChunk( ITextFont.DEFAULT_FONT_NAME, ITextFont.getSectionFontSize( 0 ),
        //                    ITextFont.BOLD, ITextFont.DEFAULT_FONT_COLOR_BLUE, ITextFont.DEFAULT_FONT_COLOR_GREEN,
        //                    ITextFont.DEFAULT_FONT_COLOR_RED, "top" );

        writeStartElement(ElementTags.CHUNK);
        writeAddAttribute(ElementTags.FONT, ITextFont.DEFAULT_FONT_NAME);
        writeAddAttribute(ElementTags.SIZE, ITextFont.getSectionFontSize(0));
        writeAddAttribute(ElementTags.STYLE, ITextFont.BOLD);
        writeAddAttribute(ElementTags.BLUE, ITextFont.DEFAULT_FONT_COLOR_BLUE);
        writeAddAttribute(ElementTags.GREEN, ITextFont.DEFAULT_FONT_COLOR_GREEN);
        writeAddAttribute(ElementTags.RED, ITextFont.DEFAULT_FONT_COLOR_RED);
        //            writeAddAttribute( ElementTags.LOCALDESTINATION, "top" );

        write(header.getTitle());//from w w  w.ja va2 s.  co m

        writeEndElement(); // ElementTags.CHUNK

        writeEndElement(); // ElementTags.TITLE
    }

    actionContext.setAction(SinkActionContext.BODY);
}

From source file:org.apache.maven.doxia.module.itext.ITextSink.java

License:Apache License

/** {@inheritDoc} */
public void table_() {
    if (tableCaptionXMLWriter != null) {
        tableCaptionXMLWriter = null;//w  w w  .j a  v  a 2  s .com

        writeEndElement(); // ElementTags.TABLE

        writeEndElement(); // ElementTags.CHUNK

        writeStartElement(ElementTags.PARAGRAPH);
        writeAddAttribute(ElementTags.ALIGN, ElementTags.ALIGN_CENTER);

        write(tableCaptionWriter.toString(), true);

        writeEndElement(); // ElementTags.PARAGRAPH

        tableCaptionWriter = null;
    } else {
        writeEndElement(); // ElementTags.TABLE

        writeEndElement(); // ElementTags.CHUNK
    }
    actionContext.release();
}

From source file:org.apache.maven.doxia.module.itext.ITextSink.java

License:Apache License

/** {@inheritDoc} */
public void table() {
    writeStartElement(ElementTags.CHUNK);
    writeAddAttribute(ElementTags.FONT, font.getFontName());
    writeAddAttribute(ElementTags.SIZE, font.getFontSize());
    writeAddAttribute(ElementTags.STYLE, font.getFontStyle());
    writeAddAttribute(ElementTags.BLUE, font.getFontColorBlue());
    writeAddAttribute(ElementTags.GREEN, font.getFontColorGreen());
    writeAddAttribute(ElementTags.RED, font.getFontColorRed());

    writeStartElement(ElementTags.TABLE);
    writeAddAttribute(ElementTags.LEFT, Boolean.TRUE.toString());
    writeAddAttribute(ElementTags.RIGHT, Boolean.TRUE.toString());
    writeAddAttribute(ElementTags.TOP, Boolean.TRUE.toString());
    writeAddAttribute(ElementTags.BOTTOM, Boolean.TRUE.toString());
    writeAddAttribute(ElementTags.ALIGN, ElementTags.ALIGN_CENTER);
    writeAddAttribute(ElementTags.WIDTH, "100.0%");
    writeAddAttribute(ElementTags.TABLEFITSPAGE, Boolean.TRUE.toString());
    writeAddAttribute(ElementTags.CELLSFITPAGE, Boolean.TRUE.toString());
    writeAddAttribute(ElementTags.CELLPADDING, "10");
    //writeAddAttribute( ElementTags.COLUMNS, "2" );

    actionContext.setAction(SinkActionContext.TABLE);
}

From source file:org.apache.maven.doxia.module.itext.ITextSink.java

License:Apache License

/** {@inheritDoc} */
public void tableHeaderCell() {
    writeStartElement(ElementTags.CELL);
    writeAddAttribute(ElementTags.LEFT, Boolean.TRUE.toString());
    writeAddAttribute(ElementTags.RIGHT, Boolean.TRUE.toString());
    writeAddAttribute(ElementTags.TOP, Boolean.TRUE.toString());
    writeAddAttribute(ElementTags.BOTTOM, Boolean.TRUE.toString());
    writeAddAttribute(ElementTags.HEADER, Boolean.TRUE.toString());
    writeAddAttribute(ElementTags.BGRED, Color.GRAY.getRed());
    writeAddAttribute(ElementTags.BGBLUE, Color.GRAY.getBlue());
    writeAddAttribute(ElementTags.BGGREEN, Color.GRAY.getGreen());
    writeAddAttribute(ElementTags.HORIZONTALALIGN, ElementTags.ALIGN_CENTER);

    actionContext.setAction(SinkActionContext.TABLE_HEADER_CELL);
}

From source file:org.apache.maven.doxia.module.itext.ITextSink.java

License:Apache License

/** {@inheritDoc} */
public void verbatim(boolean boxed) {
    // Always boxed
    writeStartElement(ElementTags.CHUNK);
    writeAddAttribute(ElementTags.FONT, font.getFontName());
    writeAddAttribute(ElementTags.SIZE, font.getFontSize());
    writeAddAttribute(ElementTags.STYLE, font.getFontStyle());
    writeAddAttribute(ElementTags.BLUE, font.getFontColorBlue());
    writeAddAttribute(ElementTags.GREEN, font.getFontColorGreen());
    writeAddAttribute(ElementTags.RED, font.getFontColorRed());

    writeStartElement(ElementTags.TABLE);
    writeAddAttribute(ElementTags.COLUMNS, "1");
    writeAddAttribute(ElementTags.LEFT, Boolean.TRUE.toString());
    writeAddAttribute(ElementTags.RIGHT, Boolean.TRUE.toString());
    writeAddAttribute(ElementTags.TOP, Boolean.TRUE.toString());
    writeAddAttribute(ElementTags.BOTTOM, Boolean.TRUE.toString());
    writeAddAttribute(ElementTags.ALIGN, ElementTags.ALIGN_CENTER);
    writeAddAttribute(ElementTags.TABLEFITSPAGE, Boolean.TRUE.toString());
    writeAddAttribute(ElementTags.CELLSFITPAGE, Boolean.TRUE.toString());
    writeAddAttribute(ElementTags.CELLPADDING, "10");
    writeAddAttribute(ElementTags.WIDTH, "100.0%");

    writeStartElement(ElementTags.ROW);/*from  w w  w.j a v  a2 s .  c o  m*/

    writeStartElement(ElementTags.CELL);
    writeAddAttribute(ElementTags.LEFT, Boolean.TRUE.toString());
    writeAddAttribute(ElementTags.RIGHT, Boolean.TRUE.toString());
    writeAddAttribute(ElementTags.TOP, Boolean.TRUE.toString());
    writeAddAttribute(ElementTags.BOTTOM, Boolean.TRUE.toString());

    actionContext.setAction(SinkActionContext.VERBATIM);
}

From source file:org.eclipse.osee.framework.ui.skynet.util.TableWriterAdaptor.java

License:Open Source License

public void writeHeader(Table table, String[] headers) throws Exception {
    for (String header : headers) {
        Cell cell = new Cell();
        cell.setHeader(true);//  w  w  w .  j  a va 2  s.  c om
        cell.setColspan(1);
        cell.setBackgroundColor(WebColors.getRGBColor("#d9d9d9"));
        cell.setHorizontalAlignment(ElementTags.ALIGN_CENTER);

        Font font = FontFactory.getFont("Times New Roman", BaseFont.CP1252, BaseFont.EMBEDDED, 9, Font.BOLD,
                WebColors.getRGBColor("#000000"));
        Paragraph paragraph = new Paragraph(header, font);
        paragraph.setAlignment(ElementTags.ALIGN_CENTER);
        cell.add(paragraph);
        table.addCell(cell);
    }
}

From source file:org.eclipse.osee.framework.ui.skynet.util.TableWriterAdaptor.java

License:Open Source License

public void writeDocument() throws DocumentException {
    Font font = FontFactory.getFont("Times New Roman", BaseFont.CP1252, BaseFont.EMBEDDED, 9, Font.BOLD,
            WebColors.getRGBColor("#000000"));
    Paragraph paragraph = new Paragraph(title, font);
    paragraph.setAlignment(ElementTags.ALIGN_CENTER);
    document.add(paragraph);/*from w ww .  j a  v  a 2  s.c om*/
    if (table != null) {
        document.add(table);
    }
}