Example usage for com.itextpdf.text Document addKeywords

List of usage examples for com.itextpdf.text Document addKeywords

Introduction

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

Prototype


public boolean addKeywords(String keywords) 

Source Link

Document

Adds the keywords to a Document.

Usage

From source file:has.GenerateReceipt.java

private static void addMetaData(Document document) {
    document.addTitle("RECEPIT ");
    document.addSubject("Using iText");
    document.addKeywords("Java, PDF, iText");
    document.addAuthor("Kesava");
    document.addCreator("Kesava");
}

From source file:ics4u.ics4u_final_project.Recipe.java

License:Open Source License

private void addMetaData(Document doc) {
    //add all the meta data of the docmuent
    doc.addTitle(title);//from w  w  w .  jav a2 s  .c o m
    doc.addSubject("Recipies");
    doc.addKeywords("recipe, " + title);
    doc.addAuthor("Isaac Wismer");
    doc.addCreator("Nutrient Calculator. Made using the iTextPDF Library 5.5.8 http://itextpdf.com/");
}

From source file:itext_result.Main.java

private int developScreeningSheet() {
    new SwingWorker<Object, Object>() {
        String filename;/*  ww  w. j  ava  2  s .co  m*/

        @Override
        protected void done() {

            // ConsoleMsg("Printing PROFILE SHEET IN PROGRESS.. ");
        }

        public PdfPCell createBarcode(PdfWriter writer, String code) throws DocumentException, IOException {
            BarcodeEAN barcode = new BarcodeEAN();
            barcode.setCodeType(Barcode.EAN8);
            barcode.setCode(code);
            PdfPCell cell = new PdfPCell(
                    barcode.createImageWithBarcode(writer.getDirectContent(), BaseColor.BLACK, BaseColor.GRAY),
                    true);
            cell.setPadding(10);
            return cell;
        }

        class ImageContent implements PdfPTableEvent {

            protected com.itextpdf.text.Image content;

            public ImageContent(com.itextpdf.text.Image content) {
                this.content = content;
            }

            public void tableLayout(PdfPTable table, float[][] widths, float[] heights, int headerRows,
                    int rowStart, PdfContentByte[] canvases) {
                try {
                    PdfContentByte canvas = canvases[PdfPTable.TEXTCANVAS];
                    float x = widths[3][1] + 10;
                    float y = heights[3] - 10 - content.getScaledHeight();
                    content.setAbsolutePosition(x, y);
                    canvas.addImage(content);
                } catch (DocumentException e) {
                    throw new ExceptionConverter(e);
                }
            }
        }

        @Override
        protected Object doInBackground() throws Exception {
            //   System.err.println(" Roll No Received ....." + rollno);
            Document doc = new Document();
            try {
                PdfWriter writer = PdfWriter.getInstance(doc, new FileOutputStream("12345" + ".pdf"));
                doc.open();
                doc.addTitle("Recruitment PET Sheett - " + "Created By SOS : ");
                doc.addSubject("Confidential Report Eyes Only");
                doc.addKeywords("");
                doc.addAuthor("SOS");
                doc.addCreator("SOS");

                // A4 = 210mm x 297mm ~ 605points x 855points
                doc.setPageSize(PageSize.A5);
                doc.setMargins(15f, 15f, 15f, 15f);

                /////////////////////////////////////////////////////////////
                int pageno = 1;

                for (int i = 0; i == pageno; i++) {

                    //    doc.add(imageRight);
                }

                PdfContentByte cb = writer.getDirectContent();
                //DONE
                BarcodeEAN codeEAN = new BarcodeEAN();
                codeEAN.setCodeType(Barcode.EAN8);
                Barcode128 code128 = new Barcode128();
                code128.setCode(String.valueOf("123456"));

                Barcode128 code128_jacket = new Barcode128();
                code128_jacket.setCode(String.valueOf("10345"));

                codeEAN.setCode(String.valueOf("123456"));
                com.itextpdf.text.Image imageEAN = code128.createImageWithBarcode(cb, null, null);
                // imageEAN.scalePercent(10f);
                //464f, 725f
                //  imageEAN.setAbsolutePosition(474f, 662f);

                int i = 1;
                while (i <= pageno) {
                    doc.newPage();
                    //   cb.addImage(imageRight);
                    //   cb.addImage(imageEAN);
                    i++;
                }

                com.itextpdf.text.Image carcode = code128_jacket.createImageWithBarcode(cb, null, null);
                carcode.scaleAbsolute(100f, 35f);
                carcode.setAbsolutePosition(500f, 600f);
                writer.addDirectImageSimple(carcode);
                //     cb.addImage(carcode);

                com.itextpdf.text.Image carcode2 = code128.createImageWithBarcode(cb, null, null);
                carcode2.scaleAbsolute(100f, 35f);
                carcode2.setAbsolutePosition(450f, 760f);
                writer.addDirectImageSimple(carcode2);
                //    cb.addImage(carcode2);

                Image image1 = Image.getInstance("jklogo.gif");

                PdfPTable table = new PdfPTable(1);
                table.setWidthPercentage(99);
                table.addCell(image1);
                doc.add(table);
                table = new PdfPTable(4);
                table.setWidthPercentage(99);

                float[] columnWidths = { 6, 2 };
                PdfPTable CandidateTable = new PdfPTable(columnWidths);
                Font f = new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL, GrayColor.BLACK);
                Font fsmall = new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL, GrayColor.BLACK);
                PdfPCell rollno = new PdfPCell(new Phrase("Roll No# " + String.valueOf("123456"), fsmall));
                PdfPCell cname = new PdfPCell(new Phrase("Name #" + String.valueOf("John Doe"), fsmall));
                //                    DateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
                //                    String today = formatter.format(cInfo.getDob());
                PdfPCell dob = new PdfPCell(new Phrase("DOB#" + String.valueOf("12-03-1989"), fsmall));
                PdfPCell fname = new PdfPCell(new Phrase("F/H Name #" + String.valueOf("Big John"), fsmall));
                PdfPCell type = new PdfPCell(new Phrase("Total Time  #" + String.valueOf("350.00"), fsmall));

                //  String scrtoday = formatter.format(cInfo.getScreeningdate());
                //  System.out.println("Today : " + today);
                PdfPCell scrdate = new PdfPCell(new Phrase("Laps  #" + String.valueOf("4"), fsmall));
                PdfPCell cell = new PdfPCell(new Phrase(" ", fsmall));

                rollno.setBorder(com.itextpdf.text.Rectangle.NO_BORDER);
                cname.setBorder(com.itextpdf.text.Rectangle.NO_BORDER);
                rollno.setBorder(com.itextpdf.text.Rectangle.NO_BORDER);
                dob.setBorder(com.itextpdf.text.Rectangle.NO_BORDER);
                fname.setBorder(com.itextpdf.text.Rectangle.NO_BORDER);
                type.setBorder(com.itextpdf.text.Rectangle.NO_BORDER);
                scrdate.setBorder(com.itextpdf.text.Rectangle.NO_BORDER);
                cell.setBorder(com.itextpdf.text.Rectangle.NO_BORDER);

                CandidateTable.addCell(rollno);
                CandidateTable.addCell(cell);
                CandidateTable.addCell(cname);
                CandidateTable.addCell(cell);
                CandidateTable.addCell(dob);
                CandidateTable.addCell(cell);

                PdfPTable CandidateOtherTable = new PdfPTable(columnWidths);
                CandidateOtherTable.addCell(fname);
                CandidateOtherTable.addCell(cell);
                CandidateOtherTable.addCell(scrdate);
                CandidateOtherTable.addCell(cell);
                CandidateOtherTable.addCell(type);
                CandidateOtherTable.addCell(cell);

                PdfPCell race_start_time = new PdfPCell(new Phrase("Start Time :XX-XX-XX ", fsmall));
                PdfPCell race_end_time = new PdfPCell(new Phrase("End Time :XX-XX-XX", fsmall));
                PdfPCell race_total_time = new PdfPCell(new Phrase("Total Time : 350.00   ", fsmall));
                race_start_time.setBorder(com.itextpdf.text.Rectangle.NO_BORDER);
                race_end_time.setBorder(com.itextpdf.text.Rectangle.NO_BORDER);
                race_total_time.setBorder(com.itextpdf.text.Rectangle.NO_BORDER);

                PdfPTable CandidateRaceDetails = new PdfPTable(columnWidths);
                CandidateRaceDetails.addCell(race_start_time);
                CandidateRaceDetails.addCell(cell);
                CandidateRaceDetails.addCell(race_end_time);
                CandidateRaceDetails.addCell(cell);
                CandidateRaceDetails.addCell(race_total_time);
                CandidateRaceDetails.addCell(cell);

                PdfPTable tablewith3cells = new PdfPTable(3);
                //1 St Col for Roll No Name and DOB
                tablewith3cells.addCell(CandidateTable);
                //2 nd Col for Father Name sCREEning Date Gurkha 
                tablewith3cells.addCell(CandidateOtherTable);
                //3rd Col for Barcode to be Printed
                tablewith3cells.addCell(CandidateRaceDetails);
                // Setting the Width here to 101
                tablewith3cells.setWidthPercentage(99);
                doc.add(tablewith3cells);

                PdfPTable userArea = new PdfPTable(1);
                userArea.setWidthPercentage(99);
                userArea.addCell(" \n \n Congratulations \n \n ");

                doc.add(userArea);

                PdfPTable footerCSBC = new PdfPTable(2);
                footerCSBC.setWidthPercentage(99);

                PdfPCell height_box = new PdfPCell(new Phrase("Height  \n\n\n", f));
                height_box.setBorder(com.itextpdf.text.Rectangle.BOX);
                PdfPCell chest_box = new PdfPCell(new Phrase("Chest  \n\n\n", f));
                chest_box.setBorder(com.itextpdf.text.Rectangle.BOX);
                PdfPCell chest_exp_box = new PdfPCell(new Phrase("Chest Exp  \n\n\n", f));
                chest_exp_box.setBorder(com.itextpdf.text.Rectangle.BOX);
                PdfPCell pushup_box = new PdfPCell(new Phrase("Pushup  \n\n\n", f));
                pushup_box.setBorder(com.itextpdf.text.Rectangle.BOX);

                //CSignatureBox.setBorder(com.itextpdf.text.Rectangle.BOX);
                // ASignatureBox.setBorder(com.itextpdf.text.Rectangle.BOX);
                footerCSBC.addCell(height_box);
                footerCSBC.addCell(chest_box);
                footerCSBC.addCell(chest_exp_box);
                footerCSBC.addCell(pushup_box);

                doc.add(footerCSBC);

                float[] columnWidths_ForBarcode = { 6, 3 };
                PdfPTable terminalinfo = new PdfPTable(columnWidths_ForBarcode);
                // terminalinfo.setWidthPercentage(99);
                String computername = InetAddress.getLocalHost().getHostName();
                System.out.println(computername);
                PdfPCell pcname = new PdfPCell(new Phrase("\t Jacket \n\n ", f));

                String UserMatchScore = "\t Barcode\n\n";

                PdfPCell score = new PdfPCell(new Phrase(UserMatchScore, f));
                PdfPCell barcode = new PdfPCell(carcode2);
                PdfPCell jacketnumber = new PdfPCell(carcode);
                pcname.setBorder(com.itextpdf.text.Rectangle.NO_BORDER);
                score.setBorder(com.itextpdf.text.Rectangle.NO_BORDER);
                barcode.setBorder(com.itextpdf.text.Rectangle.NO_BORDER);
                jacketnumber.setBorder(com.itextpdf.text.Rectangle.NO_BORDER);

                terminalinfo.addCell(score);
                terminalinfo.addCell(pcname);
                terminalinfo.addCell(barcode);
                terminalinfo.addCell(jacketnumber);

                doc.add(terminalinfo);

                PdfPCell eula_notice = new PdfPCell(new Phrase("  ", f));
                eula_notice.setBorder(com.itextpdf.text.Rectangle.NO_BORDER);

                cell.setHorizontalAlignment(Element.ALIGN_CENTER);

                PdfPTable eula_notice_table = new PdfPTable(1);
                eula_notice_table.setWidthPercentage(25);
                eula_notice_table.addCell(eula_notice);

                doc.add(eula_notice_table);

            } catch (Exception e) {
                System.err.println(e.getMessage());

                // ConsoleMsg(e.getMessage());
            } finally {
                doc.close();
                doc.close();
                doc.close();
            }

            //ConsoleMsg("PDF... GENERATED");
            return null;
            //    throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }
    }.execute();

    return 0;
}

From source file:lk.score.androphsy.report.ReportPdf.java

License:Open Source License

private void addMetaData(Document document) {
    document.addTitle("lk.score.androphsy.main.Androspy Reporting");
    document.addSubject("Evidence Report");
    document.addKeywords("lk.score.androphsy.main.Androspy, Evidence");
    document.addCreator("lk.score.androphsy.main.Androspy");
    document.addAuthor(AndrospyMain.gb_username);
    document.addCreationDate();/*from  w ww .j  av  a2  s  . c  o m*/

}

From source file:Modelo.CotizacionDAO.java

public void writePdf(OutputStream outputStream, Cotizacion x, int idcotizacion) throws Exception {

    DateFormat df = new SimpleDateFormat("dd/MM/YYYY");
    Calendar cdos = Calendar.getInstance();
    Date datediamas = new Date();
    Date dateaniomas = new Date();
    cdos.add(Calendar.DATE, 1);//  www  .j  a  v  a 2  s  . c o  m
    datediamas = cdos.getTime();
    String fechadiamas = df.format(datediamas);
    cdos.add(Calendar.YEAR, 1);
    dateaniomas = cdos.getTime();
    String fechavencimiento = df.format(dateaniomas);

    Document document = new Document(PageSize.LETTER, 50, 50, 50, 30);
    Font boldFontTitulo = new Font(Font.FontFamily.HELVETICA, 12, Font.BOLD);
    Font boldFontTexto = new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD);
    Font FontTexto = new Font(Font.FontFamily.HELVETICA, 10);

    // document.setPageSize(null);
    PdfWriter writer = PdfWriter.getInstance(document, outputStream);

    Image imagen = Image.getInstance("http://54.67.56.185/BSeguros_pa18/img/BSeguroLogo.png");
    //      Image imagen = Image.getInstance("D:\\ALEX\\Bseguros\\web\\img\\Aseguradoras\\BSeguroLogo.png");
    Image imagen2 = Image.getInstance(
            "http://54.67.56.185/BSeguros_pa18/img/Aseguradoras/" + x.getId_aseguradora() + ".png");
    //Image imagen2 = Image.getInstance("D:\\ALEX\\Bseguros\\web\\img\\Aseguradoras\\Mapfre.png");

    document.open();

    PdfContentByte canvas = writer.getDirectContent();
    Rectangle rect = new Rectangle(36, 36, 579, 756);
    rect.setBorder(Rectangle.BOX);
    rect.setBorderWidth(2);
    canvas.rectangle(rect);

    document.addTitle("Cotizacion");
    document.addSubject("Cotizacion");
    document.addKeywords("Cotizacion, seguros");
    document.addAuthor("BSeguro");
    document.addCreator("Bseguro");

    imagen.scaleAbsoluteHeight(30f);
    imagen.setAbsolutePosition(45f, 720f);
    imagen2.scaleAbsoluteHeight(30f);
    imagen2.setAbsolutePosition(450f, 720f);
    document.add(imagen);
    document.add(imagen2);

    Paragraph paragraph2 = new Paragraph("DATOS DE TU POLIZA", boldFontTitulo);
    paragraph2.setAlignment(Element.ALIGN_CENTER);
    document.add(paragraph2);

    //creas una tabla con un ancho de 3 celdas, el salto a la siguiente fila sera automatico
    PdfPTable table = new PdfPTable(3);
    table.getDefaultCell().setBorder(0);
    PdfPCell cell;

    Paragraph saltodelinea = new Paragraph(" ");
    document.add(saltodelinea);

    document.add(new Paragraph(" Datos de tu poliza folio: " + "BC" + x.getId_aseguradora().substring(0, 1)
            + x.getMetododepago().substring(0, 1) + ": 0000" + idcotizacion, boldFontTitulo));
    document.add(new Paragraph(" Vigencia de la poliza del: " + fechadiamas + " al: " + fechavencimiento,
            boldFontTitulo));
    document.add(saltodelinea);

    document.add(new Paragraph(" Datos del Contratante: ", boldFontTitulo));
    //document.add(saltodelinea);

    //agrego otra tabla
    table = new PdfPTable(6);
    table.setWidthPercentage(100);
    table.getDefaultCell().setBorder(0);
    table.addCell(new Paragraph("Nombre: ", boldFontTexto));
    PdfPCell celdaNombre = new PdfPCell(
            new Paragraph(x.getNombre_contratante() + " " + x.getApellido_paterno(), FontTexto));
    celdaNombre.setColspan(5);
    celdaNombre.setBorder(0);
    table.addCell(celdaNombre);
    table.addCell(new Paragraph("RFC : ", boldFontTexto));
    PdfPCell celdaRFC = new PdfPCell(new Paragraph(x.getRfc(), FontTexto));
    celdaRFC.setColspan(5);
    celdaRFC.setBorder(0);
    table.addCell(celdaRFC);
    table.addCell(new Paragraph("Direccion: ", boldFontTexto));
    PdfPCell celdaDir = new PdfPCell(
            new Paragraph(x.getCall() + ", " + x.getNo_ext() + ", " + x.getNo_int() + ", " + x.getColonia()
                    + ", " + x.getDelegacion() + ", " + x.getEstado() + ", " + x.getCp(), FontTexto));
    celdaDir.setColspan(5);
    celdaDir.setBorder(0);
    table.addCell(celdaDir);
    table.addCell(new Paragraph("Email: ", boldFontTexto));
    table.addCell(AddCell(x.getMail(), 5));
    table.addCell(new Paragraph("Telefono ", boldFontTexto));
    PdfPCell celdaTel = new PdfPCell(new Paragraph(x.getTelefono(), FontTexto));
    celdaTel.setColspan(5);
    celdaTel.setBorder(0);
    table.addCell(celdaTel);

    document.add(table);
    document.add(saltodelinea);

    document.add(new Paragraph(" Datos del Vehiculo: ", boldFontTitulo));
    //      document.add(saltodelinea);

    //agrego otra tabla
    table = new PdfPTable(6);
    table.setWidthPercentage(100);
    table.getDefaultCell().setBorder(0);
    table.addCell(new Paragraph("Marca: ", boldFontTexto));
    table.addCell(AddCell(x.getId_marca(), 5));
    table.addCell(new Paragraph("Modelo:", boldFontTexto));
    table.addCell(AddCell(x.getId_anio().toString(), 5));
    table.addCell(new Paragraph("Tipo: ", boldFontTexto));
    table.addCell(AddCell(x.getId_submarca(), 5));
    table.addCell(new Paragraph("Version:  ", boldFontTexto));
    table.addCell(AddCell(x.getId_modelo(), 5));
    table.addCell(new Paragraph("No. De Serie: ", boldFontTexto));
    table.addCell(AddCell(x.getSerie(), 5));

    document.add(table);
    document.add(saltodelinea);

    document.add(new Paragraph(" Informacion de la Poliza: ", boldFontTitulo));
    //    document.add(saltodelinea);

    //agrego otra tabla
    table = new PdfPTable(6);
    table.setWidthPercentage(100);
    table.getDefaultCell().setBorder(0);
    table.addCell(new Paragraph("Pago: ", boldFontTexto));
    table.addCell(AddCell(x.getTipo_pago(), 5));
    table.addCell(new Paragraph("Aseguradora: ", boldFontTexto));
    table.addCell(AddCell(x.getId_aseguradora(), 5));

    document.add(table);
    document.add(saltodelinea);

    document.add(new Paragraph(" Detalles de la Cobertura: Cobertura Amplia ", boldFontTitulo));
    //  document.add(saltodelinea);

    //agrego otra tabla
    table = new PdfPTable(3);
    table.setWidthPercentage(100);
    table.getDefaultCell().setBorder(0);
    table.addCell(new Paragraph("Cobertura ", boldFontTexto));
    table.addCell(new Paragraph("Responsabilidad Civil", boldFontTexto));
    table.addCell(new Paragraph("Deducible ", boldFontTexto));
    table.addCell(new Paragraph("Daos Materiales", FontTexto));
    table.addCell(new Paragraph("Valor Comercial", FontTexto));
    table.addCell(new Paragraph("5%", FontTexto));
    table.addCell(new Paragraph("Robo Total", FontTexto));
    table.addCell(new Paragraph("Valor Comercial", FontTexto));
    table.addCell(new Paragraph("10%", FontTexto));
    table.addCell(new Paragraph("Responsabilidad Civil", FontTexto));
    table.addCell(new Paragraph("$4,000,000.00", FontTexto));
    table.addCell(new Paragraph("", FontTexto));
    table.addCell(new Paragraph("Gastos Medicos Ocupantes", FontTexto));
    table.addCell(new Paragraph("$500,000.00", FontTexto));
    table.addCell(new Paragraph("", FontTexto));
    table.addCell(new Paragraph("Asistencia Legal", FontTexto));
    table.addCell(new Paragraph("Amparada", FontTexto));
    table.addCell(new Paragraph("", FontTexto));
    table.addCell(new Paragraph("Asistencia Vial", FontTexto));
    table.addCell(new Paragraph("Amparada", FontTexto));
    table.addCell(new Paragraph("", FontTexto));

    document.add(table);
    document.add(saltodelinea);

    document.add(new Paragraph(" Informacion del Pago ", boldFontTitulo));
    document.add(new Paragraph(" Instrumento de Pago: " + x.getMetododepago(), boldFontTexto));

    //agrego otra tabla
    table = new PdfPTable(6);
    table.setWidthPercentage(100);
    table.getDefaultCell().setBorder(0);
    table.addCell(AddCell("Concepto ", 2));
    table.addCell(AddCell("Monto", 4));
    table.addCell(AddCell("Prima Total ", 2));
    table.addCell(AddCell(x.getMonto(), 4));
    table.addCell(AddCell("Prima Inicial", 2));
    table.addCell(AddCell(x.getMonto(), 4));
    table.addCell(AddCell("Pago Subsecuente ", 2));
    table.addCell(AddCell("0", 4));

    document.add(table);
    document.add(saltodelinea);

    if (x.getCobertura_auto_siempre() == true) {

        document.add(new Paragraph(" Informacion de Modulos HDI ", boldFontTitulo));
        table = new PdfPTable(6);
        table.setWidthPercentage(100);
        table.getDefaultCell().setBorder(0);
        table.addCell(AddCell("Modulos ", 2));
        table.addCell(AddCell("Contratados", 4));
        table.addCell(AddCell("HDI - Autos por Siempre ", 2));
        table.addCell(AddCell("$ 1,799.00", 4));
        document.add(table);

    } else {
        if (x.getCobertura_auto_amante() == true) {

            document.add(new Paragraph(" Informacion de Modulos HDI ", boldFontTitulo));
            table = new PdfPTable(6);
            table.setWidthPercentage(100);
            table.getDefaultCell().setBorder(0);
            table.addCell(AddCell("Modulos ", 2));
            table.addCell(AddCell("Contratados", 4));
            table.addCell(AddCell("HDI - Amante de los Autos ", 2));
            table.addCell(AddCell("$ 1,799.00", 4));
            document.add(table);

        } else {

        }
        document.add(saltodelinea);
    }
    document.add(new Paragraph("* Estaras asegurado a partir de las 12 horas del siguiente dia habil.",
            boldFontTexto));

    document.close();

}

From source file:Modelo.ModeloPdf.java

public void crear_PDF(String t, String a, String s, String k, String c) {
    //abre ventana de dialogo "guardar"
    Colocar_Destino();/*from  ww w  .  j av  a 2 s  .  co  m*/
    //si destino es diferente de null
    if (this.ruta_destino != null) {
        try {
            // se crea instancia del documento
            Document mipdf = new Document();
            // se establece una instancia a un documento pdf
            PdfWriter.getInstance(mipdf, new FileOutputStream(this.ruta_destino + ".pdf"));
            mipdf.open();// se abre el documento
            mipdf.addTitle(t); // se aade el titulo
            mipdf.addAuthor(a); // se aade el autor del documento
            mipdf.addSubject(s); //se aade el asunto del documento
            mipdf.addKeywords(k); //Se agregan palabras claves  
            mipdf.add(new Paragraph(c)); // se aade el contendio del PDF
            mipdf.close(); //se cierra el PDF&
            JOptionPane.showMessageDialog(null, "Documento PDF creado");
        } catch (DocumentException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        } catch (FileNotFoundException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

From source file:negotiation.Contract.FormContractPdf.java

public static void addMetaData(Document document) {
    document.addTitle("FitSM Module");
    document.addSubject("Using iText");
    document.addKeywords("Java, PDF, iText, FitSM");
    document.addAuthor("Zeqian Meng");
    document.addCreator("Zeqian Meng");
}

From source file:net.FilterLogic.imaging.ToPDF.java

License:Apache License

/**
 * Iterate through properties and set each value for PDF document.
 *///from   w  ww.  j  a  va 2 s  .com
private void setDocumentProperties(Document pdf) {

    for (Enumeration e = this.documentProperties.keys(); e.hasMoreElements();) {
        String name = e.nextElement().toString().toUpperCase();
        String value = this.documentProperties.getProperty(name);

        if (name.equals("TITLE"))
            pdf.addTitle(value);

        if (name.equals("AUTHOR"))
            pdf.addAuthor(value);

        //            if(name.equals("CREATOR"))
        //                pdf.addCreator(value);

        if (name.equals("CREATIONDATE"))
            pdf.addCreationDate();

        if (name.equals("SUBJECT"))
            pdf.addSubject(value);

        if (name.equals("KEYWORDS"))
            pdf.addKeywords(value);
    }

}

From source file:org.bonitasoft.studio.migration.utils.PDFMigrationReportWriter.java

License:Open Source License

private void addMetaData(Document document) {
    document.addTitle(report.getName());
    document.addSubject("Migration status report");
    document.addKeywords("BPMN, Migration, BonitaSoft, Process");
    document.addAuthor("Bonita Studio");
    document.addCreator("Bonita Studio");
}

From source file:org.gbif.ipt.task.Eml2Pdf.java

public void writeEmlIntoPdf(Document doc, Resource resource, PdfWriter pdfWriter, String lng, String cert,
        String url) {//from w  w w.  j  ava  2s.  c om
    Locale loc = new Locale(lng);
    String[] dataCert = cert.split("-");
    resourceBundle = ResourceBundle.getBundle("ApplicationResources", loc);
    // this.action = action;
    authoritiesHome = new LinkedHashMap<String, String>();
    authoritiesHome.putAll(cfg.loadAuthorities());
    //roles list, derived from XML vocabulary, and displayed in drop-down where new contacts are created
    roles = new LinkedHashMap<String, String>();
    roles.put("", getText("eml.agent.role.selection"));
    roles.putAll(vocabManager.getI18nVocab(Constants.VOCAB_URI_ROLES, "es", false));
    Eml eml = resource.getEml();
    setInfo(eml);
    setDate(dataCert[0]);
    String keys = "";
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
    for (KeywordSet kw : eml.getKeywords()) {
        if (keys.length() == 0) {
            keys = kw.getKeywordsString(", ");
        } else {
            keys += ", " + kw.getKeywordsString(", ");
        }
    }
    doc.addKeywords(keys);
    addMetaData(doc);
    doc.open();

    String htmlText = "<html>";
    htmlText += "<style type='text/css'>";
    htmlText += " .mainTable{width:100%;} "
            + ".nota{color:#e75170;font-family:sans-serif;font-size: 14px;padding: 40px;font-weight:bold;margin-top:90px;margin-botom:400px}"
            + ".centerLine{text-align:center;} " + ".subtitle{color:#ebf7fb;} "
            + ".resumeInfo{width: 418px;padding: 40px;}"
            + "h4{font-family:sans-serif;font-size: 22px;color: #58585b}" + "span{color:#268ac7}"
            + "label{font-family:sans-serif;font-size: 18px;color: #58585b;margin-bottom:5px;font-weight:100}"
            + "a{color:#43afe3}" + "b{font-weight:bold}"
            + "h2{font-family:sans-serif;font-size: 26px;color: #58585b}"
            + "h3{font-family:sans-serif;color: #58585b}"
            + "p{font-family:sans-serif;font-size: 16px;color: #58585b;font-weight:100;text-align:justify;}";
    htmlText += "</style>";
    htmlText += "<body><table class='mainTable'><tr align='center' class='centerLine'><td>";
    htmlText += "<img width='520px' src='" + url + "/styles/certificado_header_crsibA.png' class='imgTitle'/>";
    htmlText += "</td></tr>";
    htmlText += "<tr align='center' class='centerLine'><td>";
    htmlText += "</td></tr>";
    htmlText += "<tr><td class='resumeInfo'>";
    htmlText += "<p id='resumeInfo'>";
    htmlText += "<h4><span>1. </span>" + getText("pdf.info.cert") + "</h4>";
    htmlText += "<br />";
    htmlText += "<label>" + getText("pdf.cert.number") + "<b>" + dataCert[0] + "</b></label><br/>";
    htmlText += "<label>" + getText("pdf.cert.resource.actu") + "<b>"
            + dateFormat.format(resource.getModified()) + "</b></label><br/>";
    htmlText += "<label>" + getText("pdf.cert.resource.url") + "<a href='" + url + "/resource.do?r="
            + resource.getShortname() + "'>" + url + "/resource.do?r=" + resource.getShortname()
            + "</a></label><br/>";

    if (resource.getRecordsPublished() != 0) {
        htmlText += "<label>" + getText("pdf.cert.resource.records") + "<b>" + resource.getRecordsPublished()
                + "</b></label>";
    } else {
        if (resource.getSources().size() > 0) {
            if (resource.getSources().get(0).isExcelSource()) {
                ExcelFileSource excl = new ExcelFileSource();
                excl = (ExcelFileSource) resource.getSources().get(0);
                htmlText += "<label>" + getText("pdf.cert.resource.records") + "<b>" + excl.getRows()
                        + "</b></label>";
            } else if (resource.getSources().get(0).isFileSource()) {
                TextFileSource txtcl = new TextFileSource();
                txtcl = (TextFileSource) resource.getSources().get(0);
                htmlText += "<label>" + getText("pdf.cert.resource.records") + "<b>" + txtcl.getRows()
                        + "</b></label>";
            }
        }
    }

    htmlText += "</p>";
    htmlText += "</td></tr>";

    htmlText += "<tr ><td style='text-align:justify;'>";
    //htmlText +="<br />";
    htmlText += "<h2><span>2. </span>" + getText("pdf.license") + "</h2> ";
    htmlText += "<p><b>" + getText("pdf.license.authority") + "</b><br/>" + aut + "<br/>";
    htmlText += "<b>" + getText("pdf.license.number") + "</b><br/>" + num + "<br/>";
    htmlText += "<b>" + getText("pdf.license.holder") + "</b><br/>" + hol + "<br/>";
    htmlText += "<b>" + getText("pdf.license.nit") + "</b><br/>" + nit + "<br/>";
    htmlText += "<b>" + getText("pdf.license.date") + "</b><br/>" + dte + "</p>";

    htmlText += "<h2><span>3. </span>" + getText("pdf.info.project") + "</h2> ";
    htmlText += "<p>";
    htmlText += "<b>" + getText("pdf.title.proyect") + "</b><br/>";
    htmlText += eml.getTitle().replaceAll("<", "&#60;").replaceAll(">", "&#62;");
    ;
    htmlText += "</p>";
    htmlText += "<p>";
    htmlText += "<b>" + getText("pdf.abstract") + "</b><br/>";
    htmlText += eml.getDescription().replaceAll("<", "&#60;").replaceAll(">", "&#62;");
    ;
    htmlText += "</p>";
    htmlText += "<p>";

    htmlText += "<b>" + getText("pdf.keywords") + "</b><br/>";
    htmlText += keys.replaceAll("<", "&#60;").replaceAll(">", "&#62;");
    htmlText += "</p>";

    int subI = 0;

    subI++;
    htmlText += "<h3><span>3." + subI + " </span>" + getText("pdf.contact.resource") + "</h3> ";
    htmlText += "<p>";
    htmlText += "<b>" + getText("pdf.contact.resource.name") + "</b><br/>";
    htmlText += eml.getContact().getFirstName().replaceAll("<", "&#60;").replaceAll(">", "&#62;") + " "
            + eml.getContact().getLastName().replaceAll("<", "&#60;").replaceAll(">", "&#62;") + "<br/>";
    htmlText += "<b>" + getText("pdf.contact.resource.position") + "</b><br/>";
    htmlText += eml.getContact().getPosition().replaceAll("<", "&#60;").replaceAll(">", "&#62;") + "<br/>";
    htmlText += "<b>" + getText("pdf.contact.resource.organisation") + "</b><br/>";
    htmlText += eml.getContact().getOrganisation().replaceAll("<", "&#60;").replaceAll(">", "&#62;") + "<br/>";
    htmlText += "<b>" + getText("pdf.contact.resource.address.address") + "</b><br/>";
    htmlText += eml.getContact().getAddress().getAddress().replaceAll("<", "&#60;").replaceAll(">", "&#62;")
            + "<br/>";
    htmlText += "<b>" + getText("pdf.contact.resource.address.city") + "</b><br/>";
    htmlText += eml.getContact().getAddress().getCity().replaceAll("<", "&#60;").replaceAll(">", "&#62;")
            + "<br/>";
    if (exists(eml.getContact().getAddress().getPostalCode())) {
        htmlText += "<b>" + getText("pdf.contact.resource.address.postalcode") + "</b><br/>";
        htmlText += eml.getContact().getAddress().getPostalCode().replaceAll("<", "&#60;").replaceAll(">",
                "&#62;") + "<br/>";
    }
    htmlText += "<b>" + getText("pdf.contact.resource.phone") + "</b><br/>";
    htmlText += eml.getContact().getPhone().replaceAll("<", "&#60;").replaceAll(">", "&#62;") + "<br/>";
    htmlText += "<b>" + getText("pdf.contact.resource.email") + "</b><br/>";
    htmlText += eml.getContact().getEmail().replaceAll("<", "&#60;").replaceAll(">", "&#62;") + "<br/>";
    if (exists(eml.getContact().getHomepage())) {
        htmlText += "<b>" + getText("pdf.contact.resource.homepage") + "</b><br/>"; //***
        htmlText += eml.getContact().getHomepage().replaceAll("<", "&#60;").replaceAll(">", "&#62;") + "<br/>";
    }
    htmlText += "</p>";

    subI++;
    htmlText += "<h3><span>3." + subI + " </span>" + getText("pdf.resourceCreator") + "</h3> ";
    htmlText += "<p>";
    htmlText += "<b>" + getText("pdf.resourceCreator.name") + "</b><br/>";
    htmlText += eml.getResourceCreator().getFirstName().replaceAll("<", "&#60;").replaceAll(">", "&#62;") + " "
            + eml.getResourceCreator().getLastName().replaceAll("<", "&#60;").replaceAll(">", "&#62;")
            + "<br/>";
    htmlText += "<b>" + getText("pdf.resourceCreator.position") + "</b><br/>";
    htmlText += eml.getResourceCreator().getPosition().replaceAll("<", "&#60;").replaceAll(">", "&#62;")
            + "<br/>";
    htmlText += "<b>" + getText("pdf.resourceCreator.organisation") + "</b><br/>";
    htmlText += eml.getResourceCreator().getOrganisation().replaceAll("<", "&#60;").replaceAll(">", "&#62;")
            + "<br/>";
    htmlText += "<b>" + getText("pdf.resourceCreator.address.address") + "</b><br/>";
    htmlText += eml.getResourceCreator().getAddress().getAddress().replaceAll("<", "&#60;").replaceAll(">",
            "&#62;") + "<br/>";
    htmlText += "<b>" + getText("pdf.resourceCreator.address.city") + "</b><br/>";
    htmlText += eml.getResourceCreator().getAddress().getCity().replaceAll("<", "&#60;").replaceAll(">",
            "&#62;") + "<br/>";
    if (exists(eml.getResourceCreator().getAddress().getPostalCode())) {
        htmlText += "<b>" + getText("pdf.resourceCreator.address.postalcode") + "</b><br/>";
        htmlText += eml.getResourceCreator().getAddress().getPostalCode().replaceAll("<", "&#60;")
                .replaceAll(">", "&#62;") + "<br/>";
    }
    htmlText += "<b>" + getText("pdf.resourceCreator.phone") + "</b><br/>";
    htmlText += eml.getResourceCreator().getPhone().replaceAll("<", "&#60;").replaceAll(">", "&#62;") + "<br/>";
    htmlText += "<b>" + getText("pdf.resourceCreator.email") + "</b><br/>";
    htmlText += eml.getResourceCreator().getEmail().replaceAll("<", "&#60;").replaceAll(">", "&#62;") + "<br/>";
    if (exists(eml.getResourceCreator().getHomepage())) {
        htmlText += "<b>" + getText("pdf.resourceCreator.homepage") + "</b><br/>"; //***
        htmlText += eml.getResourceCreator().getHomepage().replaceAll("<", "&#60;").replaceAll(">", "&#62;")
                + "<br/>";
    }
    htmlText += "</p>";

    subI++;
    htmlText += "<h3><span>3." + subI + " </span>" + getText("pdf.metadataProvider") + "</h3> ";
    htmlText += "<p>";
    htmlText += "<b>" + getText("pdf.metadataProvider.name") + "</b><br/>";
    htmlText += eml.getMetadataProvider().getFirstName() + " "
            + eml.getMetadataProvider().getLastName().replaceAll("<", "&#60;").replaceAll(">", "&#62;")
            + "<br/>";
    htmlText += "<b>" + getText("pdf.metadataProvider.position") + "</b><br/>";
    htmlText += eml.getMetadataProvider().getPosition().replaceAll("<", "&#60;").replaceAll(">", "&#62;")
            + "<br/>";
    htmlText += "<b>" + getText("pdf.metadataProvider.organisation") + "</b><br/>";
    htmlText += eml.getMetadataProvider().getOrganisation().replaceAll("<", "&#60;").replaceAll(">", "&#62;")
            + "<br/>";
    htmlText += "<b>" + getText("pdf.metadataProvider.address.address") + "</b><br/>";
    htmlText += eml.getMetadataProvider().getAddress().getAddress().replaceAll("<", "&#60;").replaceAll(">",
            "&#62;") + "<br/>";
    htmlText += "<b>" + getText("pdf.metadataProvider.address.city") + "</b><br/>";
    htmlText += eml.getMetadataProvider().getAddress().getCity().replaceAll("<", "&#60;").replaceAll(">",
            "&#62;") + "<br/>";
    if (exists(eml.getMetadataProvider().getAddress().getPostalCode())) {
        htmlText += "<b>" + getText("pdf.metadataProvider.address.postalcode") + "</b><br/>";
        htmlText += eml.getMetadataProvider().getAddress().getPostalCode().replaceAll("<", "&#60;")
                .replaceAll(">", "&#62;") + "<br/>";
    }
    htmlText += "<b>" + getText("pdf.metadataProvider.phone") + "</b><br/>";
    htmlText += eml.getMetadataProvider().getPhone().replaceAll("<", "&#60;").replaceAll(">", "&#62;")
            + "<br/>";
    htmlText += "<b>" + getText("pdf.metadataProvider.email") + "</b><br/>";
    htmlText += eml.getMetadataProvider().getEmail().replaceAll("<", "&#60;").replaceAll(">", "&#62;")
            + "<br/>";
    if (exists(eml.getMetadataProvider().getHomepage())) {
        htmlText += "<b>" + getText("pdf.metadataProvider.homepage") + "</b><br/>"; //***
        htmlText += eml.getMetadataProvider().getHomepage().replaceAll("<", "&#60;").replaceAll(">", "&#62;")
                + "<br/>";
    }
    htmlText += "</p>";

    subI++;
    htmlText += "<h3><span>3." + subI + " </span>" + getText("pdf.spatialCoverage") + "</h3> ";
    htmlText += "<p>";
    htmlText += getGeoCov(eml).replaceAll("<", "&#60;").replaceAll(">", "&#62;");
    htmlText += "</p>";
    //------

    subI++;
    htmlText += "<h3><span>3." + subI + " </span>" + getText("pdf.taxcoverage") + "</h3> ";
    htmlText += "<p>";
    htmlText += getTaxCov(eml);
    htmlText += "</p>";

    subI++;
    htmlText += "<h3><span>3." + subI + " </span>" + getText("pdf.tempcoverage") + "</h3> ";
    htmlText += "<p>";
    htmlText += getTempCov(eml, loc);
    htmlText += "</p>";

    subI++;
    htmlText += "<h3><span>3." + subI + " </span>" + getText("pdf.methods") + "</h3> ";
    htmlText += "<p>";
    htmlText += eml.getSampleDescription().replaceAll("<", "&#60;").replaceAll(">", "&#62;");
    htmlText += "</p>";

    //-------

    if (exists(eml.getCollectionName())) {
        subI++;
        htmlText += "<h3><span>3." + subI + " </span>" + getText("pdf.collections") + "</h3> ";
        htmlText += "<p>";
        htmlText += "<b>" + getText("pdf.collections.name") + "</b><br/>";
        htmlText += eml.getCollectionName().replaceAll("<", "&#60;").replaceAll(">", "&#62;") + "<br/>";
        htmlText += "<b>" + getText("pdf.collections.identifier") + "</b><br/>";
        htmlText += eml.getCollectionId().replaceAll("<", "&#60;").replaceAll(">", "&#62;") + "<br/>";
        htmlText += "<b>" + getText("pdf.collections.parent") + "</b><br/>";
        htmlText += eml.getParentCollectionId().replaceAll("<", "&#60;").replaceAll(">", "&#62;") + "<br/>";
        Map<String, String> metp = vocabManager.getI18nVocab(Constants.VOCAB_URI_PRESERVATION_METHOD, "es",
                false);
        if (exists(eml.getSpecimenPreservationMethod())) {
            htmlText += "<b>" + getText("pdf.collections.specimen") + "</b><br/>"; //***
            htmlText += metp
                    .get(eml.getSpecimenPreservationMethod().replaceAll("<", "&#60;").replaceAll(">", "&#62;"))
                    + "<br/>";
        }
        htmlText += "</p>";
    }

    if (exists(eml.getProject().getTitle())) {
        subI++;
        htmlText += "<h3><span>3." + subI + " </span>" + getText("pdf.project") + "</h3> ";
        htmlText += "<p>";
        htmlText += "<b>" + getText("pdf.project.title") + "</b><br/>";
        htmlText += eml.getProject().getTitle().replaceAll("<", "&#60;").replaceAll(">", "&#62;") + "<br/>";
        if (exists(eml.getProject().getPersonnel())) {
            htmlText += "<b>" + getText("pdf.project.personnel.firstName") + "</b><br/>";
            htmlText += eml.getProject().getPersonnel().getFirstName() + " "
                    + eml.getProject().getPersonnel().getLastName() + "<br/>";
        }
        if (exists(eml.getProject().getPersonnel().getRole())) {
            htmlText += "<b>" + getText("pdf.project.personnel.role") + "</b><br/>";
            htmlText += roles.get(
                    eml.getProject().getPersonnel().getRole().replaceAll("<", "&#60;").replaceAll(">", "&#62;"))
                    + "<br/>";
        }
        if (exists(eml.getProject().getFunding())) {
            htmlText += "<b>" + getText("pdf.project.funding") + "</b><br/>";
            htmlText += eml.getProject().getFunding().replaceAll("<", "&#60;").replaceAll(">", "&#62;")
                    + "<br/>";
        }
        if (exists(eml.getProject().getStudyAreaDescription())) {
            htmlText += "<b>" + getText("pdf.project.studyAreaDescription.descriptorValue") + "</b><br/>";
            htmlText += eml.getProject().getStudyAreaDescription().getDescriptorValue().replaceAll("<", "&#60;")
                    .replaceAll(">", "&#62;") + "<br/>";
        }
        if (exists(eml.getProject().getDesignDescription())) {
            htmlText += "<b>" + getText("pdf.project.designDescription") + "</b><br/>";
            htmlText += eml.getProject().getDesignDescription().replaceAll("<", "&#60;").replaceAll(">",
                    "&#62;") + "<br/>";
        }
        htmlText += "</p>";
    }

    if (eml.getAssociatedParties().size() != 0) {
        if (exists(eml.getAssociatedParties().get(0))) {
            subI++;
            htmlText += "<h3><span>3." + subI + " </span>" + getText("pdf.associatedParties") + "</h3> ";
            htmlText += "<p>";
            for (int i = 0; i < eml.getAssociatedParties().size(); i++) {
                if (exists(eml.getAssociatedParties().get(i).getLastName())) {
                    htmlText += "<b>" + getText("pdf.associatedParties.name") + "</b><br/>";
                    htmlText += eml.getAssociatedParties().get(i).getFirstName() + " "
                            + eml.getAssociatedParties().get(i).getLastName().replaceAll("<", "&#60;")
                                    .replaceAll(">", "&#62;")
                            + "<br/>";
                }
                if (exists(eml.getAssociatedParties().get(i).getPosition())) {
                    htmlText += "<b>" + getText("pdf.associatedParties.position") + "</b><br/>";
                    htmlText += eml.getAssociatedParties().get(i).getPosition().replaceAll("<", "&#60;")
                            .replaceAll(">", "&#62;") + "<br/>";
                }
                if (exists(eml.getAssociatedParties().get(i).getOrganisation())) {
                    htmlText += "<b>" + getText("pdf.associatedParties.organisation") + "</b><br/>";
                    htmlText += eml.getAssociatedParties().get(i).getOrganisation().replaceAll("<", "&#60;")
                            .replaceAll(">", "&#62;") + "<br/>";
                }
                if (exists(eml.getAssociatedParties().get(i).getAddress().getAddress())) {
                    htmlText += "<b>" + getText("pdf.associatedParties.address.address") + "</b><br/>";
                    htmlText += eml.getAssociatedParties().get(i).getAddress().getAddress()
                            .replaceAll("<", "&#60;").replaceAll(">", "&#62;") + "<br/>";
                }
                if (exists(eml.getAssociatedParties().get(i).getAddress().getCity())) {
                    htmlText += "<b>" + getText("pdf.associatedParties.city") + "</b><br/>";
                    htmlText += eml.getAssociatedParties().get(i).getAddress().getCity()
                            .replaceAll("<", "&#60;").replaceAll(">", "&#62;") + "<br/>";
                }
                if (exists(eml.getAssociatedParties().get(i).getAddress().getPostalCode())) {
                    htmlText += "<b>" + getText("pdf.associatedParties.address.postalcode") + "</b><br/>";
                    htmlText += eml.getAssociatedParties().get(i).getAddress().getPostalCode()
                            .replaceAll("<", "&#60;").replaceAll(">", "&#62;") + "<br/>";
                }
                if (exists(eml.getAssociatedParties().get(i).getPhone())) {
                    htmlText += "<b>" + getText("pdf.associatedParties.phone") + "</b><br/>";
                    htmlText += eml.getAssociatedParties().get(i).getPhone().replaceAll("<", "&#60;")
                            .replaceAll(">", "&#62;") + "<br/>";
                }
                if (exists(eml.getAssociatedParties().get(i).getEmail())) {
                    htmlText += "<b>" + getText("pdf.associatedParties.email") + "</b><br/>";
                    htmlText += eml.getAssociatedParties().get(i).getEmail().replaceAll("<", "&#60;")
                            .replaceAll(">", "&#62;") + "<br/>";
                }
                if (exists(eml.getAssociatedParties().get(i).getHomepage())) {
                    htmlText += "<b>" + getText("pdf.associatedParties.homepage") + "</b><br/>"; //***
                    htmlText += eml.getAssociatedParties().get(i).getHomepage().replaceAll("<", "&#60;")
                            .replaceAll(">", "&#62;") + "<br/>";
                }
                htmlText += "<br/>";
            }
            htmlText += "</p>";
        }
    }

    htmlText += "</td>";
    htmlText += "</tr>";

    htmlText += "<tr class='centerLine'>";
    htmlText += "<td>";
    htmlText += "</td>";
    htmlText += "</tr>";

    htmlText += "</table>";
    htmlText += "<p class='nota'>" + getText("pdf.cert.dis") + "<a href='" + url + "/pdf.do?r="
            + resource.getShortname() + "&n" + "=" + dataCert[0] + "'>" + url + "/pdf.do?r="
            + resource.getShortname() + "&amp;n=" + dataCert[0] + "</a></p><p></p></body></html>";

    try {
        Image background = Image.getInstance(url + "/styles/certificado_bg1.png");
        float width = 498;
        float height = 174;
        pdfWriter.getDirectContentUnder().addImage(background, width, 0, 0, height, 50, 490);

        parseHTML(doc, htmlText, pdfWriter);

        Image background_1 = Image.getInstance(url + "/styles/certificado_footer.png");
        width = 498;
        height = 103;
        pdfWriter.getDirectContentUnder().addImage(background_1, width, 0, 0, height, 50, 20);

    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (BadElementException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (DocumentException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    doc.close();
}