Example usage for com.itextpdf.text ListItem ListItem

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

Introduction

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

Prototype

public ListItem(final Phrase phrase) 

Source Link

Document

Constructs a ListItem with a certain Phrase.

Usage

From source file:Controller.CrearPDF.java

/**
 * We create a PDF document with iText using different elements to learn 
 * to use this library./* w ww.  j  a va 2  s  .  co m*/
 * Creamos un documento PDF con iText usando diferentes elementos para aprender 
 * a usar esta librera.
 * @param pdfNewFile  <code>String</code> 
 *      pdf File we are going to write. 
 *      Fichero pdf en el que vamos a escribir. 
 */
//    public void createPDF(File pdfNewFile, ReparacionEntity reparacion) throws Exception {
public void createPDF(File pdfNewFile) throws Exception {
    // We create the document and set the file name.        
    // Creamos el documento e indicamos el nombre del fichero.
    try {
        //            ClienteController cc = new ClienteController();
        //            Cliente cliente = cc.buscarPorId(reparacion.getCliente());
        Document document = new Document();
        try {

            PdfWriter.getInstance(document, new FileOutputStream(pdfNewFile));

        } catch (FileNotFoundException fileNotFoundException) {
            System.out.println("No such file was found to generate the PDF "
                    + "(No se encontr el fichero para generar el pdf)" + fileNotFoundException);
        }
        document.open();
        // We add metadata to PDF
        // Aadimos los metadatos del PDF
        document.addTitle("Table export to PDF (Exportamos la tabla a PDF)");
        document.addSubject("Using iText (usando iText)");
        document.addKeywords("Java, PDF, iText");
        document.addAuthor("Cdigo Xules");
        document.addCreator("Cdigo Xules");

        // First page
        // Primera pgina 
        Chunk chunk = new Chunk("RDEN DE TRABAJO", categoryFont);
        Chunk c2 = new Chunk("\n\n\nCentro de Formacin SATCAR6\n" + "Calle Artes Grficas n1 Nave 12 A\n"
                + "Pinto (28320), Madrid", smallFont);

        Chunk c3 = new Chunk("Datos del Cliente", smallBold);
        //            Chunk c4 = new Chunk("Nombre: "+cliente.getRazonSocial(),smallBold);
        //            Chunk c5 = new Chunk("Poblacin: "+cliente.getPoblacion(),smallBold);
        //            Chunk c6 = new Chunk("Provincia: "+cliente.getProvincia(),smallBold);
        //            Chunk c7 = new Chunk("Cdigo Postal: "+cliente.getCp(),smallBold);
        //            Chunk c8 = new Chunk("Num Telfono: Pepito"+cliente.getTlf1(),smallBold);
        Chunk c4 = new Chunk("Nombre: Jesus Eduardo Garcia Toril", smallBold);
        Chunk c5 = new Chunk("Poblacin: Pinto", smallBold);
        Chunk c6 = new Chunk("Provincia: Madrid", smallBold);
        Chunk c7 = new Chunk("Cdigo Postal: 28320", smallBold);
        Chunk c8 = new Chunk("Num Telfono: 659408182", smallBold);

        Paragraph parrafo = new Paragraph(chunk);
        Paragraph p2 = new Paragraph(c2);
        Paragraph p3 = new Paragraph(c3);
        Phrase ph1 = new Phrase(c4);
        Phrase ph2 = new Phrase(c5);
        Phrase ph3 = new Phrase(c6);
        Phrase ph4 = new Phrase(c7);
        Phrase ph5 = new Phrase(c8);

        // Let's create de first Chapter (Creemos el primer captulo)

        // We add an image (Aadimos una imagen)
        Image image;
        try {
            parrafo.setAlignment(Element.ALIGN_CENTER);
            image = Image.getInstance(iTextExampleImage);
            image.setAbsolutePosition(0, 750);
            p2.setAlignment(Element.ALIGN_LEFT);
            document.add(parrafo);
            document.add(image);
            document.add(p2);
            document.add(p3);
            document.add(ph1);
            document.add(ph2);
            document.add(ph3);
            document.add(ph4);
            document.add(ph5);

        } catch (BadElementException ex) {
            System.out.println("Image BadElementException" + ex);
        }

        // Second page - some elements
        // Segunda pgina - Algunos elementos

        // List by iText (listas por iText)
        String text = "test 1 2 3 ";
        for (int i = 0; i < 5; i++) {
            text = text + text;
        }
        List list = new List(List.UNORDERED);
        ListItem item = new ListItem(text);
        item.setAlignment(Element.ALIGN_JUSTIFIED);
        list.add(item);
        text = "a b c align ";
        for (int i = 0; i < 5; i++) {
            text = text + text;
        }
        item = new ListItem(text);
        item.setAlignment(Element.ALIGN_JUSTIFIED);
        list.add(item);
        text = "supercalifragilisticexpialidocious ";
        for (int i = 0; i < 3; i++) {
            text = text + text;
        }
        item = new ListItem(text);
        item.setAlignment(Element.ALIGN_JUSTIFIED);
        list.add(item);

        // How to use PdfPTable
        // Utilizacin de PdfPTable

        // We use various elements to add title and subtitle
        // Usamos varios elementos para aadir ttulo y subttulo
        Anchor anchor = new Anchor("Table export to PDF (Exportamos la tabla a PDF)", categoryFont);
        anchor.setName("Table export to PDF (Exportamos la tabla a PDF)");
        Chapter chapTitle = new Chapter(new Paragraph(anchor), 1);
        Paragraph paragraph = new Paragraph("Do it by Xules (Realizado por Xules)", subcategoryFont);
        Section paragraphMore = chapTitle.addSection(paragraph);
        paragraphMore.add(new Paragraph("This is a simple example (Este es un ejemplo sencillo)"));
        Integer numColumns = 6;
        Integer numRows = 120;
        // We create the table (Creamos la tabla).
        PdfPTable table = new PdfPTable(numColumns);
        // Now we fill the PDF table 
        // Ahora llenamos la tabla del PDF
        PdfPCell columnHeader;
        // Fill table rows (rellenamos las filas de la tabla).                
        for (int column = 0; column < numColumns; column++) {
            columnHeader = new PdfPCell(new Phrase("COL " + column));
            columnHeader.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(columnHeader);
        }
        table.setHeaderRows(1);
        // Fill table rows (rellenamos las filas de la tabla).                
        for (int row = 0; row < numRows; row++) {
            for (int column = 0; column < numColumns; column++) {
                table.addCell("Row " + row + " - Col" + column);
            }
        }
        // We add the table (Aadimos la tabla)
        paragraphMore.add(table);
        // We add the paragraph with the table (Aadimos el elemento con la tabla).
        document.add(chapTitle);
        document.close();
        System.out.println("Your PDF file has been generated!(Se ha generado tu hoja PDF!");
    } catch (DocumentException documentException) {
        System.out.println(
                "The file not exists (Se ha producido un error al generar un documento): " + documentException);
    }
}

From source file:de.extra.xtt.util.pdf.PdfCreatorImpl.java

License:Apache License

/**
 * Fr die angegebenen Kindlemente wird ein Listeneintrag fr das PDF
 * erzeugt.//from   w  w  w. j a v a2  s.  c o m
 * 
 * @param childs
 *            Kindelemente
 * @param schemaQueues
 *            Queues mit allen Elementen fr die einzelnen Schemas
 * @param strBullet
 *            Zeichen, das als Aufzhlunsgzeichen fr die Liste verwendet
 *            wird
 * @return PDF-Liste mit den Kindelementen
 */
private List erzeugeListeFuerKindElemente(XSParticle[] childs, Map<String, Queue<XSElementDecl>> schemaQueues,
        String strBullet) {

    List currList = new List(false, 12);
    currList.setListSymbol(strBullet);

    for (XSParticle currChild : childs) {

        if (currChild.getTerm() instanceof ElementDecl) {
            // Elemente von sequence bzw. choice abarbeiten
            XSElementDecl currElement = currChild.getTerm().asElementDecl();

            Phrase currPhrase = new Phrase();

            // Name, inkl. Referenz auf das Element
            currPhrase.add(getChunkTextBoldWithReference(getNameWithPrefix(currElement),
                    getReferenceForElement(currElement)));

            // Auftreten (direkt hinter dem Namen)
            currPhrase.add(getChunkText(" (" + getMinMaxStr(currChild) + ")\n"));

            // Beschreibung
            XSAnnotation currAnn = currChild.getAnnotation();
            if ((currAnn == null) && currElement.isLocal() && (currElement.getAnnotation() != null)) {
                currAnn = currElement.getAnnotation();
            }
            if (currAnn != null) {
                currPhrase.add(getChunkTextItalic(currAnn.getAnnotation().toString() + "\n"));
            }

            currList.add(new ListItem(currPhrase));

            // Element in Queue einfgen
            String currPrefix = getNsPref(currElement.getTargetNamespace());
            schemaQueues.get(currPrefix).add(currElement);

        } else if (currChild.getTerm() instanceof XSModelGroup) {
            // Element von sequence/choice kann wieder eine ModelGroup
            // (sequence/choice) sein
            XSModelGroup mg = currChild.getTerm().asModelGroup();
            XSParticle[] childChilds = mg.getChildren();
            if ((childChilds != null) && (childChilds.length > 0)) {

                // Art der Gruppe
                String strCompositor = "";
                Compositor compositor = mg.getCompositor();
                if (compositor.equals(com.sun.xml.xsom.XSModelGroup.Compositor.SEQUENCE)) {
                    strCompositor = "Sequence:";
                } else if (compositor.equals(com.sun.xml.xsom.XSModelGroup.Compositor.CHOICE)) {
                    strCompositor = "Choice:";
                }
                currList.add(new ListItem(getPhraseTextBold(strCompositor)));

                // neue Liste fr aktuelle Kindelemente erzeugen
                List subList = erzeugeListeFuerKindElemente(childChilds, schemaQueues, bulletSub);

                // Als Subliste hinzufgen
                currList.add(subList);
            }

        } else if (currChild.getTerm() instanceof XSWildcard) {
            // Element von sequence/choice kann ein Wildcard-Objekt sein,
            // z.B. 'xs:any'
            XSWildcard wildCard = currChild.getTerm().asWildcard();
            String currNamespaceStr = wildCard.apply(MySchemaWriter.WILDCARD_NS);

            Phrase currPhrase = new Phrase();
            currPhrase.add(getChunkTextBold("any"));
            currPhrase.add(getChunkText(" (" + getMinMaxStr(currChild) + ")\n"));
            if (currNamespaceStr.length() > 0) {
                currPhrase.add(getChunkText(currNamespaceStr));
            }
            currList.add(new ListItem(currPhrase));
        }
    }
    return currList;
}

From source file:de.extra.xtt.util.pdf.PdfCreatorImpl.java

License:Apache License

/**
 * Fr die Attribute des aktuellen Typs wird eine Liste erzeugt und der
 * angegebenen Sektion hinzugefgt./*from w  ww.j a  va 2 s  .  c  o m*/
 * 
 * @param currType
 *            Schemtyp, fr den die Attribute bestimmt werden
 * @param currSection
 *            Aktuelle Sektion des PDF-Dokuments
 */
private void behandleAttribute(XSType currType, Section currSection) {
    if (currType.isComplexType()) {
        @SuppressWarnings("unchecked")
        Iterator<XSAttGroupDecl> itr1 = (Iterator<XSAttGroupDecl>) currType.asComplexType().iterateAttGroups();
        @SuppressWarnings("unchecked")
        Iterator<XSAttributeUse> itr2 = (Iterator<XSAttributeUse>) currType.asComplexType()
                .iterateAttributeUses();

        if (itr1.hasNext() || itr2.hasNext()) {
            // Abstand
            currSection.add(getEmptyLineTextHalf());

            currSection.add(getParagraphTextBold("Attribute:"));

            List currList = new List(false, 12);
            currList.setListSymbol(bulletMain);

            while (itr1.hasNext()) {
                XSAttGroupDecl currAttr = itr1.next();
                String strAttribute = currAttr.getName();
                currList.add(new ListItem(getPhraseText(strAttribute)));
            }

            while (itr2.hasNext()) {
                XSAttributeDecl currAttr = itr2.next().getDecl();
                String strAttribute = currAttr.getName();
                // Typ kann lokal sein
                if (!currAttr.getType().isLocal()) {
                    strAttribute += " (" + getNameWithPrefix(currAttr.getType()) + ")";
                }
                currList.add(new ListItem(getPhraseText(strAttribute)));
            }
            currSection.add(currList);
        }
    }
}

From source file:edu.esprit.pi.gui.internalframes.PDFwithItextInternalFrame.java

public void createList(Section subCatPart) {
    List list = new List(true, false, 10);
    list.add(new ListItem("Premier point"));
    list.add(new ListItem("Deuxime point"));
    list.add(new ListItem("Troisime point"));
    subCatPart.add(list);/*from   w w  w. j  a v a2s  . c  o m*/
}

From source file:eeebees.PDFGen.java

public static void main(String[] args) {

    try {/*from   ww w. j av  a 2 s.co m*/

        OutputStream file = new FileOutputStream(new File("D:\\PDF_Java4s.pdf"));
        Document document = new Document();
        PdfWriter.getInstance(document, file);

        //Inserting Image in PDF
        //Image image = Image.getInstance ("src/pdf/java4s.png");
        //image.scaleAbsolute(120f, 60f);//image width,height    

        //Inserting Table in PDF
        PdfPTable table = new PdfPTable(3);

        PdfPCell cell = new PdfPCell(new Paragraph("Java4s.com"));

        cell.setColspan(3);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setPadding(10.0f);
        cell.setBackgroundColor(new BaseColor(140, 221, 8));

        table.addCell(cell);

        table.addCell("Name");
        table.addCell("Address");
        table.addCell("Country");
        table.addCell("Java4s");
        table.addCell("NC");
        table.addCell("United States");
        table.setSpacingBefore(30.0f); // Space Before table starts, like margin-top in CSS
        table.setSpacingAfter(30.0f); // Space After table starts, like margin-Bottom in CSS                                          

        //Inserting List in PDF
        List list = new List(true, 30);
        list.add(new ListItem("Java4s"));
        list.add(new ListItem("Php4s"));
        list.add(new ListItem("Some Thing..."));

        //Text formating in PDF
        Chunk chunk = new Chunk("Welecome To Java4s Programming Blog...");
        chunk.setUnderline(+1f, -2f);//1st co-ordinate is for line width,2nd is space between
        Chunk chunk1 = new Chunk("Php4s.com");
        chunk1.setUnderline(+4f, -8f);
        chunk1.setBackground(new BaseColor(17, 46, 193));

        //Now Insert Every Thing Into PDF Document
        document.open();//PDF document opened........                   

        //document.add(image);

        document.add(Chunk.NEWLINE); //Something like in HTML :-)

        document.add(new Paragraph("Dear Java4s.com"));
        document.add(new Paragraph("Document Generated On - " + new Date().toString()));

        document.add(table);

        document.add(chunk);
        document.add(chunk1);

        document.add(Chunk.NEWLINE); //Something like in HTML :-)                                

        document.newPage(); //Opened new page
        document.add(list); //In the new page we are going to add list

        document.close();

        file.close();

        System.out.println("Pdf created successfully..");

    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:eu.aniketos.wp1.ststool.report.pdfgenerator.AbstractContentFactory.java

License:Open Source License

protected Paragraph listParagraphs(List<Paragraph> paragraphs) {

    Paragraph pList = getDefaultParagraph();
    com.itextpdf.text.List list = new com.itextpdf.text.List(com.itextpdf.text.List.UNORDERED);
    list.setListSymbol("\u2022" + " ");
    list.setSymbolIndent(30f);//from w w  w.  j  av  a 2  s  .  c o  m
    pList.add(list);
    pList.setSpacingBefore(0f);
    pList.setSpacingAfter(0f);

    for (Paragraph p : paragraphs) {
        list.add(new ListItem(p));
    }
    return pList;
}

From source file:eu.aniketos.wp1.ststool.report.pdfgenerator.ReportContentFactory.java

License:Open Source License

private void buildSectionAuthorisationFlow(Section section) {

    String sectionIntro = "In this section are described for each role/agent, the authorisations it passes to others and what authorisations it receives from other roles/agents.";
    section.add(createParagraph(sectionIntro));

    List<Actor> selActor = getAuthorisationFlowActors();
    List<com.itextpdf.text.List> lists = new ArrayList<com.itextpdf.text.List>();

    for (Actor a : selActor) {
        StringBuilder sbOut = new StringBuilder();
        for (Authorisation au : a.getOutgoingAuthorisations()) {
            if (isValidAuth(au)) {
                if (sbOut.length() > 0)
                    sbOut.append(", and ");
                sbOut.append("authorises %i" + au.getTarget().getName() + "% to " + getOperations(au)
                        + " information ");
                List<String> resList = new ArrayList<String>();
                for (IResource r : au.getResources())
                    resList.add("%i" + r.getName() + "%");
                sbOut.append(separateListOfString(resList) + ", ");

                List<String> goalList = new ArrayList<String>();
                if (au.getGoals().size() > 0) {
                    sbOut.append("in the scope of goal");
                    if (au.getGoals().size() > 1)
                        sbOut.append("s");
                    // sbOut.append(" ");
                    for (Goal g : au.getGoals()) {
                        goalList.add("%i" + g.getName() + "%");
                    }/*from ww w  . j  a v a2s. c o m*/
                    sbOut.append(" " + separateListOfString(goalList) + ", ");
                }
                if (au.getTimesTransferable() == 0) {
                    sbOut.append("%iwithout% passing");
                } else {
                    sbOut.append("%ipassing%");
                }
                sbOut.append(" the right to further authorising other actors");

                String[] res = new String[resList.size()];
                for (int i = 0; i < resList.size(); i++)
                    res[i] = resList.get(i);
                String[] goals = new String[goalList.size()];
                for (int i = 0; i < goalList.size(); i++)
                    goals[i] = goalList.get(i);
            }
        }

        StringBuilder sbInc = new StringBuilder();
        for (Authorisation au : a.getIncomingAuthorisations()) {
            if (isValidAuth(au)) {
                if (sbInc.length() > 0)
                    sbInc.append(", and ");
                sbInc.append("is authorised by %i" + au.getSource().getName() + "% to " + getOperations(au)
                        + " information ");

                List<String> resList = new ArrayList<String>();

                for (IResource r : au.getResources())
                    resList.add("%i" + r.getName() + "%");
                sbInc.append(separateListOfString(resList) + ", ");

                List<String> goalList = new ArrayList<String>();
                if (au.getGoals().size() > 0) {
                    sbInc.append("in the scope of goal");
                    if (au.getGoals().size() > 1)
                        sbOut.append("s");
                    // sbInc.append(" ");
                    for (Goal g : au.getGoals()) {
                        goalList.add("%i" + g.getName() + "%");
                    }
                    sbInc.append(" " + separateListOfString(goalList) + ", ");
                }
                if (au.getTimesTransferable() == 0) {
                    sbInc.append("%iwithout% having");
                } else {
                    sbInc.append("%ihaving%");
                }
                sbInc.append(" the right to further authorising other actors");

                String[] res = new String[resList.size()];
                for (int i = 0; i < resList.size(); i++)
                    res[i] = resList.get(i);
                String[] goals = new String[goalList.size()];
                for (int i = 0; i < goalList.size(); i++)
                    goals[i] = goalList.get(i);
            }
        }
        if (sbOut.length() > 0 || sbInc.length() > 0) {

            String type = "%iAgent% ";
            if (a instanceof Role)
                type = "%iRole% ";

            Paragraph actorName = createParagraph(type + "%b" + a.getName() + "%:");
            actorName.setSpacingAfter(5);

            com.itextpdf.text.List list = new com.itextpdf.text.List(com.itextpdf.text.List.UNORDERED);
            list.setListSymbol("\u2022" + " ");
            list.setSymbolIndent(10f);
            list.add(new ListItem(actorName));

            if (sbOut.length() > 0) {
                com.itextpdf.text.List sublist = new com.itextpdf.text.List(com.itextpdf.text.List.UNORDERED);
                sublist.setListSymbol("- ");
                sublist.setSymbolIndent(30f);
                // Paragraph p=createParagraph("%b" + a.getName() + "% " +
                // sbOut.toString() + ".");
                Paragraph p = createParagraph(sbOut.toString() + ".");

                if (sbInc.length() > 0) {
                    p.setSpacingAfter(10);
                }

                sublist.add(new ListItem(p));
                list.add(sublist);
            }
            if (sbInc.length() > 0) {
                com.itextpdf.text.List sublist = new com.itextpdf.text.List(com.itextpdf.text.List.UNORDERED);
                sublist.setListSymbol("- ");
                sublist.setSymbolIndent(30f);
                // Paragraph p=createParagraph("%b" + a.getName() + "% " +
                // sbInc.toString() + ".");
                Paragraph p = createParagraph(sbInc.toString() + ".");
                sublist.add(new ListItem(p));
                list.add(sublist);
            }

            lists.add(list);
        }
    }
    if (lists.size() > 0) {
        String s = "In the " + getProjectName() + " project" + autDiagRef()
                + " the authorisations for each role/agent are:";
        section.add(createParagraph(s));
        for (com.itextpdf.text.List list : lists) {
            section.add(list);
        }
    } else {
        section.add(createParagraph("In the " + getProjectName()
                + " project there are no authorisation taking place for the given agents/roles."));
    }
    section.setComplete(true);
}

From source file:eu.aniketos.wp1.ststool.report.pdfgenerator.ReportContentFactory.java

License:Open Source License

private void buildAppendixCChapter(Chapter c, Document d) {

    c.setTitle(getChapterTitleParagraph("Appendix C"));
    c.setNumberDepth(0);// w w w  .  j  a  v  a  2  s .c  o m
    c.setTriggerNewPage(true);

    String sectionIntro = "STS-ml allows for the specification of security needs over actors interactions. It currently supports a non-exhaustive set of security needs and organisational constraints, namely non-repudiation, redundancy, no-delegation, non-usage, non-modification, non-production, non-disclosure and need-to-know. The purpose of security analysis is to verify whether there are any violations of security needs. As such, it includes defining the rules necessary to detect violations. In the following are provided the details for all the checks performed during security analysis.";
    c.add(createParagraph(sectionIntro));

    List<Paragraph> plist = new ArrayList<Paragraph>();

    int kk = 0;

    for (kk = kk; kk < 4; kk++) {
        plist.add(getSecurityAnalysisDescription(SecurityAnalysisTasksNames.ALL_TASKS_NAMES[kk]));
    }
    c.add(listParagraphs(plist));
    plist.clear();

    Paragraph parList = getDefaultParagraph();
    com.itextpdf.text.List list = new com.itextpdf.text.List(com.itextpdf.text.List.UNORDERED);
    list.setListSymbol("\u2022" + " ");
    list.setSymbolIndent(30f);
    parList.add(list);
    parList.setSpacingBefore(0f);
    parList.setSpacingAfter(0f);

    list.add(new ListItem(getSecurityAnalysisDescription(SecurityAnalysisTasksNames.ALL_TASKS_NAMES[kk++])));

    com.itextpdf.text.List subList = new com.itextpdf.text.List(com.itextpdf.text.List.UNORDERED);
    subList.setListSymbol("\u2022" + " ");
    subList.setSymbolIndent(15f);

    for (kk = kk; kk < 10; kk++) {
        subList.add(
                new ListItem(getSecurityAnalysisDescription(SecurityAnalysisTasksNames.ALL_TASKS_NAMES[kk])));
        // plist.add(getSecurityAnalysisDescription(SecurityAnalysisTasksNames.ALL_TASKS_NAMES[kk]));
    }

    list.add(subList);
    c.add(parList);

    /*
     * Paragraph actorName = createParagraph(type + "%b" + a.getName() +
     * "%:"); actorName.setSpacingAfter(5);
     * 
     * com.itextpdf.text.List list = new
     * com.itextpdf.text.List(com.itextpdf.text.List.UNORDERED);
     * list.setListSymbol("\u2022" + " "); list.setSymbolIndent(10f);
     * list.add(new ListItem(actorName));
     * 
     * if (sbOut.length() > 0) { com.itextpdf.text.List sublist = new
     * com.itextpdf.text.List(com.itextpdf.text.List.UNORDERED);
     * sublist.setListSymbol("- "); sublist.setSymbolIndent(30f);
     * //Paragraph p=createParagraph("%b" + a.getName() + "% " +
     * sbOut.toString() + "."); Paragraph p =
     * createParagraph(sbOut.toString() + ".");
     * 
     * if (sbInc.length() > 0) { p.setSpacingAfter(10); }
     * 
     * sublist.add(new ListItem(p)); list.add(sublist);
     */

    String text = "Apart from the verification of violations of security needs, security analysis performs checks to verify that actors comply with their authorities. For this, it searches for eventual unauthorised passages of rights. For the time being, the following violations are detected:";
    c.add(createParagraph(text));

    parList = getDefaultParagraph();
    list = new com.itextpdf.text.List(com.itextpdf.text.List.UNORDERED);
    list.setListSymbol("\u2022" + " ");
    list.setSymbolIndent(30f);
    parList.add(list);
    parList.setSpacingBefore(0f);
    parList.setSpacingAfter(0f);

    list.add(new ListItem(getSecurityAnalysisDescription(SecurityAnalysisTasksNames.ALL_TASKS_NAMES[kk++])));

    subList = new com.itextpdf.text.List(com.itextpdf.text.List.UNORDERED);
    subList.setListSymbol("\u2022" + " ");
    subList.setSymbolIndent(15f);

    for (kk = kk; kk < 16; kk++) {
        subList.add(
                new ListItem(getSecurityAnalysisDescription(SecurityAnalysisTasksNames.ALL_TASKS_NAMES[kk])));
        // plist.add(getSecurityAnalysisDescription(SecurityAnalysisTasksNames.ALL_TASKS_NAMES[kk]));
    }

    list.add(subList);
    c.add(parList);

    text = "As far as organisational constraints are concerned, security analysis verifies that the specification of SoD and BoD constraints can be satisfied in the given model. The satisfaction of role-based SoD and BoD are already covered by the consistency analysis, security analysis deals with goal-based SoD and BoD instead.";
    c.add(createParagraph(text));

    for (kk = kk; kk < SecurityAnalysisTasksNames.ALL_TASKS_NAMES.length; kk++) {
        plist.add(getSecurityAnalysisDescription(SecurityAnalysisTasksNames.ALL_TASKS_NAMES[kk]));
    }
    c.add(listParagraphs(plist));

    c.setComplete(true);
}

From source file:generadorPDF.generarPDF.java

private static void createList(Section subCatPart) {
       List list = new List(true, false, 10);
       list.add(new ListItem("First point"));
       list.add(new ListItem("Second point"));
       list.add(new ListItem("Third point"));
       subCatPart.add(list);// w ww.java  2s  .  co m
   }

From source file:gov.utah.dts.det.ccl.actions.reports.generators.LicenseRenewalLettersReport.java

private static void generateDocumentPage(FacilityLicenseView license, Date today, Document document,
        PdfWriter writer) throws BadElementException, DocumentException, Exception {
    PdfPTable table = null;/*from  w  ww.  j a  va 2s.  c  om*/
    int headerwidths[] = {};
    Paragraph paragraph = null;
    com.itextpdf.text.List blist = null;
    com.itextpdf.text.List subList = null;
    ListItem item = null;
    ListItem subItem = null;
    StringBuilder sb;
    PdfContentByte over = writer.getDirectContent();
    Facility facility = license.getFacility();
    Person licensingSpecialist = null;
    if (facility != null && facility.getLicensingSpecialist() != null) {
        licensingSpecialist = facility.getLicensingSpecialist();
    }

    // Add report date
    paragraph = new Paragraph(fixedLeading);
    paragraph.add(new Phrase(df.format(today), mediumfont));
    paragraph.setIndentationLeft(dateIndent);
    document.add(paragraph);

    // Add facility information
    paragraph = new Paragraph(fixedLeading);
    if (facility != null && StringUtils.isNotBlank(facility.getName())) {
        paragraph.add(new Phrase(facility.getName(), mediumfont));
    } else {
        paragraph.add(BLANK);
    }
    if (facility != null && facility.getMailingAddress() != null
            && StringUtils.isNotBlank(facility.getMailingAddress().getAddressOne())) {
        paragraph.add(Chunk.NEWLINE);
        paragraph.add(new Phrase(facility.getMailingAddress().getAddressOne(), mediumfont));
        if (StringUtils.isNotBlank(facility.getMailingAddress().getAddressTwo())) {
            paragraph.add(Chunk.NEWLINE);
            paragraph.add(new Phrase(facility.getMailingAddress().getAddressTwo(), mediumfont));
        }
        if (StringUtils.isNotBlank(facility.getMailingAddress().getCityStateZip())) {
            paragraph.add(Chunk.NEWLINE);
            paragraph.add(new Phrase(facility.getMailingAddress().getCityStateZip(), mediumfont));
        }
    }
    paragraph.setSpacingBefore(15);
    document.add(paragraph);

    // Add salutation
    paragraph = new Paragraph(fixedLeading);
    sb = new StringBuilder();
    sb.append("Dear ");
    if (StringUtils.isNotBlank(facility.getName())) {
        sb.append(facility.getName());
    }
    paragraph.add(new Phrase(sb.toString(), mediumfont));
    paragraph.setSpacingBefore(pageSeparatorSpace);
    document.add(paragraph);

    // Add due for renewal line
    paragraph = new Paragraph(fixedLeading);
    paragraph.add(new Phrase(
            "Your foster care license is due for renewal on " + df.format(license.getExpirationDate()),
            mediumfontB));
    paragraph.setSpacingBefore(pageSeparatorSpace);
    document.add(paragraph);

    // Add first paragraph
    paragraph = new Paragraph(fixedLeading);
    sb = new StringBuilder();
    sb.append(
            "The Office of Licensing appreciates the services you have provided for DCFS and to the foster children ");
    sb.append(
            "who have been in your care. We hope that you will continue as foster parents for the next year. ");
    sb.append("To continue licensing please complete the following:");
    paragraph.add(new Phrase(sb.toString(), mediumfont));
    paragraph.setSpacingBefore(pageSeparatorSpace);
    paragraph.setSpacingAfter(pageSeparatorSpace);
    document.add(paragraph);

    /*
     * Start of instructions list section
     */
    blist = new com.itextpdf.text.List(false, 20);
    item = new ListItem(fixedLeading);
    item.setListSymbol(new Chunk("1.", mediumfont));
    item.add(new Phrase("Complete the enclosed Renewal Resource Family Application.", mediumfont));
    item.setSpacingAfter(listSpace);
    blist.add(item);

    item = new ListItem(fixedLeading);
    item.setListSymbol(new Chunk("2.", mediumfont));
    sb = new StringBuilder();
    sb.append(
            "Complete the Utah Department of Human Services Office of Licensing Background Screening Application form for everyone ");
    sb.append("18 years of age and older living in the home. Each form must have an original signature.");
    item.add(new Phrase(sb.toString(), mediumfont));
    item.setSpacingAfter(listSpace);
    blist.add(item);

    item = new ListItem(fixedLeading);
    item.setListSymbol(new Chunk("3.", mediumfont));
    paragraph = new Paragraph(fixedLeading);
    paragraph.add(
            new Phrase("For everyone 18 years of age or older living in the home please attach:", mediumfont));
    item.add(paragraph);
    subList = new com.itextpdf.text.List(false, 18);
    subList.setIndentationLeft(10);
    subItem = new ListItem(fixedLeading);
    subItem.setListSymbol(new Chunk("(a)", mediumfontB));
    subItem.add(
            new Phrase("A legible copy of a current drivers license or a Utah State I.D. card.", mediumfontB));
    subList.add(subItem);
    subItem = new ListItem(fixedLeading);
    subItem.setListSymbol(new Chunk("(b)", mediumfontB));
    subItem.add(new Phrase("A legible copy of their social security card.", mediumfontB));
    subList.add(subItem);
    item.add(subList);
    item.setSpacingAfter(listSpace);
    blist.add(item);

    item = new ListItem(fixedLeading);
    item.setListSymbol(new Chunk("4.", mediumfont));
    item.add(new Phrase("Complete the enclosed Foster Care Renewal Information Form.", mediumfont));
    item.setSpacingAfter(listSpace);
    blist.add(item);

    item = new ListItem(fixedLeading);
    item.setListSymbol(new Chunk("5.", mediumfont));
    item.add(new Phrase("Provide copies of income verification (check stubs/or last year's income tax forms.)",
            mediumfontB));
    item.setSpacingAfter(listSpace);
    blist.add(item);

    item = new ListItem(fixedLeading);
    item.setListSymbol(new Chunk("6.", mediumfont));
    item.add(new Phrase("All paperwork must be returned 30 days before your license expires to:", mediumfontB));
    subList = new com.itextpdf.text.List(false, 0);
    subList.setListSymbol(new Chunk(" ", mediumfont));
    subList.setIndentationLeft(10);
    subItem = new ListItem(fixedLeading);
    subItem.add(new Phrase("Office of Licensing", mediumfont));
    subItem.setSpacingBefore(listItemSpace);
    subList.add(subItem);
    subItem = new ListItem(fixedLeading);
    if (licensingSpecialist != null && StringUtils.isNotBlank(licensingSpecialist.getFirstAndLastName())) {
        subItem.add(new Phrase(licensingSpecialist.getFirstAndLastName(), mediumfont));
    } else {
        subItem.add(new Phrase("<Facility Licensing Specialist>", mediumfont));
    }
    subList.add(subItem);
    if (licensingSpecialist != null && licensingSpecialist.getAddress() != null
            && StringUtils.isNotBlank(licensingSpecialist.getAddress().getAddressOne())) {
        subItem = new ListItem(fixedLeading);
        subItem.add(new Phrase(licensingSpecialist.getAddress().getAddressOne(), mediumfont));
        subList.add(subItem);
    }
    if (licensingSpecialist != null && licensingSpecialist.getAddress() != null
            && StringUtils.isNotBlank(licensingSpecialist.getAddress().getAddressTwo())) {
        subItem = new ListItem(fixedLeading);
        subItem.add(new Phrase(licensingSpecialist.getAddress().getAddressTwo(), mediumfont));
        subList.add(subItem);
    }
    if (licensingSpecialist != null && licensingSpecialist.getAddress() != null
            && StringUtils.isNotBlank(licensingSpecialist.getAddress().getCityStateZip())) {
        subItem = new ListItem(fixedLeading);
        subItem.add(new Phrase(licensingSpecialist.getAddress().getCityStateZip(), mediumfont));
        subList.add(subItem);
    }
    item.add(subList);
    item.setSpacingAfter(listSpace);
    blist.add(item);

    item = new ListItem(fixedLeading);
    item.setListSymbol(new Chunk("7.", mediumfont));
    item.add(new Phrase(
            "Please call and schedule an appointment with me for your annual health and safety check.",
            mediumfont));
    item.setSpacingAfter(listSpace);
    blist.add(item);

    item = new ListItem(fixedLeading);
    item.setListSymbol(new Chunk("8.", mediumfont));
    paragraph = new Paragraph(fixedLeading);
    sb = new StringBuilder();
    sb.append(
            "Complete the DCFS required renewal training of 12 hours for the primary provider and 4 hours for a spouse ");
    sb.append(
            "before your license expires. Please send all training to be approved and documented to the Utah Foster Care Foundation.");
    paragraph.add(new Phrase(sb.toString(), mediumfont));
    item.add(paragraph);
    paragraph = new Paragraph(fixedLeading);
    sb = new StringBuilder();
    sb.append(
            "The Utah Foster Care Foundation will then provide verification of all completed required training ");
    sb.append("to your local licensor.");
    paragraph.add(new Phrase(sb.toString(), mediumfontB));
    item.add(paragraph);
    blist.add(item);

    document.add(blist);
    /*
     * End of instructions list section
     */

    // Add final paragraph
    paragraph = new Paragraph(fixedLeading);
    paragraph.setSpacingBefore(pageSeparatorSpace);
    paragraph.add(new Phrase(
            "Your license will expire if all renewal requirements are not completed by the end of the licensing month. ",
            mediumfont));
    paragraph.add(new Phrase(
            "A license expired beyond 30 days will require initiation of the background screening process again (including ",
            mediumfontB));
    paragraph.add(new Phrase("any necessary fingerprinting). ", mediumfontB));
    paragraph.add(new Phrase(
            "If you choose to discontinue providing services or have any questions, please contact me at ",
            mediumfont));
    if (licensingSpecialist.getWorkPhone() != null
            && StringUtils.isNotBlank(licensingSpecialist.getWorkPhone().getFormattedPhoneNumber())) {
        paragraph.add(new Phrase(licensingSpecialist.getWorkPhone().getFormattedPhoneNumber(), mediumfontB));
    }
    paragraph.add(new Phrase(".", mediumfontB));
    document.add(paragraph);

    // Add closing
    paragraph = new Paragraph(fixedLeading);
    paragraph.setIndentationLeft(rightIndent);
    paragraph.setSpacingBefore(2 * pageSeparatorSpace);
    paragraph.add(new Phrase("Sincerely,", mediumfont));
    document.add(paragraph);

    paragraph = new Paragraph(fixedLeading);
    paragraph.setIndentationLeft(rightIndent);
    paragraph.setSpacingBefore(3 * pageSeparatorSpace);
    if (licensingSpecialist != null && StringUtils.isNotBlank(licensingSpecialist.getFirstAndLastName())) {
        paragraph.add(new Phrase(licensingSpecialist.getFirstAndLastName(), mediumfont));
    } else {
        paragraph.add(new Phrase("<Facility Licensing Specialist>", mediumfont));
    }
    paragraph.add(Chunk.NEWLINE);
    paragraph.add(new Phrase("Foster Family Licensing Specialist", mediumfont));
    document.add(paragraph);

    // Add Enclosures
    paragraph = new Paragraph(fixedLeading);
    paragraph.setSpacingBefore(pageSeparatorSpace);
    paragraph.add(new Phrase("Enclosures", mediumfont));
    paragraph.add(Chunk.NEWLINE);
    paragraph.add(new Phrase("cc: Provider Record", mediumfont));
    document.add(paragraph);
}