本文整理汇总了Java中com.itextpdf.text.Element.ALIGN_MIDDLE属性的典型用法代码示例。如果您正苦于以下问题:Java Element.ALIGN_MIDDLE属性的具体用法?Java Element.ALIGN_MIDDLE怎么用?Java Element.ALIGN_MIDDLE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.itextpdf.text.Element
的用法示例。
在下文中一共展示了Element.ALIGN_MIDDLE属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
示例2: 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();
}