当前位置: 首页>>代码示例>>Java>>正文


Java PdfPTable.setWidths方法代码示例

本文整理汇总了Java中com.lowagie.text.pdf.PdfPTable.setWidths方法的典型用法代码示例。如果您正苦于以下问题:Java PdfPTable.setWidths方法的具体用法?Java PdfPTable.setWidths怎么用?Java PdfPTable.setWidths使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.lowagie.text.pdf.PdfPTable的用法示例。


在下文中一共展示了PdfPTable.setWidths方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createNeedHeader

import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
private PdfPTable createNeedHeader(String name) throws DocumentException {
	Font whiteFont = new Font(Font.HELVETICA,14,Font.BOLD,Color.WHITE);
	PdfPTable table = new PdfPTable(3);
	table.setWidthPercentage(100);
	table.setWidths(new float[]{0.10f,0.20f,0.70f});
	PdfPCell emptyCell = new PdfPCell();
	emptyCell.setBorder(0);
	table.addCell(emptyCell);

	PdfPCell headerCell = new PdfPCell();
	headerCell.setColspan(2);
	headerCell.setPhrase(new Phrase(name,whiteFont));
	headerCell.setHorizontalAlignment(Element.ALIGN_CENTER);
	headerCell.setBackgroundColor(Color.LIGHT_GRAY);
	table.addCell(headerCell);
	return table;
}
 
开发者ID:williamgrosset,项目名称:OSCAR-ConCert,代码行数:18,代码来源:SummaryOfActionsAndCommentsReportGenerator.java

示例2: main

import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
/**
 * Width manipulations of cells.
 * 
 */
@Test
public void main() throws Exception {
	// step1
	Document document = new Document(PageSize.A4, 36, 36, 36, 36);
	// step2
	PdfWriter.getInstance(document, PdfTestBase.getOutputStream("CellWidths.pdf"));
	// step3
	document.open();
	// step4
	float[] widths = { 0.1f, 0.1f, 0.05f, 0.75f };
	PdfPTable table = new PdfPTable(widths);
	table.addCell("10%");
	table.addCell("10%");
	table.addCell("5%");
	table.addCell("75%");
	table.addCell("aa");
	table.addCell("aa");
	table.addCell("a");
	table.addCell("aaaaaaaaaaaaaaa");
	table.addCell("bb");
	table.addCell("bb");
	table.addCell("b");
	table.addCell("bbbbbbbbbbbbbbb");
	table.addCell("cc");
	table.addCell("cc");
	table.addCell("c");
	table.addCell("ccccccccccccccc");
	document.add(table);
	document.add(new Paragraph("We change the percentages:\n\n"));
	widths[0] = 20f;
	widths[1] = 20f;
	widths[2] = 10f;
	widths[3] = 50f;
	table.setWidths(widths);
	document.add(table);
	widths[0] = 40f;
	widths[1] = 40f;
	widths[2] = 20f;
	widths[3] = 300f;
	Rectangle r = new Rectangle(PageSize.A4.getRight(72), PageSize.A4.getTop(72));
	table.setWidthPercentage(widths, r);
	document.add(new Paragraph("We change the percentage using absolute widths:\n\n"));
	document.add(table);
	document.add(new Paragraph("We use a locked width:\n\n"));
	table.setTotalWidth(300);
	table.setLockedWidth(true);
	document.add(table);

	// step5
	document.close();
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:56,代码来源:CellWidthsTest.java

示例3: 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 );
}
 
开发者ID:dhis2,项目名称:dhis2-core,代码行数:36,代码来源:DefaultPdfDataEntryFormService.java

示例4: 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;
}
 
开发者ID:javamelody,项目名称:javamelody,代码行数:9,代码来源:PdfJavaInformationsReport.java

示例5: writeHeader

import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
private void writeHeader() throws DocumentException {
	final List<String> headers = new ArrayList<String>();
	headers.add("Beans");
	headers.addAll(calledBeans);
	final int[] relativeWidths = new int[headers.size()];
	Arrays.fill(relativeWidths, 0, headers.size(), 1);
	relativeWidths[0] = 4;

	final PdfPTable table = new PdfPTable(headers.size());
	table.setWidthPercentage(100);
	table.setWidths(relativeWidths);
	table.setHeaderRows(1);
	final PdfPCell defaultCell = table.getDefaultCell();
	defaultCell.setGrayFill(0.9f);
	defaultCell.setHorizontalAlignment(Element.ALIGN_CENTER);
	defaultCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
	defaultCell.setPaddingLeft(0);
	defaultCell.setPaddingRight(0);
	for (final String header : headers) {
		table.addCell(new Phrase(header, boldCellFont));
		// pas la première entête de colonne
		defaultCell.setRotation(90);
	}
	defaultCell.setRotation(0);
	defaultCell.setPaddingLeft(2);
	defaultCell.setPaddingRight(2);
	currentTable = table;
}
 
开发者ID:javamelody,项目名称:javamelody,代码行数:29,代码来源:PdfRuntimeDependenciesReport.java

示例6: onEndPage

import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
/**
 * Writes the footer on the last page
 * 
 * @see com.lowagie.text.pdf.PdfPageEventHelper#onEndPage(com.lowagie.text.pdf.PdfWriter, com.lowagie.text.Document)
 */
public void onEndPage(PdfWriter writer, Document document) {
    try {
        Font titleFont = FontFactory.getFont(FontFactory.HELVETICA, 12, Font.NORMAL);
        Font font = FontFactory.getFont(FontFactory.HELVETICA, 8, Font.NORMAL);

        Rectangle page = document.getPageSize();
        PdfPTable head = new PdfPTable(3);

        int[] widths = { 15, 70, 15 };
        head.setWidths(widths);

        SimpleDateFormat sdf = new SimpleDateFormat(CamsConstants.DateFormats.MONTH_DAY_YEAR + " " + CamsConstants.DateFormats.MILITARY_TIME);

        PdfPCell cell = new PdfPCell(new Phrase(sdf.format(runDate), font));
        cell.setBorder(Rectangle.NO_BORDER);
        head.addCell(cell);

        cell = new PdfPCell(new Phrase(title, titleFont));
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        head.addCell(cell);

        cell = new PdfPCell(new Phrase("Page: " + new Integer(writer.getPageNumber()), font));
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
        head.addCell(cell);

        head.setTotalWidth(page.width() - document.leftMargin() - document.rightMargin());
        head.writeSelectedRows(0, -1, document.leftMargin(), page.height() - document.topMargin() + head.getTotalHeight(), writer.getDirectContent());
    }
    catch (Exception e) {
        throw new ExceptionConverter(e);
    }
}
 
开发者ID:kuali,项目名称:kfs,代码行数:40,代码来源:DepreciationReport.java

示例7: main

import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
/**
	 * Generates a StudentCard
	 * 
	 * @param args
	 *            no arguments needed here
	 */
	public static void main(String[] args) {

		System.out.println("StudentCard");

		// step 1: creation of a document-object
		Rectangle rect = new Rectangle(243, 153);
		rect.setBackgroundColor(new Color(0xFF, 0xFF, 0xCC));
		Document document = new Document(rect, 10, 10, 10, 10);

		try {

			// step 2:
			PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(android.os.Environment.getExternalStorageDirectory() + java.io.File.separator + "droidtext" + java.io.File.separator + "studentcard.pdf"));

			// step 3: we open the document
			document.open();

			// step 4:
			Font font = FontFactory.getFont(FontFactory.HELVETICA, 14, Font.BOLD, Color.BLUE);
			Paragraph p = new Paragraph("Ghent University", font);
			p.setAlignment(Element.ALIGN_CENTER);
			document.add(p);
			PdfContentByte cb = writer.getDirectContent();
			Font f = FontFactory.getFont(FontFactory.HELVETICA, 8);
			PdfPTable outertable = new PdfPTable(3);
			outertable.setTotalWidth(200);
			outertable.getDefaultCell().setBorder(Rectangle.NO_BORDER);
			float[] outer = { 60, 25, 15 };
			outertable.setWidths(outer);
			PdfPTable innertable = new PdfPTable(2);
			float[] inner = { 35, 65 };
			innertable.setWidths(inner);
			innertable.addCell(new Paragraph("name:", f));
			innertable.addCell(new Paragraph("Bruno Lowagie", f));
			innertable.addCell(new Paragraph("date of birth:", f));
			innertable.addCell(new Paragraph("June 10th, 1970", f));
			innertable.addCell(new Paragraph("Study Program:", f));
			innertable.addCell(new Paragraph("master in civil engineering", f));
			innertable.addCell(new Paragraph("option:", f));
			innertable.addCell(new Paragraph("architecture", f));
			outertable.addCell(innertable);
			outertable.getDefaultCell().setBackgroundColor(new Color(0xFF, 0xDE, 0xAD));
//			outertable.addCell(Image.getInstance("bruno.jpg"));
			ByteArrayOutputStream stream = new ByteArrayOutputStream();
			Bitmap bitmap = BitmapFactory.decodeResource(PdfTestRunner.getActivity().getResources(), R.drawable.bruno);
			bitmap.compress(Bitmap.CompressFormat.JPEG /* FileType */,
			                        100 /* Ratio */, stream);
			Image img = Image.getInstance(stream.toByteArray());
			outertable.addCell(img);
			BarcodeEAN codeEAN = new BarcodeEAN();
			codeEAN.setCodeType(Barcode.EAN13);
			codeEAN.setCode("8010012529736");
			Image imageEAN = codeEAN.createImageWithBarcode(cb, null, null);
			imageEAN.setRotationDegrees(90);
			outertable.getDefaultCell().setBackgroundColor(Color.WHITE);
			outertable.addCell(imageEAN);
			outertable.writeSelectedRows(0, -1, 20, 100, writer.getDirectContent());
		} catch (DocumentException de) {
			System.err.println(de.getMessage());
		} catch (IOException ioe) {
			System.err.println(ioe.getMessage());
		}

		// step 5: we close the document
		document.close();
	}
 
开发者ID:fc-dream,项目名称:PDFTestForAndroid,代码行数:73,代码来源:StudentCard.java

示例8: 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;
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:79,代码来源:SimpleTable.java

示例9: main

import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
/**
 * Generates a StudentCard
 */
@Test
public void main() throws Exception {

	// step 1: creation of a document-object
	Rectangle rect = new Rectangle(243, 153);
	rect.setBackgroundColor(new Color(0xFF, 0xFF, 0xCC));
	Document document = new Document(rect, 10, 10, 10, 10);

	// step 2:
	PdfWriter writer = PdfWriter.getInstance(document, PdfTestBase.getOutputStream("studentcard.pdf"));

	// step 3: we open the document
	document.open();

	// step 4:
	Font font = FontFactory.getFont(FontFactory.HELVETICA, 14, Font.BOLD, Color.BLUE);
	Paragraph p = new Paragraph("Ghent University", font);
	p.setAlignment(Element.ALIGN_CENTER);
	document.add(p);
	PdfContentByte cb = writer.getDirectContent();
	Font f = FontFactory.getFont(FontFactory.HELVETICA, 8);
	PdfPTable outertable = new PdfPTable(3);
	outertable.setTotalWidth(200);
	outertable.getDefaultCell().setBorder(Rectangle.NO_BORDER);
	float[] outer = { 60, 25, 15 };
	outertable.setWidths(outer);
	PdfPTable innertable = new PdfPTable(2);
	float[] inner = { 35, 65 };
	innertable.setWidths(inner);
	innertable.addCell(new Paragraph("name:", f));
	innertable.addCell(new Paragraph("Bruno Lowagie", f));
	innertable.addCell(new Paragraph("date of birth:", f));
	innertable.addCell(new Paragraph("June 10th, 1970", f));
	innertable.addCell(new Paragraph("Study Program:", f));
	innertable.addCell(new Paragraph("master in civil engineering", f));
	innertable.addCell(new Paragraph("option:", f));
	innertable.addCell(new Paragraph("architecture", f));
	outertable.addCell(innertable);
	outertable.getDefaultCell().setBackgroundColor(new Color(0xFF, 0xDE, 0xAD));
	outertable.addCell(Image.getInstance(PdfTestBase.RESOURCES_DIR + "bruno.jpg"));
	BarcodeEAN codeEAN = new BarcodeEAN();
	codeEAN.setCodeType(Barcode.EAN13);
	codeEAN.setCode("8010012529736");
	Image imageEAN = codeEAN.createImageWithBarcode(cb, null, null);
	imageEAN.setRotationDegrees(90);
	outertable.getDefaultCell().setBackgroundColor(Color.WHITE);
	outertable.addCell(imageEAN);
	outertable.writeSelectedRows(0, -1, 20, 100, writer.getDirectContent());

	// step 5: we close the document
	document.close();
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:56,代码来源:StudentCardTest.java

示例10: main

import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
/**
 * Big PdfPTable with document.add().
 * 
 */
@Test
public void main() throws Exception {

	// step1
	Document document = new Document(PageSize.A4.rotate(), 10, 10, 10, 10);
	// step2
	PdfWriter.getInstance(document, PdfTestBase.getOutputStream("AddBigTable.pdf"));
	// step3
	document.open();
	// step4
	String[] bogusData = { "M0065920", "SL", "FR86000P", "PCGOLD", "119000", "96 06", "2001-08-13", "4350",
			"6011648299", "FLFLMTGP", "153", "119000.00" };
	int NumColumns = 12;

	PdfPTable datatable = new PdfPTable(NumColumns);
	int headerwidths[] = { 9, 4, 8, 10, 8, 11, 9, 7, 9, 10, 4, 10 }; // percentage
	datatable.setWidths(headerwidths);
	datatable.setWidthPercentage(100); // percentage
	datatable.getDefaultCell().setPadding(3);
	datatable.getDefaultCell().setBorderWidth(2);
	datatable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
	datatable.addCell("Clock #");
	datatable.addCell("Trans Type");
	datatable.addCell("Cusip");
	datatable.addCell("Long Name");
	datatable.addCell("Quantity");
	datatable.addCell("Fraction Price");
	datatable.addCell("Settle Date");
	datatable.addCell("Portfolio");
	datatable.addCell("ADP Number");
	datatable.addCell("Account ID");
	datatable.addCell("Reg Rep ID");
	datatable.addCell("Amt To Go ");

	datatable.setHeaderRows(1); // this is the end of the table header

	datatable.getDefaultCell().setBorderWidth(1);
	for (int i = 1; i < 750; i++) {
		if (i % 2 == 1) {
			datatable.getDefaultCell().setGrayFill(0.9f);
		}
		for (int x = 0; x < NumColumns; x++) {
			datatable.addCell(bogusData[x]);
		}
		if (i % 2 == 1) {
			datatable.getDefaultCell().setGrayFill(1);
		}
	}
	document.add(datatable);

	// step5
	document.close();
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:58,代码来源:AddBigTableTest.java

示例11: 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 );
}
 
开发者ID:dhis2,项目名称:dhis2-core,代码行数:78,代码来源:DefaultPdfDataEntryFormService.java

示例12: 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 );
}
 
开发者ID:ehatle,项目名称:AgileAlligators,代码行数:78,代码来源:DefaultPdfDataEntryFormService.java

示例13: main

import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
/**
 * Width manipulations of cells.
 * 
 * @param args
 *            no arguments needed
 */
public static void main(String[] args) {

	System.out.println("Width");
	// step1
	Document document = new Document(PageSize.A4, 36, 36, 36, 36);
	try {
		// step2
		PdfWriter.getInstance(document, new FileOutputStream(android.os.Environment.getExternalStorageDirectory() + java.io.File.separator + "droidtext" + java.io.File.separator + "CellWidths.pdf"));
		// step3
		document.open();
		// step4
		float[] widths = { 0.1f, 0.1f, 0.05f, 0.75f };
		PdfPTable table = new PdfPTable(widths);
		table.addCell("10%");
		table.addCell("10%");
		table.addCell("5%");
		table.addCell("75%");
		table.addCell("aa");
		table.addCell("aa");
		table.addCell("a");
		table.addCell("aaaaaaaaaaaaaaa");
		table.addCell("bb");
		table.addCell("bb");
		table.addCell("b");
		table.addCell("bbbbbbbbbbbbbbb");
		table.addCell("cc");
		table.addCell("cc");
		table.addCell("c");
		table.addCell("ccccccccccccccc");
		document.add(table);
		document.add(new Paragraph("We change the percentages:\n\n"));
		widths[0] = 20f;
		widths[1] = 20f;
		widths[2] = 10f;
		widths[3] = 50f;
		table.setWidths(widths);
		document.add(table);
		widths[0] = 40f;
		widths[1] = 40f;
		widths[2] = 20f;
		widths[3] = 300f;
		Rectangle r = new Rectangle(PageSize.A4.getRight(72), PageSize.A4.getTop(72));
		table.setWidthPercentage(widths, r);
		document.add(new Paragraph("We change the percentage using absolute widths:\n\n"));
		document.add(table);
		document.add(new Paragraph("We use a locked width:\n\n"));
		table.setTotalWidth(300);
		table.setLockedWidth(true);
		document.add(table);
	} catch (Exception de) {
		de.printStackTrace();
	}
	// step5
	document.close();
}
 
开发者ID:fc-dream,项目名称:PDFTestForAndroid,代码行数:62,代码来源:CellWidths.java

示例14: main

import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
/**
 * Big PdfPTable with document.add().
 * 
 * @param args
 *            no arguments needed
 */
public static void main(String[] args) {

	System.out.println("document.add(BigTable)");
	// step1
	Document document = new Document(PageSize.A4.rotate(), 10, 10, 10, 10);
	try {
		// step2
		PdfWriter.getInstance(document, new FileOutputStream(android.os.Environment.getExternalStorageDirectory() + java.io.File.separator + "droidtext" + java.io.File.separator + "AddBigTable.pdf"));
		// step3
		document.open();
		// step4
		String[] bogusData = { "M0065920", "SL", "FR86000P", "PCGOLD", "119000", "96 06", "2001-08-13", "4350",
				"6011648299", "FLFLMTGP", "153", "119000.00" };
		int NumColumns = 12;

		PdfPTable datatable = new PdfPTable(NumColumns);
		int headerwidths[] = { 9, 4, 8, 10, 8, 11, 9, 7, 9, 10, 4, 10 }; // percentage
		datatable.setWidths(headerwidths);
		datatable.setWidthPercentage(100); // percentage
		datatable.getDefaultCell().setPadding(3);
		datatable.getDefaultCell().setBorderWidth(2);
		datatable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
		datatable.addCell("Clock #");
		datatable.addCell("Trans Type");
		datatable.addCell("Cusip");
		datatable.addCell("Long Name");
		datatable.addCell("Quantity");
		datatable.addCell("Fraction Price");
		datatable.addCell("Settle Date");
		datatable.addCell("Portfolio");
		datatable.addCell("ADP Number");
		datatable.addCell("Account ID");
		datatable.addCell("Reg Rep ID");
		datatable.addCell("Amt To Go ");

		datatable.setHeaderRows(1); // this is the end of the table header

		datatable.getDefaultCell().setBorderWidth(1);
		for (int i = 1; i < 750; i++) {
			if (i % 2 == 1) {
				datatable.getDefaultCell().setGrayFill(0.9f);
			}
			for (int x = 0; x < NumColumns; x++) {
				datatable.addCell(bogusData[x]);
			}
			if (i % 2 == 1) {
				datatable.getDefaultCell().setGrayFill(1);
			}
		}
		document.add(datatable);
	} catch (Exception de) {
		de.printStackTrace();
	}
	// step5
	document.close();
}
 
开发者ID:fc-dream,项目名称:PDFTestForAndroid,代码行数:63,代码来源:AddBigTable.java

示例15: getEmployeeDetails

import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
public PdfPCell getEmployeeDetails(User user, Empprofile empprofile, Useraccount useraccount, Company company, PayrollHistory payrollHistory, DateFormat sdf, int border, HttpServletRequest request){
	PdfPTable mainTable = new PdfPTable(3);
	PdfPCell mainCell = null;
	try{
		int paddingTop = 4;
		int paddingBottom = 4;
		mainTable.setWidths(new float[]{48, 4, 48});
           String empIdName = getUserCode(useraccount.getEmployeeid(), useraccount.getUserID(), company.getCompanyID())+" "+profileHandlerDAOObj.getUserFullName(user.getUserID());
           String costCenter = payrollHistory.getCostCenter()!=null?payrollHistory.getCostCenter().getName():" ";
           String passport = " ";
           if(empprofile!=null && empprofile.getPassportno()!=null){
               passport = empprofile.getPassportno();
           }
           String period = sdf.format(payrollHistory.getPaycyclestartdate())+" to "+sdf.format(payrollHistory.getPaycycleenddate());
           
           PdfPTable leftTable = new PdfPTable(2);
           leftTable.setWidths(new float[]{40, 60});
   		PdfPCell leftCell = null;
   		leftTable.addCell(getPdfPCellInstance(messageSource.getMessage("hrms.common.company.name", null, RequestContextUtils.getLocale(request)), FontContext.REGULAR_BOLD_TIMES_NEW_ROMAN, Element.ALIGN_LEFT, Element.ALIGN_CENTER, paddingTop, paddingBottom, border));
   		leftTable.addCell(getPdfPCellInstance(company.getCompanyName(), FontContext.REGULAR_NORMAL_TIMES_NEW_ROMAN, Element.ALIGN_LEFT, Element.ALIGN_CENTER, paddingTop, paddingBottom, border));
   		leftTable.addCell(getPdfPCellInstance(messageSource.getMessage("hrms.common.employee.id", null, RequestContextUtils.getLocale(request))+"/"+messageSource.getMessage("hrms.common.name", null, RequestContextUtils.getLocale(request)), FontContext.REGULAR_BOLD_TIMES_NEW_ROMAN, Element.ALIGN_LEFT, Element.ALIGN_CENTER, paddingTop, paddingBottom, border));
   		leftTable.addCell(getPdfPCellInstance(empIdName, FontContext.REGULAR_NORMAL_TIMES_NEW_ROMAN, Element.ALIGN_LEFT, Element.ALIGN_CENTER, paddingTop, paddingBottom, border));
   		leftTable.addCell(getPdfPCellInstance(messageSource.getMessage("hrms.common.nric", null, RequestContextUtils.getLocale(request))+"/"+messageSource.getMessage("hrms.common.passport", null, RequestContextUtils.getLocale(request)), FontContext.REGULAR_BOLD_TIMES_NEW_ROMAN, Element.ALIGN_LEFT, Element.ALIGN_CENTER, paddingTop, paddingBottom, border));
   		leftTable.addCell(getPdfPCellInstance(passport, FontContext.REGULAR_NORMAL_TIMES_NEW_ROMAN, Element.ALIGN_LEFT, Element.ALIGN_CENTER, paddingTop, paddingBottom, border));
   		leftCell = new PdfPCell(leftTable);
   		leftCell.setBorder(border);
           mainTable.addCell(leftCell);
           

           PdfPCell centerCell = new PdfPCell();
           centerCell.setBorder(border);
           mainTable.addCell(centerCell);

           
           PdfPTable rigthTable = new PdfPTable(2);
           rigthTable.setWidths(new float[]{40, 60});
   		PdfPCell rigthCell = null;
   		rigthTable.addCell(getPdfPCellInstance(messageSource.getMessage("hrms.common.payment.period", null, RequestContextUtils.getLocale(request)), FontContext.REGULAR_BOLD_TIMES_NEW_ROMAN, Element.ALIGN_LEFT, Element.ALIGN_CENTER, paddingTop, paddingBottom, border));
   		rigthTable.addCell(getPdfPCellInstance(period, FontContext.REGULAR_NORMAL_TIMES_NEW_ROMAN, Element.ALIGN_LEFT, Element.ALIGN_CENTER, paddingTop, paddingBottom, border));
   		rigthTable.addCell(getPdfPCellInstance(" ", FontContext.REGULAR_BOLD_TIMES_NEW_ROMAN, Element.ALIGN_LEFT, Element.ALIGN_CENTER, paddingTop, paddingBottom, border));
   		rigthTable.addCell(getPdfPCellInstance(" ", FontContext.REGULAR_NORMAL_TIMES_NEW_ROMAN, Element.ALIGN_LEFT, Element.ALIGN_CENTER, paddingTop, paddingBottom, border));
   		rigthTable.addCell(getPdfPCellInstance(messageSource.getMessage("hrms.common.costcenter", null, RequestContextUtils.getLocale(request)), FontContext.REGULAR_BOLD_TIMES_NEW_ROMAN, Element.ALIGN_LEFT, Element.ALIGN_CENTER, paddingTop, paddingBottom, border));
   		rigthTable.addCell(getPdfPCellInstance(costCenter, FontContext.REGULAR_NORMAL_TIMES_NEW_ROMAN, Element.ALIGN_LEFT, Element.ALIGN_CENTER, paddingTop, paddingBottom, border));
           rigthCell = new PdfPCell(rigthTable);
   		rigthCell.setBorder(border);
           mainTable.addCell(rigthCell);
           
           mainCell = new PdfPCell(mainTable);
           mainCell.setPaddingTop(15);
           mainCell.setBorder(border);
           mainCell.setPaddingBottom(20);
	}catch(Exception e){
		e.printStackTrace();
	}
	return mainCell;
}
 
开发者ID:mobilipia,项目名称:Deskera-HRMS,代码行数:57,代码来源:ExportSalarySlipService.java


注:本文中的com.lowagie.text.pdf.PdfPTable.setWidths方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。