Example usage for com.lowagie.text.pdf PdfOutline PdfOutline

List of usage examples for com.lowagie.text.pdf PdfOutline PdfOutline

Introduction

In this page you can find the example usage for com.lowagie.text.pdf PdfOutline PdfOutline.

Prototype


public PdfOutline(PdfOutline parent, PdfDestination destination, Paragraph title) 

Source Link

Document

Constructs a PdfOutline.

Usage

From source file:questions.stamppages.ParagraphBookmarkEvents.java

/**
 * Adds an outline for every new Paragraph
 * //from   w  w w .  j  a  v  a2  s . co  m
 * @param writer
 * @param document
 * @param position
 */
public void onParagraph(PdfWriter writer, Document document, float position) {
    n++;
    PdfContentByte cb = writer.getDirectContent();
    PdfOutline root = cb.getRootOutline();
    PdfDestination destination = new PdfDestination(PdfDestination.FITH, position);
    if (named) {
        cb.localDestination("p" + n, destination);
        new PdfOutline(root, PdfAction.gotoLocalPage("p" + n, false), "paragraph " + n);
    } else {
        new PdfOutline(root, destination, "paragraph " + n);
    }
}

From source file:webBoltOns.server.reportWriter.JRivetWriter.java

License:Open Source License

/**
 * <h2><code>buildReport</code></h2>
 * //ww w .  j  a  v  a2 s .  co  m
 * <p>
 *  Create the PDF report        
 * </p>
 * 
 * @param   ServletRequest request  - the HTTP request
 * @param   ServletResponse response - the HTTP respones
 * 
 */
private void buildReport(ServletRequest request, ServletResponse response, DataSet reportTable) {
    try {

        rowCount = 999;
        totalRows = 0;
        document = new Document(PageSize.LEGAL.rotate());
        document.setMargins(8.0f, 8.0f, 8.0f, 18.0f);

        outputStream = new ByteArrayOutputStream();
        writer = PdfWriter.getInstance(document, outputStream);
        writer.setViewerPreferences(PdfWriter.PageModeUseOutlines);
        buildReportTitles(reportTable);

        document.open();

        contentByte = writer.getDirectContent();
        root = new PdfOutline(contentByte.getRootOutline(), new PdfDestination(PdfDestination.FIT), "Report");

        topA.setOutline(root);

        ResultSet resultSet;
        Statement statement = dataAccess.execConnectReadOnly();

        sql = new StringBuffer(reportTable.getStringField(ReportColumn.SQL_QUERY));

        sql = DataSet.removeFormat(sql, "\n");
        sql = DataSet.removeFormat(sql, "\t");

        Enumeration parameters = request.getParameterNames();
        while (parameters.hasMoreElements()) {
            String p = (String) parameters.nextElement();
            String v = request.getParameter(p);
            if (!p.equals("ReportScript") && !p.equals("") && !v.equals(""))
                sql = mergeTagValues(sql, p, v);
        }

        resultSet = statement.executeQuery(sql.toString().trim());
        String[] record = new String[reportColumns.length];

        while (resultSet.next()) {
            for (int c = 0; c < reportColumns.length; c++) {
                ReportColumn column = (ReportColumn) reportColumns[c];
                String value = (String) DataAccess.getFieldValue(resultSet, column.getFeildName(),
                        column.getDataType());
                record[c] = formatField(value, column.getDataType(), column.getDecimals());
            }

            topA.recursiveLevelBreaks(record);
            buildDetilLine(record);
            accumulateReportTotals(record);
            totalRows++;
        }

        if (totalRows == 0) {
            buildEmptyPage(request, response);

        } else {
            topA.fireGrandTotalBreak();
            resultSet.close();
            dataAccess.execClose(statement);
            document.add(reportBody);
            document.close();
            buildPDFReportPage(request, response, outputStream.toByteArray());
        }

    } catch (DocumentException e) {
        gs.log("** DocumentException: " + e);
        buildErrorPage(request, response, e.toString());
    } catch (IOException e) {
        gs.log("** IOException: " + e);
        buildErrorPage(request, response, e.toString());
    } catch (Exception e) {
        gs.log("** Exception: " + e);
        buildErrorPage(request, response, e.toString());
    }

}

From source file:webBoltOns.server.reportWriter.JRivetWriter.java

License:Open Source License

/**
 * <h2><code>fireNewSection</code></h2>
 * //from   ww w.  jav a  2 s.c om
 * <p>
 *  Executed by <code>ReportAccumulator</code> when a new section is 
 *  detected      
 * </p>
 * 
 * @param   ReportAccumulator ac - Source creating the new section. 
 * @param   String newValue - the value of the new section.
 * 
 */
public void fireNewSection(ReportAccumulator ac, String newValue) {
    PdfOutline outLine = new PdfOutline(ac.getParentAccumulator().getOutline(),
            new PdfDestination(PdfDestination.FITH, 50), newValue);
    outLine.setOpen(false);
    ac.setOutline(outLine);
}