本文整理匯總了Java中com.itextpdf.text.pdf.PdfPTable.setHorizontalAlignment方法的典型用法代碼示例。如果您正苦於以下問題:Java PdfPTable.setHorizontalAlignment方法的具體用法?Java PdfPTable.setHorizontalAlignment怎麽用?Java PdfPTable.setHorizontalAlignment使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.itextpdf.text.pdf.PdfPTable
的用法示例。
在下文中一共展示了PdfPTable.setHorizontalAlignment方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getTable
import com.itextpdf.text.pdf.PdfPTable; //導入方法依賴的package包/類
/**
* Create a table with the factory element attributes applied
* @return A table with the element attributes applied
*/
public PdfPTable getTable(int pColumns) {
PdfPTable lTable = new PdfPTable(pColumns);
// Set split late to false so that tables will be split immediately if they don't fit on a page instead of moving
// them to the next page then attempting to split if they don't fit there. iText gets in an infinite loop with the
// latter option when content in nested table rows can't split (see EDU-3490 on JIRA).
lTable.setSplitLate(false);
mElementAttributes.getTableAttributes().getWidthPercentage().ifPresent(pWidthPercentage -> {
lTable.setWidthPercentage(pWidthPercentage);
lTable.setLockedWidth(false);
});
mElementAttributes.getTableAttributes().getFixedWidth().ifPresent(pFixedWidth -> {
lTable.setTotalWidth(pFixedWidth);
lTable.setLockedWidth(true);
});
lTable.setHorizontalAlignment(mElementAttributes.getTableAttributes().getHorizontalAlignment());
lTable.setSpacingBefore(mElementAttributes.getTableAttributes().getSpacingBefore());
lTable.setSpacingAfter(mElementAttributes.getTableAttributes().getSpacingAfter());
lTable.setKeepTogether(mElementAttributes.getTableAttributes().isKeepTogether());
return lTable;
}
示例2: buildFooterVersetzungsvermerkLine
import com.itextpdf.text.pdf.PdfPTable; //導入方法依賴的package包/類
public static PdfPTable buildFooterVersetzungsvermerkLine(String versetzungsvermerk, Font footerFont) throws DocumentException {
PdfPCell labelCell = new PdfPCell(new Phrase("Versetzungsvermerk", footerFont));
labelCell.setBorder(Rectangle.BOTTOM);
labelCell.setBorderWidth(1f);
PdfPCell nameCell = new PdfPCell(new Phrase(versetzungsvermerk, footerFont));
nameCell.setBorder(Rectangle.BOTTOM);
nameCell.setBorderWidth(1f);
PdfPTable table = new PdfPTable(2);
table.setHorizontalAlignment(Element.ALIGN_LEFT);
table.setWidthPercentage(100f);
table.addCell(labelCell);
table.addCell(nameCell);
table.setWidths(new float[] {0.3f, 0.7f});
return table;
}
示例3: buildFooterDatumLine
import com.itextpdf.text.pdf.PdfPTable; //導入方法依賴的package包/類
public static PdfPTable buildFooterDatumLine(String datumString, Font footerFont) throws DocumentException {
PdfPCell labelCell = new PdfPCell(new Phrase("Datum", footerFont));
labelCell.setBorder(Rectangle.BOTTOM);
labelCell.setBorderWidth(1f);
PdfPCell nameCell = new PdfPCell(new Phrase(datumString, footerFont));
nameCell.setBorder(Rectangle.BOTTOM);
nameCell.setBorderWidth(1f);
PdfPTable table = new PdfPTable(2);
table.setHorizontalAlignment(Element.ALIGN_LEFT);
table.setWidthPercentage(100f);
table.addCell(labelCell);
table.addCell(nameCell);
table.setWidths(new float[] {0.3f, 0.7f});
return table;
}
示例4: buildFooterDienstsiegelLine
import com.itextpdf.text.pdf.PdfPTable; //導入方法依賴的package包/類
public static PdfPTable buildFooterDienstsiegelLine(Font footerFont) throws DocumentException {
PdfPCell leftCell = new PdfPCell(new Phrase("", footerFont));
leftCell.setBorder(Rectangle.NO_BORDER);
leftCell.setBorderWidth(1f);
PdfPCell centerCell = new PdfPCell(new Phrase("Dienstsiegel der Schule", footerFont));
centerCell.setBorder(Rectangle.NO_BORDER);
centerCell.setBorderWidth(1f);
centerCell.setHorizontalAlignment(Element.ALIGN_CENTER);
PdfPCell rightCell = new PdfPCell(new Phrase("", footerFont));
rightCell.setBorder(Rectangle.NO_BORDER);
rightCell.setBorderWidth(1f);
PdfPTable table = new PdfPTable(3);
table.setHorizontalAlignment(Element.ALIGN_MIDDLE);
table.setWidthPercentage(100f);
table.addCell(leftCell);
table.addCell(centerCell);
table.addCell(rightCell);
table.setWidths(new float[] {0.3f, 0.3f, 0.3f});
return table;
}
示例5: dataTableTitile
import com.itextpdf.text.pdf.PdfPTable; //導入方法依賴的package包/類
private void dataTableTitile(Document documento, String data) throws IOException, BadElementException, DocumentException {
try {
pTableEmpresaPricipal = new PdfPTable(new float[]{15f, 85f});
pTableEmpresaInforImpres1 = new PdfPTable(1);
pTableEmpresaInforImpres5 = new PdfPTable(1);
PdfPCell pCellNomeEmpresa = new PdfPCell(new Phrase(Empresa.NOME, fontCabecalhoNG));
pCellNomeEmpresa.setBorder(0);
PdfPCell pCellNomeEndereco = new PdfPCell(new Phrase(Empresa.ENDERECO, fontCabecalhoN));
pCellNomeEndereco.setBorder(0);
PdfPCell pCellCaixaPostal = new PdfPCell(new Phrase(Empresa.CAIXAPOSTAL, fontCabecalhoN));
pCellCaixaPostal.setBorder(0);
PdfPCell pCellTeleFax = new PdfPCell(new Phrase(Empresa.TELEFAX + " " + ConfigDoc.Empresa.EMAIL, fontCabecalhoN));
pCellTeleFax.setBorder(0);
PdfPCell pCellSociedade = new PdfPCell(new Phrase(Empresa.SOCIEDADE, fontCabecalhoN));
pCellSociedade.setBorder(0);
Image imageEmpresa = Image.getInstance("logo.png");
imageEmpresa.scaleToFit(120f, 85f);
pTableEmpresaInforImpres1.addCell(pCellNomeEmpresa);
pTableEmpresaInforImpres1.addCell(pCellNomeEndereco);
pTableEmpresaInforImpres1.addCell(pCellCaixaPostal);
pTableEmpresaInforImpres1.addCell(pCellTeleFax);
pTableEmpresaInforImpres1.addCell(pCellSociedade);
PdfPCell cellTabela3 = new PdfPCell(pTableEmpresaInforImpres1);
cellTabela3.setBorder(0);
pTableEmpresaInforImpres5.addCell(cellTabela3);
PdfPCell cellTabela5 = new PdfPCell(pTableEmpresaInforImpres5);
cellTabela5.setBorder(0);
PdfPCell cellTabela6 = new PdfPCell(imageEmpresa);
cellTabela6.setBorder(0);
pTableEmpresaPricipal.setWidthPercentage(95);
pTableEmpresaPricipal.addCell(cellTabela6);
pTableEmpresaPricipal.addCell(cellTabela5);
PdfPTable pTableTitulo = new PdfPTable(1);
pTableTitulo.setHorizontalAlignment(Element.ALIGN_CENTER);
pTableTitulo.setWidthPercentage(100);
SimpleDateFormat sdfEsp = new SimpleDateFormat("MMMM, yyyy", Locale.ENGLISH);
SimpleDateFormat sdf = new SimpleDateFormat("MM-yyyy");
PdfPCell cellTitulo = new PdfPCell(new Phrase("TOTAL PREMIUM COLLECTED ON TRAVEL INSURANCE AND TAXES FOR "+sdfEsp.format(sdf.parse(data)).toUpperCase(), fontCorpoNG));
cellTitulo.setBorder(0);
cellTitulo.setPaddingBottom(10f);
pTableTitulo.addCell(cellTitulo);
pTableEmpresaPricipal.setHorizontalAlignment(Element.ALIGN_CENTER);
documento.add(pTableEmpresaPricipal);
documento.add(pTableNull);
documento.add(pTableTitulo);
} catch (ParseException ex) {
Logger.getLogger(ExporOnlyViagemPdf.class.getName()).log(Level.SEVERE, null, ex);
}
}
示例6: createTable
import com.itextpdf.text.pdf.PdfPTable; //導入方法依賴的package包/類
public PdfPTable createTable(int colNumber) {
PdfPTable table = new PdfPTable(colNumber);
try {
table.setTotalWidth(maxWidth);
table.setLockedWidth(true);
table.setHorizontalAlignment(Element.ALIGN_CENTER);
table.getDefaultCell().setBorder(1);
} catch (Exception e) {
e.printStackTrace();
}
return table;
}
示例7: prebuildHeaderTable
import com.itextpdf.text.pdf.PdfPTable; //導入方法依賴的package包/類
private static PdfPTable prebuildHeaderTable() throws DocumentException {
PdfPTable table = new PdfPTable(6);
table.setHorizontalAlignment(Element.ALIGN_LEFT);
table.setWidthPercentage(100f);
table.setWidths(new float[] {0.12f, 0.2f, 0.15f, 0.2f, 0.2f, 0.08f});
return table;
}
示例8: buildFooterKenntnisLine
import com.itextpdf.text.pdf.PdfPTable; //導入方法依賴的package包/類
public static PdfPTable buildFooterKenntnisLine(Font footerFont) {
PdfPCell cell = new PdfPCell(new Phrase("Kenntnis genommen: Erziehungsberechtigte", footerFont));
cell.setBorder(Rectangle.TOP);
cell.setBorderWidth(1f);
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
PdfPTable table = new PdfPTable(1);
table.setHorizontalAlignment(Element.ALIGN_CENTER);
table.setWidthPercentage(100f);
table.addCell(cell);
return table;
}
示例9: render
import com.itextpdf.text.pdf.PdfPTable; //導入方法依賴的package包/類
public void render(AssistedObject ao, TableRDesc trd) {
fieldRenderer.setObjectAndDescriptor(ao, trd);
ObjectDesc od = descStore.getOD(ao.getDescriptorName());
table = new PdfPTable(2);
table.setHorizontalAlignment(Element.ALIGN_LEFT);
for (Node<TableRDescBase> columnNode : trd.getRootNode().getChildren()) {
String keyText = columnNode.getNodeElement().getDisplayName();
if (keyText == null) {
keyText = od.getField(columnNode.getHierarchicalId()).getDefaultDisplayName();
}
String valueText = fieldRenderer.getField(columnNode.getNodeId());
table.addCell(createCell(keyText, true));
table.addCell(createCell(valueText, false));
}
}
示例10: addItems
import com.itextpdf.text.pdf.PdfPTable; //導入方法依賴的package包/類
/**
* Adds the items to the report.
*
* @param document
* the report document.
* @param items
* the items.
* @param width
* the table width.
* @param widths
* the table cell widths.
* @param alignments
* the alignments.
* @param columnsCount
* the columns count.
* @param totalLabel
* the total label text.
* @return the array containing the item number and total number.
* @throws com.itextpdf.text.DocumentException
* if any error occurs.
*/
private static Object[] addItems(com.itextpdf.text.Document document,
List<BalancedLockboxReportResponseItem> items, int width, int[] widths,
int[] alignments, int columnsCount, String totalLabel)
throws com.itextpdf.text.DocumentException {
if (items != null) {
PdfPTable table = new PdfPTable(columnsCount);
table.setSpacingBefore(20);
table.setWidthPercentage(width);
table.setWidths(widths);
table.setHorizontalAlignment(ReportServiceHelper.RTF_ALIGN_LEFT);
String[] titles = columnsCount == 2 ? new String[]{ "Import Status", "# Items" } :
new String[]{ "Import Status", "# Items", "Imported Total" };
ReportServiceHelper.addReportTableRow(table, titles, ReportServiceHelper.PDF_REPORT_UNDERLINE_FONT,
null, alignments, ReportServiceHelper.PDF_NO_BORDER);
int totalItemNumber = 0;
BigDecimal totalTotalNumber = new BigDecimal(0);
for (int i = 0; i < items.size(); i++) {
BalancedLockboxReportResponseItem item = items.get(i);
Object[] contents = columnsCount == 2 ? new Object[]{ item.getImportStatus(), item.getItemNumber() } :
new Object[]{ item.getImportStatus(), item.getItemNumber(), item.getTotalNumber() };
ReportServiceHelper.addReportTableRow(table, contents, ReportServiceHelper.PDF_REPORT_CONTENT_FONT,
null, alignments, i == items.size() - 1 ? ReportServiceHelper.PDF_BORDER_BOTTOM :
ReportServiceHelper.PDF_NO_BORDER);
totalItemNumber += item.getItemNumber();
if (item.getTotalNumber() != null) {
totalTotalNumber = totalTotalNumber.add(item.getTotalNumber());
}
}
Object[] totalColumns = columnsCount == 2 ? new Object[]{ totalLabel, totalItemNumber } :
new Object[]{ totalLabel, totalItemNumber, totalTotalNumber };
ReportServiceHelper.addReportTableRow(table, totalColumns, ReportServiceHelper.PDF_REPORT_HEADER_FONT,
null, alignments, ReportServiceHelper.PDF_BORDER_BOTTOM);
document.add(table);
return new Object[]{ totalItemNumber, totalTotalNumber };
}
return null;
}
開發者ID:NASA-Tournament-Lab,項目名稱:CoECI-OPM-Service-Credit-Redeposit-Deposit-Application,代碼行數:60,代碼來源:BalancedLockboxReportService.java
示例11: getPhotosInParagraph
import com.itextpdf.text.pdf.PdfPTable; //導入方法依賴的package包/類
public static Paragraph getPhotosInParagraph(List<BufferedImage> bufferedImages, float scalePercent, boolean isHorizontallyCentered) throws BadElementException, IOException {
Paragraph paragraph = new Paragraph(" ", SUB_FONT);
PdfPTable table = new PdfPTable(1);
for (BufferedImage bufferedImage : bufferedImages) {
table.addCell(getPhotoCell(bufferedImage, scalePercent, isHorizontallyCentered));
}
table.setHorizontalAlignment(Element.ALIGN_CENTER);
paragraph.add(table);
paragraph.setLeading(0);
paragraph.setSpacingAfter(0);
paragraph.setSpacingBefore(0);
return paragraph;
}
示例12: createPdfAttachment
import com.itextpdf.text.pdf.PdfPTable; //導入方法依賴的package包/類
public void createPdfAttachment(OutputStream outputStream) throws Exception {
Document document = new Document();
PdfWriter.getInstance(document, outputStream);
document.open();
document.addTitle("Monitoring Report");
document.addSubject("PDF Document");
document.addKeywords("iText, email");
document.addAuthor("JMX");
document.addCreator("JMX");
Timestamp stamp = new Timestamp(System.currentTimeMillis());
Date date = new Date(stamp.getTime());
//Make the Get call to get the data from Jolokia endpoint.
HttpClient httpClient = new HttpClient();
String monData = httpClient.getMemoryData();
Log.info("Monitoring Data JSON:"+monData);
//Converting json string to java object for easy manipulation.
Map outNode = new Genson().deserialize(monData, Map.class);
Map requestNode = (Map) outNode.get("request");
Map valueNode = (Map) outNode.get("value");
HashMap<String,String> monitoringData = new HashMap<String,String>();
monitoringData.put("Current Date",date.toString());
monitoringData.put("Report Date",outNode.get("timestamp").toString());
monitoringData.put("Maximum Heap Memory",valueNode.get("max").toString());
monitoringData.put("Committed Heap Memory",valueNode.get("committed").toString());
monitoringData.put("Init Heap Memory",valueNode.get("init").toString());
monitoringData.put("Used Heap Memory",valueNode.get("used").toString());
Font boldFont = new Font(Font.FontFamily.TIMES_ROMAN, 18, Font.BOLD);
PdfPTable table = new PdfPTable(2);
table.setSpacingBefore(5);
table.addCell(new Phrase("Monitor", boldFont ));
table.addCell(new Phrase("Value", boldFont ));
for (Map.Entry<String, String> entry : monitoringData.entrySet()) {
table.addCell(entry.getKey());
System.out.println(entry.getKey());
if (entry.getValue()!="" && entry.getValue()!=null)
{
table.addCell(entry.getValue());
System.out.println(entry.getValue());
}
else{
table.addCell("NOT AVAILABLE");
}
}
table.setHorizontalAlignment(Element.ALIGN_CENTER);
document.add(table);
document.close();
}
示例13: addUserData
import com.itextpdf.text.pdf.PdfPTable; //導入方法依賴的package包/類
public static void addUserData(Document document, ReportModel reportModel) throws DocumentException {
//add line feed
document.add(new Paragraph(" "));
Paragraph paragraph = new Paragraph("My business", FONT[1]);
document.add(paragraph);
//add line feed
document.add(new Paragraph(" "));
// a table with three columns
PdfPTable table = new PdfPTable(2);
table.setHorizontalAlignment(Element.ALIGN_LEFT);
table.setWidthPercentage(50);
table.setSpacingBefore(5);
// we add a cell with colspan 2
PdfPCell cell = new PdfPCell(new Phrase("Information provided", FONT[2]));
cell.setColspan(2);
//cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
//cell.setGrayFill(0.9f);
cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
cell.setPadding(5);
table.addCell(cell);
if (StringUtils.isNotBlank(reportModel.getBusinessAge())) {
table.addCell("Business age");
table.addCell(new PdfPCell(new Phrase(reportModel.getBusinessAge(), FONT[6])));
}
if (StringUtils.isNotBlank(reportModel.getLegalStructure())) {
table.addCell("Legal structure");
table.addCell(new PdfPCell(new Phrase(reportModel.getLegalStructure(), FONT[6])));
}
if (StringUtils.isNotBlank(reportModel.getPostCode())) {
table.addCell("Location");
table.addCell(new PdfPCell(new Phrase(reportModel.getPostCode(), FONT[6])));
}
if (StringUtils.isNotBlank(reportModel.getWorkforce())) {
table.addCell("Workforce");
table.addCell(new PdfPCell(new Phrase(reportModel.getWorkforce(), FONT[6])));
}
if (StringUtils.isNotBlank(reportModel.getSector())) {
table.addCell("Sector");
table.addCell(new PdfPCell(new Phrase(reportModel.getSector(), FONT[6])));
}
document.add(table);
}
示例14: addTotal
import com.itextpdf.text.pdf.PdfPTable; //導入方法依賴的package包/類
/**
* Adds the total data to the report.
*
* @param document
* the report document.
* @param totals
* the array of total data.
* @param width
* the table width.
* @param widths
* the table cell widths.
* @param alignments
* the alignments.
* @param columnsCount
* the columns count.\
* @param imported
* the imported flag..
* @throws com.itextpdf.text.DocumentException
* if any error occurs.
*/
private static void addTotal(com.itextpdf.text.Document document, Object[] totals, int width, int[] widths,
int[] alignments, int columnsCount, boolean imported)
throws com.itextpdf.text.DocumentException {
PdfPTable table = new PdfPTable(columnsCount);
table.setWidthPercentage(width);
table.setWidths(widths);
table.setSpacingBefore(10);
table.setHorizontalAlignment(ReportServiceHelper.RTF_ALIGN_LEFT);
String totalLabel = imported ? "Total Imported This Quarter" : "Total Reversed This Quarter";
ReportServiceHelper.addReportTableRow(table, columnsCount == 2 ?
new Object[]{ totalLabel, totals[0] } :
new Object[]{ totalLabel, totals[0], totals[1] },
ReportServiceHelper.PDF_REPORT_HEADER_FONT, BaseColor.LIGHT_GRAY, alignments,
ReportServiceHelper.PDF_NO_BORDER);
document.add(table);
}
開發者ID:NASA-Tournament-Lab,項目名稱:CoECI-OPM-Service-Credit-Redeposit-Deposit-Application,代碼行數:37,代碼來源:BalancedLockboxReportService.java