Package com.lowagie.text.pdf

Examples of com.lowagie.text.pdf.PdfContentByte


   * Adds the header and the footer.
   * @see com.itextpdf.text.pdf.PdfPageEventHelper#onEndPage(
   *      com.itextpdf.text.pdf.PdfWriter, com.itextpdf.text.Document)
   */
  public void onEndPage(PdfWriter writer, Document document) {
    PdfContentByte cb = writer.getDirectContent();

    String textPageOfPage = String.format(pageOfPage, writer.getPageNumber());   
    float textBase = 18;
    float textSize = helv.getWidthPoint(textPageOfPage, fontSize);
    float adjust = helv.getWidthPoint("0", fontSize);
    cb.addTemplate(total, document.right() - adjust, textBase);
    cb.saveState();
    cb.beginText();
    cb.setFontAndSize(helv, fontSize);

    cb.setTextMatrix(document.right() - textSize - adjust*2 , textBase);
    cb.showText(textPageOfPage);

    if (editTextAlign == Chunk.ALIGN_LEFT) {
      cb.setTextMatrix(document.left(), textBase);
    } else {
      float editDateTextSize = helv.getWidthPoint(footerText, fontSize);
      cb.setTextMatrix((document.right() - document.left()- editDateTextSize)/2, textBase);
    }
    cb.showText(footerText);

    cb.endText();

    if (headerLogo != null) {

      try {
        cb.addImage(headerLogo);
      } catch (DocumentException e) {
        // TODO Auto-generated catch block
      }
    }
    if (recHeader != null) {
      cb.rectangle(recHeader.getLeft(), recHeader.getBottom(), recHeader.getWidth(), recHeader.getHeight());
      cb.setLineWidth(/*0.5f*/0f);
      //cb.stroke();
    }

    if (footerLogo != null) {

      try {
        cb.addImage(footerLogo);
      } catch (DocumentException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }
    if (recFooter != null) {
      cb.rectangle(recFooter.getLeft(), recFooter.getBottom(), recFooter.getWidth(), recFooter.getHeight());
      cb.setLineWidth(/*0.5f*/0f);
      //cb.stroke();
    }

    cb.restoreState();

  }
 
View Full Code Here


  /**
   * O PDF ORIGINAL (TEMPLATE) TEM QUE ESTAR EM A4 E NUNCA EM LETTER, SE SE QUISEREM V�RIAS P�GINAS.
   */
  public void addAndReplacePage(PDFTemplate template, ListMap values, ListMap fieldsWithSpecialFont, ListMap fieldsWithColor) throws Exception {

    PdfContentByte cb = _writer.getDirectContent();

    org.jdom.Document specTemplate = template.pdfSpec;

    PdfReader _reader = new PdfReader(template.pdfFileCb);
    addPage(cb, _reader, 1);    // S� adiciona a 1� p�gina de cada template
View Full Code Here

        try {
            PdfWriter writer = PdfWriter.getInstance(document, out);
            document.addAuthor("EAS-StaticMethods");
            document.addSubject("EAS-StandardSubject");
            document.open();
            PdfContentByte cb = writer.getDirectContent();
            PdfTemplate tp = cb.createTemplate(width, height);
            Graphics2D g2 = tp.createGraphics(width, height, mapper);
            env.getOutsideView(g2);
            g2.dispose();
            cb.addTemplate(tp, 0, 0);
        } catch (DocumentException de) {
            System.err.println(de.getMessage());
        }
        document.close();
    }
View Full Code Here

        try {
            PdfWriter writer = PdfWriter.getInstance(document, out);
            document.addAuthor("EAS-ChartPlugin");
            document.addSubject(chart.getTitle().getText());
            document.open();
            PdfContentByte cb = writer.getDirectContent();
            PdfTemplate tp = cb.createTemplate(width, height);
            Graphics2D g2 = tp.createGraphics(width, height, mapper);
            java.awt.geom.Rectangle2D r2D = new java.awt.geom.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

        Document document = new Document(new Rectangle(height, width));
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream( output ));

        document.open();

        PdfContentByte cb = writer.getDirectContent();

        int i = 0;
        while (i < n) {
            i++;
            document.newPage();
            PdfImportedPage page = writer.getImportedPage(reader, i);
            cb.addTemplate(page, factor, 0, 0, factor, left, down);
        }

        document.close();
    }
View Full Code Here

    
        try {
            writer = PdfWriter.getInstance(document, new FileOutputStream(
                    fileName));
            document.open();
            PdfContentByte contentByte = writer.getDirectContent();
            PdfTemplate template = contentByte.createTemplate(width, height);
            Graphics2D graphics2d = template.createGraphics(width, height,
                    new DefaultFontMapper());
            Rectangle2D rectangle2d = new Rectangle2D.Double(0, 0, width,
                    height);
    
            chart.draw(graphics2d, rectangle2d);
    
            graphics2d.dispose();
            contentByte.addTemplate(template, 0, 0);
    
        } catch (Exception e) {
            e.printStackTrace();
        }
        document.close();
View Full Code Here

            {
            }
            catch (IOException e)
            {
            }
            PdfContentByte cb = writer.getDirectContent();
            cb.saveState();
            // write the headertable
            table.setTotalWidth(document.right() - document.left());
            table.writeSelectedRows(0, -1, document.left(), document.getPageSize().getHeight() - 50, cb);
            // compose the footer
            String text = "Page " + writer.getPageNumber();
            float textSize = helv.getWidthPoint(text, 12);
            float textBase = document.bottom() - 20;
            cb.beginText();
            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

                 new FileOutputStream(target));
           else
              writer = PdfWriter.getInstance(document,
                 new FileOutputStream(target));
           document.open();
           PdfContentByte cb = writer.getDirectContent();
           PdfTemplate tp = cb.createTemplate(xWidth, yWidth);
           Graphics2D g2;
           if (shapes) {
              g2 = tp.createGraphicsShapes(xWidth, yWidth);
           } else {
              g2 = tp.createGraphics(xWidth, yWidth);
           }
           this.print(g2);
           g2.dispose();
           cb.addTemplate(tp, 0, -200);
        } catch (Exception e) {
            System.err.println(e.getMessage());
        }
        document.close();
    }
View Full Code Here

        try {
        PdfWriter writer = PdfWriter.getInstance(document, out);
        document.addAuthor("JFreeChart");
        document.addSubject("Demonstration");
        document.open();
        PdfContentByte cb = writer.getDirectContent();
        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());
        }
    }
View Full Code Here

        // step 2
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(filename));
        // step 3
        document.open();
        // step 4
        PdfContentByte canvas = writer.getDirectContent();
        Graphics2D g2 = canvas.createGraphics(width, height);
        Rectangle2D area = new Rectangle2D.Double(0, 0, width, height);
        chart.draw(g2, area);
        g2.dispose();
        // step 5
        document.close();
View Full Code Here

TOP

Related Classes of com.lowagie.text.pdf.PdfContentByte

Copyright © 2018 www.massapicom. 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.