Example usage for com.itextpdf.text.pdf PdfName TOGGLE

List of usage examples for com.itextpdf.text.pdf PdfName TOGGLE

Introduction

In this page you can find the example usage for com.itextpdf.text.pdf PdfName TOGGLE.

Prototype

PdfName TOGGLE

To view the source code for com.itextpdf.text.pdf PdfName TOGGLE.

Click Source Link

Document

A name

Usage

From source file:com.vectorprint.report.itext.EventHelper.java

License:Open Source License

/**
 * prints a failure and / or a debug header when applicable.
 *
 * @see #getTemplateImage(com.itextpdf.text.pdf.PdfTemplate)
 * @param writer/*from w ww. ja  va2 s  . c o m*/
 * @param document
 * @throws DocumentException
 * @throws VectorPrintException
 */
private final void renderHeader(PdfWriter writer, Document document)
        throws DocumentException, VectorPrintException {
    if ((!debugHereAfter && getSettings().getBooleanProperty(false, DEBUG))
            || (!failuresHereAfter && !getSettings().getBooleanProperty(false, DEBUG))) {

        writer.getDirectContent().addImage(getTemplateImage(template));

        if (getSettings().getBooleanProperty(false, DEBUG)) {
            ArrayList a = new ArrayList(2);
            a.add(PdfName.TOGGLE);
            a.add(elementProducer.initLayerGroup(DEBUG, writer.getDirectContent()));
            PdfAction act = PdfAction.setOCGstate(a, true);
            Chunk h = new Chunk("toggle debug info",
                    DebugHelper.debugFontLink(writer.getDirectContent(), getSettings())).setAction(act);

            ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_LEFT, new Phrase(h), 10,
                    document.top() - 15, 0);
            Font f = DebugHelper.debugFontLink(writer.getDirectContent(), getSettings());
            //            act = PdfAction.gotoLocalPage("debugpage", true);

            elementProducer.startLayerInGroup(DEBUG, writer.getDirectContent());

            h = new Chunk(getSettings().getProperty("go to debug legend", "debugheader"), f)
                    .setLocalGoto(BaseReportGenerator.DEBUGPAGE);
            ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_LEFT, new Phrase(h), 10,
                    document.top() - 3, 0);

            writer.getDirectContent().endLayer();

        }
    }
}