Exemplo n.º 1
0
  public void setHeader(Document document, String clientName)
      throws DocumentException, IOException {

    LineSeparator line = new LineSeparator(1, 80, null, Element.ALIGN_CENTER, -5);

    Image img = Image.getInstance(getClass().getResource("img/LISLogo.png"));
    // Image img = Image.getInstance("img/LISLogo.png");
    img.scaleAbsoluteHeight(80);
    img.scaleAbsoluteWidth(200);
    img.setAlignment(Element.ALIGN_CENTER);

    Paragraph clientNameParagraph = new Paragraph();
    clientNameParagraph.setAlignment(Element.ALIGN_CENTER);
    clientNameParagraph.add(clientName);
    clientNameParagraph.setSpacingAfter(12);

    Paragraph investmentRecommendations = new Paragraph("Your Legacy Investment Income Portfolio");
    investmentRecommendations.setAlignment(Element.ALIGN_CENTER);
    investmentRecommendations.add(line);
    investmentRecommendations.setSpacingAfter(4);

    document.add(clientNameParagraph);
    document.add(investmentRecommendations);
    document.add(img);
  }
Exemplo n.º 2
0
  private static Image getBarcode(Document document, PdfWriter pdfWriter, String servicio) {

    PdfContentByte cimg = pdfWriter.getDirectContent();
    Barcode128 code128 = new Barcode128();
    code128.setCode(servicio);
    code128.setCodeType(Barcode128.CODE128);
    code128.setTextAlignment(Element.ALIGN_CENTER);
    Image image = code128.createImageWithBarcode(cimg, null, null);
    float scaler = (5);
    image.scalePercent(scaler);
    image.setAlignment(Element.ALIGN_CENTER);
    image.scaleAbsoluteWidth(800);

    System.out.print(" Width: " + image.getWidth());
    System.out.println(" Heights: " + image.getHeight());
    return image;
  }