コード例 #1
0
ファイル: PlotPanel.java プロジェクト: scalalab/scalalab
  public void toPDFGraphicFile(File file, int width, int height) throws IOException {
    // otherwise toolbar appears
    plotToolBar.setVisible(false);

    com.lowagie.text.Document document = new com.lowagie.text.Document();
    document.setPageSize(new Rectangle(width, height));
    FileOutputStream fos = new FileOutputStream(file);

    PdfWriter writer = null;
    try {
      writer = PdfWriter.getInstance(document, fos);
    } catch (DocumentException ex) {
      Logger.getLogger(PlotPanel.class.getName()).log(Level.SEVERE, null, ex);
    }
    document.open();
    PdfContentByte cb = writer.getDirectContent();
    PdfTemplate tp = cb.createTemplate(width, height);
    Graphics2D g2d = tp.createGraphics(width, height);

    Image image = createImage(getWidth(), getHeight());
    paint(image.getGraphics());
    image = new ImageIcon(image).getImage();

    g2d.drawImage(image, 0, 0, Color.WHITE, null);
    g2d.dispose();
    cb.addTemplate(tp, 1, 0, 0, 1, 0, 0);

    document.close();
    // make it reappear
    plotToolBar.setVisible(true);
  }
コード例 #2
0
 /**
  * Método que se ejecuta cuando se cierra el documento.
  *
  * @param writer Creador de documentos.
  * @param document Documento del informe.
  */
 public void onCloseDocument(PdfWriter writer, Document document) {
   // Plantilla con el número total de páginas del documento
   tpl.beginText();
   tpl.setFontAndSize(HELVETICA, 8);
   tpl.setTextMatrix(0, 0);
   tpl.showText("" + (writer.getPageNumber() - 1));
   tpl.endText();
 }
コード例 #3
0
    protected void constructUnitSquare(Vector4 color, float size) {
      unitSquare = context.getOutput().createTemplate(size, size);

      unitSquare.circle(size / 2, size / 2, size / 2);

      unitSquare.setColorFill(new Color(clamp(color.x), clamp(color.y), clamp(color.z)));
      unitSquare.fill();
    }
コード例 #4
0
 public static PdfTemplate createRectTemplate(
     PdfContentByte directContent, final Color strokeColor) {
   PdfTemplate activeHealthRect = directContent.createTemplate(HEALTH_RECT_SIZE, HEALTH_RECT_SIZE);
   activeHealthRect.setLineWidth(1f);
   activeHealthRect.setColorStroke(strokeColor);
   activeHealthRect.rectangle(0, 0, HEALTH_RECT_SIZE, HEALTH_RECT_SIZE);
   activeHealthRect.stroke();
   return activeHealthRect;
 }
コード例 #5
0
ファイル: SgtUtil.java プロジェクト: BobSimons/erddap
  /**
   * This closes the pdf file created by createPDF, after you have written things to g2D.
   *
   * @param oar the object[] returned from createPdf
   * @throwsException if trouble
   */
  public static void closePdf(Object oar[]) throws Exception {
    Graphics2D g2D = (Graphics2D) oar[0];
    Document document = (Document) oar[1];
    PdfContentByte pdfContentByte = (PdfContentByte) oar[2];
    PdfTemplate pdfTemplate = (PdfTemplate) oar[3];

    g2D.dispose();

    // center it
    if (verbose)
      String2.log(
          "SgtUtil.closePdf"
              + " left="
              + document.left()
              + " right="
              + document.right()
              + " bottom="
              + document.bottom()
              + " top="
              + document.top()
              + " template.width="
              + pdfTemplate.getWidth()
              + " template.height="
              + pdfTemplate.getHeight());
    // x device = ax user + by user + e
    // y device = cx user + dy user + f
    pdfContentByte.addTemplate(
        pdfTemplate, // a,b,c,d,e,f      //x,y location in points
        0.5f,
        0,
        0,
        0.5f,
        document.left() + (document.right() - document.left() - pdfTemplate.getWidth() / 2) / 2,
        document.bottom() + (document.top() - document.bottom() - pdfTemplate.getHeight() / 2) / 2);

    /*
    //if boundingBox is small, center it
    //if boundingBox is large, shrink and center it
    //document.left/right/top/bottom include 1/2" margins
    float xScale = (document.right() - document.left())   / pdfTemplate.getWidth();
    float yScale = (document.top()   - document.bottom()) / pdfTemplate.getHeight();
    float scale = Math.min(Math.min(xScale, yScale), 1);
    float xSize = pdfTemplate.getWidth()  / scale;
    float ySize = pdfTemplate.getHeight() / scale;
    //x device = ax user + by user + e
    //y device = cx user + dy user + f
    pdfContentByte.addTemplate(pdfTemplate, //a,b,c,d,e,f
        scale, 0, 0, scale,
        document.left()   + (document.right() - document.left()   - xSize) / 2,
        document.bottom() + (document.top()   - document.bottom() - ySize) / 2);
    */

    document.close();
  }
コード例 #6
0
ファイル: UIChart.java プロジェクト: subaochen/seam
  @Override
  public void createITextObject(FacesContext context) {

    if (getBorderBackgroundPaint() != null) {
      chart.setBackgroundPaint(findColor(getBorderBackgroundPaint()));
    }

    if (getBorderPaint() != null) {
      chart.setBorderPaint(findColor(getBorderPaint()));
    }

    if (getBorderStroke() != null) {
      chart.setBorderStroke(findStroke(getBorderStroke()));
    }

    chart.setBorderVisible(getBorderVisible());

    configurePlot(chart.getPlot());

    try {
      UIDocument doc = (UIDocument) findITextParent(getParent(), UIDocument.class);
      if (doc != null) {
        PdfWriter writer = (PdfWriter) doc.getWriter();
        PdfContentByte cb = writer.getDirectContent();
        PdfTemplate tp = cb.createTemplate(getWidth(), getHeight());

        UIFont font = (UIFont) findITextParent(this, UIFont.class);

        DefaultFontMapper fontMapper;
        if (font == null) {
          fontMapper = new DefaultFontMapper();
        } else {
          fontMapper = new AsianFontMapper(font.getName(), font.getEncoding());
        }

        Graphics2D g2 = tp.createGraphics(getWidth(), getHeight(), fontMapper);
        chart.draw(g2, new Rectangle2D.Double(0, 0, getWidth(), getHeight()));
        g2.dispose();

        image = new ImgTemplate(tp);
      } else {
        ByteArrayOutputStream stream = new ByteArrayOutputStream();
        ChartUtilities.writeChartAsJPEG(stream, chart, getWidth(), getHeight());

        imageData = stream.toByteArray();
        stream.close();
      }
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
コード例 #7
0
ファイル: ImgWMF.java プロジェクト: SafetyCulture/DroidText
 /**
  * Reads the WMF into a template.
  *
  * @param template the template to read to
  * @throws IOException on error
  * @throws DocumentException on error
  */
 public void readWMF(PdfTemplate template) throws IOException, DocumentException {
   setTemplateData(template);
   template.setWidth(getWidth());
   template.setHeight(getHeight());
   InputStream is = null;
   try {
     if (rawData == null) {
       is = url.openStream();
     } else {
       is = new java.io.ByteArrayInputStream(rawData);
     }
     MetaDo meta = new MetaDo(is, template);
     meta.readAll();
   } finally {
     if (is != null) {
       is.close();
     }
   }
 }
コード例 #8
0
 public static PdfTemplate createLethalTemplate(
     PdfContentByte directContent, final Color strokeColor) {
   PdfTemplate lethalCross = directContent.createTemplate(HEALTH_RECT_SIZE, HEALTH_RECT_SIZE);
   lethalCross.addTemplate(createBashingTemplate(directContent, strokeColor), 0, 0);
   lethalCross.setLineWidth(1f);
   lethalCross.setColorStroke(strokeColor);
   lethalCross.moveTo(0, HEALTH_RECT_SIZE);
   lethalCross.lineTo(HEALTH_RECT_SIZE, 0);
   lethalCross.stroke();
   return lethalCross;
 }
コード例 #9
0
 public static PdfTemplate createAggravatedTemplate(
     PdfContentByte directContent, final Color strokeColor) {
   PdfTemplate aggravatedStar = directContent.createTemplate(HEALTH_RECT_SIZE, HEALTH_RECT_SIZE);
   aggravatedStar.addTemplate(createLethalTemplate(directContent, strokeColor), 0, 0);
   aggravatedStar.setLineWidth(1f);
   aggravatedStar.setColorStroke(strokeColor);
   aggravatedStar.moveTo(HEALTH_RECT_SIZE / 2f, 0);
   aggravatedStar.lineTo(HEALTH_RECT_SIZE / 2f, HEALTH_RECT_SIZE);
   aggravatedStar.stroke();
   return aggravatedStar;
 }
コード例 #10
0
ファイル: SgtUtil.java プロジェクト: BobSimons/erddap
  /**
   * This creates a file to capture the pdf output generated by calls to graphics2D (e.g., use
   * makeMap). This will overwrite an existing file.
   *
   * @param pageSize e.g, PageSize.LETTER or PageSize.LETTER.rotate() (or A4, or, ...)
   * @param width the bounding box width, in 1/144ths of an inch
   * @param height the bounding box height, in 1/144ths of an inch
   * @param outputStream
   * @return an object[] with 0=g2D, 1=document, 2=pdfContentByte, 3=pdfTemplate
   * @throws Exception if trouble
   */
  public static Object[] createPdf(
      com.lowagie.text.Rectangle pageSize, int bbWidth, int bbHeight, OutputStream outputStream)
      throws Exception {
    // currently, this uses itext
    // see the sample program:
    //
    // file://localhost/C:/programs/iText/examples/com/lowagie/examples/directcontent/graphics2D/G2D.java
    // Document.compress = false; //for test purposes only
    Document document = new Document(pageSize);
    document.addCreationDate();
    document.addCreator("gov.noaa.pfel.coastwatch.SgtUtil.createPdf");

    document.setPageSize(pageSize);
    PdfWriter writer = PdfWriter.getInstance(document, outputStream);
    document.open();

    // create contentByte and template and Graphics2D objects
    PdfContentByte pdfContentByte = writer.getDirectContent();
    PdfTemplate pdfTemplate = pdfContentByte.createTemplate(bbWidth, bbHeight);
    Graphics2D g2D = pdfTemplate.createGraphics(bbWidth, bbHeight);

    return new Object[] {g2D, document, pdfContentByte, pdfTemplate};
  }
コード例 #11
0
 public static PdfTemplate createBashingTemplate(
     PdfContentByte directContent, final Color strokeColor) {
   PdfTemplate bashingSlash = directContent.createTemplate(HEALTH_RECT_SIZE, HEALTH_RECT_SIZE);
   bashingSlash.setLineWidth(1f);
   bashingSlash.setColorStroke(strokeColor);
   bashingSlash.moveTo(0, 0);
   bashingSlash.lineTo(HEALTH_RECT_SIZE, HEALTH_RECT_SIZE);
   bashingSlash.stroke();
   return bashingSlash;
 }
コード例 #12
0
ファイル: Destinations.java プロジェクト: kjella/iText-4.2.0
  /**
   * Creates a document with some goto actions.
   *
   * @param args no arguments needed
   */
  public static void main(String[] args) {

    System.out.println("Destinations");

    // step 1: creation of a document-object
    Document document = new Document();
    try {

      // step 2:
      PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("Destinations.pdf"));
      // step 3:
      writer.setViewerPreferences(PdfWriter.PageModeUseOutlines);
      document.open();
      // step 4: we grab the ContentByte and do some stuff with it
      PdfContentByte cb = writer.getDirectContent();

      // we create a PdfTemplate
      PdfTemplate template = cb.createTemplate(25, 25);

      // we add some crosses to visualize the destinations
      template.moveTo(13, 0);
      template.lineTo(13, 25);
      template.moveTo(0, 13);
      template.lineTo(50, 13);
      template.stroke();

      // we add the template on different positions
      cb.addTemplate(template, 287, 787);
      cb.addTemplate(template, 187, 487);
      cb.addTemplate(template, 487, 287);
      cb.addTemplate(template, 87, 87);

      // we define the destinations
      PdfDestination d1 = new PdfDestination(PdfDestination.XYZ, 300, 800, 0);
      PdfDestination d2 = new PdfDestination(PdfDestination.FITH, 500);
      PdfDestination d3 = new PdfDestination(PdfDestination.FITR, 200, 300, 400, 500);
      PdfDestination d4 = new PdfDestination(PdfDestination.FITBV, 100);
      PdfDestination d5 = new PdfDestination(PdfDestination.FIT);

      // we define the outlines
      PdfOutline out1 = new PdfOutline(cb.getRootOutline(), d1, "root");
      PdfOutline out2 = new PdfOutline(out1, d2, "sub 1");
      new PdfOutline(out1, d3, "sub 2");
      new PdfOutline(out2, d4, "sub 2.1");
      new PdfOutline(out2, d5, "sub 2.2");
    } catch (Exception de) {
      de.printStackTrace();
    }

    // step 5: we close the document
    document.close();
  }
コード例 #13
0
 public void onCloseDocument(PdfWriter writer, Document document) {
   template.beginText();
   template.setFontAndSize(arial, FONT_SIZE);
   template.showText(String.valueOf(writer.getPageNumber() - 1));
   template.endText();
 }
コード例 #14
0
ファイル: TemplateImages.java プロジェクト: rototor/itext
  /**
   * PdfTemplates can be wrapped in an Image.
   *
   * @param args no arguments needed
   */
  public static void main(String[] args) {

    System.out.println("PdfTemplate wrapped in an Image");

    // step 1: creation of a document-object
    Rectangle rect = new Rectangle(PageSize.A4);
    rect.setBackgroundColor(new Color(238, 221, 88));
    Document document = new Document(rect, 50, 50, 50, 50);
    try {
      // step 2: we create a writer that listens to the document
      PdfWriter writer =
          PdfWriter.getInstance(document, new FileOutputStream("templateImages.pdf"));
      // step 3: we open the document
      document.open();
      // step 4:
      PdfTemplate template = writer.getDirectContent().createTemplate(20, 20);
      BaseFont bf =
          BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED);
      String text = "Vertical";
      float size = 16;
      float width = bf.getWidthPoint(text, size);
      template.beginText();
      template.setRGBColorFillF(1, 1, 1);
      template.setFontAndSize(bf, size);
      template.setTextMatrix(0, 2);
      template.showText(text);
      template.endText();
      template.setWidth(width);
      template.setHeight(size + 2);
      template.sanityCheck();
      Image img = Image.getInstance(template);
      img.setRotationDegrees(90);
      Chunk ck = new Chunk(img, 0, 0);
      PdfPTable table = new PdfPTable(3);
      table.setWidthPercentage(100);
      table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
      table.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE);
      PdfPCell cell = new PdfPCell(img);
      cell.setPadding(4);
      cell.setBackgroundColor(new Color(0, 0, 255));
      cell.setHorizontalAlignment(Element.ALIGN_CENTER);
      table.addCell("I see a template on my right");
      table.addCell(cell);
      table.addCell("I see a template on my left");
      table.addCell(cell);
      table.addCell("I see a template everywhere");
      table.addCell(cell);
      table.addCell("I see a template on my right");
      table.addCell(cell);
      table.addCell("I see a template on my left");

      Paragraph p1 = new Paragraph("This is a template ");
      p1.add(ck);
      p1.add(" just here.");
      p1.setLeading(img.getScaledHeight() * 1.1f);
      document.add(p1);
      document.add(table);
      Paragraph p2 = new Paragraph("More templates ");
      p2.setLeading(img.getScaledHeight() * 1.1f);
      p2.setAlignment(Element.ALIGN_JUSTIFIED);
      img.scalePercent(70);
      for (int k = 0; k < 20; ++k) p2.add(ck);
      document.add(p2);
      // step 5: we close the document
      document.close();
    } catch (Exception de) {
      System.err.println(de.getMessage());
    }
  }
コード例 #15
0
  protected void handleDocument(Document document, PdfWriter writer, Map model)
      throws DocumentException {

    java.util.List sampleList = (java.util.List) model.get("list");
    Integer scapeNo = (Integer) model.get("scapeNo");
    Iterator ir = sampleList.iterator();

    try {

      PdfContentByte cb = writer.getDirectContent();
      BaseFont bf = BaseFont.createFont("Helvetica", "winansi", false);

      int scapeN = scapeNo.intValue();
      int i = scapeN;
      int pageI = i;

      while (ir.hasNext()) {

        Sample sample = (Sample) ir.next();
        String internalId = sample.getPatient().getIntSampleId();

        PdfTemplate template = cb.createTemplate(templateW, templateL);

        // USING ean8 BARCODE
        Barcode128 code = new Barcode128();
        code.setCodeType(Barcode.CODE128);
        code.setX(0.75f);
        // log.debug("the x is " + codeEAN.getX());
        code.setBarHeight(barcodeSize);
        code.setSize(0);
        // code.setCode(formatBarcode(sampleId));
        code.setCode(internalId);
        Image imageBar = code.createImageWithBarcode(template, null, null);

        template.beginText();
        template.setFontAndSize(bf, fontSize);
        template.moveText(x, y2);
        template.showText(internalId);
        template.endText();

        template.addImage(imageBar, imageBar.width(), 0, 0, imageBar.height(), x, y1);

        int yNo = pageI / columnNo + 1;
        int xNo = pageI % columnNo;

        int templateX = marginX + (xNo * templateW);
        int templateY = totalPageY - marginY - (yNo * templateL);

        // log.debug("the i is "+i + " the adjustY is " + tempYAdjust + " the templateY is " +
        // templateY);

        cb.addTemplate(template, templateX, templateY);

        i++;
        pageI++;

        if ((i % (rowNo * columnNo)) == 0) {
          pageI = 0;

          // we go to a new page
          document.newPage();
        }
      }

      document.close();
      System.out.println("Finished.");
    } catch (Exception de) {
      de.printStackTrace();
    }
  }
コード例 #16
0
  /** Demonstrates the use of ColumnText. */
  @Test
  public void main() throws Exception {

    // step 1: creation of a document-object
    Document document = new Document();

    // step 2: creation of the writer
    PdfWriter writer =
        PdfWriter.getInstance(document, PdfTestBase.getOutputStream("columnirregular.pdf"));

    // step 3: we open the document
    document.open();

    // step 4:
    // we grab the contentbyte and do some stuff with it
    PdfContentByte cb = writer.getDirectContent();

    PdfTemplate t = cb.createTemplate(600, 800);
    Image caesar = Image.getInstance(PdfTestBase.RESOURCES_DIR + "caesar_coin.jpg");
    cb.addImage(caesar, 100, 0, 0, 100, 260, 595);
    t.setGrayFill(0.75f);
    t.moveTo(310, 112);
    t.lineTo(280, 60);
    t.lineTo(340, 60);
    t.closePath();
    t.moveTo(310, 790);
    t.lineTo(310, 710);
    t.moveTo(310, 580);
    t.lineTo(310, 122);
    t.stroke();
    cb.addTemplate(t, 0, 0);

    ColumnText ct = new ColumnText(cb);
    ct.addText(
        new Phrase(
            "GALLIA est omnis divisa in partes tres, quarum unam incolunt Belgae, aliam Aquitani, tertiam qui ipsorum lingua Celtae, nostra Galli appellantur.  Hi omnes lingua, institutis, legibus inter se differunt. Gallos ab Aquitanis Garumna flumen, a Belgis Matrona et Sequana dividit. Horum omnium fortissimi sunt Belgae, propterea quod a cultu atque humanitate provinciae longissime absunt, minimeque ad eos mercatores saepe commeant atque ea quae ad effeminandos animos pertinent important, proximique sunt Germanis, qui trans Rhenum incolunt, quibuscum continenter bellum gerunt.  Qua de causa Helvetii quoque reliquos Gallos virtute praecedunt, quod fere cotidianis proeliis cum Germanis contendunt, cum aut suis finibus eos prohibent aut ipsi in eorum finibus bellum gerunt.\n",
            FontFactory.getFont(FontFactory.HELVETICA, 12)));
    ct.addText(
        new Phrase(
            "[Eorum una, pars, quam Gallos obtinere dictum est, initium capit a flumine Rhodano, continetur Garumna flumine, Oceano, finibus Belgarum, attingit etiam ab Sequanis et Helvetiis flumen Rhenum, vergit ad septentriones. Belgae ab extremis Galliae finibus oriuntur, pertinent ad inferiorem partem fluminis Rheni, spectant in septentrionem et orientem solem. Aquitania a Garumna flumine ad Pyrenaeos montes et eam partem Oceani quae est ad Hispaniam pertinet; spectat inter occasum solis et septentriones.]\n",
            FontFactory.getFont(FontFactory.HELVETICA, 12)));
    ct.addText(
        new Phrase(
            "Apud Helvetios longe nobilissimus fuit et ditissimus Orgetorix.  Is M. Messala, [et P.] M.  Pisone consulibus regni cupiditate inductus coniurationem nobilitatis fecit et civitati persuasit ut de finibus suis cum omnibus copiis exirent:  perfacile esse, cum virtute omnibus praestarent, totius Galliae imperio potiri.  Id hoc facilius iis persuasit, quod undique loci natura Helvetii continentur:  una ex parte flumine Rheno latissimo atque altissimo, qui agrum Helvetium a Germanis dividit; altera ex parte monte Iura altissimo, qui est inter Sequanos et Helvetios; tertia lacu Lemanno et flumine Rhodano, qui provinciam nostram ab Helvetiis dividit.  His rebus fiebat ut et minus late vagarentur et minus facile finitimis bellum inferre possent; qua ex parte homines bellandi cupidi magno dolore adficiebantur.  Pro multitudine autem hominum et pro gloria belli atque fortitudinis angustos se fines habere arbitrabantur, qui in longitudinem milia passuum CCXL, in latitudinem CLXXX patebant.\n",
            FontFactory.getFont(FontFactory.HELVETICA, 12)));
    ct.addText(
        new Phrase(
            "His rebus adducti et auctoritate Orgetorigis permoti constituerunt ea quae ad proficiscendum pertinerent comparare, iumentorum et carrorum quam maximum numerum coemere, sementes quam maximas facere, ut in itinere copia frumenti suppeteret, cum proximis civitatibus pacem et amicitiam confirmare.  Ad eas res conficiendas biennium sibi satis esse duxerunt; in tertium annum profectionem lege confirmant.  Ad eas res conficiendas Orgetorix deligitur.  Is sibi legationem ad civitates suscipit.  In eo itinere persuadet Castico, Catamantaloedis filio, Sequano, cuius pater regnum in Sequanis multos annos obtinuerat et a senatu populi Romani amicus appellatus erat, ut regnum in civitate sua occuparet, quod pater ante habuerit; itemque Dumnorigi Haeduo, fratri Diviciaci, qui eo tempore principatum in civitate obtinebat ac maxime plebi acceptus erat, ut idem conaretur persuadet eique filiam suam in matrimonium dat.  Perfacile factu esse illis probat conata perficere, propterea quod ipse suae civitatis imperium obtenturus esset:  non esse dubium quin totius Galliae plurimum Helvetii possent; se suis copiis suoque exercitu illis regna conciliaturum confirmat.  Hac oratione adducti inter se fidem et ius iurandum dant et regno occupato per tres potentissimos ac firmissimos populos totius Galliae sese potiri posse sperant.\n",
            FontFactory.getFont(FontFactory.HELVETICA, 12)));
    ct.addText(
        new Phrase(
            "Ea res est Helvetiis per indicium enuntiata.  Moribus suis Orgetoricem ex vinculis causam dicere coegerunt; damnatum poenam sequi oportebat, ut igni cremaretur.  Die constituta causae dictionis Orgetorix ad iudicium omnem suam familiam, ad hominum milia decem, undique coegit, et omnes clientes obaeratosque suos, quorum magnum numerum habebat, eodem conduxit; per eos ne causam diceret se eripuit.  Cum civitas ob eam rem incitata armis ius suum exequi conaretur multitudinemque hominum ex agris magistratus cogerent, Orgetorix mortuus est; neque abest suspicio, ut Helvetii arbitrantur, quin ipse sibi mortem consciverit.",
            FontFactory.getFont(FontFactory.HELVETICA, 12)));

    float[] left1 = {70, 790, 70, 60};
    float[] right1 = {300, 790, 300, 700, 240, 700, 240, 590, 300, 590, 300, 106, 270, 60};
    float[] left2 = {320, 790, 320, 700, 380, 700, 380, 590, 320, 590, 320, 106, 350, 60};
    float[] right2 = {550, 790, 550, 60};

    int status = 0;
    int column = 0;
    while ((status & ColumnText.NO_MORE_TEXT) == 0) {
      if (column == 0) {
        ct.setColumns(left1, right1);
        column = 1;
      } else {
        ct.setColumns(left2, right2);
        column = 0;
      }
      status = ct.go();
      ct.setYLine(790);
      ct.setAlignment(Element.ALIGN_JUSTIFIED);
      status = ct.go();
      if ((column == 0) && ((status & ColumnText.NO_MORE_COLUMN) != 0)) {
        document.newPage();
        cb.addTemplate(t, 0, 0);
        cb.addImage(caesar, 100, 0, 0, 100, 260, 595);
      }
    }

    // step 5: we close the document
    document.close();
  }
コード例 #17
0
 /**
  * Método que se ejecuta cuando se abre el documento.
  *
  * @param writer Creador de documentos.
  * @param document Documento del informe.
  */
 public void onOpenDocument(PdfWriter writer, Document document) {
   // initialization of the template
   tpl = writer.getDirectContent().createTemplate(100, 100);
   tpl.setBoundingBox(new Rectangle(-20, -20, 100, 100));
 }