Java 类com.lowagie.text.HeaderFooter 实例源码

项目:javamelody    文件:MPdfWriter.java   
/**
 * 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;
}
项目:CoECI-OPM-Service-Credit-Redeposit-Deposit-Application    文件:ReportHelper.java   
/**
 * 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;
}
项目:seg.jUCMNav    文件:ReportHeader.java   
/**
 * 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();

    }

}
项目:itext2    文件:PdfDocument.java   
/**
 * 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);
}
项目:itext2    文件:PdfDocument.java   
/**
 * 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);
}
项目:itext2    文件:RtfHeaderFooterGroup.java   
/**
 * 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);
}
项目:itext2    文件:RtfHeaderFooterGroup.java   
/**
 * 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;
    }
}
项目:itext2    文件:RtfHeaderFooter.java   
/**
 * Constructs a RtfHeaderFooter based on a HeaderFooter with a certain type and displayAt
 * location. For internal use only.
 * 
 * @param doc The RtfDocument this RtfHeaderFooter belongs to
 * @param headerFooter The HeaderFooter to base this RtfHeaderFooter on
 * @param type The type of RtfHeaderFooter
 * @param displayAt The display location of this RtfHeaderFooter
 */
protected RtfHeaderFooter(RtfDocument doc, HeaderFooter headerFooter, int type, int displayAt) {
    super(new Phrase(""), false);
    this.document = doc;
    this.type = type;
    this.displayAt = displayAt;
    Paragraph par = new Paragraph();
    par.setAlignment(headerFooter.alignment());
    if (headerFooter.getBefore() != null) {
        par.add(headerFooter.getBefore());
    }
    if (headerFooter.isNumbered()) {
        par.add(new RtfPageNumber(this.document));
    }
    if (headerFooter.getAfter() != null) {
        par.add(headerFooter.getAfter());
    }
    try {
        this.content = new Object[1];
        if(this.document != null) {
            this.content[0] = this.document.getMapper().mapElement(par)[0];
            ((RtfBasicElement) this.content[0]).setInHeader(true);
        } else {
            this.content[0] = par;
        }
    } catch(DocumentException de) {
        de.printStackTrace();
    }
}
项目:itext2    文件:RtfHeaderFooter.java   
/**
 * Constructs a RtfHeaderFooter for a HeaderFooter.
 *  
 * @param doc The RtfDocument this RtfHeaderFooter belongs to
 * @param headerFooter The HeaderFooter to base this RtfHeaderFooter on
 */
protected RtfHeaderFooter(RtfDocument doc, HeaderFooter headerFooter) {
    super(new Phrase(""), false);
    this.document = doc;
    Paragraph par = new Paragraph();
    par.setAlignment(headerFooter.alignment());
    if (headerFooter.getBefore() != null) {
        par.add(headerFooter.getBefore());
    }
    if (headerFooter.isNumbered()) {
        par.add(new RtfPageNumber(this.document));
    }
    if (headerFooter.getAfter() != null) {
        par.add(headerFooter.getAfter());
    }
    try {
        this.content = new Object[1];
        this.content[0] = doc.getMapper().mapElement(par)[0];
        ((RtfBasicElement) this.content[0]).setInHeader(true);
    } catch(DocumentException de) {
        de.printStackTrace();
    }
}
项目:itext2    文件:RtfDocumentHeader.java   
/**
 * 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);
    }
}
项目:dhis2-core    文件:PdfDataEntryFormUtil.java   
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 );
}
项目:evaluation    文件:EvalPDFReportBuilder.java   
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);
}
项目:javamelody    文件:PdfDocumentFactory.java   
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());
}
项目:javamelody    文件:MRtfWriter.java   
/**
 * 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;
}
项目:AgileAlligators    文件:PdfDataEntryFormUtil.java   
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 );
}
项目:gomall.la    文件:SimpleChinesePdfView.java   
/**
 * 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);
    }
}
项目:CoECI-OPM-Service-Credit-Redeposit-Deposit-Application    文件:ManualPaymentReportService.java   
/**
 * 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));
    }
}
项目:CoECI-OPM-Service-Credit-Redeposit-Deposit-Application    文件:ReportHelper.java   
/**
 * 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;
}
项目:Deskera-HRMS    文件:ExportServlet.java   
public static void setHeaderFooter(Document doc, String headerText) {
    HeaderFooter footer = new HeaderFooter(new Phrase("  ", FontFactory.getFont("Helvetica", 8, Font.NORMAL, Color.BLACK)), true);
    footer.setBorderWidth(0);
    footer.setBorderWidthTop(1);
    footer.setAlignment(HeaderFooter.ALIGN_RIGHT);
    doc.setFooter(footer);
    HeaderFooter header = new HeaderFooter(new Phrase(headerText, FontFactory.getFont("Helvetica", 14, Font.BOLD, Color.BLACK)), false);
    doc.setHeader(header);
}
项目:Deskera-HRMS    文件:exportDAOImpl.java   
public void setHeaderFooter(Document doc, String headerText) {
    HeaderFooter footer = new HeaderFooter(new Phrase(fontFamilySelector.process("  ", FontContext.SMALL_NORMAL_HELVETICA)), true);
    footer.setBorderWidth(0);
    footer.setBorderWidthTop(1);
    footer.setAlignment(HeaderFooter.ALIGN_RIGHT);
    doc.setFooter(footer);
    HeaderFooter header = new HeaderFooter(new Phrase(fontFamilySelector.process(headerText, FontContext.FOOTER_BOLD_HELVETICA)), false);
    doc.setHeader(header);
}
项目:DroidText    文件:PdfDocument.java   
/**
 * 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);
}
项目:DroidText    文件:PdfDocument.java   
/**
 * 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);
}
项目:MesquiteArchive    文件:PdfDocument.java   
/**
 * 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);
}
项目:MesquiteArchive    文件:PdfDocument.java   
/**
 * 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);
}
项目:MesquiteArchive    文件:PdfDocument.java   
/**
 * 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);
}
项目:MesquiteArchive    文件:PdfDocument.java   
/**
 * 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);
}
项目:MesquiteArchive    文件:PdfDocument.java   
/**
 * 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);
}
项目:MesquiteArchive    文件:PdfDocument.java   
/**
 * 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);
}
项目:MesquiteArchive    文件:PdfDocument.java   
/**
 * 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);
}
项目:MesquiteArchive    文件:PdfDocument.java   
/**
 * 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);
}
项目:MesquiteArchive    文件:PdfDocument.java   
/**
 * 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);
}
项目:MesquiteArchive    文件:PdfDocument.java   
/**
 * 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);
}
项目:MesquiteArchive    文件:PdfDocument.java   
/**
 * 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);
}
项目:MesquiteArchive    文件:PdfDocument.java   
/**
 * 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);
}
项目:MesquiteArchive    文件:PdfDocument.java   
/**
 * 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);
}
项目:MesquiteArchive    文件:PdfDocument.java   
/**
 * 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);
}
项目:MesquiteArchive    文件:PdfDocument.java   
/**
 * 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);
}
项目:MesquiteArchive    文件:PdfDocument.java   
/**
 * 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);
}
项目:MesquiteArchive    文件:PdfDocument.java   
/**
 * 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);
}
项目:MesquiteArchive    文件:PdfDocument.java   
/**
 * 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);
}