Example usage for com.lowagie.text.pdf ColumnText setLeading

List of usage examples for com.lowagie.text.pdf ColumnText setLeading

Introduction

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

Prototype

public void setLeading(float fixedLeading, float multipliedLeading) 

Source Link

Document

Sets the leading fixed and variable.

Usage

From source file:com.develog.utils.report.engine.export.JRPdfExporter.java

License:Open Source License

/**
 *
 *///from   w ww  .  j a  v  a2 s. c om
protected void exportText(JRPrintText text) throws JRException, DocumentException, IOException {
    JRStyledText styledText = getStyledText(text);

    if (styledText == null) {
        return;
    }

    int textLength = styledText.length();

    int x = text.getX();
    int y = text.getY();
    int width = text.getWidth();
    int height = text.getHeight();

    double angle = 0;

    switch (text.getRotation()) {
    case JRTextElement.ROTATION_LEFT: {
        y = text.getY() + text.getHeight();
        width = text.getHeight();
        height = text.getWidth();
        angle = Math.PI / 2;
        break;
    }
    case JRTextElement.ROTATION_RIGHT: {
        x = text.getX() + text.getWidth();
        width = text.getHeight();
        height = text.getWidth();
        angle = -Math.PI / 2;
        break;
    }
    case JRTextElement.ROTATION_NONE:
    default: {
    }
    }

    AffineTransform atrans = new AffineTransform();
    atrans.rotate(angle, x, jasperPrint.getPageHeight() - y);
    pdfContentByte.transform(atrans);

    if (text.getMode() == JRElement.MODE_OPAQUE) {
        pdfContentByte.setRGBColorStroke(text.getBackcolor().getRed(), text.getBackcolor().getGreen(),
                text.getBackcolor().getBlue());
        pdfContentByte.setRGBColorFill(text.getBackcolor().getRed(), text.getBackcolor().getGreen(),
                text.getBackcolor().getBlue());
        pdfContentByte.setLineWidth(1f);
        pdfContentByte.setLineDash(0f);
        pdfContentByte.rectangle(x, jasperPrint.getPageHeight() - y, width - 1, -height + 1);
        pdfContentByte.fillStroke();
    } else {
        /*
        pdfContentByte.setRGBColorStroke(
           text.getForecolor().getRed(),
           text.getForecolor().getGreen(),
           text.getForecolor().getBlue()
           );
        pdfContentByte.setLineWidth(0.1f);
        pdfContentByte.setLineDash(0f);
        pdfContentByte.rectangle(
           text.getX(),
           jasperPrint.getPageHeight() - text.getY(),
           text.getWidth(),
           - text.getHeight()
           );
        pdfContentByte.stroke();
        */
    }

    if (textLength == 0) {
        return;
    }

    int horizontalAlignment = Element.ALIGN_LEFT;
    switch (text.getTextAlignment()) {
    case JRAlignment.HORIZONTAL_ALIGN_LEFT: {
        horizontalAlignment = Element.ALIGN_LEFT;
        break;
    }
    case JRAlignment.HORIZONTAL_ALIGN_CENTER: {
        horizontalAlignment = Element.ALIGN_CENTER;
        break;
    }
    case JRAlignment.HORIZONTAL_ALIGN_RIGHT: {
        horizontalAlignment = Element.ALIGN_RIGHT;
        break;
    }
    case JRAlignment.HORIZONTAL_ALIGN_JUSTIFIED: {
        horizontalAlignment = Element.ALIGN_JUSTIFIED;
        break;
    }
    default: {
        horizontalAlignment = Element.ALIGN_LEFT;
    }
    }

    float verticalOffset = 0f;
    switch (text.getVerticalAlignment()) {
    case JRTextElement.VERTICAL_ALIGN_TOP: {
        verticalOffset = 0f;
        break;
    }
    case JRTextElement.VERTICAL_ALIGN_MIDDLE: {
        verticalOffset = ((float) height - text.getTextHeight()) / 2f;
        break;
    }
    case JRTextElement.VERTICAL_ALIGN_BOTTOM: {
        verticalOffset = height - text.getTextHeight();
        break;
    }
    default: {
        verticalOffset = 0f;
    }
    }

    ColumnText colText = new ColumnText(pdfContentByte);
    colText.setSimpleColumn(getPhrase(styledText, getHyperlinkInfoChunk(text)), x,
            jasperPrint.getPageHeight() - y - verticalOffset - text.getLeadingOffset(),
            //+ text.getLineSpacingFactor() * text.getFont().getSize(), 
            x + width, jasperPrint.getPageHeight() - y - height, 0, //text.getLineSpacingFactor(),// * text.getFont().getSize(),
            horizontalAlignment);

    colText.setLeading(0, text.getLineSpacingFactor());// * text.getFont().getSize());

    colText.go();

    atrans = new AffineTransform();
    atrans.rotate(-angle, x, jasperPrint.getPageHeight() - y);
    pdfContentByte.transform(atrans);
}

From source file:corner.orm.tapestry.jasper.exporter.CornerPdfExporter.java

License:Apache License

/**
 * ?.????.//from  w  ww.ja v  a 2 s . co  m
 * <p>:ColumnText?,
 * ?NO_MORE_COLUMN???,TextField??.
 * TextField?.
 * @see net.sf.jasperreports.engine.export.JRPdfExporter#exportText(net.sf.jasperreports.engine.JRPrintText)
 */
@Override
protected void exportText(JRPrintText text) throws DocumentException {

    JRStyledText styledText = getStyledText(text, false);

    if (styledText == null) {
        return;
    }

    int textLength = styledText.length();

    int x = text.getX() + getOffsetX();
    int y = text.getY() + getOffsetY();
    int width = text.getWidth();
    int height = text.getHeight();
    int topPadding = text.getTopPadding();
    int leftPadding = text.getLeftPadding();
    int bottomPadding = text.getBottomPadding();
    int rightPadding = text.getRightPadding();

    int xFillCorrection = 0;
    int yFillCorrection = 0;

    double angle = 0;

    switch (text.getRotation()) {
    case JRTextElement.ROTATION_LEFT: {
        y = text.getY() + getOffsetY() + text.getHeight();
        xFillCorrection = 1;
        width = text.getHeight();
        height = text.getWidth();
        int tmpPadding = topPadding;
        topPadding = leftPadding;
        leftPadding = bottomPadding;
        bottomPadding = rightPadding;
        rightPadding = tmpPadding;
        angle = Math.PI / 2;
        break;
    }
    case JRTextElement.ROTATION_RIGHT: {
        x = text.getX() + getOffsetX() + text.getWidth();
        yFillCorrection = -1;
        width = text.getHeight();
        height = text.getWidth();
        int tmpPadding = topPadding;
        topPadding = rightPadding;
        rightPadding = bottomPadding;
        bottomPadding = leftPadding;
        leftPadding = tmpPadding;
        angle = -Math.PI / 2;
        break;
    }
    case JRTextElement.ROTATION_UPSIDE_DOWN: {
        x = text.getX() + getOffsetX() + text.getWidth();
        y = text.getY() + getOffsetY() + text.getHeight();
        int tmpPadding = topPadding;
        topPadding = bottomPadding;
        bottomPadding = tmpPadding;
        tmpPadding = leftPadding;
        leftPadding = rightPadding;
        rightPadding = tmpPadding;
        angle = Math.PI;
        break;
    }
    case JRTextElement.ROTATION_NONE:
    default: {
    }
    }

    AffineTransform atrans = new AffineTransform();
    atrans.rotate(angle, x, jasperPrint.getPageHeight() - y);
    pdfContentByte.transform(atrans);

    if (text.getMode() == JRElement.MODE_OPAQUE) {
        Color backcolor = text.getBackcolor();
        pdfContentByte.setRGBColorStroke(backcolor.getRed(), backcolor.getGreen(), backcolor.getBlue());
        pdfContentByte.setRGBColorFill(backcolor.getRed(), backcolor.getGreen(), backcolor.getBlue());
        pdfContentByte.setLineWidth(1f);
        pdfContentByte.setLineDash(0f);
        pdfContentByte.rectangle(x + xFillCorrection, jasperPrint.getPageHeight() - y + yFillCorrection,
                width - 1, -height + 1);
        pdfContentByte.fillStroke();
    } else {
        /*
         * pdfContentByte.setRGBColorStroke( text.getForecolor().getRed(),
         * text.getForecolor().getGreen(), text.getForecolor().getBlue() );
         * pdfContentByte.setLineWidth(0.1f);
         * pdfContentByte.setLineDash(0f); pdfContentByte.rectangle(
         * text.getX() + offsetX, jasperPrint.getPageHeight() - text.getY() -
         * offsetY, text.getWidth(), - text.getHeight() );
         * pdfContentByte.stroke();
         */
    }

    if (textLength > 0) {
        int horizontalAlignment = Element.ALIGN_LEFT;
        switch (text.getHorizontalAlignment()) {
        case JRAlignment.HORIZONTAL_ALIGN_LEFT: {
            if (text.getRunDirection() == JRPrintText.RUN_DIRECTION_LTR) {
                horizontalAlignment = Element.ALIGN_LEFT;
            } else {
                horizontalAlignment = Element.ALIGN_RIGHT;
            }
            break;
        }
        case JRAlignment.HORIZONTAL_ALIGN_CENTER: {
            horizontalAlignment = Element.ALIGN_CENTER;
            break;
        }
        case JRAlignment.HORIZONTAL_ALIGN_RIGHT: {
            if (text.getRunDirection() == JRPrintText.RUN_DIRECTION_LTR) {
                horizontalAlignment = Element.ALIGN_RIGHT;
            } else {
                horizontalAlignment = Element.ALIGN_LEFT;
            }
            break;
        }
        case JRAlignment.HORIZONTAL_ALIGN_JUSTIFIED: {
            horizontalAlignment = Element.ALIGN_JUSTIFIED;
            break;
        }
        default: {
            horizontalAlignment = Element.ALIGN_LEFT;
        }
        }

        float verticalOffset = 0f;
        switch (text.getVerticalAlignment()) {
        case JRAlignment.VERTICAL_ALIGN_TOP: {
            verticalOffset = 0f;
            break;
        }
        case JRAlignment.VERTICAL_ALIGN_MIDDLE: {
            verticalOffset = (height - topPadding - bottomPadding - text.getTextHeight()) / 2f;
            break;
        }
        case JRAlignment.VERTICAL_ALIGN_BOTTOM: {
            verticalOffset = height - topPadding - bottomPadding - text.getTextHeight();
            break;
        }
        default: {
            verticalOffset = 0f;
        }
        }

        float llx = x + leftPadding;
        float lly = jasperPrint.getPageHeight() - y - topPadding - verticalOffset - text.getLeadingOffset();
        float urx = x + width - rightPadding;
        float ury = jasperPrint.getPageHeight() - y - height + bottomPadding;

        //?,???
        if (this.jasperMoveXY != null) {
            llx = x + leftPadding + jasperMoveXY.getX();
            lly = jasperPrint.getPageHeight() - y - topPadding - verticalOffset - text.getLeadingOffset()
                    - jasperMoveXY.getY();
            urx = x + width - rightPadding + jasperMoveXY.getX();
            ury = jasperPrint.getPageHeight() - y - height + bottomPadding - jasperMoveXY.getY();
        }

        boolean isOver = false;
        int status = ColumnText.START_COLUMN;
        Phrase phrase = getPhrase(styledText, text);

        ColumnText colText = new ColumnText(pdfContentByte);
        colText.setSimpleColumn(phrase, llx, lly, urx, ury, 0, // text.getLineSpacingFactor(),//
                // *
                // text.getFont().getSize(),
                horizontalAlignment);

        colText.setLeading(0, text.getLineSpacingFactor());// *
        // text.getFont().getSize());
        colText.setRunDirection(
                text.getRunDirection() == JRPrintText.RUN_DIRECTION_LTR ? PdfWriter.RUN_DIRECTION_LTR
                        : PdfWriter.RUN_DIRECTION_RTL);

        float yLine = colText.getYLine();

        // ColumnText
        while (colText.hasMoreText(status)) {
            status = colText.go(true);
            colText.setYLine(yLine);

            // ??,true
            if (status == ColumnText.NO_MORE_COLUMN) {
                isOver = true;
                break;
            }
        }

        // ,ColumnText
        if (!isOver) {
            colText.setText(phrase);
            status = ColumnText.START_COLUMN;

            while (colText.hasMoreText(status)) {
                status = colText.go();
                colText.setYLine(yLine);
            }

        } else {
            // TextField,??
            String key = text.getKey();// PdfTextid
            if (alreadyExistFields.contains(key)) { // ?
                key = createUniqueName();
            }
            alreadyExistFields.add(key);
            TextField tf = new TextField(pdfContentByte.getPdfWriter(), new Rectangle(llx, lly, urx, ury), key);
            tf.setAlignment(horizontalAlignment);
            tf.setText(text.getText());
            tf.setFont(PdfUtils.createSongLightBaseFont());

            // styledText ??,?
            if (!text.isStyledText()) {
                tf.setOptions(TextField.MULTILINE);
            }

            try {
                pdfContentByte.getPdfWriter().addAnnotation(tf.getTextField());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    atrans = new AffineTransform();
    atrans.rotate(-angle, x, jasperPrint.getPageHeight() - y);
    pdfContentByte.transform(atrans);

    /*   */
    exportBox(text, text);
}

From source file:net.sf.jasperreports.engine.export.JRPdfExporter.java

License:LGPL

/**
 *
 *//*from  w w  w . ja  v  a2s.  co m*/
protected void exportText(JRPrintText text) throws DocumentException {
    JRStyledText styledText = getStyledText(text, false);

    if (styledText == null) {
        return;
    }

    int textLength = styledText.length();

    int x = text.getX() + getOffsetX();
    int y = text.getY() + getOffsetY();
    int width = text.getWidth();
    int height = text.getHeight();
    int topPadding = text.getLineBox().getTopPadding().intValue();
    int leftPadding = text.getLineBox().getLeftPadding().intValue();
    int bottomPadding = text.getLineBox().getBottomPadding().intValue();
    int rightPadding = text.getLineBox().getRightPadding().intValue();

    int xFillCorrection = 0;
    int yFillCorrection = 0;

    double angle = 0;

    switch (text.getRotation()) {
    case JRTextElement.ROTATION_LEFT: {
        y = text.getY() + getOffsetY() + text.getHeight();
        xFillCorrection = 1;
        width = text.getHeight();
        height = text.getWidth();
        int tmpPadding = topPadding;
        topPadding = leftPadding;
        leftPadding = bottomPadding;
        bottomPadding = rightPadding;
        rightPadding = tmpPadding;
        angle = Math.PI / 2;
        break;
    }
    case JRTextElement.ROTATION_RIGHT: {
        x = text.getX() + getOffsetX() + text.getWidth();
        yFillCorrection = -1;
        width = text.getHeight();
        height = text.getWidth();
        int tmpPadding = topPadding;
        topPadding = rightPadding;
        rightPadding = bottomPadding;
        bottomPadding = leftPadding;
        leftPadding = tmpPadding;
        angle = -Math.PI / 2;
        break;
    }
    case JRTextElement.ROTATION_UPSIDE_DOWN: {
        x = text.getX() + getOffsetX() + text.getWidth();
        y = text.getY() + getOffsetY() + text.getHeight();
        int tmpPadding = topPadding;
        topPadding = bottomPadding;
        bottomPadding = tmpPadding;
        tmpPadding = leftPadding;
        leftPadding = rightPadding;
        rightPadding = tmpPadding;
        angle = Math.PI;
        break;
    }
    case JRTextElement.ROTATION_NONE:
    default: {
    }
    }

    AffineTransform atrans = new AffineTransform();
    atrans.rotate(angle, x, jasperPrint.getPageHeight() - y);
    pdfContentByte.transform(atrans);

    if (text.getMode() == JRElement.MODE_OPAQUE) {
        Color backcolor = text.getBackcolor();
        pdfContentByte.setRGBColorFill(backcolor.getRed(), backcolor.getGreen(), backcolor.getBlue());
        pdfContentByte.rectangle(x + xFillCorrection, jasperPrint.getPageHeight() - y + yFillCorrection, width,
                -height);
        pdfContentByte.fill();
    }

    if (textLength > 0) {
        int horizontalAlignment = Element.ALIGN_LEFT;
        switch (text.getHorizontalAlignment()) {
        case JRAlignment.HORIZONTAL_ALIGN_LEFT: {
            if (text.getRunDirection() == JRPrintText.RUN_DIRECTION_LTR) {
                horizontalAlignment = Element.ALIGN_LEFT;
            } else {
                horizontalAlignment = Element.ALIGN_RIGHT;
            }
            break;
        }
        case JRAlignment.HORIZONTAL_ALIGN_CENTER: {
            horizontalAlignment = Element.ALIGN_CENTER;
            break;
        }
        case JRAlignment.HORIZONTAL_ALIGN_RIGHT: {
            if (text.getRunDirection() == JRPrintText.RUN_DIRECTION_LTR) {
                horizontalAlignment = Element.ALIGN_RIGHT;
            } else {
                horizontalAlignment = Element.ALIGN_LEFT;
            }
            break;
        }
        case JRAlignment.HORIZONTAL_ALIGN_JUSTIFIED: {
            horizontalAlignment = Element.ALIGN_JUSTIFIED;
            break;
        }
        default: {
            horizontalAlignment = Element.ALIGN_LEFT;
        }
        }

        float verticalOffset = 0f;
        switch (text.getVerticalAlignment()) {
        case JRAlignment.VERTICAL_ALIGN_TOP: {
            verticalOffset = 0f;
            break;
        }
        case JRAlignment.VERTICAL_ALIGN_MIDDLE: {
            verticalOffset = (height - topPadding - bottomPadding - text.getTextHeight()) / 2f;
            break;
        }
        case JRAlignment.VERTICAL_ALIGN_BOTTOM: {
            verticalOffset = height - topPadding - bottomPadding - text.getTextHeight();
            break;
        }
        default: {
            verticalOffset = 0f;
        }
        }

        ColumnText colText = new ColumnText(pdfContentByte);
        colText.setSimpleColumn(getPhrase(styledText, text), x + leftPadding,
                jasperPrint.getPageHeight() - y - topPadding - verticalOffset - text.getLeadingOffset(),
                //+ text.getLineSpacingFactor() * text.getFont().getSize(),
                x + width - rightPadding, jasperPrint.getPageHeight() - y - height + bottomPadding, 0, //text.getLineSpacingFactor(),// * text.getFont().getSize(),
                horizontalAlignment);

        colText.setLeading(0, text.getLineSpacingFactor());// * text.getFont().getSize());
        colText.setRunDirection(
                text.getRunDirection() == JRPrintText.RUN_DIRECTION_LTR ? PdfWriter.RUN_DIRECTION_LTR
                        : PdfWriter.RUN_DIRECTION_RTL);

        colText.go();
    }

    atrans = new AffineTransform();
    atrans.rotate(-angle, x, jasperPrint.getPageHeight() - y);
    pdfContentByte.transform(atrans);

    /*   */
    exportBox(text.getLineBox(), text);
}

From source file:net.sf.jasperreports.engine.export.SimplePdfTextRenderer.java

License:Open Source License

/**
 * /* www.j  av  a2  s .  c o  m*/
 */
public void render() {
    ColumnText colText = new ColumnText(pdfContentByte);
    colText.setSimpleColumn(getPhrase(styledText, text), x + leftPadding,
            pdfExporter.getCurrentJasperPrint().getPageHeight() - y - topPadding - verticalAlignOffset
                    - text.getLeadingOffset(),
            //+ text.getLineSpacingFactor() * text.getFont().getSize(),
            x + width - rightPadding,
            pdfExporter.getCurrentJasperPrint().getPageHeight() - y - height + bottomPadding, 0, //text.getLineSpacingFactor(),// * text.getFont().getSize(),
            horizontalAlignment == Element.ALIGN_JUSTIFIED_ALL ? Element.ALIGN_JUSTIFIED : horizontalAlignment);

    colText.setLeading(0, text.getLineSpacingFactor());// * text.getFont().getSize());
    colText.setRunDirection(text.getRunDirectionValue() == RunDirectionEnum.LTR ? PdfWriter.RUN_DIRECTION_LTR
            : PdfWriter.RUN_DIRECTION_RTL);

    try {
        colText.go();
    } catch (DocumentException e) {
        throw new JRRuntimeException(e);
    }
}

From source file:org.tellervo.desktop.print.CompleteBoxLabel.java

License:Open Source License

public void generateBoxLabel(OutputStream output) {

    try {/*from  ww  w.j  av  a2  s. com*/

        PdfWriter writer = PdfWriter.getInstance(document, output);

        document.setPageSize(PageSize.LETTER);
        document.open();

        cb = writer.getDirectContent();

        // Set basic metadata
        document.addAuthor("Peter Brewer");
        document.addSubject("Box Label");

        for (WSIBox b : this.boxlist) {

            // Title Left      
            ColumnText ct = new ColumnText(cb);
            ct.setSimpleColumn(document.left(), document.top(15) - 210, 368, document.top(15), 20,
                    Element.ALIGN_LEFT);
            ct.addText(getTitlePDF(b));
            ct.go();

            // Barcode
            ColumnText ct2 = new ColumnText(cb);
            ct2.setSimpleColumn(370, document.top(15) - 100, document.right(0), document.top(0), 20,
                    Element.ALIGN_RIGHT);
            ct2.addElement(getBarCode(b));
            ct2.go();

            // Timestamp
            ColumnText ct3 = new ColumnText(cb);
            ct3.setSimpleColumn(document.left(), document.top(15) - 223, 350, document.top(15) - 60, 20,
                    Element.ALIGN_LEFT);
            ct3.setLeading(0, 1.2f);
            ct3.addText(getTimestampPDF(b));
            ct3.go();

            // Pad text
            document.add(new Paragraph(" "));
            Paragraph p2 = new Paragraph();
            p2.setSpacingBefore(70);
            p2.setSpacingAfter(10);
            p2.add(new Chunk(" ", bodyFontLarge));
            document.add(new Paragraph(p2));

            // Ring samples table
            addTable(b);
            document.add(getParagraphSpace());

            document.add(getComments(b));

            document.newPage();

        }

    } catch (DocumentException de) {
        System.err.println(de.getMessage());
    }

    // Close the document
    document.close();
}

From source file:org.tellervo.desktop.print.ProSheet.java

License:Open Source License

private void generateProSheet(OutputStream output) {

    Paragraph spacingPara = new Paragraph();
    spacingPara.setSpacingBefore(10);/* w  w  w  .ja v a2s  .  c om*/
    spacingPara.add(new Chunk(" ", bodyFont));

    try {

        PdfWriter writer = PdfWriter.getInstance(document, output);
        document.setPageSize(PageSize.LETTER);

        // Set basic metadata
        document.addAuthor("Peter Brewer");
        document.addSubject("Corina Provenience Sheet for " + o.getTitle());

        HeaderFooter footer = new HeaderFooter(new Phrase(""), new Phrase(""));
        footer.setAlignment(Element.ALIGN_RIGHT);
        footer.setBorder(0);
        document.setFooter(footer);

        HeaderFooter header = new HeaderFooter(new Phrase(o.getLabCode() + " - " + o.getTitle(), bodyFont),
                false);
        header.setAlignment(Element.ALIGN_RIGHT);
        header.setBorder(0);
        document.setHeader(header);

        document.open();
        cb = writer.getDirectContent();

        // Title Left      
        ColumnText ct = new ColumnText(cb);
        ct.setSimpleColumn(document.left(), document.top() - 193, document.right(), document.top() - 20, 20,
                Element.ALIGN_LEFT);
        ct.addText(getTitlePDF());
        ct.go();

        // Timestamp
        ColumnText ct3 = new ColumnText(cb);
        ct3.setSimpleColumn(document.left(), document.top() - 223, 283, document.top() - 60, 20,
                Element.ALIGN_LEFT);
        ct3.setLeading(0, 1.2f);
        ct3.addText(getTimestampPDF());
        ct3.go();

        // Pad text
        document.add(spacingPara);
        document.add(getObjectDescription());
        document.add(getObjectComments());

        document.add(spacingPara);

        getElementTable();

    } catch (DocumentException de) {
        System.err.println(de.getMessage());
    }

    // Close the document
    document.close();
}

From source file:org.tellervo.desktop.print.SeriesReport.java

License:Open Source License

private void generateSeriesReport(OutputStream output) {

    displayUnits = NormalTridasUnit//from  ww  w .  jav a 2 s  .com
            .valueOf(App.prefs.getPref(PrefKey.DISPLAY_UNITS, NormalTridasUnit.MICROMETRES.name().toString()));

    try {

        PdfWriter writer = PdfWriter.getInstance(document, output);
        document.setPageSize(PageSize.LETTER);
        document.open();
        cb = writer.getDirectContent();

        // Set basic metadata
        document.addAuthor("Peter Brewer");
        document.addSubject("Tellervo Series Report for " + s.getDisplayTitle());

        // Title Left      
        ColumnText ct = new ColumnText(cb);
        ct.setSimpleColumn(document.left(), document.top() - 163, 283, document.top(), 20, Element.ALIGN_LEFT);
        ct.addText(getTitlePDF());
        ct.go();

        // Barcode
        ColumnText ct2 = new ColumnText(cb);
        ct2.setSimpleColumn(370, document.top(15) - 100, document.right(0), document.top(0), 20,
                Element.ALIGN_RIGHT);
        ct2.addElement(getBarCode());
        ct2.go();

        // Timestamp
        ColumnText ct3 = new ColumnText(cb);
        ct3.setSimpleColumn(document.left(), document.top() - 223, 283, document.top() - 60, 20,
                Element.ALIGN_LEFT);
        ct3.setLeading(0, 1.2f);
        ct3.addText(getTimestampPDF());
        ct3.go();

        // Authorship
        ColumnText ct4 = new ColumnText(cb);
        ct4.setSimpleColumn(284, document.top() - 223, document.right(10), document.top() - 60, 20,
                Element.ALIGN_RIGHT);
        ct4.setLeading(0, 1.2f);
        ct4.addText(getAuthorshipPDF());
        ct4.go();

        // Pad text
        document.add(new Paragraph(" "));
        Paragraph p2 = new Paragraph();
        p2.setSpacingBefore(50);
        p2.setSpacingAfter(10);
        p2.add(new Chunk(" ", bodyFont));
        document.add(new Paragraph(p2));

        // Ring width table
        getRingWidthTable();
        document.add(getParagraphSpace());

        if (s.getSeries() instanceof TridasMeasurementSeries) {
            // MEASUREMENT SERIES

            //document.add(getRingRemarks());
            document.add(getWoodCompletenessPDF());
            document.add(getParagraphSpace());
            document.add(getSeriesComments());
            document.add(getParagraphSpace());
            document.add(getInterpretationPDF());
            document.add(getParagraphSpace());
            document.add(getElementAndSampleInfo());
        } else {
            // DERIVED SERIES
            getWJTable();
            document.add(getParagraphSpace());
            document.add(getSeriesComments());
            document.add(getParagraphSpace());
            //document.add(getRingRemarks());

        }

    } catch (DocumentException de) {
        System.err.println(de.getMessage());
    }

    // Close the document
    document.close();
}