Package com.lowagie.text.pdf

Examples of com.lowagie.text.pdf.LwgPdfPCell


          new GfrFileOutputStream("com.lowagie.examples.objects.tables.TableWidthAlignment.pdf"));
      // step3
      document.open();
      // step4
      LwgPdfPTable table = new LwgPdfPTable(3);
      LwgPdfPCell cell = new LwgPdfPCell(new Paragraph("header with colspan 3"));
      cell.setColspan(3);
      table.add(cell);
      table.add("1.1");
      table.add("2.1");
      table.add("3.1");
      table.add("1.2");
      table.add("2.2");
      table.add("3.2");
      cell = new LwgPdfPCell(new Paragraph("cell test1"));
      cell.setBorderColor(new Color(255, 0, 0));
      table.add(cell);
      cell = new LwgPdfPCell(new Paragraph("cell test2"));
      cell.setColspan(2);
      cell.setBackgroundColor(new Color(0xC0, 0xC0, 0xC0));
      table.add(cell);
      document.add(table);
      table.setWidthPercentage(100);
      document.add(table);
      table.setWidthPercentage(50);
View Full Code Here


          new GfrFileOutputStream("com.lowagie.examples.objects.tables.CellAlignment.pdf"));
      // step3
      document.open();
      // step4
      LwgPdfPTable table = new LwgPdfPTable(2);
      LwgPdfPCell cell;
      Paragraph p = new Paragraph("Quick brown fox jumps over the lazy dog. Quick brown fox jumps over the lazy dog.");
      table.add("default alignment");
      cell = new LwgPdfPCell(p);
      table.add(cell);
      table.add("centered alignment");
      cell = new LwgPdfPCell(p);
      cell.setHorizontalAlignment(LwgElement.ALIGN_CENTER);
      table.add(cell);
      table.add("right alignment");
      cell = new LwgPdfPCell(p);
      cell.setHorizontalAlignment(LwgElement.ALIGN_RIGHT);
      table.add(cell);
      table.add("justified alignment");
      cell = new LwgPdfPCell(p);
      cell.setHorizontalAlignment(LwgElement.ALIGN_JUSTIFIED);
      table.add(cell);
      table.add("blah\nblah\nblah\nblah\nblah\nblah\nblah\nblah\nblah\n");
      table.getDefaultCell().setVerticalAlignment(LwgElement.ALIGN_BASELINE);
      table.add("baseline");
      table.add("blah\nblah\nblah\nblah\nblah\nblah\nblah\nblah\nblah\n");
View Full Code Here

      float[] widths = {1f, 4f};
      LwgPdfPTable table = new LwgPdfPTable(widths);
      table.add("This is my dog");
      table.add(image);
      table.add("This two");
      table.add(new LwgPdfPCell(image, true));
      table.add("This three");
      table.add(new LwgPdfPCell(image, false));
      document.add(table);
    } catch (DocumentException de) {
      System.err.println(de.getMessage());
    } catch (IOException ioe) {
      System.err.println(ioe.getMessage());
View Full Code Here

          new GfrFileOutputStream("com.lowagie.examples.objects.tables.CellColors.pdf"));
      // step3
      document.open();
      // step4
      LwgPdfPTable table = new LwgPdfPTable(4);
      LwgPdfPCell cell;
      cell = new LwgPdfPCell(new Paragraph("test colors:"));
      table.add(cell);
      cell = new LwgPdfPCell(new Paragraph("red"));
      cell.setBorder(LwgRectangle.NO_BORDER);
      cell.setBackgroundColor(Color.red);
      table.add(cell);
      cell = new LwgPdfPCell(new Paragraph("green"));
      cell.setBorder(LwgRectangle.BOTTOM);
      cell.setBorderColorBottom(Color.magenta);
      cell.setBorderWidthBottom(10f);
      cell.setBackgroundColor(Color.green);
      table.add(cell);
      cell = new LwgPdfPCell(new Paragraph("blue"));
      cell.setBorder(LwgRectangle.TOP);
          cell.setUseBorderPadding(true);
      cell.setBorderWidthTop(5f);
      cell.setBorderColorTop(Color.cyan);
      cell.setBackgroundColor(Color.blue);
      table.add(cell);
      cell = new LwgPdfPCell(new Paragraph("test GrayFill:"));
      table.add(cell);
      cell = new LwgPdfPCell(new Paragraph("0.25"));
      cell.setBorder(LwgRectangle.NO_BORDER);
      cell.setGrayFill(0.25f);
      table.add(cell);
      cell = new LwgPdfPCell(new Paragraph("0.5"));
      cell.setBorder(LwgRectangle.NO_BORDER);
      cell.setGrayFill(0.5f);
      table.add(cell);
      cell = new LwgPdfPCell(new Paragraph("0.75"));
      cell.setBorder(LwgRectangle.NO_BORDER);
      cell.setGrayFill(0.75f);
      table.add(cell);
      document.add(table);
    } catch (Exception de) {
      de.printStackTrace();
    }
View Full Code Here

   * @return a PdfPCell
   * @throws BadElementException
   */
  public LwgPdfPCell createPdfPCell() throws BadElementException {
    if (rowspan > 1) throw new BadElementException(MessageLocalization.getComposedMessage("pdfpcells.can.t.have.a.rowspan.gt.1"));
    if (isTable()) return new LwgPdfPCell(((Table)arrayList.get(0)).createPdfPTable());
    LwgPdfPCell cell = new LwgPdfPCell();
    cell.setVerticalAlignment(verticalAlignment);
    cell.setHorizontalAlignment(horizontalAlignment);
    cell.setColspan(colspan);
    cell.setUseBorderPadding(useBorderPadding);
    cell.setUseDescender(useDescender);
    cell.setLeading(getLeading(), 0);
    cell.cloneNonPositionParameters(this);
    cell.setNoWrap(getMaxLines() == 1);
    for (Iterator i = getElements(); i.hasNext(); ) {
            LwgElement e = (LwgElement)i.next();
            if (e.type() == LwgElement.PHRASE || e.type() == LwgElement.PARAGRAPH) {
                Paragraph p = new Paragraph((LwgPhrase)e);
                p.setAlignment(horizontalAlignment);
                e = p;
            }
      cell.addElement(e);
    }
    return cell;
  }
View Full Code Here

            Chunk ck = new Chunk(img, 0, 0);
            LwgPdfPTable table = new LwgPdfPTable(3);
            table.setWidthPercentage(100);
            table.getDefaultCell().setHorizontalAlignment(LwgElement.ALIGN_CENTER);
            table.getDefaultCell().setVerticalAlignment(LwgElement.ALIGN_MIDDLE);
            LwgPdfPCell cell = new LwgPdfPCell(img);
            cell.setPadding(4);
            cell.setBackgroundColor(new Color(0, 0, 255));
            cell.setHorizontalAlignment(LwgElement.ALIGN_CENTER);
            table.add("I see a template on my right");
            table.add(cell);
            table.add("I see a template on my left");
            table.add(cell);
            table.add("I see a template everywhere");
View Full Code Here

            // step 4: we create a table and add it to the document
            LwgImage img = LwgImage.getInstance("pngnow.png");
            img.scalePercent(70);
            Chunk ck = new Chunk(img, 0, -5);
            LwgPdfPTable table = new LwgPdfPTable(3);
            LwgPdfPCell cell = new LwgPdfPCell();
            cell.addElement(new Chunk(img, 5, -5));
            cell.setBackgroundColor(new Color(0xC0, 0xC0, 0xC0));
            cell.setHorizontalAlignment(LwgElement.ALIGN_CENTER);
            table.add("I see an image\non my right");
            table.add(cell);
            table.add("I see an image\non my left");
            table.add(cell);
            table.add("I see images\neverywhere");
View Full Code Here

           
            LwgPdfPTable cell = new LwgPdfPTable(1);
            cell.getDefaultCell().setBorder(LwgRectangle.NO_BORDER);
            cell.getDefaultCell().setPadding(0f);
           
            LwgPdfPCell info = new LwgPdfPCell(new LwgPhrase("Barcode EAN 128"));
            info.setBorder(LwgRectangle.NO_BORDER);
            pageTot.add(info);
           
            Barcode128 shipBarCode = new Barcode128();
            shipBarCode.setX(0.75f);
            shipBarCode.setN(1.5f);
            shipBarCode.setChecksumText(true);
            shipBarCode.setGenerateChecksum(true);
            shipBarCode.setSize(10f);
            shipBarCode.setTextAlignment(LwgElement.ALIGN_CENTER);
            shipBarCode.setBaseline(10f);
            shipBarCode.setCode(data);
            shipBarCode.setBarHeight(50f);
           
            LwgImage imgShipBarCode = shipBarCode.createImageWithBarcode(cb, Color.black, Color.blue);
            LwgPdfPCell shipment = new LwgPdfPCell(new LwgPhrase(
            new Chunk(imgShipBarCode, 0, 0)));
            shipment.setFixedHeight(shipBarCode.getBarcodeSize().getHeight() + 16f);
            shipment.setPaddingTop(5f);
            shipment.setPaddingBottom(10f);
            shipment.setBorder(LwgRectangle.BOX);
            shipment.setVerticalAlignment(LwgElement.ALIGN_TOP);
            shipment.setHorizontalAlignment(LwgElement.ALIGN_CENTER);
            cell.add(shipment);
           
            pageTot.add(cell);
           
           
View Full Code Here

            float[] outer = { 60, 25, 15 };
            outertable.setWidths(outer);
            LwgPdfPTable innertable = new LwgPdfPTable(2);
            float[] inner = {35, 65};
            innertable.setWidths(inner);
            LwgPdfPCell cell;
            TextField text;
            innertable.add(new Paragraph("name:", f));
            cell = new LwgPdfPCell();
            text = new TextField(writer, new LwgRectangle(0, 0), "name");
            text.setOptions(TextField.MULTILINE);
            text.setFontSize(8);
            PdfFormField name = text.getTextField();
            cell.setCellEvent(new StudentCardForm(name));
            innertable.add(cell);
            innertable.add(new Paragraph("date of birth:", f));
            cell = new LwgPdfPCell();
            text = new TextField(writer, new LwgRectangle(0, 0), "birthday");
            text.setOptions(TextField.MULTILINE);
            text.setFontSize(8);
            PdfFormField birthdate = text.getTextField();
            cell.setCellEvent(new StudentCardForm(birthdate));
            innertable.add(cell);
            innertable.add(new Paragraph("Study Program:", f));
            cell = new LwgPdfPCell();
            text = new TextField(writer, new LwgRectangle(0, 0), "studyprogram");
            text.setOptions(TextField.MULTILINE);
            text.setFontSize(8);
            PdfFormField studyprogram = text.getTextField();
            studyprogram.setFieldName("studyprogram");
            cell.setCellEvent(new StudentCardForm(studyprogram));
            innertable.add(cell);
            innertable.add(new Paragraph("option:", f));
            cell = new LwgPdfPCell();
            text = new TextField(writer, new LwgRectangle(0, 0), "option");
            text.setOptions(TextField.MULTILINE);
            text.setFontSize(8);
            PdfFormField option = text.getTextField();
            option.setFieldName("option");
            cell.setCellEvent(new StudentCardForm(option));
            innertable.add(cell);
            outertable.add(innertable);
            cell = new LwgPdfPCell();
      cell.setBackgroundColor(new Color(0xFF, 0xDE, 0xAD));
            PdfFormField picture = PdfFormField.createPushButton(writer);
            picture.setFieldName("picture");
            cell.setCellEvent(new StudentCardForm(picture));
            outertable.add(cell);
            cell = new LwgPdfPCell();
      cell.setBackgroundColor(Color.WHITE);
            PdfFormField barcode = PdfFormField.createPushButton(writer);
            barcode.setFieldName("barcode");
            cell.setCellEvent(new StudentCardForm(barcode));
            outertable.add(cell);
            outertable.writeSelectedRows(0, -1, 20, 100, writer.getDirectContent());
            writer.addAnnotation(name);
            writer.addAnnotation(birthdate);
            writer.addAnnotation(studyprogram);
View Full Code Here

          new FileOutputStream("SimpleRegistrationForm.pdf"));
      // step 3
      document.open();
      // step 4
      LwgPdfPTable table = new LwgPdfPTable(2);
      LwgPdfPCell cell;
      table.getDefaultCell().setPadding(5f);

      table.add("Your name:");
      cell = new LwgPdfPCell();
      cell.setCellEvent(new SimpleRegistrationForm(writer, "name"));
      table.add(cell);

      table.add("Your home address:");
      cell = new LwgPdfPCell();
      cell.setCellEvent(new SimpleRegistrationForm(writer, "address"));
      table.add(cell);

      table.add("Postal code:");
      cell = new LwgPdfPCell();
      cell
          .setCellEvent(new SimpleRegistrationForm(writer,
              "postal_code"));
      table.add(cell);

      table.add("Your email address:");
      cell = new LwgPdfPCell();
      cell.setCellEvent(new SimpleRegistrationForm(writer, "email"));
      table.add(cell);

      document.add(table);

    } catch (DocumentException de) {
View Full Code Here

TOP

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

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.