Example usage for com.itextpdf.text Image scaleToFit

List of usage examples for com.itextpdf.text Image scaleToFit

Introduction

In this page you can find the example usage for com.itextpdf.text Image scaleToFit.

Prototype

public void scaleToFit(final float fitWidth, final float fitHeight) 

Source Link

Document

Scales the image so that it fits a certain width and height.

Usage

From source file:utils.pdf.cv_templates.Template1.java

private void addImageAddress() throws DocumentException, IOException {
    Image address_img;
    address_img = Image//from  w  w w. jav a2 s .com
            .getInstance(String.format("public/images/orientation/cv-templates/CV1/ic_location.png"));
    address_img.setAbsolutePosition(173, 730);
    address_img.setAlignment(Image.LEFT | Image.TEXTWRAP);
    address_img.setBorder(Image.BOX);
    address_img.setBorderWidth(10);
    address_img.setBorderColor(BaseColor.WHITE);
    address_img.scaleToFit(1000, 18);
    document.add(address_img);
}

From source file:utils.pdf.cv_templates.Template1.java

private void addImageLine() throws DocumentException, IOException {
    Image line_img;
    line_img = Image/* w ww  .  j a  v a2  s . com*/
            .getInstance(String.format("public/images/orientation/cv-templates/CV1/ic_barra_lineas3.png"));
    line_img.setAbsolutePosition(40, 50);
    line_img.setAlignment(Image.LEFT | Image.TEXTWRAP);
    line_img.setBorder(Image.BOX);
    line_img.setBorderWidth(10);
    line_img.setBorderColor(BaseColor.WHITE);
    line_img.scaleToFit(1000, 100);
    document.add(line_img);
}

From source file:utils.pdf.cv_templates.Template1.java

private void addImageLine1() throws DocumentException, IOException {
    Image line_img;
    line_img = Image//from  w  w w.j av a  2s . c  o  m
            .getInstance(String.format("public/images/orientation/cv-templates/CV1/ic_barra_lineas3.png"));
    line_img.setAbsolutePosition(40, 150);
    line_img.setAlignment(Image.LEFT | Image.TEXTWRAP);
    line_img.setBorder(Image.BOX);
    line_img.setBorderWidth(10);
    line_img.setBorderColor(BaseColor.WHITE);
    line_img.scaleToFit(1000, 100);
    document.add(line_img);
}

From source file:utils.pdf.cv_templates.Template1.java

private void addImageLine2() throws DocumentException, IOException {
    Image line_img;
    line_img = Image//from  w  w w. ja  va  2 s .co  m
            .getInstance(String.format("public/images/orientation/cv-templates/CV1/ic_barra_lineas3.png"));
    line_img.setAbsolutePosition(40, 250);
    line_img.setAlignment(Image.LEFT | Image.TEXTWRAP);
    line_img.setBorder(Image.BOX);
    line_img.setBorderWidth(10);
    line_img.setBorderColor(BaseColor.WHITE);
    line_img.scaleToFit(1000, 100);
    document.add(line_img);
}

From source file:utils.pdf.cv_templates.Template1.java

private void addImageLine3() throws DocumentException, IOException {
    Image line_img;
    line_img = Image/*from   w  w  w.j a  v a 2  s . c  o m*/
            .getInstance(String.format("public/images/orientation/cv-templates/CV1/ic_barra_lineas3.png"));
    line_img.setAbsolutePosition(40, 350);
    line_img.setAlignment(Image.LEFT | Image.TEXTWRAP);
    line_img.setBorder(Image.BOX);
    line_img.setBorderWidth(10);
    line_img.setBorderColor(BaseColor.WHITE);
    line_img.scaleToFit(1000, 100);
    document.add(line_img);
}

From source file:utils.pdf.cv_templates.Template1.java

private void addImageLine4() throws DocumentException, IOException {
    Image line_img;
    line_img = Image/*w  w w .j a v  a2s  . c o  m*/
            .getInstance(String.format("public/images/orientation/cv-templates/CV1/ic_barra_lineas3.png"));
    line_img.setAbsolutePosition(40, 450);
    line_img.setAlignment(Image.LEFT | Image.TEXTWRAP);
    line_img.setBorder(Image.BOX);
    line_img.setBorderWidth(10);
    line_img.setBorderColor(BaseColor.WHITE);
    line_img.scaleToFit(1000, 100);
    document.add(line_img);
}

From source file:utils.pdf.cv_templates.Template1.java

private void addImageLine5() throws DocumentException, IOException {
    Image line_img;
    line_img = Image/*from   ww  w  . jav a  2 s. c o  m*/
            .getInstance(String.format("public/images/orientation/cv-templates/CV1/ic_barra_lineas3.png"));
    line_img.setAbsolutePosition(40, 550);
    line_img.setAlignment(Image.LEFT | Image.TEXTWRAP);
    line_img.setBorder(Image.BOX);
    line_img.setBorderWidth(10);
    line_img.setBorderColor(BaseColor.WHITE);
    line_img.scaleToFit(1000, 100);
    document.add(line_img);
}

From source file:utils.pdf.cv_templates.Template3.java

private void addLineImage() throws DocumentException, IOException {
    Image short_line_img = Image.getInstance(SHORT_LINE_IMAGE);
    short_line_img.setAbsolutePosition(213, 756);
    short_line_img.setAlignment(Image.MIDDLE | Image.TEXTWRAP);
    short_line_img.setBorderWidth(10);
    short_line_img.setBorderColor(BaseColor.WHITE);
    short_line_img.scaleToFit(300, 55);
    document.add(short_line_img);
}

From source file:utils.pdf.cv_templates.Template3.java

private void addPersonalInformation(User user) throws DocumentException, IOException {
    Paragraph paragraph;/*from   w  w  w.  j a v  a  2 s . c  om*/
    PdfPCell cell;
    PdfPTable table;
    Image photo_img;
    if (!user.photo.id.equals("")) {
        photo_img = Image
                .getInstance(String.format("https://s3.amazonaws.com/aunclickdelempleo2/" + user.photo.id));
    } else {
        photo_img = Image.getInstance(String.format("public/images/orientation/photo/ic_profile.png"));
    }

    table = new PdfPTable(new float[] { 3, 7 });
    table.setWidthPercentage(100);

    //First column
    cell = new PdfPCell();
    cell.setBorder(PdfPCell.NO_BORDER);
    cell.setPaddingRight(15);
    cell.setPaddingLeft(50);
    cell.setPaddingTop(30);

    photo_img.setBorder(Image.BOX);
    photo_img.setBorderColor(BaseColor.WHITE);
    photo_img.scaleToFit(1000, 115);

    cell.addElement(photo_img);
    table.addCell(cell);

    //Second column
    cell = new PdfPCell();
    cell.setPaddingLeft(55);
    cell.setPaddingTop(19);
    cell.setBorder(PdfPCell.NO_BORDER);

    paragraph = new Paragraph("Datos Personales", font1);
    paragraph.setAlignment(paragraph.ALIGN_LEFT);
    cell.addElement(paragraph);

    paragraph = new Paragraph(user.name + " " + user.surnames, font2);
    paragraph.setAlignment(paragraph.ALIGN_LEFT);
    paragraph.setSpacingBefore(8);
    cell.addElement(paragraph);

    paragraph = new Paragraph(user.birthDate, font3);
    paragraph.setAlignment(paragraph.ALIGN_LEFT);
    cell.addElement(paragraph);

    paragraph = new Paragraph("Calle " + user.residenceAddress + ", N " + user.residenceNumber + ", Ciudad "
            + user.residenceCity, font3);
    paragraph.setAlignment(paragraph.ALIGN_LEFT);
    cell.addElement(paragraph);

    paragraph = new Paragraph("Telfono: " + user.phoneNumber, font3);
    paragraph.setAlignment(paragraph.ALIGN_LEFT);
    cell.addElement(paragraph);

    paragraph = new Paragraph(user.email, font3);
    paragraph.setAlignment(paragraph.ALIGN_LEFT);
    cell.addElement(paragraph);

    if (!user.drivingLicense.equals("No tengo carnet")) {
        paragraph = new Paragraph("Permiso de conducir: " + user.drivingLicense, font3);
        paragraph.setAlignment(paragraph.ALIGN_LEFT);
        paragraph.setSpacingBefore(10);
        cell.addElement(paragraph);
    }

    table.addCell(cell);
    document.add(table);
}

From source file:utils.pdf.cv_templates.Template3.java

private void addAcademicExperience(User user) throws DocumentException, IOException {
    Paragraph paragraph1, paragraph2;//w ww  .ja va  2  s.  com
    PdfPCell cell1, cell2, cell3;
    PdfPTable table1, table2, table3;

    // TABLE 1
    table1 = new PdfPTable(new float[] { 5 });
    table1.setWidthPercentage(100);
    cell1 = new PdfPCell();
    cell1.setBorder(PdfPCell.NO_BORDER);
    cell1.setPaddingRight(15);
    cell1.setPaddingLeft(50);
    cell1.setPaddingTop(15);

    paragraph1 = new Paragraph("Experiencia acadmica", font1);
    paragraph1.setAlignment(paragraph1.ALIGN_LEFT);
    cell1.addElement(paragraph1);
    table1.addCell(cell1);
    document.add(table1);

    // TABLE 2
    table2 = new PdfPTable(new float[] { 9, 1 });
    table2.setWidthPercentage(100);

    // First column
    cell2 = new PdfPCell();
    cell2.setBorder(PdfPCell.NO_BORDER);
    cell2.setPaddingTop(5);
    Image long_line_img = Image.getInstance(LONG_LINE_IMAGE);
    long_line_img.setBorderWidth(10);
    long_line_img.setBorderColor(BaseColor.WHITE);
    long_line_img.scaleToFit(475, 50);
    cell2.addElement(long_line_img);
    //cell2.setBorderColor(Constants.COLOR_BLUE_T3);
    //cell2.setBorderWidthTop(2);
    table2.addCell(cell2);

    // Second column
    cell2 = new PdfPCell();
    cell2.setBorder(PdfPCell.NO_BORDER);
    table2.addCell(cell2);

    document.add(table2);

    // TABLE 3
    table3 = new PdfPTable(new float[] { 5 });
    table3.setWidthPercentage(100);
    cell3 = new PdfPCell();
    cell3.setBorder(PdfPCell.NO_BORDER);
    cell3.setPaddingRight(15);
    cell3.setPaddingLeft(50);
    cell3.setPaddingTop(-1);
    paragraph2 = new Paragraph(user.studyTitle.toUpperCase() + ".\n" + user.studyLocation.toUpperCase() + ".",
            font3);
    paragraph2.setAlignment(paragraph2.ALIGN_LEFT);
    cell3.addElement(paragraph2);
    table3.addCell(cell3);
    document.add(table3);
}