当前位置: 首页>>代码示例>>Java>>正文


Java Element.ALIGN_CENTER属性代码示例

本文整理汇总了Java中com.itextpdf.text.Element.ALIGN_CENTER属性的典型用法代码示例。如果您正苦于以下问题:Java Element.ALIGN_CENTER属性的具体用法?Java Element.ALIGN_CENTER怎么用?Java Element.ALIGN_CENTER使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.itextpdf.text.Element的用法示例。


在下文中一共展示了Element.ALIGN_CENTER属性的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: cellRodape

private PdfPTable cellRodape(String value, boolean l,boolean r,int align)
{
    Font fontCorpoTableO= FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED ,7.5f);
    PdfPTable pTable = new PdfPTable(1);
    pTable.setWidthPercentage(100f);
    PdfPCell cellValue = new PdfPCell(new Phrase(value,fontCorpoTableO));
    if(l){cellValue.setBorderWidthLeft(0);}
    if(r){cellValue.setBorderWidthRight(0);}
   switch (align) 
   {
       case Element.ALIGN_RIGHT:cellValue.setHorizontalAlignment(Element.ALIGN_RIGHT);break;
       case Element.ALIGN_LEFT:cellValue.setHorizontalAlignment(Element.ALIGN_LEFT);break;
       case Element.ALIGN_CENTER:cellValue.setHorizontalAlignment(Element.ALIGN_CENTER);break;
       default:break;
   }
    pTable.addCell(cellValue);
    return pTable;
}
 
开发者ID:JIGAsoftSTP,项目名称:NICON,代码行数:18,代码来源:ExporOnlyViagemPdf.java

示例2: createPdf

/**
 * <a href="http://stackoverflow.com/questions/44005834/changing-rowspans">
 * Changing rowspans
 * </a>
 * <p>
 * The original code used by the OP. This code adds the second cell
 * with rowspan 2 too early. Fixed in {@link #createPdfFixed(String)}.
 * </p>
 * @see #testUseRowspanLikeUser7968180()
 * @see #addCellToTableCzech(PdfPTable, int, int, String, int, int, String, float)
 */
public void createPdf(String dest) throws IOException, DocumentException {
    int horizontalAlignmentCenter = Element.ALIGN_CENTER;
    int verticalAlignmentMiddle = Element.ALIGN_MIDDLE;
    String fontTypeRegular = "c:/Windows/Fonts/arial.ttf";
    float fontSizeRegular = 10f;

    float[] columns = { 100, 50, 100, 50, 50, 50, 50, 50, 75, 50, 50, 50 };
    int numberOfColumns = columns.length;
    Document document = new Document(PageSize.A4.rotate(), 36, 36, 36, 36);
    PdfWriter.getInstance(document, new FileOutputStream(dest));
    document.open();

    PdfPTable subTableZkouska = new PdfPTable(numberOfColumns);
    subTableZkouska.setTotalWidth(columns);
    subTableZkouska.setLockedWidth(true);

    addCellToTableCzech(subTableZkouska, horizontalAlignmentCenter,
            verticalAlignmentMiddle, "Brno �pit�lka 8 Brno H�jeck� 1068/14 CZ5159", 1,
            2, fontTypeRegular, fontSizeRegular);

    addCellToTableCzech(subTableZkouska, horizontalAlignmentCenter,
            verticalAlignmentMiddle, "38", 1, 2, fontTypeRegular, fontSizeRegular);

    for (int i = 0; i < 19; i++) {
        addCellToTableCzech(subTableZkouska, horizontalAlignmentCenter,
                verticalAlignmentMiddle, "38", 1, 1, fontTypeRegular,
                fontSizeRegular);
    }
    addCellToTableCzech(subTableZkouska, horizontalAlignmentCenter,
            verticalAlignmentMiddle, "38", 1, 1, fontTypeRegular, fontSizeRegular);

    document.add(subTableZkouska);
    document.close();
}
 
开发者ID:mkl-public,项目名称:testarea-itext5,代码行数:45,代码来源:UseRowspan.java

示例3: createPdfFixed

/**
 * <a href="http://stackoverflow.com/questions/44005834/changing-rowspans">
 * Changing rowspans
 * </a>
 * <p>
 * The fixed code. This code adds the second cell with rowspan 2
 * in twelfth place. Fixed of {@link #createPdf(String)}.
 * </p>
 * @see #testUseRowspanLikeUser7968180Fixed()
 * @see #addCellToTableCzech(PdfPTable, int, int, String, int, int, String, float)
 */
public void createPdfFixed(String dest) throws IOException, DocumentException {
    int horizontalAlignmentCenter = Element.ALIGN_CENTER;
    int verticalAlignmentMiddle = Element.ALIGN_MIDDLE;
    String fontTypeRegular = "c:/Windows/Fonts/arial.ttf";
    float fontSizeRegular = 10f;

    float[] columns = { 100, 50, 100, 50, 50, 50, 50, 50, 75, 50, 50, 50 };
    int numberOfColumns = columns.length;
    Document document = new Document(PageSize.A4.rotate(), 36, 36, 36, 36);
    PdfWriter.getInstance(document, new FileOutputStream(dest));
    document.open();

    PdfPTable subTableZkouska = new PdfPTable(numberOfColumns);
    subTableZkouska.setTotalWidth(columns);
    subTableZkouska.setLockedWidth(true);

    addCellToTableCzech(subTableZkouska, horizontalAlignmentCenter,
            verticalAlignmentMiddle, "Brno �pit�lka 8 Brno H�jeck� 1068/14 CZ5159", 1,
            2, fontTypeRegular, fontSizeRegular);

    for (int i = 2; i < 12; i++) {
        addCellToTableCzech(subTableZkouska, horizontalAlignmentCenter,
                verticalAlignmentMiddle, "38", 1, 1, fontTypeRegular,
                fontSizeRegular);
    }

    addCellToTableCzech(subTableZkouska, horizontalAlignmentCenter,
            verticalAlignmentMiddle, "38", 1, 2, fontTypeRegular, fontSizeRegular);

    for (int i = 13; i < 23; i++) {
        addCellToTableCzech(subTableZkouska, horizontalAlignmentCenter,
                verticalAlignmentMiddle, "38", 1, 1, fontTypeRegular,
                fontSizeRegular);
    }

    document.add(subTableZkouska);
    document.close();
}
 
开发者ID:mkl-public,项目名称:testarea-itext5,代码行数:49,代码来源:UseRowspan.java

示例4: columnAlignment

public int columnAlignment(int col) {
    TableColumnNode tcn = tableNodeColumns.get(col);
    switch (tcn.getAlignment()) {
        case Left:
            return Element.ALIGN_LEFT;
        case Right:
            return Element.ALIGN_RIGHT;
        case None:
            return Element.ALIGN_UNDEFINED;
        case Center:
        default:
            return Element.ALIGN_CENTER;
    }
}
 
开发者ID:Arnauld,项目名称:gutenberg,代码行数:14,代码来源:TableInfos.java

示例5: renderField

@Override
protected void renderField(String content, ColRDesc colRDesc) {
    PdfPCell cell = new PdfPCell(new Paragraph(content, pdfStyle.getDataCellFont()));
    cell.setColspan(1);

    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);

    if (colRDesc != null && colRDesc.getHAlign() != null) {
        int alignment = Element.ALIGN_CENTER;
        switch (colRDesc.getHAlign()) {
            case LEFT:
                alignment = Element.ALIGN_LEFT;
                break;
            case RIGHT:
                alignment = Element.ALIGN_RIGHT;
                break;
            case CENTER:
                alignment = Element.ALIGN_CENTER;
                break;
            default:
                break;
        }

        cell.setHorizontalAlignment(alignment);
    }

    if (withNoBorders) {
        cell.setBorder(Rectangle.NO_BORDER);
    }
    customizeFieldCell(cell);
    table.addCell(cell);
}
 
开发者ID:inepex,项目名称:ineform,代码行数:33,代码来源:PdfRenderer.java

示例6: parseURL2PDFFile

/**
 * 直接把网页内容转为PDF文件
 * 
 * @param fileName
 * @throws Exception
 */
public static void parseURL2PDFFile(String pdfFile, String blogURL)
		throws Exception {

	BaseFont bfCN = BaseFont.createFont("STSongStd-Light", "UniGB-UCS2-H",
			false);
	// 中文字体定义
	Font chFont = new Font(bfCN, 14, Font.NORMAL, BaseColor.BLUE);
	Font secFont = new Font(bfCN, 12, Font.NORMAL, new BaseColor(0, 204,
			255));
	Font textFont = new Font(bfCN, 12, Font.NORMAL, BaseColor.BLACK);

	Document document = new Document();
	PdfWriter pdfwriter = PdfWriter.getInstance(document,
			new FileOutputStream(pdfFile));
	pdfwriter.setViewerPreferences(PdfWriter.HideToolbar);
	document.open();

	String[] blogInfo = extractBlogInfo(blogURL);

	int chNum = 1;
	Chapter chapter = new Chapter(new Paragraph("URL转PDF测试", chFont),
			chNum++);

	Section section = chapter
			.addSection(new Paragraph(blogInfo[0], secFont));
	section.setIndentation(10);
	section.setIndentationLeft(10);
	section.setBookmarkOpen(false);
	section.setNumberStyle(Section.NUMBERSTYLE_DOTTED_WITHOUT_FINAL_DOT);
	section.add(new Chunk("分类:" + blogInfo[1] + " 日期:" + blogInfo[2],
			textFont));

	LineSeparator line = new LineSeparator(1, 100, new BaseColor(204, 204,
			204), Element.ALIGN_CENTER, -2);
	Paragraph p_line = new Paragraph(" ");
	p_line.add(line);
	section.add(p_line);
	section.add(Chunk.NEWLINE);

	document.add(chapter);

	// html文件
	XMLWorkerHelper.getInstance().parseXHtml(pdfwriter, document,
			parse2Stream(blogInfo[3]));

	document.close();
}
 
开发者ID:wkeyuan,项目名称:DWSurvey,代码行数:53,代码来源:Demo4URL2PDF.java

示例7: connectChunk

private Chunk connectChunk(Styles styles) {
    return new Chunk(new LineSeparator(0.5f, 95, styles.defaultColor(), Element.ALIGN_CENTER, -.5f));
}
 
开发者ID:Arnauld,项目名称:gutenberg,代码行数:3,代码来源:TableOfContentsPostProcessor.java

示例8: getCaptionHorizontalAlignment

/**
 * Obtain the caption horizontal alignment; Meant to be overriden if a different style is desired.
 * @return The caption horizontal alignment.
 */
protected int getCaptionHorizontalAlignment()
{
    return Element.ALIGN_CENTER;
}
 
开发者ID:webbfontaine,项目名称:displaytag,代码行数:8,代码来源:ItextTableWriter.java

示例9: getHeaderHorizontalAlignment

/**
 * Obtain the horizontal alignment used to render header text; Meant to be overridden if a different alignment is
 * desired.
 * @return The horizontal alignment used to render header text;
 */
protected int getHeaderHorizontalAlignment()
{
    return Element.ALIGN_CENTER;
}
 
开发者ID:webbfontaine,项目名称:displaytag,代码行数:9,代码来源:ItextTableWriter.java


注:本文中的com.itextpdf.text.Element.ALIGN_CENTER属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。