Example usage for com.itextpdf.text Paragraph Paragraph

List of usage examples for com.itextpdf.text Paragraph Paragraph

Introduction

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

Prototype

public Paragraph() 

Source Link

Document

Constructs a Paragraph.

Usage

From source file:com.photon.phresco.framework.docs.impl.DocumentUtil.java

License:Apache License

/**
 * Creates and returns PDF input stream for the supplied string.
 * @param string to be printed in the PDF
 * @return PDF input stream./* w  w w.  j ava  2s  .c o  m*/
 * @throws PhrescoException
 */
public static InputStream getStringAsPDF(String string) throws PhrescoException {
    if (isDebugEnabled) {
        S_LOGGER.debug("Entering Method DocumentUtil.getStringAsPDF(String string)");
    }
    try {
        com.itextpdf.text.Document docu = new com.itextpdf.text.Document();
        ByteArrayOutputStream os = new ByteArrayOutputStream();
        PdfWriter.getInstance(docu, os);
        docu.open();
        Paragraph paragraph = new Paragraph();
        paragraph.setAlignment(Element.ALIGN_LEFT);
        paragraph.setFirstLineIndent(MAGICNUMBER.INDENTLINE);
        paragraph.add("\n"); //$NON-NLS-1$
        paragraph.add(string);
        paragraph.add("\n\n"); //$NON-NLS-1$
        docu.add(paragraph);

        docu.close();

        //Create an inputstream to return.
        return new ByteArrayInputStream(os.toByteArray());
    } catch (DocumentException e) {
        e.printStackTrace();
        throw new PhrescoException(e);
    }

}

From source file:com.photon.phresco.framework.docs.impl.DocumentUtil.java

License:Apache License

private static void updateDoc(List<ArtifactGroup> modules, com.itextpdf.text.Document docu, PdfWriter writer,
        String moduleName) throws PhrescoException {
    try {// w w  w .j av  a2s  .  c o m
        Paragraph para = new Paragraph();
        para.setAlignment(Element.ALIGN_CENTER);
        para.setFont(DocConstants.BODY_FONT);
        para.setFont(DocConstants.CATEGORY_FONT);
        para.add(moduleName);
        addBlankLines(para, MAGICNUMBER.BLANKLINESTWO);
        docu.add(para);

        for (ArtifactGroup artifactGroup : modules) {
            para = new Paragraph();
            para.setFont(DocConstants.CATEGORY_FONT);
            para.add(artifactGroup.getName());
            docu.add(para);

            if (StringUtils.isNotEmpty(artifactGroup.getDescription())) {
                para = new Paragraph();
                para.setFont(DocConstants.BODY_FONT);
                para.add(artifactGroup.getDescription());
                addBlankLines(para, 2);
                docu.add(para);
            }
            //          Documentation document = tupleBean.getDoc(DocumentationType.DESCRIPTION);
            //          if (document != null) {
            //              if(!StringUtils.isEmpty(document.getUrl())){
            //                  PdfInput convertToPdf = DocConvertor.convertToPdf(document.getUrl());
            //                  if(convertToPdf != null) {
            //                      DocumentUtil.addPages(convertToPdf.getInputStream(), writer, docu);
            //                  }
            //              } else {
            //                  para = new Paragraph();
            //                  para.setFont(DocConstants.BODY_FONT);
            //                  para.add(document.getContent());
            //                  addBlankLines(para, 2);
            //                  docu.add(para);
            //              }
            //          }
        }
    } catch (DocumentException e) {
        e.printStackTrace();
        throw new PhrescoException(e);
    }
}

From source file:com.photon.phresco.service.docs.impl.DocumentUtil.java

License:Apache License

/**
 * Adds title section.//  w  ww  . j  a  va2s  .c  om
 * @param info the project info object
 * @return PDF input stream
 * @throws DocumentException
 */
public static InputStream getTitleSection(ProjectInfo info) throws DocumentException {
    if (isDebugEnabled) {
        S_LOGGER.debug(" Entering Method DocumentUtil.getTitleSection(ProjectInfo info)");
    }
    if (isDebugEnabled) {
        S_LOGGER.debug("getTitleSection() projectCode=" + info.getCode());
    }
    //create output stream
    com.itextpdf.text.Document docu = new com.itextpdf.text.Document();
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    PdfWriter.getInstance(docu, os);
    docu.open();

    //add standard title section with supplied info object
    Paragraph paragraph = new Paragraph();
    paragraph.setAlignment(Element.ALIGN_CENTER);
    paragraph.setFont(DocConstants.TITLE_FONT);
    addBlankLines(paragraph, 10);
    paragraph.add(info.getName());
    addBlankLines(paragraph, 4);
    docu.add(paragraph);

    paragraph = new Paragraph();
    paragraph.setAlignment(Element.ALIGN_CENTER);
    addBlankLines(paragraph, 10);
    String techName = info.getTechnology().getName();
    if (info.getTechnology().getVersions() != null) {
        paragraph.add(techName + " - " + info.getTechnology().getVersions().get(0));
    } else {
        paragraph.add(techName);
    }
    docu.add(paragraph);

    paragraph = new Paragraph();
    addBlankLines(paragraph, 10);
    paragraph.setAlignment(Element.ALIGN_CENTER);
    paragraph.add(DocumentMessages.getString("Documents.version.name") + getVersion(info)); //$NON-NLS-1$
    addBlankLines(paragraph, 7);
    docu.add(paragraph);
    paragraph = new Paragraph();
    paragraph.setAlignment(Element.ALIGN_RIGHT);
    paragraph.setFont(DocConstants.DESC_FONT);
    paragraph.setFirstLineIndent(8);
    paragraph.add(info.getDescription());
    docu.add(paragraph);

    docu.close();

    //Create an inputstream to return.
    return new ByteArrayInputStream(os.toByteArray());

}

From source file:com.photon.phresco.service.docs.impl.DocumentUtil.java

License:Apache License

/**
 * Creates and returns PDF input stream for the supplied string.
 * @param string to be printed in the PDF
 * @return PDF input stream./*  www. j  a v a  2  s . c  o m*/
 * @throws DocumentException
 */
public static InputStream getStringAsPDF(String string) throws DocumentException {
    if (isDebugEnabled) {
        S_LOGGER.debug("Entering Method DocumentUtil.getStringAsPDF(String string)");
    }
    com.itextpdf.text.Document docu = new com.itextpdf.text.Document();
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    PdfWriter.getInstance(docu, os);
    docu.open();
    Paragraph paragraph = new Paragraph();
    paragraph.setAlignment(Element.ALIGN_LEFT);
    paragraph.setFirstLineIndent(180);
    paragraph.add("\n"); //$NON-NLS-1$
    paragraph.add(string);
    paragraph.add("\n\n"); //$NON-NLS-1$
    docu.add(paragraph);

    docu.close();

    //Create an inputstream to return.
    return new ByteArrayInputStream(os.toByteArray());

}

From source file:com.photon.phresco.service.docs.impl.DocumentUtil.java

License:Apache License

private static void updateDoc(List<ModuleGroup> modules, com.itextpdf.text.Document docu, PdfWriter writer,
        String moduleName) throws DocumentException, PhrescoException, IOException {
    Paragraph para = new Paragraph();
    para.setAlignment(Element.ALIGN_CENTER);
    para.setFont(DocConstants.BODY_FONT);
    para.setFont(DocConstants.CATEGORY_FONT);
    para.add(moduleName);//from ww  w  . jav  a 2 s . c om
    addBlankLines(para, 2);
    docu.add(para);

    for (ModuleGroup tupleBean : modules) {
        para = new Paragraph();
        para.setFont(DocConstants.CATEGORY_FONT);
        para.add(tupleBean.getName());
        docu.add(para);
        Documentation document = tupleBean.getDoc(DocumentationType.DESCRIPTION);
        if (document != null) {
            if (!StringUtils.isEmpty(document.getUrl())) {
                PdfInput convertToPdf = DocConvertor.convertToPdf(document.getUrl());
                if (convertToPdf != null) {
                    DocumentUtil.addPages(convertToPdf.getInputStream(), writer, docu);
                }
            } else {
                para = new Paragraph();
                para.setFont(DocConstants.BODY_FONT);
                para.add(document.getContent());
                addBlankLines(para, 2);
                docu.add(para);
            }
        }
    }
}

From source file:com.photoshop.misc.Factuurgenerator.java

private void addTitlePage(Document document) throws DocumentException {
    Paragraph preface = new Paragraph();
    addEmptyLine(preface, 1);//from  w ww.  j av  a 2  s.  c o  m

    Image Logo = null;
    try {
        Logo = Image.getInstance(env.getProperty("logo") + "Photoshop_black.png");
        Logo.scaleAbsolute(200, 100);
    } catch (BadElementException | IOException ex) {
        Logger.getLogger(OrderController.class.getName()).log(Level.SEVERE, null, ex);
    }
    SimpleDateFormat simpledatafo = new SimpleDateFormat("dd/MM/yyyy");
    preface.add(Logo);
    Paragraph datum = new Paragraph(this.Getspringmessage("Date") + ": " + simpledatafo.format(new Date()),
            smallBold);
    datum.setAlignment(Element.ALIGN_RIGHT);
    preface.add(datum);
    Paragraph Factuurnummer = new Paragraph(this.Getspringmessage("invoicenumber") + ": " + order.getId(),
            smallBold);
    Factuurnummer.setAlignment(Element.ALIGN_RIGHT);
    preface.add(Factuurnummer);
    addEmptyLine(preface, 1);

    //Aanmaken van de bedrijfs gegevens
    preface.add(new Paragraph(this.Getspringmessage("company"), subtitel));
    preface.add(new Paragraph("Rachelsmolen 1", subFont));
    preface.add(new Paragraph("5612MA Eindhoven", subFont)); //order nummer ingelezen worde
    preface.add(new Paragraph(this.Getspringmessage("accountNumber") + ": 165947888", subFont));
    preface.add(new Paragraph("Bank: Paypal", subFont));
    addEmptyLine(preface, 1);

    //Aanmaken van de bestellende persoons gegevens
    preface.add(new Paragraph(this.Getspringmessage("reciver") + ":", subtitel));
    preface.add(new Paragraph(order.getInvoiceaddress().getKlantnaam(), subFont)); //order nummer ingelezen worde
    preface.add(new Paragraph(order.getInvoiceaddress().getAdres(), subFont));
    preface.add(new Paragraph(
            order.getInvoiceaddress().getPostcode() + " " + order.getInvoiceaddress().getWoonplaats(),
            subFont));
    preface.add(new Paragraph(order.getInvoiceaddress().getTelefoonnummer(), subFont));
    addEmptyLine(preface, 1);

    //Aanmaken van de start zin 
    preface.add(new Paragraph(
            this.Getspringmessage("dear") + " " + order.getInvoiceaddress().getKlantnaam() + ",", subtitel));
    addEmptyLine(preface, 1);
    preface.add(new Paragraph(this.Getspringmessage("paymentvieuw"), subFont));
    addEmptyLine(preface, 1);
    //Aanmaken van de betaal tabel
    createTable(preface);
    //Overzicht bwt bedrag
    addEmptyLine(preface, 1);
    Paragraph btw = new Paragraph(this.Getspringmessage("taxamount") + ": " + " "
            + String.format("%.2f", (this.totaalprijs / 100) * 19), subFont);
    btw.setAlignment(Element.ALIGN_RIGHT);
    preface.add(btw);
    //Overzicht Totaalbedrag
    Paragraph Totaalbedrag = new Paragraph(
            this.Getspringmessage("totalamount") + ": " + " " + String.format("%.2f", this.totaalprijs),
            subtitel);
    Totaalbedrag.setAlignment(Element.ALIGN_RIGHT);
    preface.add(Totaalbedrag);
    addEmptyLine(preface, 1);

    //Toevoegen footerzin
    Paragraph footer = new Paragraph(this.Getspringmessage("invoicend"), subFont);
    footer.setAlignment(Element.ALIGN_CENTER);
    preface.add(footer);
    document.add(preface);
    Mailgenerator mail = new Mailgenerator();
    mail.Sendmail("willem1995@hotmail.com", order, env, filename);
}

From source file:com.photoshop.misc.Indexkaartgenerator.java

private void addTitlePage(Document document) throws DocumentException {
    document.newPage();/*w w  w. j  a v  a 2 s.  co  m*/
    Paragraph preface = new Paragraph();
    addEmptyLine(preface, 1);

    Image Logo = null;
    try {
        Logo = Image.getInstance(env.getProperty("logo") + "Photoshop_black.png");
        Logo.scaleAbsolute(200, 100);
    } catch (BadElementException | IOException ex) {
        Logger.getLogger(OrderController.class.getName()).log(Level.SEVERE, null, ex);
    }
    SimpleDateFormat simpledatafo = new SimpleDateFormat("dd/MM/yyyy");
    preface.add(Logo);
    Paragraph datum = new Paragraph(Getspringmessage("Date") + " " + simpledatafo.format(new Date()),
            smallBold);
    datum.setAlignment(Element.ALIGN_RIGHT);
    preface.add(datum);
    Paragraph Factuurnummer = new Paragraph(this.Getspringmessage("invoicenumber") + " " + order.getId(),
            smallBold);
    Factuurnummer.setAlignment(Element.ALIGN_RIGHT);
    preface.add(Factuurnummer);
    addEmptyLine(preface, 1);

    //Aanmaken van de bedrijfs gegevens
    preface.add(new Paragraph(this.Getspringmessage("company"), subtitel));
    preface.add(new Paragraph("Rachelsmolen 1", subFont));
    preface.add(new Paragraph("5612MA Eindhoven", subFont)); //order nummer ingelezen worde
    preface.add(new Paragraph(this.Getspringmessage("accountNumber") + ": 165947888", subFont));
    preface.add(new Paragraph("Bank: Paypal", subFont));
    addEmptyLine(preface, 1);

    //Aanmaken van de bestellende persoons gegevens
    preface.add(new Paragraph(this.Getspringmessage("reciver") + ": ", subtitel));
    preface.add(new Paragraph(order.getInvoiceaddress().getKlantnaam(), subFont)); //order nummer ingelezen worde
    preface.add(new Paragraph(order.getInvoiceaddress().getAdres(), subFont));
    preface.add(new Paragraph(
            order.getInvoiceaddress().getPostcode() + " " + order.getInvoiceaddress().getWoonplaats(),
            subFont));
    preface.add(new Paragraph(order.getInvoiceaddress().getTelefoonnummer(), subFont));
    addEmptyLine(preface, 1);

    //Aanmaken van de start zin 
    preface.add(new Paragraph(this.Getspringmessage("dear") + " " + order.getInvoiceaddress().getKlantnaam(),
            subtitel));
    addEmptyLine(preface, 1);
    preface.add(new Paragraph(
            this.Getspringmessage("allordersby") + " " + order.getInvoiceaddress().getKlantnaam(), subFont));
    addEmptyLine(preface, 1);
    //Aanmaken van de betaal tabel
    createTable(preface);

    //Toevoegen footerzin
    Paragraph footer = new Paragraph(this.Getspringmessage("thanksforordering"), subFont);
    footer.setAlignment(Element.ALIGN_CENTER);
    preface.add(footer);

    document.add(preface);

}

From source file:com.planning.project.controller.CreatePDF.java

/**
 * @param args//from ww w.  ja  va 2s  .  com
 * @throws Exception
 */
public static Document createPDFBudwork(String file, TbDescriptionstatement tbDescriptionstatement,
        List<TbAddmoneyvara> tbAddmoneyvaras, List<TbAddmoneynovara> tbAddmoneynovaras,
        List<TbRemunerationcommittee> tbRemunerationcommittees, List<TbMaketimeformeal> tbMaketimeformeals,
        List<TbRentshouse> tbRentshouses, List<TbTeachextra> tbTeachextras, List<TbExpenpaper> tbExpenpapers,
        List<TbComlecturer> tbComlecturers, List<TbOthercompensation> tbOthercompensations,
        List<TbAllowancesrental> tbAllowancesrentals, List<TbRepairofequipment> tbRepairofequipments,
        List<TbWageservice> tbWageservices, List<TbMeetingofthesnack> tbMeetingofthesnacks,
        List<TbSocialsecurity> tbSocialsecuritys, List<TbRentalproperty> tbRentalpropertys,
        List<TbThecertificationfood> tbThecertificationfoods,
        List<TbThecertificationdrink> tbThecertificationdrinks, List<TbThegift> tbThegifts, List<TbTax> tbTaxs,
        List<TbFee> tbFees, List<TbInsurance> tbInsurances, List<TbEmploy> tbEmploys,
        List<TbMaterial> tbMaterials1, List<TbMaterial> tbMaterials2, List<TbMaterial> tbMaterials3,
        List<TbMaterial> tbMaterials4, List<TbMaterial> tbMaterials5, List<TbMaterial> tbMaterials6,
        List<TbMaterial> tbMaterials7, List<TbMaterial> tbMaterials8, List<TbMaterial> tbMaterials9,
        List<TbMaterial> tbMaterials10, List<TbMaterial> tbMaterials11, List<TbPublicutility> tbPublicutilitys,
        List<TbGasolineDetail> tbGasolineDetails) throws Exception {

    Document document = null;

    try {
        Font font16 = new Font(
                BaseFont.createFont("D:/THSarabunNew.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED));
        font16.setSize(16);
        document = new Document();
        PdfWriter.getInstance(document, new FileOutputStream(file));
        document.open();
        Paragraph paragraph = new Paragraph();

        addMetaData(document);

        addTitlePageBud(document);

        createPagePDFBudwork(document, tbDescriptionstatement);

        createHeadlistBudwork(document, "1");

        PdfPTable table = createtableAddmoneyvara(tbAddmoneyvaras, tbDescriptionstatement.getSumAddmoneyvara());
        document.add(table);
        table.setSpacingBefore(25);

        table = createtableAddmoneynovara(tbAddmoneynovaras, tbDescriptionstatement.getSumAddmoneynovara());
        table.setSpacingBefore(25);
        document.add(table);

        table = createtableRemunerationcommittee(tbRemunerationcommittees,
                tbDescriptionstatement.getSumRemunerationcomnittee());
        table.setSpacingBefore(25);
        document.add(table);

        table = createtableMaketimeformeal(tbMaketimeformeals, tbDescriptionstatement.getSumMaketimeformeals());
        table.setSpacingBefore(25);
        document.add(table);

        table = createtableRentshouse(tbRentshouses, tbDescriptionstatement.getSumRentshouse());
        table.setSpacingBefore(25);
        document.add(table);

        table = createtableTeachextra(tbTeachextras, tbDescriptionstatement.getSumTeachextra());
        table.setSpacingBefore(25);
        document.add(table);

        table = createtableExpenpaper(tbExpenpapers, tbDescriptionstatement.getSumExpenpaper());
        table.setSpacingBefore(25);
        document.add(table);

        table = createtableComlecturer(tbComlecturers, tbDescriptionstatement.getSumComlecturer());
        table.setSpacingBefore(25);
        document.add(table);

        table = createtableOthercompensation(tbOthercompensations,
                tbDescriptionstatement.getSumOthercompensation());
        table.setSpacingBefore(25);
        document.add(table);

        createHeadlistBudwork(document, "2");

        table = createtableAllowancesrental(tbAllowancesrentals,
                tbDescriptionstatement.getSumAllowancesrental());
        table.setSpacingBefore(25);
        document.add(table);

        table = createtableGasolineDetail(tbGasolineDetails, tbDescriptionstatement.getSumGasoline());
        table.setSpacingBefore(25);
        document.add(table);

        table = createtableRepairofequipment(tbRepairofequipments,
                tbDescriptionstatement.getSumRepairofequipment());
        table.setSpacingBefore(25);
        document.add(table);

        table = createtableWageservice(tbWageservices, tbDescriptionstatement.getSumWageservice());
        table.setSpacingBefore(25);
        document.add(table);

        table = createtableMeetingofthesnack(tbMeetingofthesnacks,
                tbDescriptionstatement.getSumMeetingofthesnack());
        table.setSpacingBefore(25);
        document.add(table);

        table = createtableSocialsecurity(tbSocialsecuritys, tbDescriptionstatement.getSumSocialsecurity());
        table.setSpacingBefore(25);
        document.add(table);

        table = createtableRentalproperty(tbRentalpropertys, tbDescriptionstatement.getSumRentalproperty());
        table.setSpacingBefore(25);
        document.add(table);

        table = createtableThecertificationfood(tbThecertificationfoods,
                tbDescriptionstatement.getSumThecertificationfood());
        table.setSpacingBefore(25);
        document.add(table);

        table = createtableThecertificationdrinks(tbThecertificationdrinks,
                tbDescriptionstatement.getSumThecertificationdrink());
        table.setSpacingBefore(25);
        document.add(table);

        table = createtableThegift(tbThegifts, tbDescriptionstatement.getSumThegift());
        table.setSpacingBefore(25);
        document.add(table);

        table = createtableTax(tbTaxs, tbDescriptionstatement.getSumTax());
        table.setSpacingBefore(25);
        document.add(table);

        table = createtableFee(tbFees, tbDescriptionstatement.getSumFee());
        table.setSpacingBefore(25);
        document.add(table);

        table = createtableInsurance(tbInsurances, tbDescriptionstatement.getSumInsurance());
        table.setSpacingBefore(25);
        document.add(table);

        table = createtableEmploy(tbEmploys, tbDescriptionstatement.getSumEmploy());
        table.setSpacingBefore(25);
        document.add(table);

        createHeadlistBudwork(document, "3");

        table = createtableMaterial1(tbMaterials1, tbDescriptionstatement.getSumMOffice());
        table.setSpacingBefore(25);
        document.add(table);

        table = createtableMaterial2(tbMaterials2, tbDescriptionstatement.getSumMBuild());
        table.setSpacingBefore(25);
        document.add(table);

        table = createtableMaterial3(tbMaterials3, tbDescriptionstatement.getSumMKitchen());
        table.setSpacingBefore(25);
        document.add(table);

        table = createtableMaterial4(tbMaterials4, tbDescriptionstatement.getSumMElectrical());
        table.setSpacingBefore(25);
        document.add(table);

        table = createtableMaterial5(tbMaterials5, tbDescriptionstatement.getSumMMedic());
        table.setSpacingBefore(25);
        document.add(table);

        table = createtableMaterial6(tbMaterials6, tbDescriptionstatement.getSumMStudy());
        table.setSpacingBefore(25);
        document.add(table);

        table = createtableMaterial7(tbMaterials7, tbDescriptionstatement.getSumMBook());
        table.setSpacingBefore(25);
        document.add(table);

        table = createtableMaterial8(tbMaterials8, tbDescriptionstatement.getSumMFarm());
        table.setSpacingBefore(25);
        document.add(table);

        table = createtableMaterial9(tbMaterials9, tbDescriptionstatement.getSumMCom());
        table.setSpacingBefore(25);
        document.add(table);

        table = createtableMaterial10(tbMaterials10, tbDescriptionstatement.getSumMMul());
        table.setSpacingBefore(25);
        document.add(table);

        table = createtableMaterial11(tbMaterials11, tbDescriptionstatement.getSumMOther());
        table.setSpacingBefore(25);
        document.add(table);

        createHeadlistBudwork(document, "4");

        table = createtablePublicutility(tbPublicutilitys, tbDescriptionstatement.getSumPublicutility());
        table.setSpacingBefore(25);
        document.add(table);

        document.close();
    } catch (FileNotFoundException e) {

        e.printStackTrace();
    } catch (DocumentException e) {
        e.printStackTrace();
    }
    return document;
}

From source file:com.planning.project.controller.CreatePDF.java

public static Document createPDFActivity(String file, Long activityId) throws Exception {

    Document document = null;/*www .j  a v a  2 s  .c o m*/

    try {
        document = new Document();
        PdfWriter.getInstance(document, new FileOutputStream(file));
        document.open();

        addMetaData(document);

        addTitlePageProject(document);

        Paragraph created = new Paragraph();
        created.setFont(TIME_ROMAN_SMALL);
        created.add(activityId.toString());
        created.setAlignment(Element.ALIGN_RIGHT);
        document.add(created);
        document.close();

    } catch (FileNotFoundException e) {

        e.printStackTrace();
    } catch (DocumentException e) {
        e.printStackTrace();
    }
    return document;
}

From source file:com.planning.project.controller.CreatePDF.java

private static void addTitlePage(Document document) throws DocumentException, IOException {

    Font font = new Font(BaseFont.createFont("D:/THSarabunNew.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED));
    font.setSize(24);//from   ww w  .ja va  2 s .c o m

    String imagepath = "src/main/webapp/resources/images/curt.gif";
    Image img = Image.getInstance(imagepath);
    img.scaleToFit(70f, 70f);

    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM/dd/yyyy");

    Paragraph created = new Paragraph();
    created.setFont(TIME_ROMAN_SMALL);
    created.add("Report created on " + simpleDateFormat.format(new Date()));
    created.setAlignment(Element.ALIGN_RIGHT);

    Paragraph logo = new Paragraph();
    logo.setFont(TIME_ROMAN_SMALL);
    logo.add(img);
    logo.setAlignment(Element.ALIGN_LEFT);
    document.add(created);
    document.add(logo);

    // Paragraph created = new Paragraph();
    // created.setFont(TIME_ROMAN_SMALL);
    // created.add("Report created on " + simpleDateFormat.format(new
    // Date()));
    // created.setAlignment(Element.ALIGN_RIGHT);

    Paragraph paragraph = new Paragraph();
    paragraph.setFont(font);
    paragraph.add("FormProject ");

    paragraph.setAlignment(Element.ALIGN_CENTER);
    document.add(paragraph);
    creteEmptyLine(created, 1);

}