本文整理汇总了Java中com.lowagie.text.pdf.PdfPTable.setHorizontalAlignment方法的典型用法代码示例。如果您正苦于以下问题:Java PdfPTable.setHorizontalAlignment方法的具体用法?Java PdfPTable.setHorizontalAlignment怎么用?Java PdfPTable.setHorizontalAlignment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.lowagie.text.pdf.PdfPTable
的用法示例。
在下文中一共展示了PdfPTable.setHorizontalAlignment方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: insertTable_TextRow
import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
private void insertTable_TextRow( PdfWriter writer, PdfPTable mainTable, String text, Font font )
{
boolean hasBorder = false;
// Add Organization ID/Period textfield
// Create A table to add for each group AT HERE
PdfPTable table = new PdfPTable( 1 );
table.setHorizontalAlignment( Element.ALIGN_LEFT );
addCell_Text( table, PdfDataEntryFormUtil.getPdfPCell( hasBorder ), text, Element.ALIGN_LEFT, font );
// Add to the main table
PdfPCell cell_withInnerTable = new PdfPCell( table );
cell_withInnerTable.setBorder( Rectangle.NO_BORDER );
mainTable.addCell( cell_withInnerTable );
}
示例2: writeGraph
import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
private void writeGraph() throws IOException, DocumentException {
final JRobin jrobin = collector.getJRobin(graphName);
if (jrobin != null) {
final byte[] img = jrobin.graph(range, 960, 400);
final Image image = Image.getInstance(img);
image.scalePercent(50);
final PdfPTable table = new PdfPTable(1);
table.setHorizontalAlignment(Element.ALIGN_CENTER);
table.setWidthPercentage(100);
table.getDefaultCell().setBorder(0);
table.addCell("\n");
table.addCell(image);
table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
table.addCell(new Phrase(getString("graph_units"), cellFont));
addToDocument(table);
} else {
// just in case request is null and collector.getJRobin(graphName) is null, we must write something in the document
addToDocument(new Phrase("\n", cellFont));
}
}
示例3: addResultExample
import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
private void addResultExample(Section section, ApiDoc apiDoc) throws Exception {
Paragraph result = new Paragraph(itemFont.process("★返回示例"));
// result.setLeading(6f);
result.setSpacingBefore(6f);
result.setSpacingAfter(8f);
PdfPTable table = new PdfPTable(1);
table.setWidthPercentage(95f);
table.setHorizontalAlignment(Element.ALIGN_LEFT);
PdfPCell pdfPCell = table.getDefaultCell();
pdfPCell.setHorizontalAlignment(Element.ALIGN_LEFT);
pdfPCell.setBackgroundColor(Color.LIGHT_GRAY);
if (apiDoc.getResultDoc() != null && apiDoc.getResultExample() != null) {
pdfPCell.setPhrase(DefaultPdfTable.tableBSelector.process(apiDoc.getResultExample()));
}
table.addCell(pdfPCell);
Paragraph wrapperTable = new Paragraph();
wrapperTable.setSpacingAfter(8f);
wrapperTable.setIndentationLeft(12f);
wrapperTable.add(table);
section.add(result);
section.add(wrapperTable);
}
示例4: addComponyLogo
import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
private static void addComponyLogo(Document d, HttpServletRequest req) throws ConfigurationException, DocumentException {
PdfPTable table = new PdfPTable(1);
imgPath = StorageHandler.GetProfileImgStorePath() + "logo.gif";
table.setHorizontalAlignment(Element.ALIGN_LEFT);
table.setWidthPercentage(50);
PdfPCell cell = null;
try {
if(StringUtil.isStandAlone()){
imgPath = URLUtil.getPageURL(req, "").concat(defaultCompanyImgPath);
}
Image img = Image.getInstance(imgPath);
cell = new PdfPCell(img);
} catch (Exception e) {
cell = new PdfPCell(new Paragraph(companyName, fontBig));
}
cell.setBorder(0);
cell.setHorizontalAlignment(Element.ALIGN_LEFT);
table.addCell(cell);
d.add(table);
}
示例5: getProgramStageMainTable
import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
private PdfPTable getProgramStageMainTable()
{
PdfPTable mainTable = new PdfPTable( 1 ); // Code 1
mainTable.setTotalWidth( 800f );
mainTable.setLockedWidth( true );
mainTable.setHorizontalAlignment( Element.ALIGN_LEFT );
return mainTable;
}
示例6: insertTable_OrgAndPeriod
import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
private void insertTable_OrgAndPeriod( PdfPTable mainTable, PdfWriter writer, List<Period> periods )
throws IOException, DocumentException
{
boolean hasBorder = false;
float width = 220.0f;
// Input TextBox size
Rectangle rectangle = new Rectangle( width, PdfDataEntryFormUtil.CONTENT_HEIGHT_DEFAULT );
// Add Organization ID/Period textfield
// Create A table to add for each group AT HERE
PdfPTable table = new PdfPTable( 2 ); // Code 1
table.setWidths( new int[]{ 1, 3 } );
table.setHorizontalAlignment( Element.ALIGN_LEFT );
addCell_Text( table, PdfDataEntryFormUtil.getPdfPCell( hasBorder ), "Organization unit identifier", Element.ALIGN_RIGHT );
addCell_WithTextField( table, rectangle, writer, PdfDataEntryFormUtil.getPdfPCell( hasBorder ), PdfDataEntryFormUtil.LABELCODE_ORGID,
PdfFieldCell.TYPE_TEXT_ORGUNIT );
String[] periodsTitle = getPeriodTitles( periods, format );
String[] periodsValue = getPeriodValues( periods );
addCell_Text( table, PdfDataEntryFormUtil.getPdfPCell( hasBorder ), "Period", Element.ALIGN_RIGHT );
addCell_WithDropDownListField( table, rectangle, writer, PdfDataEntryFormUtil.getPdfPCell( hasBorder ), PdfDataEntryFormUtil.LABELCODE_PERIODID, periodsTitle, periodsValue );
// Add to the main table
PdfPCell cell_withInnerTable = new PdfPCell( table );
// cell_withInnerTable.setPadding(0);
cell_withInnerTable.setBorder( Rectangle.NO_BORDER );
cell_withInnerTable.setHorizontalAlignment( Element.ALIGN_LEFT );
mainTable.addCell( cell_withInnerTable );
}
示例7: insertSaveAsButton
import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
private void insertSaveAsButton( Document document, PdfWriter writer, String name, String dataSetName )
throws DocumentException
{
boolean hasBorder = false;
// Button Table
PdfPTable tableButton = new PdfPTable( 1 );
tableButton.setWidthPercentage( 20.0f );
float buttonHeight = PdfDataEntryFormUtil.UNITSIZE_DEFAULT + 5;
tableButton.setHorizontalAlignment( Element.ALIGN_CENTER );
//FIXME
String jsAction = "var newFileName = this.getField(\"" + PdfDataEntryFormUtil.LABELCODE_PERIODID + "\").value + ' ' + "
+ " this.getField(\"" + PdfDataEntryFormUtil.LABELCODE_ORGID + "\").value + ' ' + "
+ " \"" + dataSetName + ".pdf\";"
+ "var returnVal = app.alert('This will save this PDF file as ' + newFileName + '. Do you want to Continue?', 1, 2);"
+ "if(returnVal == 4) { "
+ " var aMyPath = this.path.split(\"/\");"
+ " aMyPath.pop();"
+ " aMyPath.push(newFileName);"
+ " this.saveAs(aMyPath.join(\"/\"));"
+ " this.saveAs({cPath:cMyPath, bPromptToOverwrite:true});"
+ " app.alert('File Saved.', 1);"
+ "} ";
addCell_WithPushButtonField( tableButton, writer, PdfDataEntryFormUtil.getPdfPCell( buttonHeight, PdfDataEntryFormUtil.CELL_COLUMN_TYPE_ENTRYFIELD, hasBorder ), name, jsAction );
document.add( tableButton );
}
示例8: writeRequestRumData
import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
private void writeRequestRumData() throws DocumentException {
final CounterRequestRumData rumData = request.getRumData();
final DecimalFormat percentFormat = I18N.createPercentFormat();
final int networkTimeMean = rumData.getNetworkTimeMean();
final int serverMean = request.getMean();
final int domProcessingMean = rumData.getDomProcessingMean();
final int pageRenderingMean = rumData.getPageRenderingMean();
final int totalTime = networkTimeMean + serverMean + domProcessingMean + pageRenderingMean;
final double networkPercent = 100d * networkTimeMean / totalTime;
final double serverPercent = 100d * serverMean / totalTime;
final double domProcessingPercent = 100d * domProcessingMean / totalTime;
final double pageRenderingPercent = 100d * pageRenderingMean / totalTime;
final PdfPTable table = new PdfPTable(2);
table.setHorizontalAlignment(Element.ALIGN_LEFT);
table.setWidthPercentage(25);
table.getDefaultCell().setBorderWidth(0);
table.addCell(new Phrase(I18N.getString("Network"), cellFont));
table.addCell(new Phrase(integerFormat.format(networkTimeMean) + " ms ("
+ percentFormat.format(networkPercent) + "%)", cellFont));
table.addCell(new Phrase(I18N.getString("Server"), cellFont));
table.addCell(new Phrase(integerFormat.format(serverMean) + " ms ("
+ percentFormat.format(serverPercent) + "%)", cellFont));
table.addCell(new Phrase(I18N.getString("DOM_processing"), cellFont));
table.addCell(new Phrase(integerFormat.format(domProcessingMean) + " ms ("
+ percentFormat.format(domProcessingPercent) + "%)", cellFont));
table.addCell(new Phrase(I18N.getString("Page_rendering"), cellFont));
table.addCell(new Phrase(integerFormat.format(pageRenderingMean) + " ms ("
+ percentFormat.format(pageRenderingPercent) + "%)", cellFont));
addToDocument(table);
addToDocument(new Phrase("\n", cellFont));
}
示例9: createJavaInformationsTable
import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
private static PdfPTable createJavaInformationsTable() throws DocumentException {
final PdfPTable table = new PdfPTable(2);
table.setHorizontalAlignment(Element.ALIGN_LEFT);
table.setWidthPercentage(100);
table.setWidths(new int[] { 2, 8 });
table.getDefaultCell().setBorder(0);
return table;
}
示例10: insertSaveAsButton
import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
private void insertSaveAsButton( Document document, PdfWriter writer, String name, String dataSetName )
throws DocumentException
{
boolean hasBorder = false;
// Button Table
PdfPTable tableButton = new PdfPTable( 1 );
tableButton.setWidthPercentage( 20.0f );
float buttonHeight = PdfDataEntryFormUtil.UNITSIZE_DEFAULT + 5;
tableButton.setHorizontalAlignment( Element.ALIGN_CENTER );
String jsAction = "var newFileName = this.getField(\"" + PdfDataEntryFormUtil.LABELCODE_PERIODID + "\").value + ' ' + "
+ " this.getField(\"" + PdfDataEntryFormUtil.LABELCODE_ORGID + "\").value + ' ' + "
+ " \"" + dataSetName + ".pdf\";"
+ "var returnVal = app.alert('This will save this PDF file as ' + newFileName + '. Do you want to Continue?', 1, 2);"
+ "if(returnVal == 4) { "
+ " var aMyPath = this.path.split(\"/\");"
+ " aMyPath.pop();"
+ " aMyPath.push(newFileName);"
+ " this.saveAs(aMyPath.join(\"/\"));"
+ " this.saveAs({cPath:cMyPath, bPromptToOverwrite:true});"
+ " app.alert('File Saved.', 1);"
+ "} ";
addCell_WithPushButtonField( tableButton, writer, PdfDataEntryFormUtil.getPdfPCell( buttonHeight, PdfDataEntryFormUtil.CELL_COLUMN_TYPE_ENTRYFIELD, hasBorder ), name, jsAction );
document.add( tableButton );
}
示例11: createTableOfDistributionItems
import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
/**
* Create table with distribution items.
*
* @param paragraph
* @param distributionItems
*/
private void createTableOfDistributionItems(Paragraph paragraph, List<DistributionItem> distributionItems)
{
PdfPTable table = new PdfPTable(3);
table.setHorizontalAlignment(Element.ALIGN_LEFT);
table.setWidthPercentage(50f);
PdfPCell c1 = new PdfPCell(new Phrase("Name", tableFontBold));
table.addCell(c1);
c1 = new PdfPCell(new Phrase("Abteilung", tableFontBold));
table.addCell(c1);
c1 = new PdfPCell(new Phrase("Phone", tableFontBold));
table.addCell(c1);
table.setHeaderRows(1);
for (DistributionItem distributionItem : distributionItems)
{
table.addCell(new PdfPCell(new Phrase(distributionItem.getName(), tableFont)));
table.addCell(new PdfPCell(new Phrase(distributionItem.getDepartment(), tableFont)));
table.addCell(new PdfPCell(new Phrase(distributionItem.getPhone(), tableFont)));
}
paragraph.add(table);
}
示例12: createPdfPTable
import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
/**
* Creates a PdfPTable object based on this TableAttributes object.
* @return a com.lowagie.text.pdf.PdfPTable object
* @throws DocumentException
*/
public PdfPTable createPdfPTable() throws DocumentException {
if (content.isEmpty()) throw new BadElementException("Trying to create a table without rows.");
SimpleCell row = (SimpleCell)content.get(0);
SimpleCell cell;
int columns = 0;
for (Iterator i = row.getContent().iterator(); i.hasNext(); ) {
cell = (SimpleCell)i.next();
columns += cell.getColspan();
}
float[] widths = new float[columns];
float[] widthpercentages = new float[columns];
PdfPTable table = new PdfPTable(columns);
table.setTableEvent(this);
table.setHorizontalAlignment(alignment);
int pos;
for (Iterator rows = content.iterator(); rows.hasNext(); ) {
row = (SimpleCell)rows.next();
pos = 0;
for (Iterator cells = row.getContent().iterator(); cells.hasNext(); ) {
cell = (SimpleCell)cells.next();
if (Float.isNaN(cell.getSpacing_left())) {
cell.setSpacing_left(cellspacing / 2f);
}
if (Float.isNaN(cell.getSpacing_right())) {
cell.setSpacing_right(cellspacing / 2f);
}
if (Float.isNaN(cell.getSpacing_top())) {
cell.setSpacing_top(cellspacing / 2f);
}
if (Float.isNaN(cell.getSpacing_bottom())) {
cell.setSpacing_bottom(cellspacing / 2f);
}
cell.setPadding(cellpadding);
table.addCell(cell.createPdfPCell(row));
if (cell.getColspan() == 1) {
if (cell.getWidth() > 0) widths[pos] = cell.getWidth();
if (cell.getWidthpercentage() > 0) widthpercentages[pos] = cell.getWidthpercentage();
}
pos += cell.getColspan();
}
}
float sumWidths = 0f;
for(int i = 0; i < columns; i++) {
if (widths[i] == 0) {
sumWidths = 0;
break;
}
sumWidths += widths[i];
}
if (sumWidths > 0) {
table.setTotalWidth(sumWidths);
table.setWidths(widths);
}
else {
for(int i = 0; i < columns; i++) {
if (widthpercentages[i] == 0) {
sumWidths = 0;
break;
}
sumWidths += widthpercentages[i];
}
if (sumWidths > 0) {
table.setWidths(widthpercentages);
}
}
if (width > 0) {
table.setTotalWidth(width);
}
if (widthpercentage > 0) {
table.setWidthPercentage(widthpercentage);
}
return table;
}
示例13: setMainTable
import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
private void setMainTable( PdfPTable mainTable )
{
mainTable.setWidthPercentage( 100.0f );
mainTable.setHorizontalAlignment( Element.ALIGN_LEFT );
}
示例14: insertTable_DataSetSections
import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
private void insertTable_DataSetSections( PdfPTable mainTable, PdfWriter writer, Rectangle rectangle,
Collection<DataElement> dataElements, String sectionName )
throws IOException, DocumentException
{
boolean hasBorder = true;
// Add Section Name and Section Spacing
insertTable_TextRow( writer, mainTable, TEXT_BLANK );
if ( sectionName != null && !sectionName.isEmpty() )
{
insertTable_TextRow( writer, mainTable, sectionName,
pdfFormFontSettings.getFont( PdfFormFontSettings.FONTTYPE_SECTIONHEADER ) );
}
// Create A Table To Add For Each Section
PdfPTable table = new PdfPTable( 2 );
table.setWidths( new int[]{ 2, 1 } );
table.setWidthPercentage( 100.0f );
table.setHorizontalAlignment( Element.ALIGN_LEFT );
// For each DataElement and Category Combo of the dataElement, create
// row.
for ( DataElement dataElement : dataElements )
{
for ( DataElementCategoryOptionCombo categoryOptionCombo : dataElement.getSortedCategoryOptionCombos() )
{
String categoryOptionComboDisplayName = "";
// Hide Default category option combo name
if ( !categoryOptionCombo.isDefault() )
{
categoryOptionComboDisplayName = categoryOptionCombo.getDisplayName();
}
addCell_Text( table, PdfDataEntryFormUtil.getPdfPCell( hasBorder ), dataElement.getFormNameFallback() + " " +
categoryOptionComboDisplayName, Element.ALIGN_RIGHT );
String strFieldLabel = PdfDataEntryFormUtil.LABELCODE_DATAENTRYTEXTFIELD + dataElement.getUid() + "_"
+ categoryOptionCombo.getUid();
ValueType valueType = dataElement.getValueType();
// Yes Only case - render as check-box
if ( ValueType.TRUE_ONLY == valueType )
{
addCell_WithCheckBox( table, writer, PdfDataEntryFormUtil.getPdfPCell( hasBorder ), strFieldLabel );
}
else if ( ValueType.BOOLEAN == valueType )
{
// Create Yes - true, No - false, Select..
String[] optionList = new String[]{ "[No Value]", "Yes", "No" };
String[] valueList = new String[]{ "", "true", "false" };
// addCell_WithRadioButton(table, writer, strFieldLabel);
addCell_WithDropDownListField( table, rectangle, writer, PdfDataEntryFormUtil.getPdfPCell( hasBorder ), strFieldLabel, optionList, valueList );
}
else if ( valueType.isNumeric() )
{
Rectangle rectNum = new Rectangle( TEXTBOXWIDTH_NUMBERTYPE, PdfDataEntryFormUtil.CONTENT_HEIGHT_DEFAULT );
addCell_WithTextField( table, rectNum, writer, PdfDataEntryFormUtil.getPdfPCell( hasBorder ), strFieldLabel, PdfFieldCell.TYPE_TEXT_NUMBER );
}
else
{
addCell_WithTextField( table, rectangle, writer, PdfDataEntryFormUtil.getPdfPCell( hasBorder ), strFieldLabel );
}
}
}
PdfPCell cell_withInnerTable = new PdfPCell( table );
cell_withInnerTable.setBorder( Rectangle.NO_BORDER );
mainTable.addCell( cell_withInnerTable );
}
示例15: insertTable_DataSetSections
import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
private void insertTable_DataSetSections( PdfPTable mainTable, PdfWriter writer, Rectangle rectangle,
Collection<DataElement> dataElements, String sectionName )
throws IOException, DocumentException
{
boolean hasBorder = true;
// Add Section Name and Section Spacing
insertTable_TextRow( writer, mainTable, TEXT_BLANK );
if ( sectionName != null && !sectionName.isEmpty() )
{
insertTable_TextRow( writer, mainTable, sectionName,
pdfFormFontSettings.getFont( PdfFormFontSettings.FONTTYPE_SECTIONHEADER ) );
}
// Create A Table To Add For Each Section
PdfPTable table = new PdfPTable( 2 );
table.setWidths( new int[]{ 2, 1 } );
table.setWidthPercentage( 100.0f );
table.setHorizontalAlignment( Element.ALIGN_LEFT );
// For each DataElement and Category Combo of the dataElement, create
// row.
for ( DataElement dataElement : dataElements )
{
for ( DataElementCategoryOptionCombo categoryOptionCombo : dataElement.getCategoryCombo().getSortedOptionCombos() )
{
String categoryOptionComboDisplayName = "";
// Hide Default category option combo name
if ( !categoryOptionCombo.isDefault() )
{
categoryOptionComboDisplayName = categoryOptionCombo.getDisplayName();
}
addCell_Text( table, PdfDataEntryFormUtil.getPdfPCell( hasBorder ), dataElement.getFormNameFallback() + " " +
categoryOptionComboDisplayName, Element.ALIGN_RIGHT );
String strFieldLabel = PdfDataEntryFormUtil.LABELCODE_DATAENTRYTEXTFIELD + dataElement.getUid() + "_"
+ categoryOptionCombo.getUid();
ValueType valueType = dataElement.getValueType();
// Yes Only case - render as check-box
if ( ValueType.TRUE_ONLY == valueType )
{
addCell_WithCheckBox( table, writer, PdfDataEntryFormUtil.getPdfPCell( hasBorder ), strFieldLabel );
}
else if ( ValueType.BOOLEAN == valueType )
{
// Create Yes - true, No - false, Select..
String[] optionList = new String[]{ "[No Value]", "Yes", "No" };
String[] valueList = new String[]{ "", "true", "false" };
// addCell_WithRadioButton(table, writer, strFieldLabel);
addCell_WithDropDownListField( table, rectangle, writer, PdfDataEntryFormUtil.getPdfPCell( hasBorder ), strFieldLabel, optionList, valueList );
}
else if ( valueType.isNumeric() )
{
Rectangle rectNum = new Rectangle( TEXTBOXWIDTH_NUMBERTYPE, PdfDataEntryFormUtil.CONTENT_HEIGHT_DEFAULT );
addCell_WithTextField( table, rectNum, writer, PdfDataEntryFormUtil.getPdfPCell( hasBorder ), strFieldLabel, PdfFieldCell.TYPE_TEXT_NUMBER );
}
else
{
addCell_WithTextField( table, rectangle, writer, PdfDataEntryFormUtil.getPdfPCell( hasBorder ), strFieldLabel );
}
}
}
PdfPCell cell_withInnerTable = new PdfPCell( table );
cell_withInnerTable.setBorder( Rectangle.NO_BORDER );
mainTable.addCell( cell_withInnerTable );
}