當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。