Example usage for com.lowagie.text.pdf PdfContentByte concatCTM

List of usage examples for com.lowagie.text.pdf PdfContentByte concatCTM

Introduction

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

Prototype

public void concatCTM(float a, float b, float c, float d, float e, float f) 

Source Link

Document

Concatenate a matrix to the current transformation matrix.

Usage

From source file:com.aryjr.nheengatu.testes.AbsolutePosition.java

License:Open Source License

public static void main(final String[] args) {
    //      System.out.println("My First PdfPTable");
    final Document document = new Document();
    try {//  www .jav a2  s. c o  m
        final PdfWriter writer = PdfWriter.getInstance(document,
                new FileOutputStream("/home/aryjr/MyFirstTable.pdf"));
        document.open();
        // PdfPTable table = createTable();
        // document.add(table);
        // table.writeSelectedRows(0, -1, 50, 200,
        // writer.getDirectContent());
        final PdfContentByte cb = writer.getDirectContent();
        cb.concatCTM(1f, 0f, 0f, -1f, 0f, 0f);
        // Paragraph text = new Paragraph("Ary Junior",
        // FontFactory.getFont(Style.DEFAULT_FONT_FAMILY,
        // Style.DEFAULT_FONT_SIZE, Font.NORMAL, Style.DEFAULT_FONT_COLOR));
        final BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
        cb.beginText();
        cb.setFontAndSize(bf, 12);
        cb.showText("Ary Junior");
        cb.endText();
        Runtime.getRuntime().exec("acroread /home/aryjr/MyFirstTable.pdf");
    } catch (final DocumentException de) {
        System.err.println(de.getMessage());
    } catch (final IOException ioe) {
        System.err.println(ioe.getMessage());
    }
    document.close();
}

From source file:org.eclipse.birt.report.engine.emitter.pdf.PDFPage.java

License:Open Source License

/**
 * Draws a line with the line-style specified in advance from the start
 * position to the end position with the given linewidth, color, and style
 * at the given pdf layer. If the line-style is NOT set before invoking this
 * method, "solid" will be used as the default line-style.
 *
 * @param startX/*from   w w  w  .  j a v  a2 s . co  m*/
 *            the start X coordinate of the line
 * @param startY
 *            the start Y coordinate of the line
 * @param endX
 *            the end X coordinate of the line
 * @param endY
 *            the end Y coordinate of the line
 * @param width
 *            the lineWidth
 * @param color
 *            the color of the line
 * @param contentByte
 *            the given pdf layer
 */
private void drawRawLine(float startX, float startY, float endX, float endY, float width, Color color,
        PdfContentByte contentByte) {
    startY = transformY(startY);
    endY = transformY(endY);
    contentByte.concatCTM(1, 0, 0, 1, startX, startY);

    contentByte.moveTo(0, 0);
    contentByte.lineTo(endX - startX, endY - startY);

    contentByte.setLineWidth(width);
    contentByte.setColorStroke(color);
    contentByte.stroke();
}

From source file:org.eclipse.birt.report.engine.emitter.pdf.PDFPage.java

License:Open Source License

private void setTextMatrix(PdfContentByte cb, FontInfo fi, float x, float y) {
    cb.concatCTM(1, 0, 0, 1, x, y);
    if (!fi.getSimulation()) {
        cb.setTextMatrix(0, 0);/*from   w  ww. j  a  va2 s.com*/
        return;
    }
    switch (fi.getFontStyle()) {
    case Font.ITALIC: {
        simulateItalic(cb);
        break;
    }
    case Font.BOLD: {
        simulateBold(cb, fi.getFontWeight());
        break;
    }
    case Font.BOLDITALIC: {
        simulateBold(cb, fi.getFontWeight());
        simulateItalic(cb);
        break;
    }
    }
}

From source file:org.interpss.editor.codecs.FileExportPDF.java

License:Open Source License

/**
 * @see java.awt.event.ActionListener#actionPerformed(ActionEvent)
 *//* w  w w . ja v a2s  . co  m*/
public void actionPerformed(ActionEvent e) {
    Document document = new Document();
    try {

        String file = saveDialog(Translator.getString("FileSaveAsLabel") + " " + fileType.toUpperCase(),
                fileType.toLowerCase(), fileType.toUpperCase() + " Image");
        if (file == null)
            return;

        JGraph graph = getCurrentGraph();
        Object[] cells = graph.getDescendants(graph.getRoots());
        if (cells.length > 0 && file != null && file.length() > 0) {
            PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(file));
            document.open();

            Rectangle2D bounds = graph.getCellBounds(cells);
            graph.toScreen(bounds);
            Dimension d = bounds.getBounds().getSize();

            Object[] selection = graph.getSelectionCells();
            boolean gridVisible = graph.isGridVisible();
            boolean doubleBuffered = graph.isDoubleBuffered();
            graph.setGridVisible(false);
            graph.setDoubleBuffered(false);
            graph.clearSelection();

            PdfContentByte cb = writer.getDirectContent();
            cb.saveState();
            cb.concatCTM(1, 0, 0, 1, 50, 400);
            Graphics2D g2 = cb.createGraphics(d.width + 10, d.height + 10);

            g2.setColor(graph.getBackground());
            g2.fillRect(0, 0, d.width + 10, d.height + 10);
            g2.translate(-bounds.getX() + 5, -bounds.getY() + 5);

            graph.paint(g2);

            graph.setSelectionCells(selection);
            graph.setGridVisible(gridVisible);
            graph.setDoubleBuffered(doubleBuffered);

            g2.dispose();
            cb.restoreState();
        }
    } catch (IOException ex) {
        graphpad.error(ex.getMessage());
    } catch (DocumentException e2) {
        graphpad.error(e2.getMessage());
    }
    document.close();
}