Example usage for com.itextpdf.text Paragraph setSpacingAfter

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

Introduction

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

Prototype

public void setSpacingAfter(float spacing) 

Source Link

Usage

From source file:ara.Confirmsec.java

public void myfunction() throws IOException, DocumentException {
    String a = preres.getText();/*from w  w  w . j a v a2s  . c  om*/
    File file = new File(DEST);
    file.getParentFile().mkdirs();
    Document document = new Document();
    PdfWriter.getInstance(document, new FileOutputStream(DEST));
    document.open();
    Image image = Image.getInstance("logo.jpg");
    document.add(image);
    Font chapterFont = FontFactory.getFont(FontFactory.HELVETICA, 16, Font.BOLD);
    Font paragraphFont = FontFactory.getFont(FontFactory.HELVETICA, 12, Font.NORMAL);
    Font small = FontFactory.getFont(FontFactory.HELVETICA, 5, Font.BOLD);
    String date = new Date().toString();
    Paragraph paragraph1 = new Paragraph(date);
    Paragraph paragraph2 = new Paragraph("To Whom it May Concern", chapterFont);
    paragraph2.setAlignment(Element.ALIGN_CENTER);
    paragraph1.setAlignment(Element.ALIGN_RIGHT);
    paragraph2.setSpacingBefore(20f);
    paragraph2.setSpacingAfter(10f);
    Paragraph paragraph3 = new Paragraph(a, paragraphFont);
    paragraph3.setSpacingAfter(20f);
    Paragraph paragraph4 = new Paragraph("Registrar");
    paragraph4.setAlignment(Element.ALIGN_RIGHT);
    paragraph4.setSpacingAfter(100f);
    Paragraph paragraph5 = new Paragraph(
            "This is a digitally signed document. Use Ref No. " + c + " to verify.", small);
    document.add(paragraph1);
    document.add(paragraph2);
    document.add(paragraph3);
    document.add(paragraph4);
    document.add(paragraph5);
    document.close();
    JOptionPane.showMessageDialog(null, "Document Generated.");
}

From source file:avalonscrollmaker20.AnothakScribe.java

License:Open Source License

public void writeToDoc(ArrayList<AnothakScroll> spellList, boolean simpleMode) {
    // Format content for inserting into a PDF
    for (int i = 0; i < spellList.size(); i++) {
        Paragraph spellCode = new Paragraph(spellList.get(i).spellCode, f_code);
        spellCode.setAlignment(ElementTags.ALIGN_RIGHT);
        spellCode.setMultipliedLeading(0.5f);
        spellCode.setIndentationRight(15f);

        Paragraph spellTitle = new Paragraph(spellList.get(i).spellTitle + "\n", f_title);
        spellTitle.setAlignment(ElementTags.ALIGN_CENTER);
        spellTitle.setMultipliedLeading(0.5f);
        spellTitle.setSpacingAfter(36f);

        Paragraph spellCircleSchool;/*from   w w w  .  j  a v a  2  s .com*/
        if (spellList.get(i).isPure())
            spellCircleSchool = new Paragraph(spellList.get(i).spellCircle.toString() + " Circle\n    of "
                    + spellList.get(i).spellOldSchool.toString(), f_schoolPure);
        else // !spellList.get( i ).isPure()
            spellCircleSchool = new Paragraph(spellList.get(i).spellCircle.toString() + " Circle\n    of "
                    + spellList.get(i).spellOldSchool.toString(), f_school);
        spellCircleSchool.setAlignment(ElementTags.ALIGN_LEFT);
        spellCircleSchool.setIndentationLeft(18f);
        spellCircleSchool.setMultipliedLeading(1.75f);

        Paragraph sourceKeu = new Paragraph(spellList.get(i).sourceKeu.toString() + "|~", f_keu);
        sourceKeu.setAlignment(ElementTags.ALIGN_RIGHT);
        sourceKeu.setIndentationRight(36f);
        sourceKeu.setMultipliedLeading(1f);

        Paragraph directionKeu = new Paragraph("", f_keu);
        directionKeu.setAlignment(ElementTags.ALIGN_RIGHT);
        directionKeu.setIndentationRight(90f);
        directionKeu.setMultipliedLeading(0.875f);

        Paragraph destinationKeu = new Paragraph(spellList.get(i).destinationKeu.toString() + "|~", f_keu);
        destinationKeu.setAlignment(ElementTags.ALIGN_RIGHT);
        destinationKeu.setIndentationRight(36f);
        destinationKeu.setMultipliedLeading(0.625f);

        Paragraph phraseCommon;
        Paragraph phraseSymbol;

        if (spellList.get(i).spellCircle != Circle.SEVENTH
                && spellList.get(i).spellCircle != Circle.PURE_SEVENTH) {
            phraseCommon = new Paragraph("", f_phraseCommon);
            phraseCommon.setSpacingAfter(27f);
            phraseSymbol = new Paragraph("", f_phraseSymbol);
            if ((i % 2) <= 0)
                phraseSymbol.setSpacingAfter(90f);
            else // ( (i % 2) > 0 )
                phraseSymbol.setSpacingAfter(0f);
        } else {
            phraseCommon = new Paragraph("", f_phraseCommonBreath);
            phraseCommon.setSpacingAfter(36f);
            phraseSymbol = new Paragraph("", f_phraseSymbolBreath);
            if ((i % 2) <= 0)
                phraseSymbol.setSpacingAfter(103.5f);
            else // ( (i % 2) > 0 )
                phraseSymbol.setSpacingAfter(0f);
        }

        phraseCommon.setAlignment(ElementTags.ALIGN_CENTER);
        phraseCommon.setMultipliedLeading(1.5f);
        for (AnothakScroll.Word w : spellList.get(i).liersethPhrase_Common)
            phraseCommon.add(w.toString() + " ");

        if (simpleMode) {
            phraseSymbol.setAlignment(ElementTags.ALIGN_CENTER);
            phraseSymbol.setSpacingBefore(36f);
            phraseSymbol.setSpacingAfter(0f);
            phraseSymbol.setMultipliedLeading(0.75f);
        } else // not simpleMode
        {
            phraseSymbol.setAlignment(ElementTags.ALIGN_CENTER);
            phraseSymbol.setMultipliedLeading(0.5f);
        }

        for (AnothakScroll.Symbol s : spellList.get(i).liersethPhrase_Symbol) {
            phraseSymbol.add(s.toString());
        }

        // Add content to the document
        try {
            if (simpleMode)
                doc_scrolls.add(phraseSymbol);
            else {
                Image tmpImage = null;
                tmpImage = spellList.get(i).backgroundImageFull;

                if (tmpImage != null) {
                    if ((i % 2) <= 0)
                        tmpImage.setAbsolutePosition(9f, 405f);
                    else // (i % 2) >= 0
                        tmpImage.setAbsolutePosition(9f, 9f);

                    doc_scrolls.add(tmpImage);
                }

                //doc_scrolls.add( Chunk.NEWLINE );
                doc_scrolls.add(spellCode);
                doc_scrolls.add(spellTitle);

                // Crap, I hate formatting
                MultiColumnText mct = new MultiColumnText(108f);
                mct.addRegularColumns(doc_scrolls.left(), doc_scrolls.right(), 54f, 2);
                mct.addElement(spellCircleSchool);
                mct.addElement(sourceKeu);
                mct.addElement(directionKeu);
                mct.addElement(destinationKeu);

                doc_scrolls.add(mct);

                doc_scrolls.add(new Chunk("\n", new Font(Font.FontFamily.COURIER, 18f, Font.NORMAL)));

                doc_scrolls.add(phraseCommon);
                doc_scrolls.add(phraseSymbol);

                if ((i % 2) > 0)
                    doc_scrolls.newPage();
            }

        } catch (Exception ex) {
            System.err.println(ex + "\nProgram closing.");
            System.exit(4);
        }
    }

    // Close the Document
    doc_scrolls.close();

    JOptionPane.showMessageDialog(null, doc_name + " was printed successfully!", "Print Status",
            JOptionPane.INFORMATION_MESSAGE);
}

From source file:br.edu.unipampa.recipemanager.pdf.CreatePDF.java

public boolean newPdf(List<MenuRecipe> menuRecipe, String month, String responsibleName) {
    double valueMonth = 0;
    try {//from   www.ja va 2s  .  co m
        Document doc = new Document(PageSize.A4, 72, 72, 72, 72);
        OutputStream os = new FileOutputStream(namePdf(menuRecipe));
        PdfWriter.getInstance(doc, os);

        doc.open();
        Paragraph p;
        Font f = new Font(Font.FontFamily.TIMES_ROMAN, 18, Font.BOLD);

        p = new Paragraph("Ms: " + month, f);
        doc.add(p);

        f = new Font(Font.FontFamily.COURIER, 14, Font.ITALIC);

        for (MenuRecipe menu : menuRecipe) {
            valueMonth += menu.priceMenu();
            p.setSpacingBefore(5);
            p.setSpacingAfter(5);
            p = new Paragraph(menu.toString(), f);
            doc.add(p);
        }

        p = new Paragraph("Preo total de todos os cardpios: " + valueMonth, f);
        doc.add(p);

        f = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD);
        p = new Paragraph("_____________________________________\n" + responsibleName, f);
        p.setSpacingAfter(15);
        p.setAlignment(Element.ALIGN_RIGHT);
        doc.add(p);

        doc.close();
        os.close();
        return true;
    } catch (Exception e) {
        return false;
    }
}

From source file:br.unisc.video_locadora.controll.Generator_PDF.java

public void geraRelatorio() throws DocumentException, FileNotFoundException {
    // Cria um novo documento com tamanho e margens definidas pelo usurio
    // new Document(tamanho da pgina, margem esquerda, margem direita,
    // margem topo, margem rodap);
    Document doc = new Document(PageSize.A4, 10, 10, 10, 10);
    try {/*  w ww  .java 2 s . c om*/

        JFileChooser jFileChooser = new JFileChooser();

        //seta para selecionar apenas arquivos
        jFileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);

        //desabilita todos os tipos de arquivos
        jFileChooser.setAcceptAllFileFilterUsed(false);

        //filtra por extensao
        jFileChooser.setFileFilter(new FileFilter() {
            @Override
            public String getDescription() {
                return "Extenso PDF";
            }

            @Override
            public boolean accept(File f) {
                return f.getName().toLowerCase().endsWith("pdf");
            }
        });

        //mostra janela para salvar
        int acao = jFileChooser.showSaveDialog(null);

        //executa acao conforme opcao selecionada
        if (acao == JFileChooser.APPROVE_OPTION) {
            //escolheu arquivo
            System.out.println(jFileChooser.getSelectedFile().getAbsolutePath());
            PdfWriter.getInstance(doc,
                    new FileOutputStream(jFileChooser.getSelectedFile().getAbsolutePath() + ".pdf"));
            doc.open();

            listaF = f.buscaFilme("");

            // Definindo uma fonte, com tamanho 20 e negrito
            Font f = new Font(Font.FontFamily.COURIER, 30, Font.BOLD);
            Font f2 = new Font(Font.FontFamily.HELVETICA, 20, Font.BOLD);

            // adicionando um pargrafo ao documento com a fonte acima
            Paragraph pa = new Paragraph("Relatrio", f);
            // Setando o alinhamento p/ o centro
            pa.setAlignment(Paragraph.ALIGN_CENTER);

            // Definindo
            pa.setSpacingAfter(50);
            doc.add(pa);

            //doc.add(new Paragraph(" "));

            // Criando uma tabela com 4 colunas
            PdfPTable table = new PdfPTable(7);
            // Ttulo para a tabela
            Paragraph tableHeader = new Paragraph("Todos os Ttulos", f2);

            PdfPCell header = new PdfPCell(tableHeader);
            // Definindo que o header vai ocupar as 4 colunas
            header.setColspan(7);
            // Definindo alinhamento do header
            header.setHorizontalAlignment(Paragraph.ALIGN_CENTER);
            // Adicionando o header  tabela
            table.addCell(header);

            List<String> list = new ArrayList<>();
            list.add("Id");
            list.add("Ttulo");
            list.add("Ano");
            list.add("Diretor");
            list.add("Gnero");
            list.add("Linguagem");
            list.add("Locado");
            for (Filmes p : listaF) {
                list.add(String.valueOf(p.getId()));
                list.add(p.getTitulo());
                list.add(String.valueOf(p.getAno()));
                list.add(p.getDiretor());
                list.add(p.getGenero());
                list.add(p.getIdioma());
                list.add(p.getLocado());
            }

            for (String s : list) {
                table.addCell(s);
            }

            doc.add(table);

            /* doc.add(new Paragraph(" ID | Nome | Idade | Cidade"));
            for (Pessoa p : lista) {
                doc.add(new Paragraph(p.getId() + " |  " + p.getNome() + "  |  " + p.getIdade() + "  |  " + p.getCidade()));
            }*/
        }
    } catch (FileNotFoundException | DocumentException e) {
        System.err.println(e.getMessage());
    }
    doc.close();
}

From source file:cashiermode.PrintRecieptPdf.java

public static void printPdf() {
    Document transPdf = null;/*  ww  w  .  ja  v  a 2s  .co m*/
    PdfWriter writer = null;

    // NumberFormat fmt = NumberFormat.getPercentInstance();
    // DecimalFormat fmt1 = new DecimalFormat("0.0");
    Font font1 = new Font(Font.FontFamily.HELVETICA, 3, Font.NORMAL);
    Font font2 = new Font(Font.FontFamily.TIMES_ROMAN, 7);
    Font font3 = new Font(Font.FontFamily.COURIER, 8, Font.NORMAL);
    Font font4 = new Font(Font.FontFamily.COURIER, 9, Font.BOLD);

    try {
        transPdf = new Document();
        File file = new File("Report.pdf");
        System.out.println("File crearted");

        writer = PdfWriter.getInstance(transPdf, new FileOutputStream(file));
        transPdf.open();
        transPdf.setMargins(0, 5, 0, 2);
    } catch (FileNotFoundException | DocumentException ex) {

    }

    try {
        transPdf.add(new Paragraph(
                "                                             TERM TWO ACCADEMIC REPORT FORM", font3));
        transPdf.add(new Paragraph(
                "NAME :                                    ADM NO:             FORM             ", font3));
        transPdf.add(
                new Paragraph("FORM POS         OUT OF           CLASS POS           OUT OF         ", font3));

        PdfPTable table = new PdfPTable(10); // 4 column
        table.setWidthPercentage(100);
        table.setSpacingBefore(10f);
        table.setSpacingAfter(10f);

        PdfPCell cell0 = new PdfPCell(new Paragraph("SUBJECT", font2));
        PdfPCell cell1 = new PdfPCell(new Paragraph("CAT1", font2));
        PdfPCell cell2 = new PdfPCell(new Paragraph("CAT2", font2));
        PdfPCell cell3 = new PdfPCell(new Paragraph("EXAM", font2));
        PdfPCell cell4 = new PdfPCell(new Paragraph("TOTAL", font2));
        PdfPCell cell5 = new PdfPCell(new Paragraph("GRADE", font2));
        PdfPCell cell6 = new PdfPCell(new Paragraph("PNTS", font2));
        PdfPCell cell7 = new PdfPCell(new Paragraph("POS", font2));
        PdfPCell cell8 = new PdfPCell(new Paragraph("RMK", font2));
        PdfPCell cell9 = new PdfPCell(new Paragraph("SIGN", font2));

        // cell2.setColspan(2);
        table.addCell(cell0);
        table.addCell(cell1);
        table.addCell(cell2);
        table.addCell(cell3);
        table.addCell(cell4);
        table.addCell(cell5);
        table.addCell(cell6);
        table.addCell(cell7);
        table.addCell(cell8);
        table.addCell(cell9);

        for (int i = 0; i < 11; i++) {

            //                cell0 = new PdfPCell(new Paragraph(mysubs[i], font2));
            cell1 = new PdfPCell(new Paragraph("", font2));
            cell2 = new PdfPCell(new Paragraph("", font2));
            cell3 = new PdfPCell(new Paragraph("", font2));
            cell4 = new PdfPCell(new Paragraph("", font2));
            cell5 = new PdfPCell(new Paragraph("", font2));
            cell6 = new PdfPCell(new Paragraph("", font2));
            cell7 = new PdfPCell(new Paragraph("", font2));
            cell8 = new PdfPCell(new Paragraph("", font2));
            cell9 = new PdfPCell(new Paragraph("", font2));

            table.addCell(cell0);
            table.addCell(cell1);
            table.addCell(cell2);
            table.addCell(cell3);
            table.addCell(cell4);
            table.addCell(cell5);
            table.addCell(cell6);
            table.addCell(cell7);
            table.addCell(cell8);
            table.addCell(cell9);

        }

        transPdf.add(table);

        Paragraph p = new Paragraph(
                "Closing Date                                  Next Term Begins On                          ",
                font3);
        p.setSpacingBefore(185f);
        transPdf.add(p);
        transPdf.add(new Paragraph(
                "Outstanding Fee                    Next Term Fee                     Total                 ",
                font3));
        transPdf.add(new Paragraph(
                "Feedback                                                Sign             Date              ",
                font3));
        transPdf.add(new Paragraph("                       Parent/Guardian", font3));
        Paragraph lastp = new Paragraph("Closing date is on   27/14/2005", font3);
        lastp.setSpacingAfter(0f);
        transPdf.add(lastp);

        //transPdf.newPage();

    } catch (DocumentException ex) {
        System.err.println("NOT YET.." + ex.getMessage());
    }

    transPdf.close();

}

From source file:cimav.restrh.services.JustificacionREST.java

@GET
@Path("pdficar")
@Produces("application/pdf")
public Response pdficar(@DefaultValue("0") @QueryParam("id") Integer id_param) {
    Justificacion justi = (Justificacion) JustificacionREST.this.find(id_param);

    String diasCorresponde = "corresponde a " + justi.getNumDiasPlazo() + " das";
    if (justi.getNumDiasPlazo() == 1) {
        diasCorresponde = "corresponde a un da";
    }/*from ww  w  . ja v a  2  s.  c om*/

    // <editor-fold defaultstate="collapsed" desc="Constantes de texto">            
    HashMap<String, String> mapa = new HashMap();
    mapa.put("texto1_I",
            "No existan bienes o servicios alternativos o sustitutos tcnicamente razonables, o bien, que en el "
                    + "mercado slo existe un posible oferente, o se trate de una persona que posee la titularidad o el "
                    + "licenciamiento exclusivo de patentes, derechos de autor, u otros derechos exclusivos, o por "
                    + "tratarse de obras de arte.");
    mapa.put("texto1_III",
            "Existan circunstancias que puedan provocar prdidas o costos adicionales importantes, "
                    + "cuantificados y justificados.");
    mapa.put("texto1_XIV",
            "Se trate de los servicios prestados por una persona fsica a que se refiere la fraccin "
                    + "VII del artculo 3 de esta Ley, siempre que stos sean realizados por ella misma sin "
                    + "requerir de la utilizacin de ms de un especialista o tcnico.");
    mapa.put("texto1_XV",
            "Se trate de servicios de mantenimiento de bienes en los que no sea posible precisar "
                    + "su alcance, establecer las cantidades de trabajo o determinar las especificaciones "
                    + "correspondientes.");
    mapa.put("texto1_XVII",
            "Se trate de equipos especializados, sustancias y materiales de origen qumico, fsico "
                    + "qumico o bioqumico para ser utilizadas en actividades experimentales requeridas "
                    + "en proyectos de investigacin cientfica y desarrollo tecnolgico, siempre que dichos "
                    + "proyectos se encuentren autorizados por quien determine el titular de la dependencia "
                    + "o el rgano de gobierno de la entidad.");
    mapa.put("plazo_0", "El plazo en que se requiere el suministro de los " + justi.getBienServicioTxt()
            + ", corresponde al periodo del " + justi.getFechaInicio().getDayOfMonth() + " de "
            + justi.getFechaInicio().getMonth().getDisplayName(TextStyle.FULL, new Locale("es", "ES")) + " de "
            + justi.getFechaInicio().getYear() + " y hasta el " + justi.getFechaTermino().getDayOfMonth()
            + " de " + justi.getFechaTermino().getMonth().getDisplayName(TextStyle.FULL, new Locale("es", "ES"))
            + " de " + justi.getFechaTermino().getYear() + ". Las condiciones en las que se "
            + "entregarn los " + justi.getBienServicioTxt() + " son las siguientes:\n\n "
            + justi.getCondicionesPago());
    mapa.put("plazo_1", "La fecha en que se requiere el suministro de los " + justi.getBienServicioTxt()
            + ", corresponde al da " + justi.getFechaTermino().getDayOfMonth() + " de "
            + justi.getFechaTermino().getMonth().getDisplayName(TextStyle.FULL, new Locale("es", "ES")) + " de "
            + justi.getFechaTermino().getYear() + ". Las condiciones en las que se " + "entregarn los "
            + justi.getBienServicioTxt() + " son las siguientes:\n\n " + justi.getCondicionesPago());
    mapa.put("plazo_2",
            "El plazo en que se requiere el suministro de los " + justi.getBienServicioTxt() + ", "
                    + diasCorresponde + " despus de la elaboracin de este documento."
                    + " Las condiciones en las que se " + "entregarn los " + justi.getBienServicioTxt()
                    + " son las siguientes:\n\n " + justi.getCondicionesPago());
    mapa.put("nota_1",
            "Asimismo se hace constar mediante el sello y firma del responsable del rea de "
                    + "Almacn, la No Existencia de Bienes o Nivel de Inventario que demuestra que se "
                    + "cumpli con lo establecido en el artculo 27 del RLAASP.");
    mapa.put("transparencia_unico",
            "Para la integracin del procedimiento de contratacin por adjudicacin directa, los servidores "
                    + "pblicos de las reas requirentes han tenido acceso de manera oportuna, clara y completa de "
                    + "las caractersticas requeridas de los " + justi.getBienServicioTxt()
                    + " con el fin de demostrar que es " + "el nico proveedor que proporciona los "
                    + justi.getBienServicioTxt() + " que se pretenden contratar, en "
                    + "el entendido que para garantizar la transparencia del procedimiento de contratacin, la "
                    + "informacin respectiva ser incorporada al Sistema de Compras Gubernamentales "
                    + "(CompraNet), en los trminos de las disposiciones legales aplicables, "
                    + "Lo anterior de acuerdo con lo establecido en el numeral 4.2.4 (ADJUDICACIN DIRECTA) y "
                    + "numeral 4.2.4.1.1 (Verificar Acreditamiento de Excepcin) del Acuerdo por el que se modifica el "
                    + "Manual Administrativo de Aplicacin General en Materia de Adquisiciones, Arrendamientos y "
                    + "Servicios del Sector Pblico, publicado en el Diario Oficial de la Federacin el 21 de noviembre "
                    + "de 2012.");
    mapa.put("transparencia_no_unico",
            "Todas las personas que han presentado cotizacin para la integracin del procedimiento de "
                    + "contratacin por adjudicacin directa, han tenido acceso de manera oportuna, clara y completa "
                    + "de las caractersticas requeridas de los " + justi.getBienServicioTxt()
                    + ", en el entendido que para "
                    + "garantizar la transparencia del procedimiento de contratacin, la informacin respectiva ser "
                    + "incorporada al Sistema de Compras Gubernamentales (CompraNet), en los trminos de las "
                    + "disposiciones legales aplicables. "
                    + "Lo anterior de acuerdo con lo establecido en el numeral 4.2.4 (ADJUDICACIN DIRECTA) y "
                    + "numeral 4.2.4.1.1 (Verificar Acreditamiento de Excepcin) del Acuerdo por el que se modifica el "
                    + "Manual Administrativo de Aplicacin General en Materia de Adquisiciones, Arrendamientos y "
                    + "Servicios del Sector Pblico, publicado en el Diario Oficial de la Federacin el 21 de noviembre "
                    + "de 2012.");

    // </editor-fold>
    StreamingOutput streamingOutput = new StreamingOutput() {
        public void write(OutputStream outputStream) throws IOException, WebApplicationException {

            try {
                String masIva = "";
                if (justi.getIva() != 0) {
                    masIva = " ms IVA";
                }
                String datosBanco = "";
                if (justi.getDatosBanco() != null) {
                    datosBanco = ", datos bancarios: " + justi.getDatosBanco();
                }

                //Create Document instance.
                Document document = new Document();
                PdfWriter.getInstance(document, outputStream);

                document.addAuthor("Generador adquisiciones | " + justi.getEmpleado().getCuentaCimav());
                String fileName1 = (justi.getRequisicion() + "-" + justi.getEmpleado().getCuentaCimav())
                        .replace(" ", "").replace(",", "");
                document.addTitle("Justificacin: " + fileName1);
                document.addSubject("Justificacin de Requisicin");

                document.open();

                Paragraph parrafo = new Paragraph("Centro de Investigacin en Materiales Avanzados S. C.",
                        new Font(Font.FontFamily.TIMES_ROMAN, 17, Font.BOLD));
                parrafo.setAlignment(Element.ALIGN_CENTER);
                document.add(parrafo);

                parrafo = new Paragraph(
                        "JUSTIFICACIN PARA ACREDITAR Y FUNDAR PROCEDIMIENTOS DE "
                                + "CONTRATACIN POR ADJUDICACIN DIRECTA, COMO EXCEPCIN AL DE "
                                + "LICITACIN PBLICA EN EL SUPUESTO DEL ARTICULO 41 FRACCION "
                                + justi.getRomano() + " DE LA "
                                + "LEY DE ADQUISICIONES, ARRENDAMIENTOS Y SERVICIOS DEL SECTOR " + "PBLICO.",
                        new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD));
                parrafo.setSpacingAfter(20);
                parrafo.setIndentationLeft(30);
                parrafo.setLeading(15);
                parrafo.setSpacingBefore(20);
                parrafo.setAlignment(Element.ALIGN_JUSTIFIED);
                document.add(parrafo);

                parrafo = new Paragraph("COMIT DE ADQUISICIONES, ARRENDAMIENTOS Y SERVICIOS");
                parrafo.setAlignment(Element.ALIGN_CENTER);
                parrafo.setSpacingBefore(20);
                parrafo.setIndentationLeft(80);
                parrafo.setIndentationRight(80);
                document.add(parrafo);

                parrafo = new Paragraph("P R E S E N T E:",
                        new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD));
                parrafo.setIndentationLeft(30);
                parrafo.setSpacingBefore(20);
                document.add(parrafo);

                parrafo = new Paragraph("Oficio nmero: ",
                        new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL));
                parrafo.setIndentationLeft(300);
                parrafo.setAlignment(Element.ALIGN_JUSTIFIED_ALL);
                parrafo.setLeading(15);
                parrafo.setSpacingBefore(20);

                Chunk frase = new Chunk(justi.getRequisicion() + "\n",
                        new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD));
                parrafo.add(frase);
                frase = new Chunk(
                        "Asunto: Se emite justificacin por la que se "
                                + "acredita y funda la contratacin por adjudicacin directa que se indica.",
                        new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL));
                parrafo.add(frase);
                document.add(parrafo);

                parrafo = new Paragraph("", new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL));
                parrafo.setSpacingAfter(20);
                parrafo.setIndentationLeft(30);
                parrafo.setLeading(15);
                parrafo.setSpacingBefore(20);
                parrafo.setAlignment(Element.ALIGN_JUSTIFIED);

                frase = new Chunk(
                        "En cumplimiento a lo establecido en el segundo prrafo del artculo 40 de la Ley de "
                                + "Adquisiciones, Arrendamientos y Servicios del Sector Pblico, as como en el artculo 71 del "
                                + "Reglamento de la Ley de Adquisiciones, Arrendamientos y Servicios del Sector Pblico, y con el "
                                + "carcter de Titular del ?rea Requirente, por este conducto hago constar el acreditamiento del o "
                                + "de los criterios, razones, fundamentos y motivos para no llevar a cabo el procedimiento de "
                                + "licitacin pblica y celebrar la contratacin a travs del procedimiento de adjudicacin directa en "
                                + "los trminos establecidos en el artculo 41 Fraccin " + justi.getRomano()
                                + " de la Ley de Adquisiciones, "
                                + "Arrendamientos y Servicios del Sector Pblico",
                        new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL));
                parrafo.setSpacingAfter(20);
                parrafo.setIndentationLeft(30);
                parrafo.setLeading(15);
                parrafo.setSpacingBefore(20);
                parrafo.setAlignment(Element.ALIGN_JUSTIFIED);
                parrafo.add(frase);

                /*
                frase = new Chunk("Las dependencias y "
                    + "entidades, bajo su responsabilidad, podrn contratar adquisiciones, arrendamientos y "
                    + "servicios, sin sujetarse al procedimiento de licitacin pblica, a travs de los "
                    + "procedimientos de invitacin a cuando menos tres personas o de adjudicacin directa, "
                    + "cuando:\n" + mapa.get("texto1_" + justi.getRomano()),
                    new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD));
                parrafo.setSpacingAfter(20);
                parrafo.setIndentationLeft(30);
                parrafo.setLeading(15);
                parrafo.setSpacingBefore(20);
                parrafo.setAlignment(Element.ALIGN_JUSTIFIED);
                parrafo.add(frase); */
                document.add(parrafo);

                parrafo = new Paragraph("Para tal efecto presento la siguiente informacin:",
                        new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL));
                parrafo.setSpacingAfter(20);
                parrafo.setIndentationLeft(60);
                parrafo.setLeading(15);
                parrafo.setSpacingBefore(20);
                parrafo.setAlignment(Element.ALIGN_JUSTIFIED);
                document.add(parrafo);

                parrafo = new Paragraph("I.- DESCRIPCIN DE LOS " + justi.getBienServicioTxt().toUpperCase(),
                        new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD));
                parrafo.setAlignment(Element.ALIGN_CENTER);
                parrafo.setSpacingAfter(10);
                document.add(parrafo);

                parrafo = new Paragraph(
                        "El/Los " + justi.getBienServicioTxt()
                                + " que se pretende contratar, son los siguientes:",
                        new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL));
                parrafo.setAlignment(Element.ALIGN_JUSTIFIED);
                parrafo.setIndentationLeft(30);
                document.add(parrafo);

                parrafo = new Paragraph(justi.getDescripcion(),
                        new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL));
                parrafo.setAlignment(Element.ALIGN_JUSTIFIED);
                parrafo.setSpacingBefore(20);
                parrafo.setLeading(15);
                parrafo.setIndentationLeft(30);
                document.add(parrafo);

                parrafo = new Paragraph(
                        "II.- PLAZOS Y CONDICIONES DEL SUMINISTRO DE LOS "
                                + justi.getBienServicioTxt().toUpperCase(),
                        new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD));
                parrafo.setAlignment(Element.ALIGN_CENTER);
                parrafo.setSpacingBefore(20);
                document.add(parrafo);

                parrafo = new Paragraph(mapa.get("plazo_" + justi.getPlazo()),
                        new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL));
                parrafo.setAlignment(Element.ALIGN_JUSTIFIED);
                parrafo.setSpacingBefore(20);
                parrafo.setLeading(15);
                parrafo.setIndentationLeft(30);
                document.add(parrafo);

                parrafo = new Paragraph("III.- RESULTADO DE LA INVESTIGACIN DE MERCADO",
                        new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD));
                parrafo.setAlignment(Element.ALIGN_CENTER);
                parrafo.setSpacingBefore(20);
                document.add(parrafo);

                parrafo = new Paragraph(
                        "La Investigacin de Mercado fue realizada en los trminos de los artculos 28, 29 y 30 del "
                                + "Reglamento de la Ley de Adquisiciones, Arrendamientos y Servicios del Sector Pblico, en "
                                + "forma conjunta por el ?rea Requirente y el ?rea Contratante, en la cual se verific previo al "
                                + "inicio del procedimiento de contratacin, la existencia de oferta, en la cantidad, calidad y "
                                + "oportunidad requeridas; la existencia de proveedores a nivel nacional o internacional con "
                                + "posibilidad de cumplir con las necesidades de la contratacin, conocer el precio prevaleciente al "
                                + "momento de llevar a cabo la Investigacin de mercado as como en la informacin disponible "
                                + "en el Sistema informtico denominado COMPRANET:",
                        new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL));
                parrafo.setAlignment(Element.ALIGN_JUSTIFIED);
                parrafo.setSpacingBefore(20);
                parrafo.setSpacingAfter(20);
                parrafo.setLeading(15);
                parrafo.setIndentationLeft(30);
                document.add(parrafo);

                PdfPTable table = new PdfPTable(2); // 3 columns.

                table.setWidths(new int[] { 100, 50 });

                if (justi.getEsUnico()) {

                    PdfPCell cell1 = new PdfPCell(
                            new Paragraph("PROVEEDOR", new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.BOLD)));
                    PdfPCell cell2 = new PdfPCell(new Paragraph("IMPORTE SIN IVA",
                            new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.BOLD)));
                    cell1.setBorder(PdfPCell.NO_BORDER);
                    cell2.setBorder(PdfPCell.NO_BORDER);
                    cell2.setHorizontalAlignment(Element.ALIGN_RIGHT);
                    table.addCell(cell1);
                    table.addCell(cell2);

                    cell1 = new PdfPCell(new Paragraph(justi.getProveedorUno().toUpperCase(),
                            new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL)));
                    cell2 = new PdfPCell(new Paragraph(montoFormatComas(justi.getMontoUno(), justi),
                            new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL)));
                    cell1.setBorder(PdfPCell.NO_BORDER);
                    cell2.setBorder(PdfPCell.NO_BORDER);
                    cell2.setHorizontalAlignment(Element.ALIGN_RIGHT);
                    table.addCell(cell1);
                    table.addCell(cell2);
                    document.add(table);

                    /* Si es nico, no lleva motivo de seleccin
                    parrafo = new Paragraph(justi.getMotivoSeleccion().toUpperCase(),
                        new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL));
                    parrafo.setAlignment(Element.ALIGN_JUSTIFIED);
                    parrafo.setSpacingBefore(20);
                    parrafo.setLeading(15);
                    parrafo.setIndentationLeft(30);
                    document.add(parrafo);
                    */

                    parrafo = new Paragraph(
                            "Concluyendo que en conjunto es la nica oferta en cuanto a obtener las mejores condiciones, calidad, "
                                    + "precio, oportunidad y financiamiento, por ser el nico proveedor que proporcione los "
                                    + justi.getBienServicioTxt() + " que se pretende contratar la de "
                                    + justi.getProveedorUno().toUpperCase() + ". La referida "
                                    + "Investigacin de Mercado se acompaa a la presente justificacin para determinar que el "
                                    + "procedimiento de contratacin por adjudicacin directa es el idneo.",
                            new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL));
                    parrafo.setAlignment(Element.ALIGN_JUSTIFIED);
                    parrafo.setSpacingBefore(20);
                    parrafo.setLeading(15);
                    parrafo.setIndentationLeft(30);
                    document.add(parrafo);

                } else {
                    PdfPCell cell1 = new PdfPCell(
                            new Paragraph("PROVEEDOR", new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.BOLD)));
                    PdfPCell cell2 = new PdfPCell(new Paragraph("IMPORTE SIN IVA",
                            new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.BOLD)));
                    cell1.setBorder(PdfPCell.NO_BORDER);
                    cell2.setBorder(PdfPCell.NO_BORDER);
                    cell2.setHorizontalAlignment(Element.ALIGN_RIGHT);
                    table.addCell(cell1);
                    table.addCell(cell2);

                    cell1 = new PdfPCell(new Paragraph(justi.getProveedorUno().toUpperCase(),
                            new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.BOLD)));
                    cell2 = new PdfPCell(new Paragraph(montoFormatComas(justi.getMontoUno(), justi),
                            new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.BOLD)));
                    cell1.setBorder(PdfPCell.NO_BORDER);
                    cell2.setBorder(PdfPCell.NO_BORDER);
                    cell2.setHorizontalAlignment(Element.ALIGN_RIGHT);
                    table.addCell(cell1);
                    table.addCell(cell2);

                    cell1 = new PdfPCell(new Paragraph(justi.getProveedorDos().toUpperCase(),
                            new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL)));
                    cell2 = new PdfPCell(new Paragraph(montoFormatComas(justi.getMontoDos(), justi),
                            new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL)));
                    cell1.setBorder(PdfPCell.NO_BORDER);
                    cell2.setBorder(PdfPCell.NO_BORDER);
                    cell2.setHorizontalAlignment(Element.ALIGN_RIGHT);
                    table.addCell(cell1);
                    table.addCell(cell2);

                    if (justi.getProveedorTres() != null && justi.getProveedorTres().trim().length() > 0) {
                        cell1 = new PdfPCell(new Paragraph(justi.getProveedorTres().toUpperCase(),
                                new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL)));
                        cell2 = new PdfPCell(new Paragraph(montoFormatComas(justi.getMontoTres(), justi),
                                new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL)));
                        cell2.setHorizontalAlignment(Element.ALIGN_RIGHT);
                        cell1.setBorder(PdfPCell.NO_BORDER);
                        cell2.setBorder(PdfPCell.NO_BORDER);
                        table.addCell(cell1);
                        table.addCell(cell2);
                    }

                    document.add(table);

                    parrafo = new Paragraph("Motivo de la seleccin: " + justi.getMotivoSeleccion(),
                            new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL));
                    parrafo.setAlignment(Element.ALIGN_JUSTIFIED);
                    parrafo.setIndentationLeft(30);
                    document.add(parrafo);

                    parrafo = new Paragraph(
                            "Siendo la oferta que en conjunto presenta las mejores condiciones en cuanto a calidad, precio, oportunidad  "
                                    + "y financiamiento, la de " + justi.getProveedorUno().toUpperCase() + ". "
                                    + "La referida Investigacin de Mercado se acompaa a la presente justificacin para determinar  "
                                    + "que el procedimiento de contratacin por adjudicacin directa es el idneo.",
                            new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL));
                    parrafo.setSpacingBefore(20);
                    parrafo.setLeading(15);
                    parrafo.setAlignment(Element.ALIGN_JUSTIFIED);
                    parrafo.setIndentationLeft(30);
                    document.add(parrafo);
                }

                parrafo = new Paragraph("IV.- PROCEDIMIENTO DE CONTRATACIN PROPUESTO",
                        new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD));
                parrafo.setAlignment(Element.ALIGN_CENTER);
                parrafo.setSpacingBefore(20);
                document.add(parrafo);

                parrafo = new Paragraph("", new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL));
                parrafo.setSpacingAfter(20);
                parrafo.setIndentationLeft(30);
                parrafo.setLeading(15);
                parrafo.setSpacingBefore(20);
                parrafo.setAlignment(Element.ALIGN_JUSTIFIED);

                frase = new Chunk(
                        "El procedimiento de contratacin propuesto es el de adjudicacin directa, en virtud de que en el "
                                + "presente caso la adjudicacin se llevara a cabo conforme la fraccin "
                                + justi.getRomano() + " del artculo 41 el cual "
                                + "menciona que este tipo de adjudicacin se puede llevar a cabo siempre y cuando: \n",
                        new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL));
                parrafo.setSpacingAfter(20);
                parrafo.setIndentationLeft(30);
                parrafo.setLeading(15);
                parrafo.setSpacingBefore(20);
                parrafo.setAlignment(Element.ALIGN_JUSTIFIED);
                parrafo.add(frase);

                frase = new Chunk(mapa.get("texto1_" + justi.getRomano()),
                        new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD));
                parrafo.setSpacingAfter(20);
                parrafo.setIndentationLeft(30);
                parrafo.setLeading(15);
                parrafo.setSpacingBefore(20);
                parrafo.setAlignment(Element.ALIGN_JUSTIFIED);
                parrafo.add(frase);

                frase = new Chunk(" Actualizndose el supuesto de excepcin a la licitacin pblica "
                        + "establecido en la fraccin " + justi.getRomano()
                        + " del artculo 41 de la Ley de Adquisiciones, Arrendamientos y "
                        + "Servicios del Sector Pblico, en relacin con lo establecido en el artculo 72 de su Reglamento.",
                        new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL));
                parrafo.setSpacingAfter(20);
                parrafo.setIndentationLeft(30);
                parrafo.setLeading(15);
                parrafo.setSpacingBefore(20);
                parrafo.setAlignment(Element.ALIGN_JUSTIFIED);
                parrafo.add(frase);
                document.add(parrafo);

                parrafo = new Paragraph("IV.1.     MOTIVACIN Y FUNDAMENTACIN LEGAL:",
                        new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD));
                parrafo.setSpacingBefore(20);
                parrafo.setIndentationLeft(30);
                document.add(parrafo);

                parrafo = new Paragraph("", new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL));
                parrafo.setSpacingAfter(20);
                parrafo.setIndentationLeft(60);
                parrafo.setLeading(15);
                parrafo.setSpacingBefore(20);
                parrafo.setAlignment(Element.ALIGN_JUSTIFIED);

                frase = new Chunk("A)", new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD));
                parrafo.add(frase);

                frase = new Chunk("  MOTIVOS: ", new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD));
                parrafo.add(frase);

                frase = new Chunk("La contratacin de los " + justi.getBienServicioTxt()
                        + " objeto de la presente justificacin "
                        + "es necesaria para satisfacer los requerimientos del proyecto identificado por: "
                        + justi.getProyecto() + ".  " + justi.getRazonCompra() + "." + " \nPor lo anterior, la "
                        + "contratacin propuesta se adeca al supuesto de excepcin establecido en la Ley "
                        + "de Adquisiciones, Arrendamientos y Servicios del Sector Pblico en su artculo 41, "
                        + "fraccin " + justi.getRomano()
                        + "; adems de que se renen los requisitos previstos en el artculo 72 del "
                        + "Reglamento de la Ley de Adquisiciones, Arrendamientos y Servicios del Sector "
                        + "Pblico, tal y como se desprende de la informacin presentada en esta justificacin, "
                        + "as como de la Investigacin de Mercado; "
                        + "por lo que resulta procedente la contratacin bajo el procedimiento de adjudicacin "
                        + "directa previsto en el artculo 26, fraccin III de la Ley antes mencionada.",
                        new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL));
                parrafo.add(frase);
                document.add(parrafo);

                parrafo = new Paragraph("", new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL));
                parrafo.setSpacingAfter(20);
                parrafo.setIndentationLeft(60);
                parrafo.setLeading(15);
                parrafo.setSpacingBefore(20);
                parrafo.setAlignment(Element.ALIGN_JUSTIFIED);

                frase = new Chunk("B)", new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD));
                parrafo.add(frase);

                frase = new Chunk("  FUNDAMENTOS: ", new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD));
                parrafo.add(frase);

                frase = new Chunk("La contratacin se encuentra debidamente fundada en el artculo "
                        + "134 de la Constitucin Poltica de los Estados Unidos Mexicanos; en los artculos 26 "
                        + "fraccin III, 40 y 41 fraccin " + justi.getRomano()
                        + " de la Ley de Adquisiciones, Arrendamientos y "
                        + "Servicios del Sector Pblico; as como en los artculos 71 y 72 del Reglamento de la "
                        + "Ley de Adquisiciones, Arrendamientos y Servicios del Sector Pblico.",
                        new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL));
                parrafo.add(frase);
                document.add(parrafo);

                parrafo = new Paragraph("V.- MONTO ESTIMADO Y FORMA DE PAGO PROPUESTO:",
                        new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD));
                parrafo.setAlignment(Element.ALIGN_CENTER);
                parrafo.setSpacingBefore(20);
                document.add(parrafo);

                parrafo = new Paragraph("V.1.      MONTO ESTIMADO:",
                        new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD));
                parrafo.setSpacingBefore(20);
                parrafo.setIndentationLeft(30);
                document.add(parrafo);

                DecimalFormat decimalFormat = new DecimalFormat("0.00");
                parrafo = new Paragraph("El monto estimado de la contratacin es la cantidad de "
                        + montoFormatComas(justi.getSubTotal(), justi) + " ("
                        + new Numero_a_Letra().Convertir(decimalFormat.format(justi.getSubTotal()), true) + " "
                        + /*codigoDivisa(justi)*/ justi.getMoneda().getCode() + ")" + masIva + ", mismo que "
                        + "result el ms conveniente de acuerdo con la Investigacin de Mercado"
                        + ", mediante la cual se verific previo al inicio del procedimiento "
                        + "de contratacin, la existencia de oferta de los " + justi.getBienServicioTxt()
                        + " en la cantidad, "
                        + "calidad y oportunidad requeridos en los trminos del artculo 28 del Reglamento de la Ley de "
                        + "Adquisiciones, Arrendamientos y Servicios del Sector Pblico.",
                        new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL));
                parrafo.setSpacingAfter(20);
                parrafo.setIndentationLeft(30);
                parrafo.setLeading(15);
                parrafo.setSpacingBefore(20);
                parrafo.setAlignment(Element.ALIGN_JUSTIFIED);
                document.add(parrafo);

                table = new PdfPTable(3); // 3 columns.

                table.setWidths(new int[] { 30, 10, 10 });
                PdfPCell cell1 = new PdfPCell(
                        new Paragraph("Subtotal:", new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL)));
                PdfPCell cell2 = new PdfPCell(new Paragraph(montoFormatComas(justi.getSubTotal(), justi),
                        new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL)));
                PdfPCell cell0 = new PdfPCell(
                        new Paragraph("", new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL)));
                cell0.setBorder(PdfPCell.NO_BORDER);
                table.addCell(cell0);
                cell1.setBorder(PdfPCell.NO_BORDER);
                cell1.setHorizontalAlignment(Element.ALIGN_RIGHT);
                cell2.setBorder(PdfPCell.NO_BORDER);
                cell2.setHorizontalAlignment(Element.ALIGN_RIGHT);
                table.addCell(cell1);
                table.addCell(cell2);
                cell1 = new PdfPCell(
                        new Paragraph("Iva:", new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL)));
                cell2 = new PdfPCell(new Paragraph(montoFormatComas(justi.getIva(), justi),
                        new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL)));
                cell0 = new PdfPCell(new Paragraph("", new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL)));
                cell0.setBorder(PdfPCell.NO_BORDER);
                table.addCell(cell0);
                cell1.setBorder(PdfPCell.NO_BORDER);
                cell1.setHorizontalAlignment(Element.ALIGN_RIGHT);
                cell2.setBorder(PdfPCell.NO_BORDER);
                cell2.setHorizontalAlignment(Element.ALIGN_RIGHT);
                table.addCell(cell1);
                table.addCell(cell2);
                cell1 = new PdfPCell(
                        new Paragraph("Total:", new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.BOLD)));
                cell2 = new PdfPCell(new Paragraph(montoFormatComas(justi.getImporte(), justi),
                        new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.BOLD)));
                cell0 = new PdfPCell(new Paragraph("", new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL)));
                cell0.setBorder(PdfPCell.NO_BORDER);
                table.addCell(cell0);
                cell1.setBorder(PdfPCell.NO_BORDER);
                cell1.setHorizontalAlignment(Element.ALIGN_RIGHT);
                cell2.setBorder(PdfPCell.NO_BORDER);
                cell2.setHorizontalAlignment(Element.ALIGN_RIGHT);
                table.addCell(cell1);
                table.addCell(cell2);
                document.add(table);

                parrafo = new Paragraph("V.1.      FORMA DE PAGO PROPUESTA:",
                        new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD));
                parrafo.setSpacingBefore(20);
                parrafo.setIndentationLeft(30);
                document.add(parrafo);

                parrafo = new Paragraph("El monto total ser pagado en " + justi.getNumPagos() + " pago/s de "
                        + montoFormatComas(justi.getSubTotal() / justi.getNumPagos(), justi) + " ("
                        + new Numero_a_Letra().Convertir(
                                decimalFormat.format(justi.getSubTotal() / (justi.getNumPagos())).toString(),
                                true)
                        + " " + /*codigoDivisa(justi)*/ justi.getMoneda().getCode() + ")" + masIva
                        + ". Los pagos se realizarn previa verificacin de la entrega y calidad de los "
                        + justi.getBienServicioTxt()
                        + " as como previo envo en formatos .pdf y .xml del Comprobante Fiscal "
                        + "Digital por Internet (CFDI) correspondiente que rena los requisitos fiscales respectivos. Los "
                        + "pagos se efectuarn mediante " + justi.getFormaPago(),
                        new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL));
                parrafo.setSpacingAfter(20);
                parrafo.setIndentationLeft(30);
                parrafo.setLeading(15);
                parrafo.setSpacingBefore(20);
                parrafo.setAlignment(Element.ALIGN_JUSTIFIED);
                document.add(parrafo);

                parrafo = new Paragraph("VI.- PERSONA PROPUESTA PARA LA ADJUDICACIN DIRECTA:",
                        new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD));
                parrafo.setAlignment(Element.ALIGN_CENTER);
                parrafo.setSpacingBefore(20);
                document.add(parrafo);

                parrafo = new Paragraph(
                        "Por lo anteriormente expuesto y fundado, se propone a "
                                + justi.getProveedorUno().toUpperCase() + ", con domicilio ubicado en "
                                + justi.getDomicilio() + ", Registro Federal de Contribuyentes: "
                                + justi.getRfc() + ", correo electrnico: " + justi.getCorreo()
                                + " y nmero telefnico " + justi.getTelefono() + datosBanco,
                        new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL));
                parrafo.setSpacingAfter(20);
                parrafo.setIndentationLeft(30);
                parrafo.setLeading(15);
                parrafo.setSpacingBefore(20);
                parrafo.setAlignment(Element.ALIGN_JUSTIFIED);
                document.add(parrafo);

                parrafo = new Paragraph(
                        "VII.- ACREDITAMIENTO DEL O LOS CRITERIOS EN LOS QUE SE FUNDA Y MOTIVA LA "
                                + "SELECCIN DEL PROCEDIMIENTO DE EXCEPCIN A LA LICITACIN PBLICA:",
                        new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD));
                parrafo.setAlignment(Element.ALIGN_CENTER);
                parrafo.setLeading(15);
                parrafo.setIndentationLeft(30);
                parrafo.setSpacingBefore(20);
                document.add(parrafo);

                parrafo = new Paragraph(
                        "El procedimiento de contratacin por adjudicacin directa es el idneo, al actualizarse el "
                                + "supuesto de excepcin al procedimiento de licitacin pblica previsto en el artculo 41, fraccin "
                                + justi.getRomano()
                                + " de la Ley de Adquisiciones, Arrendamientos y Servicios del Sector Pblico, aunado a que se "
                                + "corrobor la capacidad y experiencia de la persona propuesta, quien por ser proveedor nico "
                                + "present las mejores condiciones en cuanto a precio, calidad, financiamiento, oportunidad y "
                                + "dems circunstancias pertinentes a efecto de asegurar a esta Entidad las mejores condiciones "
                                + "para su contratacin, tal y como se acredita con la informacin presentada en esta justificacin, "
                                + "as como con la Investigacin de Mercado.\n\n"
                                + "El acreditamiento del o los criterios en los que se funda la excepcin de licitacin pblica, son "
                                + "los siguientes:",
                        new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL));
                parrafo.setSpacingAfter(20);
                parrafo.setIndentationLeft(30);
                parrafo.setLeading(15);
                parrafo.setSpacingBefore(20);
                parrafo.setAlignment(Element.ALIGN_JUSTIFIED);
                document.add(parrafo);

                parrafo = new Paragraph("", new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL));
                parrafo.setSpacingAfter(20);
                parrafo.setIndentationLeft(30);
                parrafo.setLeading(15);
                parrafo.setSpacingBefore(20);
                parrafo.setAlignment(Element.ALIGN_JUSTIFIED);

                frase = new Chunk(" -  Economa\n", new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD));
                parrafo.add(frase);
                frase = new Chunk(
                        "Con la Investigacin de Mercado se establecieron precios y dems condiciones de calidad, "
                                + "financiamiento y oportunidad, respecto de los " + justi.getBienServicioTxt()
                                + " requeridos, con lo cual "
                                + "se asegura cumplir con los principios del artculo 134 de la Constitucin Poltica de los Estados "
                                + "Unidos Mexicanos y de la Ley de Adquisiciones, Arrendamientos y Servicios del Sector Pblico, "
                                + "en cuanto a precio, calidad, financiamiento, oportunidad y dems circunstancias pertinentes, por "
                                + "lo que el procedimiento de adjudicacin directa permite en contraposicin al procedimiento de "
                                + "licitacin pblica, obtener con mayor oportunidad los "
                                + justi.getBienServicioTxt() + " requeridos al "
                                + "menor costo econmico para el CIMAV, S.C. segn lo detallado en la investigacin de mercado "
                                + "que se realiz, generando ahorro de recursos por estar proponiendo la adjudicacin al "
                                + "proveedor nico cuya propuesta se considera aceptable en cuanto a su solvencia. "
                                + "Lo anterior de acuerdo con lo establecido en el numeral 4.2.4 (ADJUDICACIN DIRECTA) y "
                                + "numeral 4.2.4.1.1 (Verificar Acreditamiento de Excepcin) del Acuerdo por el que se modifica el "
                                + "Manual Administrativo de Aplicacin General en Materia de Adquisiciones, Arrendamientos y "
                                + "Servicios del Sector Pblico, publicado en el Diario Oficial de la Federacin el 21 de noviembre "
                                + "de 2012.",
                        new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL));
                parrafo.add(frase);
                document.add(parrafo);

                parrafo = new Paragraph("", new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL));
                parrafo.setSpacingAfter(20);
                parrafo.setIndentationLeft(30);
                parrafo.setLeading(15);
                parrafo.setSpacingBefore(20);
                parrafo.setAlignment(Element.ALIGN_JUSTIFIED);

                frase = new Chunk(" -  Eficacia\n", new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD));
                parrafo.add(frase);
                frase = new Chunk(
                        "Con el procedimiento de contratacin por adjudicacin directa, se lograr obtener con "
                                + "oportunidad los " + justi.getBienServicioTxt()
                                + " atendiendo a las caractersticas requeridas en "
                                + "contraposicin con el procedimiento de licitacin pblica, dado que se reducen tiempos y se "
                                + "generan economas; aunado a que la persona propuesta cuenta con experiencia y capacidad "
                                + "para satisfacer las necesidades requeridas, adems de que es el nico que ofrece las mejores "
                                + "condiciones disponibles en cuanto a precio, calidad y oportunidad, con lo que se lograra el "
                                + "cumplimiento de los objetivos y resultados deseados en el tiempo requerido, situacin que se "
                                + "puede demostrar en base a la investigacin de mercado. "
                                + "Lo anterior de acuerdo con lo establecido en el numeral 4.2.4 (ADJUDICACIN DIRECTA) y "
                                + "numeral 4.2.4.1.1 (Verificar Acreditamiento de Excepcin) del Acuerdo por el que se modifica el "
                                + "Manual Administrativo de Aplicacin General en Materia de Adquisiciones, Arrendamientos y "
                                + "Servicios del Sector Pblico, publicado en el Diario Oficial de la Federacin el 21 de noviembre "
                                + "de 2012.",
                        new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL));
                parrafo.add(frase);
                document.add(parrafo);

                parrafo = new Paragraph("", new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL));
                parrafo.setSpacingAfter(20);
                parrafo.setIndentationLeft(30);
                parrafo.setLeading(15);
                parrafo.setSpacingBefore(20);
                parrafo.setAlignment(Element.ALIGN_JUSTIFIED);

                frase = new Chunk(" -  Eficiencia\n", new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD));
                parrafo.add(frase);
                frase = new Chunk(
                        "Con el procedimiento de adjudicacin directa, a diferencia del procedimiento de licitacin "
                                + "pblica, se logra el uso racional de recursos con los que cuenta la Entidad para realizar la "
                                + "contratacin, obteniendo las mejores condiciones de precio, calidad y oportunidad, evitando la "
                                + "prdida de tiempo y recursos al Estado, lo cual se demuestra con la investigacin de mercado "
                                + "que se realiz, quedando evidencia de su resultado ya que los recursos disponibles con los que "
                                + "cuenta el CIMAV se aplican conforme a los lineamientos de racionalidad y austeridad "
                                + "presupuestaria. "
                                + "Lo anterior de acuerdo con lo establecido en el numeral 4.2.4 (ADJUDICACIN DIRECTA) y "
                                + "numeral 4.2.4.1.1 (Verificar Acreditamiento de Excepcin) del Acuerdo por el que se modifica el "
                                + "Manual Administrativo de Aplicacin General en Materia de Adquisiciones, Arrendamientos y "
                                + "Servicios del Sector Pblico, publicado en el Diario Oficial de la Federacin el 21 de noviembre "
                                + "de 2012.",
                        new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL));
                parrafo.add(frase);
                document.add(parrafo);

                parrafo = new Paragraph("", new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL));
                parrafo.setSpacingAfter(20);
                parrafo.setIndentationLeft(30);
                parrafo.setLeading(15);
                parrafo.setSpacingBefore(20);
                parrafo.setAlignment(Element.ALIGN_JUSTIFIED);

                frase = new Chunk(" -  Imparcialidad\n", new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD));
                parrafo.add(frase);
                frase = new Chunk(
                        "El tipo de adjudicacin que se propone, se llev a cabo sin prejuicios ni situaciones que "
                                + "pudieran afectar la imparcialidad, y sin que medie algn inters personal de los servidores "
                                + "pblicos involucrados en la contratacin o de cualquier otra ndole que pudiera otorgar "
                                + "condiciones ventajosas a alguna persona, en relacin con los dems ni limitar la libre "
                                + "participacin, esto debido a que es proveedor nico, dicha situacin queda demostrada "
                                + "conforme al resultado que se da con base a la investigacin de mercado. "
                                + "Lo anterior de acuerdo con lo establecido en el numeral 4.2.4 (ADJUDICACIN DIRECTA) y "
                                + "numeral 4.2.4.1.1 (Verificar Acreditamiento de Excepcin) del Acuerdo por el que se modifica el "
                                + "Manual Administrativo de Aplicacin General en Materia de Adquisiciones, Arrendamientos y "
                                + "Servicios del Sector Pblico, publicado en el Diario Oficial de la Federacin el 21 de noviembre "
                                + "de 2012.",
                        new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL));
                parrafo.add(frase);
                document.add(parrafo);

                parrafo = new Paragraph("", new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL));
                parrafo.setSpacingAfter(20);
                parrafo.setIndentationLeft(30);
                parrafo.setLeading(15);
                parrafo.setSpacingBefore(20);
                parrafo.setAlignment(Element.ALIGN_JUSTIFIED);

                frase = new Chunk(" -  Honradez\n", new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD));
                parrafo.add(frase);
                frase = new Chunk(
                        "La seleccin del procedimiento de adjudicacin directa tiene como nico fin contratar bajo "
                                + "las mejores condiciones los " + justi.getBienServicioTxt()
                                + " requeridos, actuando con rectitud, "
                                + "responsabilidad e integridad y con apego estricto al marco jurdico aplicable, evitando as "
                                + "incurrir en actos de corrupcin y conflictos de inters, ya que por parte de los servidores "
                                + "pblicos que intervinieron en este procedimiento quedo evidenciado que no se ha favorecido a "
                                + "persona alguna interesada en la contratacin ya que en base a la investigacin de mercado "
                                + "queda demostrado que es proveedor nico.\n\n"
                                + "Lo anterior de acuerdo con lo establecido en el numeral 4.2.4 (ADJUDICACIN DIRECTA) y "
                                + "numeral 4.2.4.1.1 (Verificar Acreditamiento de Excepcin) del Acuerdo por el que se modifica el "
                                + "Manual Administrativo de Aplicacin General en Materia de Adquisiciones, Arrendamientos y "
                                + "Servicios del Sector Pblico, publicado en el Diario Oficial de la Federacin el 21 de noviembre "
                                + "de 2012.",
                        new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL));
                parrafo.add(frase);
                document.add(parrafo);

                if (justi.getEsUnico()) {
                    parrafo = new Paragraph("", new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL));
                    parrafo.setSpacingAfter(20);
                    parrafo.setIndentationLeft(30);
                    parrafo.setLeading(15);
                    parrafo.setSpacingBefore(20);
                    parrafo.setAlignment(Element.ALIGN_JUSTIFIED);

                    frase = new Chunk(" -  Transparencia\n",
                            new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD));
                    parrafo.add(frase);
                    frase = new Chunk(mapa.get("transparencia_unico"),
                            new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL));
                    parrafo.add(frase);
                    document.add(parrafo);
                } else {
                    parrafo = new Paragraph("", new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL));
                    parrafo.setSpacingAfter(20);
                    parrafo.setIndentationLeft(30);
                    parrafo.setLeading(15);
                    parrafo.setSpacingBefore(20);
                    parrafo.setAlignment(Element.ALIGN_JUSTIFIED);

                    frase = new Chunk(" -  Transparencia\n",
                            new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD));
                    parrafo.add(frase);
                    frase = new Chunk(mapa.get("transparencia_no_unico"),
                            new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL));
                    parrafo.add(frase);
                    document.add(parrafo);
                }

                parrafo = new Paragraph("VIII.- LUGAR Y FECHA DE EMISIN:",
                        new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD));
                parrafo.setAlignment(Element.ALIGN_CENTER);
                parrafo.setLeading(15);
                parrafo.setSpacingBefore(20);
                document.add(parrafo);

                parrafo = new Paragraph("En la Ciudad de Chihuahua, Estado de Chihuahua a los "
                        + justi.getFechaElaboracion().getDayOfMonth() + " das del mes de "
                        + justi.getFechaElaboracion().getMonth().getDisplayName(TextStyle.FULL,
                                new Locale("es", "ES"))
                        + " de " + justi.getFechaElaboracion().getYear()
                        + ", se emite la presente justificacin para los efectos legales a que haya lugar.",
                        new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL));
                parrafo.setAlignment(Element.ALIGN_JUSTIFIED);
                parrafo.setLeading(15);
                parrafo.setIndentationLeft(30);
                parrafo.setSpacingBefore(20);
                document.add(parrafo);

                parrafo = new Paragraph(
                        "En cumplimiento a lo establecido en el penltimo prrafo del artculo 71 del Reglamento "
                                + "de la Ley de Adquisiciones, Arrendamientos y Servicios del Sector Pblico, se acompaa a la "
                                + "presente como ANEXO DOS?, la Requisicin o Solicitud de Contratacin (Requisicin) A la "
                                + "cual se deber anexar, mediante sello del departamento de Presupuesto, la Constancia con la "
                                + "que se acredita la existencia de recursos para iniciar el procedimiento de contratacin.",
                        new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL));
                parrafo.setAlignment(Element.ALIGN_JUSTIFIED);
                parrafo.setLeading(15);
                parrafo.setIndentationLeft(30);
                parrafo.setSpacingBefore(20);
                document.add(parrafo);

                if (justi.getEsUnico()) {
                    parrafo = new Paragraph(mapa.get("nota_1"),
                            new Font(Font.FontFamily.TIMES_ROMAN, 13, Font.BOLD));
                    parrafo.setAlignment(Element.ALIGN_JUSTIFIED);
                    parrafo.setLeading(15);
                    parrafo.setIndentationLeft(30);
                    parrafo.setSpacingBefore(20);
                    document.add(parrafo);
                }

                parrafo = new Paragraph("ATENTAMENTE", new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD));
                parrafo.setAlignment(Element.ALIGN_CENTER);
                parrafo.setLeading(15);
                parrafo.setSpacingBefore(60);
                document.add(parrafo);

                parrafo = new Paragraph(
                        justi.getAutoriza().getName() + "\n" + justi.getAutorizaCargo().toUpperCase(),
                        new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD));
                parrafo.setAlignment(Element.ALIGN_CENTER);
                parrafo.setLeading(15);
                parrafo.setSpacingBefore(60);
                document.add(parrafo);

                document.close();
                outputStream.close();

            } catch (DocumentException ex) {
                Logger.getLogger(JustificacionREST.class.getName()).log(Level.SEVERE, null, ex);
            }

        }
    };

    ResponseBuilder response = Response.ok(streamingOutput);
    String fileName = ("inline; filename=" + justi.getRequisicion() + "-" + justi.getEmpleado().getCuentaCimav()
            + ".pdf").replace(" ", "").replace(",", "-");
    response.header("Content-Disposition", fileName);

    return response.build();
}

From source file:cimav.restrh.services.JustificacionREST.java

private Response tablaMercado(Integer id_param) {
    Justificacion justif = (Justificacion) JustificacionREST.this.find(id_param);

    StreamingOutput streamingOutput = new StreamingOutput() {
        public void write(OutputStream outputStream) throws IOException, WebApplicationException {

            try {
                //Create Document instance.
                Document document = new Document();
                PdfWriter.getInstance(document, outputStream);

                document.addAuthor("Generador adquisiciones | " + justif.getEmpleado().getCuentaCimav());
                String fileName1 = (justif.getRequisicion() + "-" + justif.getEmpleado().getCuentaCimav())
                        .replace(" ", "").replace(",", "");
                document.addTitle("Justificacin: " + fileName1);
                document.addSubject("Justificacin de Requisicin");

                document.open();/*from w  ww. jav a 2  s  . c  o m*/

                //Titulo del documento
                Paragraph parrafo = new Paragraph("Centro de Investigacin en Materiales Avanzados S. C.",
                        new Font(Font.FontFamily.TIMES_ROMAN, 17, Font.BOLD));
                parrafo.setAlignment(Element.ALIGN_CENTER);
                parrafo.setSpacingAfter(20);
                document.add(parrafo);

                PdfPTable table = new PdfPTable(3); // 3 columns.

                table.setWidths(new int[] { 30, 50, 100 });

                PdfPCell cell0 = new PdfPCell(
                        new Paragraph("Fecha:", new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL)));
                PdfPCell cell1 = new PdfPCell(new Paragraph(
                        justif.getFechaInicio().getDayOfMonth() + " de "
                                + justif.getFechaInicio().getMonth().getDisplayName(TextStyle.FULL,
                                        new Locale("es", "ES"))
                                + " de " + justif.getFechaInicio().getYear(),
                        new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL)));
                PdfPCell cell2 = new PdfPCell(
                        new Paragraph("", new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL)));
                cell0.setBorder(PdfPCell.BOX);
                cell1.setBorder(PdfPCell.BOX);
                cell2.setBorder(PdfPCell.NO_BORDER);
                cell1.setHorizontalAlignment(Element.ALIGN_CENTER);
                table.addCell(cell0);
                table.addCell(cell1);
                table.addCell(cell2);

                cell0 = new PdfPCell(new Paragraph("No. de Requisicin:",
                        new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL)));
                cell1 = new PdfPCell(new Paragraph(justif.getRequisicion(),
                        new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL)));
                cell2 = new PdfPCell(new Paragraph("", new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL)));
                cell0.setBorder(PdfPCell.BOX);
                cell1.setBorder(PdfPCell.BOX);
                cell2.setBorder(PdfPCell.NO_BORDER);
                cell1.setHorizontalAlignment(Element.ALIGN_CENTER);
                table.addCell(cell0);
                table.addCell(cell1);
                table.addCell(cell2);

                cell0 = new PdfPCell(new Paragraph("Procedimiento:",
                        new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL)));
                cell1 = new PdfPCell(new Paragraph("Adjudicacin Directa",
                        new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL)));
                cell2 = new PdfPCell(new Paragraph("", new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL)));
                cell0.setBorder(PdfPCell.BOX);
                cell1.setBorder(PdfPCell.BOX);
                cell2.setBorder(PdfPCell.NO_BORDER);
                cell1.setHorizontalAlignment(Element.ALIGN_CENTER);
                table.addCell(cell0);
                table.addCell(cell1);
                table.addCell(cell2);

                cell0 = new PdfPCell(new Paragraph("Origen de los bienes:",
                        new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL)));
                cell1 = new PdfPCell(new Paragraph(justif.esNacional(),
                        new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL)));
                cell2 = new PdfPCell(new Paragraph("", new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL)));
                cell0.setBorder(PdfPCell.BOX);
                cell1.setBorder(PdfPCell.BOX);
                cell2.setBorder(PdfPCell.NO_BORDER);
                cell1.setHorizontalAlignment(Element.ALIGN_CENTER);
                table.addCell(cell0);
                table.addCell(cell1);
                table.addCell(cell2);

                document.add(table);

                parrafo = new Paragraph("", new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL));
                parrafo.setSpacingAfter(20);
                parrafo.setIndentationLeft(30);
                parrafo.setLeading(15);
                parrafo.setSpacingBefore(20);
                parrafo.setAlignment(Element.ALIGN_JUSTIFIED);
                document.add(parrafo);

                table = new PdfPTable(5);// 5 columns.
                table.setWidthPercentage(90); //table size %

                table.setWidths(new int[] { 'a', 'a', 'a', 'a', 'a' });

                cell0 = new PdfPCell(
                        new Paragraph("PARTIDA", new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.BOLD)));
                cell1 = new PdfPCell(
                        new Paragraph("DESCIPCIMAV", new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.BOLD)));
                cell2 = new PdfPCell(
                        new Paragraph("PROVEEDOR No. 1", new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.BOLD)));
                PdfPCell cell3 = new PdfPCell(
                        new Paragraph("PROVEEDOR No.2", new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.BOLD)));
                PdfPCell cell4 = new PdfPCell(
                        new Paragraph("PROVEEDOR No.3", new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.BOLD)));
                cell0.setBorder(PdfPCell.BOX);
                cell1.setBorder(PdfPCell.BOX);
                cell2.setBorder(PdfPCell.BOX);
                cell3.setBorder(PdfPCell.BOX);
                cell4.setBorder(PdfPCell.BOX);
                cell0.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell1.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell2.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell3.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell4.setHorizontalAlignment(Element.ALIGN_CENTER);
                table.addCell(cell0);
                table.addCell(cell1);
                table.addCell(cell2);
                table.addCell(cell3);
                table.addCell(cell4);

                cell0 = new PdfPCell(
                        new Paragraph("Partida #1", new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.BOLD)));
                cell1 = new PdfPCell(new Paragraph(justif.getDescripcion(),
                        new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL)));
                cell0.setBorder(PdfPCell.BOX);
                cell1.setBorder(PdfPCell.BOX);
                cell0.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell0.setVerticalAlignment(Element.ALIGN_MIDDLE);
                cell1.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell1.setVerticalAlignment(Element.ALIGN_MIDDLE);
                cell0.setRowspan(2);
                cell1.setRowspan(2);
                table.addCell(cell0);
                table.addCell(cell1);

                cell2 = new PdfPCell(new Paragraph(justif.getProveedorUno(),
                        new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL)));
                cell3 = new PdfPCell(new Paragraph(justif.getProveedorDos(),
                        new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL)));
                cell4 = new PdfPCell(new Paragraph(justif.getProveedorTres(),
                        new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL)));
                cell2.setBorder(PdfPCell.BOX);
                cell3.setBorder(PdfPCell.BOX);
                cell4.setBorder(PdfPCell.BOX);
                cell2.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell3.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell4.setHorizontalAlignment(Element.ALIGN_CENTER);
                table.addCell(cell2);
                table.addCell(cell3);
                table.addCell(cell4);

                if (justif.getMontoUno() <= 1 && justif.getMontoDos() <= 1 && justif.getMontoTres() <= 1) {
                    cell2 = new PdfPCell(
                            new Paragraph("NO APLICA", new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL)));
                    cell3 = new PdfPCell(
                            new Paragraph("NO APLICA", new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL)));
                    cell4 = new PdfPCell(
                            new Paragraph("NO APLICA", new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL)));

                } else if (justif.getMontoUno() <= 1 && justif.getMontoDos() <= 1) {
                    cell2 = new PdfPCell(
                            new Paragraph("NO APLICA", new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL)));
                    cell3 = new PdfPCell(
                            new Paragraph("NO APLICA", new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL)));
                    cell4 = new PdfPCell(new Paragraph(montoFormatComas(justif.getMontoTres(), justif),
                            new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL)));

                } else if (justif.getMontoUno() <= 1 && justif.getMontoTres() <= 1) {
                    cell2 = new PdfPCell(
                            new Paragraph("NO APLICA", new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL)));
                    cell3 = new PdfPCell(new Paragraph(montoFormatComas(justif.getMontoDos(), justif),
                            new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL)));
                    cell4 = new PdfPCell(
                            new Paragraph("NO APLICA", new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL)));

                } else if (justif.getMontoDos() <= 1 && justif.getMontoTres() <= 1) {
                    cell2 = new PdfPCell(new Paragraph(montoFormatComas(justif.getMontoUno(), justif),
                            new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL)));
                    cell3 = new PdfPCell(
                            new Paragraph("NO APLICA", new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL)));
                    cell4 = new PdfPCell(
                            new Paragraph("NO APLICA", new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL)));

                } else if (justif.getMontoUno() <= 1) {
                    cell2 = new PdfPCell(
                            new Paragraph("NO APLICA", new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL)));
                    cell3 = new PdfPCell(new Paragraph(montoFormatComas(justif.getMontoDos(), justif),
                            new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL)));
                    cell4 = new PdfPCell(new Paragraph(montoFormatComas(justif.getMontoTres(), justif),
                            new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL)));

                } else if (justif.getMontoDos() <= 1) {
                    cell2 = new PdfPCell(new Paragraph(
                            "Subtotal: " + justif.getSubTotal() + "\n" + "IVA: " + justif.getIva() + "\n"
                                    + "Total:" + "\n" + montoFormatComas(justif.getImporte(), justif),
                            new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL)));
                    cell3 = new PdfPCell(
                            new Paragraph("NO APLICA", new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL)));
                    cell4 = new PdfPCell(new Paragraph(montoFormatComas(justif.getMontoTres(), justif),
                            new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL)));

                } else if (justif.getMontoTres() <= 1) {
                    cell2 = new PdfPCell(new Paragraph(
                            "Subtotal: " + justif.getSubTotal() + "\n" + "IVA: " + justif.getIva() + "\n"
                                    + "Total:" + "\n" + montoFormatComas(justif.getImporte(), justif),
                            new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL)));
                    cell3 = new PdfPCell(new Paragraph(montoFormatComas(justif.getMontoDos(), justif),
                            new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL)));
                    cell4 = new PdfPCell(
                            new Paragraph("NO APLICA", new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL)));
                } else {
                    cell2 = new PdfPCell(new Paragraph(
                            "Subtotal: " + justif.getSubTotal() + "\n" + "IVA: " + justif.getIva() + "\n"
                                    + "Total:" + "\n" + montoFormatComas(justif.getImporte(), justif),
                            new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL)));
                    cell3 = new PdfPCell(new Paragraph(montoFormatComas(justif.getMontoDos(), justif),
                            new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL)));
                    cell4 = new PdfPCell(new Paragraph(montoFormatComas(justif.getMontoTres(), justif),
                            new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL)));
                }
                cell2.setBorder(PdfPCell.BOX);
                cell3.setBorder(PdfPCell.BOX);
                cell4.setBorder(PdfPCell.BOX);
                cell2.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell2.setVerticalAlignment(Element.ALIGN_MIDDLE);
                cell3.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell3.setVerticalAlignment(Element.ALIGN_MIDDLE);
                cell4.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell4.setVerticalAlignment(Element.ALIGN_MIDDLE);
                table.addCell(cell2);
                table.addCell(cell3);
                table.addCell(cell4);
                document.add(table);

                parrafo = new Paragraph(
                        "Tal como lo establece el artculo 29 " + "del Reglamento de la Ley de Adquisiciones, "
                                + "Arrendamientos y Servicios del Sector Pblico,"
                                + " la investigacin de mercado arrojo los siguientes resultados:\n",
                        new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL));
                parrafo.setSpacingAfter(20);
                parrafo.setIndentationLeft(30);
                parrafo.setLeading(15);
                parrafo.setSpacingBefore(10);
                parrafo.setAlignment(Element.ALIGN_JUSTIFIED);
                document.add(parrafo);

                parrafo = new Paragraph(
                        "Fraccin I, determinamos la existencia de oferta de los bienes requeridos.\n"
                                + "Fraccin II, verificamos existencias de los mismos con los proveedores que nos proporcionaron cotizacin formal.\n"
                                + "Fraccin III, conocimos los precios que prevalecan en el mercado nacional.\n",
                        new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL));

                parrafo.setIndentationLeft(50);
                parrafo.setLeading(15);
                parrafo.setAlignment(Element.ALIGN_JUSTIFIED);
                document.add(parrafo);

                parrafo = new Paragraph(
                        "A travs de la investigacin de mercado realizada, "
                                + "concluimos que la mejor opcin de compra es la oferta del proveedor" + " "
                                + justif.getProveedorUno(),
                        new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL));
                parrafo.setSpacingAfter(10);
                parrafo.setIndentationLeft(30);
                parrafo.setLeading(15);
                parrafo.setSpacingBefore(20);
                parrafo.setAlignment(Element.ALIGN_JUSTIFIED);
                document.add(parrafo);

                document.close();
                outputStream.close();

            } catch (DocumentException ex) {
                Logger.getLogger(JustificacionREST.class.getName()).log(Level.SEVERE, null, ex);
            }

        }
    };
    ResponseBuilder response = Response.ok(streamingOutput);
    String fileName = ("inline; filename=" + justif.getRequisicion() + "-"
            + justif.getEmpleado().getCuentaCimav() + ".pdf").replace(" ", "").replace(",", "-");
    response.header("Content-Disposition", fileName);

    return response.build();
}

From source file:climbingcompranking.model.ranking.RankingGenerator.java

License:Open Source License

public void createRankingPDF(String competitionName, CompetitionType compType) {
    doTheRanking(compType);//w  w w . ja v  a  2  s.  co  m
    try {
        Document document = new Document(PageSize.A4.rotate()); // Landscape
        Date date = new Date();
        String dateStr = "";
        if (Locale.getDefault().equals(Locale.FRANCE)) {
            dateStr = new SimpleDateFormat("dd-MM-yyyy").format(date);
        } else {
            dateStr = new SimpleDateFormat("yyyy-MM-dd").format(date);
        }
        PdfWriter.getInstance(document,
                new FileOutputStream("data/pdf/" + competitionName + '-' + dateStr + ".pdf"));

        document.open();
        // Meta data
        document.addTitle(competitionName);
        document.addSubject(competitionName + " ranking.");
        document.addKeywords(competitionName + ", ranking, climbingcompetition, climbcompranking");
        document.addAuthor("ClimbingCompRanking - https://github.com/Yaty/ClimbingCompRanking");
        document.addCreator("ClimbingCompRanking - https://github.com/Yaty/ClimbingCompRanking");
        document.addCreationDate();
        document.setMargins(0, 0, 0, 0);

        PdfPCell club = new PdfPCell(new Phrase(I18n.MODEL.getString("Club")));
        PdfPCell climberName = new PdfPCell(new Phrase(I18n.MODEL.getString("ClimberName")));
        PdfPCell ranking = new PdfPCell(new Phrase(I18n.MODEL.getString("Ranking")));

        for (Map.Entry<Category, ArrayList<Climber>> climbersCategory : climbersMap.entrySet()) {
            if (climbersCategory.getValue().isEmpty())
                continue;
            document.newPage();
            // Title
            Paragraph title = new Paragraph(
                    competitionName + " : " + climbersCategory.getKey().getCategoryName());
            title.setAlignment(Element.ALIGN_CENTER);
            title.setFont(new Font(Font.FontFamily.HELVETICA, 36));
            title.setSpacingAfter(20);

            // Table
            PdfPTable table = null;
            switch (compType) {
            case BOULDERING:
            case LEAD:
            case SPEED:
                table = new PdfPTable(3); // Club | Full name | Ranking
                table.addCell(club);
                table.addCell(climberName);
                table.addCell(ranking);
                for (Climber climber : climbersCategory.getValue()) {
                    table.addCell(new PdfPCell(new Phrase(climber.getClubName())));
                    table.addCell(new PdfPCell(new Phrase(climber.getFullName())));
                    table.addCell(new PdfPCell(new Phrase(String.valueOf(climber.getRank().getOverallRank()))));
                }
                break;
            case LEAD_AND_BOULDERING:
                table = new PdfPTable(6); // Club | Full name | Ranking
                table.addCell(club);
                table.addCell(climberName);
                table.addCell(new PdfPCell(new Phrase(I18n.MODEL.getString("LeadRanking"))));
                table.addCell(new PdfPCell(new Phrase(I18n.MODEL.getString("BoulderingRanking"))));
                table.addCell(new PdfPCell(new Phrase(I18n.MODEL.getString("Sum"))));
                table.addCell(ranking);
                for (Climber climber : climbersCategory.getValue()) {
                    table.addCell(new PdfPCell(new Phrase(climber.getClubName())));
                    table.addCell(new PdfPCell(new Phrase(climber.getFullName())));
                    table.addCell(new PdfPCell(new Phrase(String.valueOf(climber.getRank().getLeadRank()))));
                    table.addCell(
                            new PdfPCell(new Phrase(String.valueOf(climber.getRank().getBoulderingRank()))));
                    table.addCell(new PdfPCell(
                            new Phrase(String.valueOf(climber.getRank().getTotalPoints(compType)))));
                    table.addCell(new PdfPCell(new Phrase(String.valueOf(climber.getRank().getOverallRank()))));
                }
                break;
            case SPEED_AND_BOULDERING:
                table = new PdfPTable(6); // Club | Full name | Ranking
                table.addCell(club);
                table.addCell(climberName);
                table.addCell(new PdfPCell(new Phrase(I18n.MODEL.getString("SpeedRanking"))));
                table.addCell(new PdfPCell(new Phrase(I18n.MODEL.getString("BoulderingRanking"))));
                table.addCell(new PdfPCell(new Phrase(I18n.MODEL.getString("Sum"))));
                table.addCell(ranking);
                for (Climber climber : climbersCategory.getValue()) {
                    table.addCell(new PdfPCell(new Phrase(climber.getClubName())));
                    table.addCell(new PdfPCell(new Phrase(climber.getFullName())));
                    table.addCell(new PdfPCell(new Phrase(String.valueOf(climber.getRank().getSpeedRank()))));
                    table.addCell(
                            new PdfPCell(new Phrase(String.valueOf(climber.getRank().getBoulderingRank()))));
                    table.addCell(new PdfPCell(
                            new Phrase(String.valueOf(climber.getRank().getTotalPoints(compType)))));
                    table.addCell(new PdfPCell(new Phrase(String.valueOf(climber.getRank().getOverallRank()))));
                }
                break;
            case SPEED_AND_LEAD:
                table = new PdfPTable(6); // Club | Full name | Ranking
                table.addCell(club);
                table.addCell(climberName);
                table.addCell(new PdfPCell(new Phrase(I18n.MODEL.getString("SpeedRanking"))));
                table.addCell(new PdfPCell(new Phrase(I18n.MODEL.getString("LeadRanking"))));
                table.addCell(new PdfPCell(new Phrase(I18n.MODEL.getString("Sum"))));
                table.addCell(ranking);
                for (Climber climber : climbersCategory.getValue()) {
                    table.addCell(new PdfPCell(new Phrase(climber.getClubName())));
                    table.addCell(new PdfPCell(new Phrase(climber.getFullName())));
                    table.addCell(new PdfPCell(new Phrase(String.valueOf(climber.getRank().getSpeedRank()))));
                    table.addCell(new PdfPCell(new Phrase(String.valueOf(climber.getRank().getLeadRank()))));
                    table.addCell(new PdfPCell(
                            new Phrase(String.valueOf(climber.getRank().getTotalPoints(compType)))));
                    table.addCell(new PdfPCell(new Phrase(String.valueOf(climber.getRank().getOverallRank()))));
                }
                break;
            case COMBINED:
                table = new PdfPTable(7); // Club | Full name | Ranking
                table.addCell(club);
                table.addCell(climberName);
                table.addCell(new PdfPCell(new Phrase(I18n.MODEL.getString("LeadRanking"))));
                table.addCell(new PdfPCell(new Phrase(I18n.MODEL.getString("BoulderingRanking"))));
                table.addCell(new PdfPCell(new Phrase(I18n.MODEL.getString("SpeedRanking"))));
                table.addCell(new PdfPCell(new Phrase(I18n.MODEL.getString("Sum"))));
                table.addCell(ranking);
                for (Climber climber : climbersCategory.getValue()) {
                    table.addCell(new PdfPCell(new Phrase(climber.getClubName())));
                    table.addCell(new PdfPCell(new Phrase(climber.getFullName())));
                    table.addCell(new PdfPCell(new Phrase(String.valueOf(climber.getRank().getLeadRank()))));
                    table.addCell(
                            new PdfPCell(new Phrase(String.valueOf(climber.getRank().getBoulderingRank()))));
                    table.addCell(new PdfPCell(new Phrase(String.valueOf(climber.getRank().getSpeedRank()))));
                    table.addCell(new PdfPCell(
                            new Phrase(String.valueOf(climber.getRank().getTotalPoints(compType)))));
                    table.addCell(new PdfPCell(new Phrase(String.valueOf(climber.getRank().getOverallRank()))));
                }
                break;
            }

            // Alignment
            for (PdfPRow row : table.getRows()) {
                PdfPCell[] cells = row.getCells();
                for (PdfPCell cellToAlign : cells) {
                    cellToAlign.setHorizontalAlignment(Element.ALIGN_CENTER);
                    cellToAlign.setVerticalAlignment(Element.ALIGN_CENTER);
                }
            }

            table.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.setHeaderRows(1);

            document.add(title);
            document.add(table);
        }
        document.close();
    } catch (DocumentException | FileNotFoundException ex) {
        Logger.getLogger(RankingGenerator.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:com.athena.chameleon.engine.core.PDFCommonEventHelper.java

License:Apache License

/**
 * /*from w  w w . j ava 2s .  c  o  m*/
 *  Paragraph ?.(Navigation  ?  title ) 
 *
 * @param title 
 * @param pageNumber 
 * @param depth 
 * @param x1 document left 
 * @param x2 document right 
 * @return Paragraph
 */
public Paragraph getTocParagraph(String title, int pageNumber, int depth, float x1, float x2) {

    Font tocFont = new Font(bfKorean, 10);
    if (depth == 0)
        tocFont.setStyle(Font.BOLD);

    Paragraph p = new Paragraph();
    p.setSpacingAfter(5);

    Chunk tit = new Chunk(title + " ", tocFont);
    tit.setAction(PdfAction.gotoLocalPage(title, false));

    Chunk point = new Chunk(".", tocFont);

    Chunk number = new Chunk(" " + pageNumber, tocFont);
    number.setAction(PdfAction.gotoLocalPage(title, false));

    p.add(tit);

    float width = x2 - x1 - tit.getWidthPoint() - number.getWidthPoint() - (depth * 12);

    if ((x2 - x1) < tit.getWidthPoint())
        width = x2 - x1 - (tit.getWidthPoint() - (x2 - x1)) - number.getWidthPoint() - (depth * 12) - 65;

    float i = point.getWidthPoint();
    while (i < width) {
        p.add(point);
        i += point.getWidthPoint();
    }

    p.add(number);

    return p;
}

From source file:com.athena.chameleon.engine.core.PDFDocGenerator.java

License:Apache License

/**
 * /*from ww w . j  a  va 2s. c o m*/
 * PDF Title Page 
 *
 * @param doc
 * @param writer
 */
public static void setTitleMainPage(Document doc, PdfWriter writer, PDFCommonEventHelper event, Upload upload)
        throws Exception {

    Font fnTitle = new Font(bfKorean, 20, Font.BOLD);
    Font fnLabel = new Font(bfKorean, 11, Font.BOLD);
    Font fnText = new Font(bfKorean, 11);
    LineSeparator UNDERLINE = new LineSeparator(1, 80, null, com.itextpdf.text.Element.ALIGN_CENTER, -5);
    doc.newPage();
    doc.add(Chunk.NEWLINE);

    event.setTitleFlag(true);

    int toc = writer.getPageNumber();
    Image img = Image.getInstance(PDFDocGenerator.class.getResource("/image/title.gif"));
    img.setAlignment(com.itextpdf.text.Element.ALIGN_CENTER);
    img.scalePercent(80, 80);
    doc.add(img);

    Paragraph titlePh = new Paragraph(MessageUtil.getMessage("pdf.message.main.title"), fnTitle);
    titlePh.setAlignment(com.itextpdf.text.Element.ALIGN_CENTER);
    titlePh.setSpacingBefore(50);
    titlePh.setSpacingAfter(30);
    doc.add(titlePh);

    doc.add(UNDERLINE);

    PdfPTable t1 = new PdfPTable(2);
    t1.setSpacingBefore(20);
    t1.setWidths(new int[] { 110, 290 });
    t1.getDefaultCell().setBorder(0);
    t1.getDefaultCell().setFixedHeight(32);

    t1.addCell(new Phrase(MessageUtil.getMessage("pdf.message.main.label.project_name"), fnLabel));
    t1.addCell(new Phrase(upload.getProjectNm(), fnText));
    t1.addCell(new Phrase(MessageUtil.getMessage("pdf.message.main.label.department"), fnLabel));
    t1.addCell(new Phrase(upload.getDepartment(), fnText));
    t1.addCell(new Phrase(MessageUtil.getMessage("pdf.message.main.label.focus_name"), fnLabel));
    t1.addCell(new Phrase(MessageUtil.getMessage("pdf.message.main.text.focus_name"), fnText));
    t1.addCell(new Phrase(MessageUtil.getMessage("pdf.message.main.label.product"), fnLabel));
    t1.addCell(new Phrase(MessageUtil.getMessage("pdf.message.main.text.product", upload.getBeforeWas(),
            upload.getAfterWas()), fnText));
    doc.add(t1);

    doc.add(UNDERLINE);

    Paragraph executedPh = new Paragraph(MessageUtil.getMessage("pdf.message.main.label.executed"), fnLabel);
    executedPh.setSpacingBefore(30);
    executedPh.setSpacingAfter(15);
    executedPh.setIndentationLeft(50);
    doc.add(executedPh);

    PdfPTable t2 = new PdfPTable(2);
    t2.getDefaultCell().setFixedHeight(28);
    t2.getDefaultCell().setVerticalAlignment(com.itextpdf.text.Element.ALIGN_MIDDLE);

    t2.getDefaultCell().setBackgroundColor(new BaseColor(217, 217, 217));
    t2.addCell(new Phrase(MessageUtil.getMessage("pdf.message.main.label.owner"), fnLabel));
    t2.addCell(new Phrase(MessageUtil.getMessage("pdf.message.main.label.project_role"), fnLabel));
    t2.getDefaultCell().setBackgroundColor(new BaseColor(255, 255, 255));
    t2.addCell(new Phrase(upload.getPerson(), fnText));
    t2.addCell(new Phrase(upload.getOrgRole(), fnText));
    doc.add(t2);

    doc.newPage();
    int total = writer.reorderPages(null);

    int[] order = new int[total];
    for (int i = 0; i < total; i++) {
        order[i] = i + toc;
        if (order[i] > total)
            order[i] -= total;
    }
    // apply the new order
    writer.reorderPages(order);

}