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


Java HeaderFooter类代码示例

本文整理汇总了Java中com.lowagie.text.HeaderFooter的典型用法代码示例。如果您正苦于以下问题:Java HeaderFooter类的具体用法?Java HeaderFooter怎么用?Java HeaderFooter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: createWriter

import com.lowagie.text.HeaderFooter; //导入依赖的package包/类
/**
 * We create a writer that listens to the document and directs a PDF-stream to out
 *
 * @param table
 *           MBasicTable
 * @param document
 *           Document
 * @param out
 *           OutputStream
 * @return DocWriter
 * @throws DocumentException
 *            e
 */
protected DocWriter createWriter(final MBasicTable table, final Document document,
		final OutputStream out) throws DocumentException {
	final PdfWriter writer = PdfWriter.getInstance(document, out);
	// writer.setViewerPreferences(PdfWriter.PageLayoutTwoColumnLeft);

	// title
	if (table.getName() != null) {
		final HeaderFooter header = new HeaderFooter(new Phrase(table.getName()), false);
		header.setAlignment(Element.ALIGN_LEFT);
		header.setBorder(Rectangle.NO_BORDER);
		document.setHeader(header);
		document.addTitle(table.getName());
	}

	// simple page numbers : x
	// HeaderFooter footer = new HeaderFooter(new Phrase(), true);
	// footer.setAlignment(Element.ALIGN_RIGHT);
	// footer.setBorder(Rectangle.TOP);
	// document.setFooter(footer);

	// add the event handler for advanced page numbers : x/y
	writer.setPageEvent(new AdvancedPageNumberEvents());

	return writer;
}
 
开发者ID:javamelody,项目名称:javamelody,代码行数:39,代码来源:MPdfWriter.java

示例2: generateSimpleHeader

import com.lowagie.text.HeaderFooter; //导入依赖的package包/类
/**
 * Creates a common format header for the reports.
 *
 * @param document the report document
 * @param reportGenerationDate the date of printing
 * @param reportNameText the name of the report
 * @return the header to include
 */
public static HeaderFooter generateSimpleHeader(Document document, Date reportGenerationDate,
    String reportNameText) {
    Paragraph header = new Paragraph();

    if (reportNameText != null) {
        Paragraph reportName = new Paragraph(reportNameText, ReportHelper.REPORT_HEADER_FONT);
        header.add(reportName);
    }

    if (reportGenerationDate != null) {
        Paragraph reportDate = new Paragraph(
            new SimpleDateFormat(HEADER_DATE_FORMAT, Locale.US).format(reportGenerationDate),
            ReportHelper.HEADER_DATE_FONT);
        header.add(reportDate);
    }

    HeaderFooter head = new HeaderFooter(new Phrase(header), false);
    head.setAlignment(Element.ALIGN_CENTER);
    head.setBorder(Rectangle.BOTTOM);
    return head;
}
 
开发者ID:NASA-Tournament-Lab,项目名称:CoECI-OPM-Service-Credit-Redeposit-Deposit-Application,代码行数:30,代码来源:ReportHelper.java

示例3: createReportHeader

import com.lowagie.text.HeaderFooter; //导入依赖的package包/类
/**
 * creates the data dictionary section in the report
 * 
 * @param document
 *            the document in which the report is created
 * @param filename
 *            the name of the file used to create the report
 */
public void createReportHeader(Document document, String filename) {
    try {
        Chunk headerText = new Chunk("jUCMNav - " + filename, headerFont); //$NON-NLS-1$
        HeaderFooter header = new HeaderFooter(new Phrase(headerText), false);
        Chunk footerPage = new Chunk(Messages.getString("ReportHeader.Page"), footerFont); //$NON-NLS-1$
        HeaderFooter footer = new HeaderFooter(new Phrase(footerPage), new Phrase(".")); //$NON-NLS-1$
        document.setHeader(header);
        document.setFooter(footer);
    } catch (Exception e) {
        jUCMNavErrorDialog error = new jUCMNavErrorDialog(e.getMessage());
        e.printStackTrace();

    }

}
 
开发者ID:McGill-DP-Group,项目名称:seg.jUCMNav,代码行数:24,代码来源:ReportHeader.java

示例4: setHeader

import com.lowagie.text.HeaderFooter; //导入依赖的package包/类
/**
 * Changes the header of this document.
 *
 * @param header the new header
 */
public void setHeader(HeaderFooter header) {
    if (writer != null && writer.isPaused()) {
        return;
    }
    super.setHeader(header);
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:12,代码来源:PdfDocument.java

示例5: setFooter

import com.lowagie.text.HeaderFooter; //导入依赖的package包/类
/**
 * Changes the footer of this document.
 *
 * @param	footer		the new footer
 */
public void setFooter(HeaderFooter footer) {
    if (writer != null && writer.isPaused()) {
        return;
    }
    super.setFooter(footer);
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:12,代码来源:PdfDocument.java

示例6: RtfHeaderFooterGroup

import com.lowagie.text.HeaderFooter; //导入依赖的package包/类
/**
 * Constructs a RtfHeaderGroup for a certain HeaderFooter
 * 
 * @param doc The RtfDocument this RtfHeaderFooter belongs to
 * @param headerFooter The HeaderFooter to display
 * @param type The type of RtfHeaderFooterGroup to create
 */
public RtfHeaderFooterGroup(RtfDocument doc, HeaderFooter headerFooter, int type) {
    super(new Phrase(""), false);
    this.document = doc;
    this.type = type;
    this.mode = MODE_SINGLE;
    headerAll = new RtfHeaderFooter(doc, headerFooter, type, RtfHeaderFooter.DISPLAY_ALL_PAGES);
    headerAll.setType(this.type);
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:16,代码来源:RtfHeaderFooterGroup.java

示例7: setHeaderFooter

import com.lowagie.text.HeaderFooter; //导入依赖的package包/类
/**
 * Set a HeaderFooter to be displayed at a certain position
 * 
 * @param headerFooter The HeaderFooter to set
 * @param displayAt The display location to use
 */
public void setHeaderFooter(HeaderFooter headerFooter, int displayAt) {
    this.mode = MODE_MULTIPLE;
    switch(displayAt) {
        case RtfHeaderFooter.DISPLAY_ALL_PAGES:
            headerAll = new RtfHeaderFooter(this.document, headerFooter, this.type, displayAt);
        	break;
        case RtfHeaderFooter.DISPLAY_FIRST_PAGE:
            headerFirst = new RtfHeaderFooter(this.document, headerFooter, this.type, displayAt);
            break;
        case RtfHeaderFooter.DISPLAY_LEFT_PAGES:
            headerLeft = new RtfHeaderFooter(this.document, headerFooter, this.type, displayAt);
            break;
        case RtfHeaderFooter.DISPLAY_RIGHT_PAGES:
            headerRight = new RtfHeaderFooter(this.document, headerFooter, this.type, displayAt);
            break;
    }
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:24,代码来源:RtfHeaderFooterGroup.java

示例8: convertHeaderFooter

import com.lowagie.text.HeaderFooter; //导入依赖的package包/类
/**
 * Converts a HeaderFooter into a RtfHeaderFooterGroup. Depending on which class
 * the HeaderFooter is, the correct RtfHeaderFooterGroup is created.
 * 
 * @param hf The HeaderFooter to convert.
 * @param type Whether the conversion is being done on a footer or header
 * @return The converted RtfHeaderFooterGroup.
 * @see com.lowagie.text.rtf.headerfooter.RtfHeaderFooter
 * @see com.lowagie.text.rtf.headerfooter.RtfHeaderFooterGroup
 */
private RtfHeaderFooterGroup convertHeaderFooter(HeaderFooter hf, int type) {
    if(hf != null) {
        if(hf instanceof RtfHeaderFooterGroup) {
            return new RtfHeaderFooterGroup(this.document, (RtfHeaderFooterGroup) hf, type);
        } else if(hf instanceof RtfHeaderFooter) {
            return new RtfHeaderFooterGroup(this.document, (RtfHeaderFooter) hf, type);
        } else {
            return new RtfHeaderFooterGroup(this.document, hf, type);
        }
    } else {
        return new RtfHeaderFooterGroup(this.document, type);
    }
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:24,代码来源:RtfDocumentHeader.java

示例9: setFooterOnDocument

import com.lowagie.text.HeaderFooter; //导入依赖的package包/类
public static void setFooterOnDocument( Document document, String footerText, Font font )
{
    boolean isNumbered = true;

    HeaderFooter footer = new HeaderFooter( new Phrase( footerText, font ), isNumbered );
    footer.setBorder( Rectangle.NO_BORDER );
    footer.setAlignment( Element.ALIGN_RIGHT );
    document.setFooter( footer );
}
 
开发者ID:dhis2,项目名称:dhis2-core,代码行数:10,代码来源:PdfDataEntryFormUtil.java

示例10: addFooter

import com.lowagie.text.HeaderFooter; //导入依赖的package包/类
public void addFooter(String text)
{
	HeaderFooter footer = new HeaderFooter((new Phrase(text+" - Pag. ",paragraphFont)),true);;
	footer.setAlignment(HeaderFooter.ALIGN_RIGHT);
	footer.disableBorderSide(HeaderFooter.BOTTOM);
	
	document.setFooter(footer);
}
 
开发者ID:sakaicontrib,项目名称:evaluation,代码行数:9,代码来源:EvalPDFReportBuilder.java

示例11: createWriter

import com.lowagie.text.HeaderFooter; //导入依赖的package包/类
private void createWriter(Document document, String title)
		throws DocumentException, IOException {
	final PdfWriter writer = PdfWriter.getInstance(document, output);
	//writer.setViewerPreferences(PdfWriter.PageLayoutTwoColumnLeft);

	// title
	final HeaderFooter header = new HeaderFooter(new Phrase(title), false);
	header.setAlignment(Element.ALIGN_LEFT);
	header.setBorder(Rectangle.NO_BORDER);
	document.setHeader(header);

	// simple page numbers : x
	//HeaderFooter footer = new HeaderFooter(new Phrase(), true);
	//footer.setAlignment(Element.ALIGN_RIGHT);
	//footer.setBorder(Rectangle.TOP);
	//document.setFooter(footer);

	// add the event handler for advanced page numbers : x/y
	writer.setPageEvent(new PdfAdvancedPageNumberEvents());
}
 
开发者ID:javamelody,项目名称:javamelody,代码行数:21,代码来源:PdfDocumentFactory.java

示例12: createWriter

import com.lowagie.text.HeaderFooter; //导入依赖的package包/类
/**
 * We create a writer that listens to the document and directs a RTF-stream to out
 *
 * @param table
 *           MBasicTable
 * @param document
 *           Document
 * @param out
 *           OutputStream
 * @return DocWriter
 */
@Override
protected DocWriter createWriter(final MBasicTable table, final Document document,
		final OutputStream out) {
	final RtfWriter2 writer = RtfWriter2.getInstance(document, out);

	// title
	final String title = buildTitle(table);
	if (title != null) {
		final HeaderFooter header = new RtfHeaderFooter(new Paragraph(title));
		header.setAlignment(Element.ALIGN_LEFT);
		header.setBorder(Rectangle.NO_BORDER);
		document.setHeader(header);
		document.addTitle(title);
	}

	// advanced page numbers : x/y
	final Paragraph footerParagraph = new Paragraph();
	final Font font = FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL);
	footerParagraph.add(new RtfPageNumber(font));
	footerParagraph.add(new Phrase(" / ", font));
	footerParagraph.add(new RtfTotalPageNumber(font));
	footerParagraph.setAlignment(Element.ALIGN_CENTER);
	final HeaderFooter footer = new RtfHeaderFooter(footerParagraph);
	footer.setBorder(Rectangle.TOP);
	document.setFooter(footer);

	return writer;
}
 
开发者ID:javamelody,项目名称:javamelody,代码行数:40,代码来源:MRtfWriter.java

示例13: doExport

import com.lowagie.text.HeaderFooter; //导入依赖的package包/类
/**
 * Do export.
 * 
 * @param out
 *            the out
 * @throws JspException
 *             the jsp exception
 * @see org.displaytag.export.BinaryExportView#doExport(OutputStream)
 */
public void doExport(OutputStream out) throws JspException {
	try {
		// Initialize the table with the appropriate number of columns
		initTable();

		// Initialize the Document and register it with PdfWriter listener
		// and the OutputStream
		Document document = new Document(PageSize.A4.rotate(), 60, 60, 40, 40);
		document.addCreationDate();
		HeaderFooter footer = new HeaderFooter(new Phrase(TagConstants.EMPTY_STRING, smallFont), true);
		footer.setBorder(Rectangle.NO_BORDER);
		footer.setAlignment(Element.ALIGN_CENTER);

		PdfWriter.getInstance(document, out);

		// Fill the virtual PDF table with the necessary data
		generatePDFTable();
		document.open();
		document.setFooter(footer);
		document.add(this.tablePDF);
		document.close();

	} catch (Exception e) {
		throw new PdfGenerationException(e);
	}
}
 
开发者ID:8090boy,项目名称:gomall.la,代码行数:36,代码来源:SimpleChinesePdfView.java

示例14: exportReport

import com.lowagie.text.HeaderFooter; //导入依赖的package包/类
/**
 * Renders the report using the given model.
 *
 * @param response the report model
 * @param exportType the file type to generate
 * @return the rendered report document
 * @throws IllegalArgumentException if any argument is null
 * @throws ReportGenerationException - if there is any problem when generating response.
 */
public byte[] exportReport(ManualPaymentReportResponse response, ExportType exportType)
    throws ReportGenerationException {
    String signature = CLASS_NAME + "#exportReport(ManualPaymentReportResponse response, ExportType exportType)";
    Logger logger = getLogger();

    LoggingHelper.logEntrance(logger, signature, new String[] {"response", "exportType"}, new Object[] {response,
        exportType});

    Helper.checkNull(logger, signature, response, "response");
    Helper.checkNull(logger, signature, exportType, "exportType");

    try {
        byte[] result = null;

        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        Document document = new Document();
        document.setMargins(ReportHelper.MARGIN_LR, ReportHelper.MARGIN_LR, ReportHelper.MARGIN_TB,
            ReportHelper.MARGIN_TB);

        // Associate it with output stream
        ReportHelper.initDocumentFormat(document, outputStream, exportType);

        HeaderFooter head = ReportHelper.generateSimpleHeader(document, response.getReportGenerationDate(),
            response.getReportName());

        document.setHeader(head);
        document.open();

        renderItems(response, document);

        document.close();
        result = outputStream.toByteArray();
        LoggingHelper.logExit(logger, signature, new Object[] {result});
        return result;
    } catch (DocumentException e) {
        throw LoggingHelper.logException(logger, signature, new ReportGenerationException(
            "An error has occurred when rendering the document.", e));
    }
}
 
开发者ID:NASA-Tournament-Lab,项目名称:CoECI-OPM-Service-Credit-Redeposit-Deposit-Application,代码行数:49,代码来源:ManualPaymentReportService.java

示例15: generateHeaderNoBorder

import com.lowagie.text.HeaderFooter; //导入依赖的package包/类
/**
 * Creates a common format header for the reports, without a header border.
 *
 * @param document the report document
 * @param reportGenerationDate the date of printing
 * @param reportNameText the name of the report
 * @param subTitle report sub title
 * @return the header to include
 * @since 1.1
 */
public static HeaderFooter generateHeaderNoBorder(Document document, Date reportGenerationDate,
    String reportNameText, String subTitle) {
    Paragraph header = new Paragraph();

    if (reportNameText != null) {
        Paragraph reportName = new Paragraph(reportNameText, ReportHelper.REPORT_HEADER_FONT);
        header.add(reportName);
    }

    if (reportGenerationDate != null) {
        Paragraph reportDate = new Paragraph(
            new SimpleDateFormat(HEADER_DATE_FORMAT, Locale.US).format(reportGenerationDate),
            ReportHelper.HEADER_DATE_FONT);
        header.add(reportDate);
    }

    if (subTitle != null) {
        Paragraph sub = new Paragraph(subTitle, ReportHelper.HEADER_SUB_TITLE_FONT);
        header.add(sub);
    }

    HeaderFooter head = new HeaderFooter(new Phrase(header), false);
    head.setAlignment(Element.ALIGN_CENTER);
    head.setBorder(Rectangle.NO_BORDER);
    return head;
}
 
开发者ID:NASA-Tournament-Lab,项目名称:CoECI-OPM-Service-Credit-Redeposit-Deposit-Application,代码行数:37,代码来源:ReportHelper.java


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