本文整理匯總了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();
}