當前位置: 首頁>>代碼示例>>Java>>正文


Java PdfPTable.setHeaderRows方法代碼示例

本文整理匯總了Java中com.itextpdf.text.pdf.PdfPTable.setHeaderRows方法的典型用法代碼示例。如果您正苦於以下問題:Java PdfPTable.setHeaderRows方法的具體用法?Java PdfPTable.setHeaderRows怎麽用?Java PdfPTable.setHeaderRows使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.itextpdf.text.pdf.PdfPTable的用法示例。


在下文中一共展示了PdfPTable.setHeaderRows方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createGridTable

import com.itextpdf.text.pdf.PdfPTable; //導入方法依賴的package包/類
protected PdfPTable createGridTable(ReportDataModel dataModel, boolean isRepeatHeader) throws Exception {
	PdfPTable table = new PdfPTable(calculateGridColumnCount(dataModel.getTopColumnHeaders()));
	table.setWidthPercentage(100);
	Collection<ColumnHeader> topHeaders = dataModel.getTopColumnHeaders();
	List<Integer> widths = new ArrayList<Integer>();
	generateGridColumnWidths(topHeaders, widths);
	int[] values = new int[widths.size()];
	for (int i = 0; i < widths.size(); i++) {
		values[i] = widths.get(i);
	}
	table.setWidths(values);
	int maxHeaderLevel = getGridMaxColumngroup(topHeaders);
	createGridColumnHeader(table, topHeaders, maxHeaderLevel);
	createGridTableDatas(table, dataModel.getReportData());
	if (isRepeatHeader) {
		table.setHeaderRows(maxHeaderLevel);
	}
	return table;
}
 
開發者ID:bsteker,項目名稱:bdf2,代碼行數:20,代碼來源:AbstractPdfReportBuilder.java

示例2: process

import com.itextpdf.text.pdf.PdfPTable; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
@Override
public void process(int level, Node node, InvocationContext context) {
    TreeNavigation nav = context.treeNavigation();
    boolean isHeaderRow = nav.ancestorTreeMatches(TableRowNode.class, TableHeaderNode.class);

    List<Element> elements = context.collectChildren(level, node);

    TableInfos tableInfos = context.peekTable();
    PdfPTable table = tableInfos.getTable();
    int col = 0;
    for (Element element : elements) {
        PdfPCell cell = (PdfPCell) element;
        cell.setHorizontalAlignment(tableInfos.columnAlignment(col));
        table.addCell(cell);

        col += cell.getColspan();
    }
    table.completeRow();

    if (isHeaderRow) {
        int headerRows = table.getHeaderRows();
        table.setHeaderRows(headerRows + 1);
    }

}
 
開發者ID:Arnauld,項目名稱:gutenberg,代碼行數:27,代碼來源:TableRowNodeProcessor.java

示例3: processRequest

import com.itextpdf.text.pdf.PdfPTable; //導入方法依賴的package包/類
/**
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");

    try (PrintWriter out = response.getWriter()) {

        //special font sizes
        //user for this entire page
        Font titleFont = new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.BOLD, new BaseColor(0, 0, 0));
        Font bodyFont = new Font(Font.FontFamily.TIMES_ROMAN, 10);

        //set document response type
        documentResponse(response);

        //generate new document. 
        Document doc = new Document();

        //add properties
        documentProperties(response, doc);

        //open document
        doc.open();

        //create title of report
        Paragraph title = new Paragraph("PDF in Java");

        //get the current date and time form the class
        CurrentDateTime date = new CurrentDateTime();
        
        //add header
        documentHeader(doc, date, title, response);

        //set number of columns and their widths, f is float
        float[] columnWidths = {2f, 3f, 3f, 3f};
        PdfPTable table = new PdfPTable(columnWidths);

        //set width and spacing of table, default width is 100f, f is float
        table.setWidthPercentage(90f);
        table.setSpacingBefore(10f);
        table.setSpacingBefore(10f);

        //set heading of table
        insertCell(table, "User Id", Element.ALIGN_CENTER, 1, titleFont);
        insertCell(table, "UserName", Element.ALIGN_CENTER, 1, titleFont);
        insertCell(table, "Address", Element.ALIGN_CENTER, 1, titleFont);
        insertCell(table, "Email", Element.ALIGN_CENTER, 1, titleFont);

        //add header row to the table, we can set more than one row
        table.setHeaderRows(1);

        //set body part of the table
        insertCell(table, "1", Element.ALIGN_CENTER, 1, bodyFont);
        insertCell(table, "budthapa", Element.ALIGN_CENTER, 1, bodyFont);
        insertCell(table, "Kathmandu", Element.ALIGN_CENTER, 1, bodyFont);
        insertCell(table, "[email protected]", Element.ALIGN_CENTER, 1, bodyFont);
        
        //add document footer
        //this footer adds above table in the paragraph
        documentFooter(doc, table);

        //close the document
        doc.close();
    } catch (Exception e) {
        //exception here
    }
}
 
開發者ID:budthapa,項目名稱:Create-PDF-in-Java-,代碼行數:74,代碼來源:createPDF.java

示例4: createHeader

import com.itextpdf.text.pdf.PdfPTable; //導入方法依賴的package包/類
private void createHeader(final PdfPTable table,
                          final String challengeTitle,
                          final String catTitle,
                          final String division,
                          final String judgingGroup,
                          final Tournament tournament)
    throws BadElementException {
  final PdfPCell tournamentCell = PdfUtils.createHeaderCell(String.format("%s - %s", challengeTitle,
                                                                          tournament.getDescription()));
  tournamentCell.setColspan(4);
  table.addCell(tournamentCell);

  final PdfPCell categoryHeader = PdfUtils.createHeaderCell(String.format("Category: %s - Award Group: %s - JudgingGroup: %s",
                                                                          catTitle, division, judgingGroup));
  categoryHeader.setColspan(4);
  table.addCell(categoryHeader);

  table.addCell(PdfUtils.createHeaderCell(TournamentSchedule.TEAM_NUMBER_HEADER));
  table.addCell(PdfUtils.createHeaderCell(TournamentSchedule.TEAM_NAME_HEADER));
  table.addCell(PdfUtils.createHeaderCell(TournamentSchedule.ORGANIZATION_HEADER));
  table.addCell(PdfUtils.createHeaderCell("Scaled Score"));

  table.setHeaderRows(3);
}
 
開發者ID:jpschewe,項目名稱:fll-sw,代碼行數:25,代碼來源:CategoryScoresByScoreGroup.java

示例5: writeHeader

import com.itextpdf.text.pdf.PdfPTable; //導入方法依賴的package包/類
private void writeHeader(PdfPTable datatable) {
    if (bean.getReportLayout().isHeaderOnEveryPage()) {
        int headerNo = bean.getReportLayout().getHeaderBand().getRowCount();
        if (headerNo > 0) {
            datatable.setHeaderRows(headerNo);
        }
    }
}
 
開發者ID:nextreports,項目名稱:nextreports-engine,代碼行數:9,代碼來源:PdfExporter.java

示例6: outputSubjectiveScheduleByDivision

import com.itextpdf.text.pdf.PdfPTable; //導入方法依賴的package包/類
private void outputSubjectiveScheduleByDivision(final Document detailedSchedules,
                                                final String subjectiveStation)
    throws DocumentException {
  final PdfPTable table = PdfUtils.createTable(6);
  table.setWidths(new float[] { 2, 1, 3, 3, 2, 2 });

  final PdfPCell tournamentCell = PdfUtils.createHeaderCell("Tournament: "
      + getName()
      + " - "
      + subjectiveStation);
  tournamentCell.setColspan(6);
  table.addCell(tournamentCell);

  table.addCell(PdfUtils.createHeaderCell(TEAM_NUMBER_HEADER));
  table.addCell(PdfUtils.createHeaderCell(AWARD_GROUP_HEADER));
  table.addCell(PdfUtils.createHeaderCell(ORGANIZATION_HEADER));
  table.addCell(PdfUtils.createHeaderCell(TEAM_NAME_HEADER));
  table.addCell(PdfUtils.createHeaderCell(subjectiveStation));
  table.addCell(PdfUtils.createHeaderCell(JUDGE_GROUP_HEADER));
  table.setHeaderRows(2);

  Collections.sort(_schedule, getComparatorForSubjectiveByDivision(subjectiveStation));
  for (final TeamScheduleInfo si : _schedule) {
    table.addCell(PdfUtils.createCell(String.valueOf(si.getTeamNumber())));
    table.addCell(PdfUtils.createCell(si.getAwardGroup()));
    table.addCell(PdfUtils.createCell(si.getOrganization()));
    table.addCell(PdfUtils.createCell(si.getTeamName()));
    table.addCell(PdfUtils.createCell(formatTime(si.getSubjectiveTimeByName(subjectiveStation).getTime())));
    table.addCell(PdfUtils.createCell(si.getJudgingGroup()));
  }

  detailedSchedules.add(table);

}
 
開發者ID:jpschewe,項目名稱:fll-sw,代碼行數:35,代碼來源:TournamentSchedule.java

示例7: addFormSection

import com.itextpdf.text.pdf.PdfPTable; //導入方法依賴的package包/類
@Override
public void addFormSection(Document document, Report report, FormSection formSection) {
	int MAX_NUMBER_OF_COLUMNS = 2;
	
	addInvisibleChapterForHeader(document, formSection);
	
	// create table
	PdfPTable pdfTable = new PdfPTable(MAX_NUMBER_OF_COLUMNS);
	pdfTable.setHeaderRows(2);
	pdfTable.setWidthPercentage(100);

	// // header title
	// PdfPCell cell = new PdfPCell(new Paragraph(title, TITLE_FONT));
	// cell.setColspan(MAX_NUMBER_OF_COLUMNS);
	// cell.setHorizontalAlignment(Element.ALIGN_CENTER);
	// cell.setBackgroundColor(new BaseColor(Color.LIGHT_GRAY));
	// cell.setPadding(5.0f);
	// pdfTable.addCell(cell);

	// add properties as rows
	Object domainObject = formSection.getDomainObject();
	Class<?> domainClass = domainObject.getClass();
	
	// get propertyInfos
	ClassInfo classInfo = reflectionProvider.getClassInfo(domainClass);
	List<PropertyInfo> propertyInfos = classInfo.getPropertyInfosSortedAnsVisibleInTable();

	for (PropertyInfo propertyInfo : propertyInfos) {
		// add propertyName
		String propertyName = propertyInfo.getDisplayName();
		PdfPCell cell = new PdfPCell(new Paragraph(propertyName, SMALL_FONT));
		cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
		pdfTable.addCell(cell);

		// put value in the cell with the right type
		Object value = propertyInfo.getValue(domainObject);
		if (value == null) {
			pdfTable.addCell("");
		} else {
			value = propertyInfo.getFormat().format(value);
			pdfTable.addCell(new Phrase(value.toString(), SMALL_FONT));
		}

	}

	// add table to PDF document
	try {
		document.add(pdfTable);
	} catch (DocumentException e) {
		throw new RuntimeException(e);
	}
}
 
開發者ID:ntenhoeve,項目名稱:Introspect-Framework,代碼行數:53,代碼來源:PdfReportFactory.java

示例8: outputSubjectiveScheduleByTime

import com.itextpdf.text.pdf.PdfPTable; //導入方法依賴的package包/類
private void outputSubjectiveScheduleByTime(final Document detailedSchedules,
                                            final String subjectiveStation)
    throws DocumentException {
  final PdfPTable table = PdfUtils.createTable(6);
  int currentRow = 0;
  table.setWidths(new float[] { 2, 1, 3, 3, 2, 2 });

  final PdfPCell tournamentCell = PdfUtils.createHeaderCell("Tournament: "
      + getName()
      + " - "
      + subjectiveStation);
  tournamentCell.setColspan(6);
  table.addCell(tournamentCell);
  table.completeRow();
  currentRow++;

  table.addCell(PdfUtils.createHeaderCell(TEAM_NUMBER_HEADER));
  table.addCell(PdfUtils.createHeaderCell(AWARD_GROUP_HEADER));
  table.addCell(PdfUtils.createHeaderCell(ORGANIZATION_HEADER));
  table.addCell(PdfUtils.createHeaderCell(TEAM_NAME_HEADER));
  table.addCell(PdfUtils.createHeaderCell(subjectiveStation));
  table.addCell(PdfUtils.createHeaderCell(JUDGE_GROUP_HEADER));
  table.completeRow();
  currentRow++;
  table.setHeaderRows(2);

  Collections.sort(_schedule, getComparatorForSubjectiveByTime(subjectiveStation));
  LocalTime prevTime = null;
  for (final TeamScheduleInfo si : _schedule) {
    final LocalTime time = si.getSubjectiveTimeByName(subjectiveStation).getTime();

    final float topBorderWidth;
    if (Objects.equals(time, prevTime)) {
      topBorderWidth = Rectangle.UNDEFINED;

      // keep the rows with the same times together
      table.getRow(currentRow
          - 1).setMayNotBreak(true);
    } else {
      topBorderWidth = TIME_SEPARATOR_LINE_WIDTH;
    }

    PdfPCell cell = PdfUtils.createCell(String.valueOf(si.getTeamNumber()));
    cell.setBorderWidthTop(topBorderWidth);
    table.addCell(cell);

    cell = PdfUtils.createCell(si.getAwardGroup());
    cell.setBorderWidthTop(topBorderWidth);
    table.addCell(cell);

    cell = PdfUtils.createCell(si.getOrganization());
    cell.setBorderWidthTop(topBorderWidth);
    table.addCell(cell);

    cell = PdfUtils.createCell(si.getTeamName());
    cell.setBorderWidthTop(topBorderWidth);
    table.addCell(cell);

    cell = PdfUtils.createCell(formatTime(time));
    cell.setBorderWidthTop(topBorderWidth);
    table.addCell(cell);

    cell = PdfUtils.createCell(si.getJudgingGroup());
    cell.setBorderWidthTop(topBorderWidth);
    table.addCell(cell);
    table.completeRow();

    currentRow++;
    prevTime = time;
  }

  // make sure the last row isn't by itself
  table.getRow(currentRow
      - 1).setMayNotBreak(true);

  detailedSchedules.add(table);

}
 
開發者ID:jpschewe,項目名稱:fll-sw,代碼行數:79,代碼來源:TournamentSchedule.java


注:本文中的com.itextpdf.text.pdf.PdfPTable.setHeaderRows方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。