Package com.lowagie.text.pdf

Examples of com.lowagie.text.pdf.PdfContentByte.addTemplate()


        rotation = reader.getPageRotation(i);
        if (rotation == 90 || rotation == 270) {
          cb.addTemplate(page, 0, -factor, factor, 0, x1 + dx, y2[p] + dy + rect.height() * factor);
        }
        else {
          cb.addTemplate(page, factor, 0, 0, factor, x1 + dx, y2[p] + dy);
        }
        cb.setRGBColorStroke(0xC0, 0xC0, 0xC0);
        cb.rectangle(x3 - 5f, y2[p] - 5f, x4 - x3 + 10f, y1[p] - y2[p] + 10f);
        for (float l = y1[p] - 19; l > y2[p]; l -= 16) {
          cb.moveTo(x3, l);
View Full Code Here


        float adjust = headerFont.getWidthPoint("0", 10);
        cb.setTextMatrix(document.right() - textSize - adjust, textBase);
        cb.showText(text);
        cb.endText();
        cb.addTemplate(tpl, document.right() - adjust, textBase);

        cb.saveState();
        // draw a Rectangle around the page
        cb.setLineWidth(1);
        cb.rectangle(30, 30, document.getPageSize().width() - 60, document.getPageSize().height() - 60);
View Full Code Here

        document.setPageSize(reader.getPageSizeWithRotation(i));
        document.newPage();
        page = writer.getImportedPage(reader, i);
        rotation = reader.getPageRotation(i);
        if (rotation == 90 || rotation == 270) {
          cb.addTemplate(page, 0, -1f, 1f, 0, 0, reader
              .getPageSizeWithRotation(i).getHeight());
        } else {
          cb.addTemplate(page, 1f, 0, 0, 1f, 0, 0);
        }
        System.out.printf("Processed page %s\n", i);
View Full Code Here

        rotation = reader.getPageRotation(i);
        if (rotation == 90 || rotation == 270) {
          cb.addTemplate(page, 0, -1f, 1f, 0, 0, reader
              .getPageSizeWithRotation(i).getHeight());
        } else {
          cb.addTemplate(page, 1f, 0, 0, 1f, 0, 0);
        }
        System.out.printf("Processed page %s\n", i);
      }
      // --Add JS code
      writer
View Full Code Here

        PdfTemplate tp = cb.createTemplate(width, height);
        Graphics2D g2 = tp.createGraphics(width, height, mapper);
        Rectangle2D r2D = new Rectangle2D.Double(0, 0, width, height);
        chart.draw(g2, r2D);
        g2.dispose();
        cb.addTemplate(tp, 0, 0);
      }
      catch (DocumentException de) {
        System.err.println(de.getMessage());
      }
      document.close();
View Full Code Here

            try {
              PdfReader reader = new PdfReader(content);
              PdfContentByte cb = writer.getDirectContent();
              PdfImportedPage page = writer.getImportedPage(reader, 1);
              float[] tm = getTransformationMatrix(page, xPos, yPos, tableWidth, tableHeight);
              cb.addTemplate(page, tm[0], tm[1], tm[2], tm[3], tm[4], tm[5]);
            } catch (Exception x) {
              logger.error("Error in inserting image for document " + label, e);
              logger.error("Error in inserting pdf file for document " + label, x);
            }
            continue;
View Full Code Here

            while (i < n) {
                document.newPage();
                p++;
                i++;
                PdfImportedPage page1 = writer.getImportedPage(reader, i);
                cb.addTemplate(page1, .5f, 0, 0, .5f, 60, 120);
                if (i < n) {
                    i++;
                    PdfImportedPage page2 = writer.getImportedPage(reader, i);
                    cb.addTemplate(page2, .5f, 0, 0, .5f, width / 2 + 60, 120);
                }
View Full Code Here

                PdfImportedPage page1 = writer.getImportedPage(reader, i);
                cb.addTemplate(page1, .5f, 0, 0, .5f, 60, 120);
                if (i < n) {
                    i++;
                    PdfImportedPage page2 = writer.getImportedPage(reader, i);
                    cb.addTemplate(page2, .5f, 0, 0, .5f, width / 2 + 60, 120);
                }
                BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
                cb.beginText();
                cb.setFontAndSize(bf, 14);
                cb.showTextAligned(PdfContentByte.ALIGN_CENTER, "page " + p + " of " + ((n / 2) + (n % 2 > 0? 1 : 0)), width / 2, 40, 0);
View Full Code Here

            FontMetrics metrics = g2.getFontMetrics();
            int width = metrics.stringWidth(pear);
            g2.drawString(pear, (w - width) / 2, 20);
            g2.dispose();
            tp.sanityCheck(); // all the g2 content is written to tp, not cb
            cb.addTemplate(tp, 50, 400);
            cb.sanityCheck();
        }
        catch(DocumentException de) {
            System.err.println(de.getMessage());
        }
View Full Code Here

            cb.setFontAndSize(helv, 12);
            float adjust = helv.getWidthPoint("0", 12);
            cb.setTextMatrix(document.right() - textSize - adjust, textBase);
            cb.showText(text);
            cb.endText();
            cb.addTemplate(tpl, document.right() - adjust, textBase);
            cb.saveState();
        }
    }
}
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.