Example usage for com.itextpdf.text List add

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

Introduction

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

Prototype

public boolean add(final Element o) 

Source Link

Document

Adds an Element to the List.

Usage

From source file:com.havoc.hotel.util.BookingPdf.java

public static String generateBookingPDF(Booking booking)
        throws DocumentException, FileNotFoundException, IOException {
    Document document = new Document(PageSize.A4);
    String bookingname = booking.getFirstName() + " " + booking.getLastName();
    document.addHeader("HOTEL HAVOC", "Hotel havoc Booking confirmation");
    PdfWriter writer = PdfWriter.getInstance(document,
            new FileOutputStream(FILE + "Booking" + "" + booking.getCustomer().getFirstName() + ".pdf "));
    writer.setViewerPreferences(PdfWriter.PageModeUseOC);
    writer.setPdfVersion(PdfWriter.VERSION_1_7);
    document.open();/*from   w  w  w. ja  v a 2s. c om*/
    String html = htmlTemplate(booking);

    List unorderedList = new List(List.UNORDERED);

    unorderedList.add(new ListItem("Name       :" + booking.getFirstName() + " " + booking.getLastName()));
    //        unorderedList.add(new ListItem("Room Price :" + booking.getRoom().getRoomPrice()));
    unorderedList.add(new ListItem("Total Price :" + booking.getTotalPrice()));
    unorderedList.add(new ListItem("check in   :" + booking.getCheckinDate()));
    unorderedList.add(new ListItem("Total Nights:" + booking.getTotalNights()));
    unorderedList.add(new ListItem("check out  :" + booking.getCheckoutDate()));
    unorderedList.add(new ListItem("Booked By  :" + booking.getCustomer().getUsername()));

    document.add(unorderedList);
    document.close();
    return bookingname;

}

From source file:com.poscoict.license.service.CertificateService.java

public Map<String, Object> getLicenseCertification(String userNo, String licenseFileName,
        HttpServletRequest req) throws Exception {
    logger.info("_________getLicenseCertification: " + userNo + " " + licenseFileName);
    String PDFFileName = userNo + licenseFileName;
    String PDFFilePath = Consts.PDF_PATH + PDFFileName + ".pdf";
    String ImgFilePath = Consts.IMG_PATH + PDFFileName + "1." + Consts.IMG_FORMAT;

    Map<String, Object> map = new HashMap<String, Object>();
    map.put("PDFFileName", PDFFileName + ".pdf");
    map.put("ImgFileName", PDFFileName + "1." + Consts.IMG_FORMAT);

    Map<String, Object> licenseInfo = (Map<String, Object>) managementDao.getLicenseCertification(userNo,
            licenseFileName);/*from  w ww .  j a v  a  2  s.  c om*/

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

        Paragraph p0 = new Paragraph(" ");
        Paragraph p1 = null;

        p1 = setParagraph("License Certificate", Fonts.FONT20BOLD);
        p1.setAlignment(Paragraph.ALIGN_CENTER);
        document.add(p1);

        document.add(p0);
        document.add(p0);

        document.add(
                setParagraph("? End User (?) : " + licenseInfo.get("USER_NAME"), Fonts.FONT12BOLD));
        document.add(
                setParagraph("? Address (): " + licenseInfo.get("USER_ADDRESS"), Fonts.FONT12BOLD));
        document.add(
                setParagraph("? Project (): " + licenseInfo.get("PROJECT_NAME"), Fonts.FONT12BOLD));

        document.add(p0);

        PdfPTable table = new PdfPTable(2);
        table.setWidthPercentage(100);

        PdfPCell cell;
        cell = new PdfPCell(new Phrase(" Product Description", getFont(Fonts.FONT12BOLD)));
        cell.setFixedHeight(30);
        cell.setPaddingTop(8f);
        table.addCell(cell);
        cell = new PdfPCell(new Phrase(" " + licenseInfo.get("PRODUCT_FILE_NAME"), getFont(Fonts.FONT12NOAML)));
        cell.setFixedHeight(30);
        cell.setPaddingTop(8f);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(" License Number", getFont(Fonts.FONT12BOLD)));
        cell.setFixedHeight(30);
        cell.setPaddingTop(8f);
        table.addCell(cell);
        cell = new PdfPCell(new Phrase(" " + licenseInfo.get("LICENSE_KEY"), getFont(Fonts.FONT12NOAML)));
        cell.setFixedHeight(30);
        cell.setPaddingTop(8f);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(" Quantity", getFont(Fonts.FONT12BOLD)));
        cell.setFixedHeight(30);
        cell.setPaddingTop(8f);
        table.addCell(cell);
        cell = new PdfPCell(
                new Phrase(" " + licenseInfo.get("LICENSE_QUANTITY") + " EA", getFont(Fonts.FONT12NOAML)));
        cell.setFixedHeight(30);
        cell.setPaddingTop(8f);
        table.addCell(cell);

        document.add(table);

        document.add(p0);

        List list = new List(false, 20);
        list.add(new ListItem(
                " License Certificate  ?? ? ?  ? ?   ?? ??.",
                getFont(Fonts.FONT12NOAML)));
        list.add(new ListItem(
                "License Certificate ?  ??  ? ?  ?    ?  ?.",
                getFont(Fonts.FONT12NOAML)));
        list.add(new ListItem(",  ? ?? .",
                getFont(Fonts.FONT12NOAML)));
        document.add(list);

        document.add(p0);
        document.add(p0);
        document.add(p0);
        document.add(p0);
        document.add(p0);
        document.add(p0);
        document.add(p0);
        document.add(p0);

        p1 = setParagraph(licenseInfo.get("USER_START_DATE").toString(), Fonts.FONT20BOLD);
        p1.setAlignment(Paragraph.ALIGN_CENTER);
        document.add(p1);
        p1 = setParagraph(licenseInfo.get("COMPANY_NAME").toString(), Fonts.FONT20BOLD);
        p1.setAlignment(Paragraph.ALIGN_CENTER);
        document.add(p1);

        //         Image img = Image.getInstance(Consts.SIGNET_IMG_PATH);
        //         img.setAbsolutePosition(350f, 390f);
        //         document.add(img);

        document.close();
    } catch (DocumentException de) {
        logger.error(ImgFilePath, de);
    } catch (IOException ioe) {
        logger.error(ImgFilePath, ioe);
    }

    String temp = req.getSession().getServletContext().getRealPath(Consts.IMG_TEMP_FOLDER);
    System.out.println("________________________________________________" + temp);
    if (extractPagesAsImage(PDFFilePath, PDFFileName, 100, "")) {
        fileCopy(ImgFilePath, temp + File.separator + map.get("ImgFileName"));
    }

    return map;
}

From source file:com.poscoict.license.service.CertificateService.java

public Map<String, Object> getTechSupportCertificationInfo(String userNo, String productFileId,
        HttpServletRequest req) throws Exception {
    logger.info("_________getTechSupportCertificationInfo: " + userNo + " " + productFileId);

    String PDFFileName = userNo + "_TechSupportCertification";
    String PDFFilePath = Consts.PDF_PATH + PDFFileName + ".pdf";
    String ImgFilePath = Consts.IMG_PATH + PDFFileName + "1." + Consts.IMG_FORMAT;

    Map<String, Object> map = new HashMap<String, Object>();
    map.put("PDFFileName", PDFFileName + ".pdf");
    map.put("ImgFileName", PDFFileName + "1." + Consts.IMG_FORMAT);

    Map<String, Object> productInfo = managementDao.getTechSupportCertificationInfo(userNo, productFileId);

    if (productInfo.get("TECH_SUPPORT_DATE").equals("0")) {
        throw new UserException(
                "? ? .  ?? ?.");
    }/*  ww w  .  ja  v  a 2  s .  co  m*/

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

        Paragraph p0 = new Paragraph(" ");
        Paragraph p1 = null;

        Paragraph header = new Paragraph("? ", getFont(Fonts.FONT20BOLD));
        header.setAlignment(Paragraph.ALIGN_CENTER);
        document.add(header);

        document.add(p0);
        document.add(p0);
        document.add(p0);

        p1 = setParagraph("POSCO ICT   ?  ?  "
                + productInfo.get("PRODUCT_FILE_NAME") + " ? ,"
                + " ?  ? ??  ?  ?  ?"
                + " ?  .", Fonts.FONT18NOAML);
        document.add(p1);

        document.add(p0);
        document.add(p0);

        p1 = setParagraph("-     -", Fonts.FONT18NOAML);
        p1.setAlignment(Paragraph.ALIGN_CENTER);
        document.add(p1);

        document.add(p0);
        document.add(p0);

        List list = new List(false, 30);
        list.add(new ListItem("? ?     ? : " + productInfo.get("USER_START_DATE"),
                getFont(Fonts.FONT18NOAML)));
        list.add(new ListItem("?    : " + productInfo.get("PRODUCT_FILE_NAME") + " ("
                + productInfo.get("LICENSE_QUANTITY") + "?)", getFont(Fonts.FONT18NOAML)));
        list.add(new ListItem("?   ? : POSCO ICT", getFont(Fonts.FONT18NOAML)));
        list.add(new ListItem("?    : " + productInfo.get("PROJECT_NAME"),
                getFont(Fonts.FONT18NOAML)));
        list.add(new ListItem("?  : " + productInfo.get("COMPANY_NAME"),
                getFont(Fonts.FONT18NOAML)));
        list.add(new ListItem("? ?  : " + productInfo.get("TECH_SUPPORT_DATE"),
                getFont(Fonts.FONT18NOAML)));
        document.add(list);

        document.add(p0);
        document.add(p0);
        document.add(p0);

        p1 = setParagraph("POSCO ICT", Fonts.FONT20BOLD);
        p1.setAlignment(Paragraph.ALIGN_CENTER);
        document.add(p1);

        //         Image img = Image.getInstance(Consts.SIGNET_IMG_PATH);
        //         img.setAbsolutePosition(350f, 260f);
        //         document.add(img);

        document.close();
    } catch (DocumentException de) {
        logger.error(ImgFilePath, de);
    } catch (IOException ioe) {
        logger.error(ImgFilePath, ioe);
    }

    String temp = req.getSession().getServletContext().getRealPath(Consts.IMG_TEMP_FOLDER);
    if (extractPagesAsImage(PDFFilePath, PDFFileName, 100, "")) {
        fileCopy(ImgFilePath, temp + File.separator + map.get("ImgFileName"));
    }

    return map;
}

From source file:com.zaptech.pdfdemo.MainActivity.java

private void createList(Section section) {
    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"));
    section.add(list);/*w w  w.j av a  2  s . c o  m*/
}

From source file:Controller.CrearPDF.java

/**
 * We create a PDF document with iText using different elements to learn 
 * to use this library.// w  w w.jav a2 s. c  o 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

/**
 * Alle Elemente, die sich fr das angegebene Schema in der entsprechenden
 * Queue befinden, werden behandelt./*from ww  w .  j a v a2 s  . com*/
 * 
 * @param currSchemaPrefix
 *            Prfix des zu behandelnden Schemas
 * @param schemaQueues
 *            Map enthlt Queues fr jedes Schema (Key ist der
 *            Namepace-Prfix)
 * @param xmlSchemaSet
 *            SchemaSet, in dem alle Typen und Elemente definiert sind
 * @throws DocumentException
 */
private void behandleSchemaQueue(String currSchemaPrefix, Map<String, Queue<XSElementDecl>> schemaQueues,
        XSSchemaSet xmlSchemaSet) throws DocumentException {

    // Liste mit allen bereits behandelten Elementen
    java.util.List<XSElementDecl> listElementsInserted = new LinkedList<XSElementDecl>();

    // Aktuelle Queue
    Queue<XSElementDecl> currQueue = schemaQueues.get(currSchemaPrefix);

    if (currQueue != null) {

        // zur Sicherheit nochmal alle Elemente dieses Schema in Queue
        // einfgen
        // damit ist sichergestellt, dass auch nicht direkt verknpfte
        // Elemente (any => Plugins) behandelt werden
        XSSchema currSchema = xmlSchemaSet.getSchema(configurator.getPropertyNamespace(currSchemaPrefix));
        for (Entry<String, XSElementDecl> currElement : currSchema.getElementDecls().entrySet()) {
            currQueue.add(currElement.getValue());
        }

        if (currQueue.peek() != null) {
            // Kapitel inkl. Sprungmarke erstellen
            String targetNsUrl = currQueue.peek().getTargetNamespace();
            String chapterTitle = getNsPref(targetNsUrl) + ":" + targetNsUrl;
            chapterCounter++;
            Chunk chunkChapter = getChunkChapter(chapterTitle);
            chunkChapter.setLocalDestination(chapterTitle);
            Chapter currChapter = new Chapter(new Paragraph(chunkChapter), chapterCounter);

            // Kapitel dem Dokument hinzufgen
            docPdf.add(currChapter);

            // Eintrag fr Inhaltsverzeichnis (Chapter)
            ContPdfEntry currEntry = new ContPdfEntry(null, currChapter.getTitle().getContent(), chapterTitle,
                    currPageNumber);
            listEntries.add(currEntry);

            while (currQueue.peek() != null) {
                // Aktuelles Element aus Queue holen
                XSElementDecl currElement = currQueue.poll();
                if (!listElementsInserted.contains(currElement)) {
                    behandleElement(currElement, currChapter, currEntry, schemaQueues);
                    listElementsInserted.add(currElement);
                }
            }
        }
    }
}

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

License:Apache License

/**
 * Fr die angegebenen Kindlemente wird ein Listeneintrag fr das PDF
 * erzeugt.// w  ww . j  a  v a 2s. com
 * 
 * @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./*w w w  .  j ava  2 s. co 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.clemson.lph.pdfgen.PDFGen.java

License:Open Source License

private void printDoc() {
    if (sSourceFile == null || osDest == null) {
        logger.error("Cannot print nothing");
        return;//from ww  w .ja  v a  2  s  . com
    }
    boolean bBold = false;
    boolean bCenter = false;
    boolean bItalic = false;
    boolean bSmallItalic = false;
    boolean bUnderline = false;
    try {
        Document doc = new Document();
        float fCorr = doc.getPageSize().getWidth() / 8.5f;
        doc.setMargins(1.0f * fCorr, 1.0f * fCorr, 1.0f * fCorr, 1.0f * fCorr);

        PdfWriter.getInstance(doc, osDest);
        doc.open();
        BufferedReader br = new BufferedReader(new FileReader(sSourceFile));
        String sLine = br.readLine();
        while (sLine != null) {
            bBold = false;
            bCenter = false;
            if (sLine.startsWith(".")) {
                String sRest = sLine.substring(1);
                String sCodes = sRest.substring(0, sRest.indexOf('.'));
                sLine = sRest.substring(sRest.indexOf('.') + 1);
                if ("image".equals(sCodes)) {
                    String sFileName = sLine;
                    com.itextpdf.text.Image image = com.itextpdf.text.Image.getInstance(sFileName);
                    image.setAlignment(Element.ALIGN_CENTER);
                    doc.add(image);
                    sLine = br.readLine();
                    continue;
                } else if ("himage".equals(sCodes)) {
                    String sFileName = sLine;
                    com.itextpdf.text.Image image = com.itextpdf.text.Image.getInstance(sFileName);
                    image.scaleToFit(500, 40);
                    image.setAlignment(Element.ALIGN_CENTER);
                    doc.add(image);
                    Paragraph p = new Paragraph(" ");
                    doc.add(p);
                    sLine = br.readLine();
                    continue;
                } else if ("fimage".equals(sCodes)) {
                    int iBlanks = 9; // How do I figure out how many to get to end?
                    for (int i = 0; i < iBlanks; i++) {
                        Paragraph p = new Paragraph(" ");
                        doc.add(p);
                    }
                    String sFileName = sLine;
                    com.itextpdf.text.Image image = com.itextpdf.text.Image.getInstance(sFileName);
                    image.scaleToFit(500, 40);
                    image.setAlignment(Element.ALIGN_CENTER);
                    doc.add(image);
                    sLine = br.readLine();
                    continue;
                } else if ("list".equals(sCodes)) {
                    String sFullLine = doSub(sLine);
                    StringTokenizer tok = new StringTokenizer(sFullLine, "\n");
                    List list = new List(List.UNORDERED);
                    while (tok.hasMoreTokens()) {
                        String sNextLine = tok.nextToken();
                        ListItem listItem = new ListItem(sNextLine, fNormal);
                        list.add(listItem);
                    }
                    doc.add(list);
                    sLine = br.readLine();
                    continue;
                }
                if (sCodes.contains("b"))
                    bBold = true;
                if (sCodes.contains("c"))
                    bCenter = true;
                if (sCodes.contains("i"))
                    bItalic = true;
                if (sCodes.contains("si"))
                    bSmallItalic = true;
                if (sCodes.contains("u"))
                    bUnderline = true;
            }
            if (sLine.trim().length() == 0)
                sLine = " ";

            String sFullLine = doSub(sLine);
            Paragraph p = new Paragraph();
            if (bBold)
                p.setFont(fBold);
            else if (bSmallItalic)
                p.setFont(fSmallItalic);
            else if (bItalic)
                p.setFont(fItalic);
            else if (bUnderline)
                p.setFont(fUnderline);
            else
                p.setFont(fNormal);
            if (bCenter) {
                p.setAlignment(Element.ALIGN_CENTER);
            } else {
                p.setAlignment(Element.ALIGN_LEFT);
            }
            p.add(sFullLine);
            doc.add(p);
            sLine = br.readLine();
        }
        br.close();
        doc.close();
    } catch (FileNotFoundException e) {
        logger.error("Could not find source file " + sSourceFile + " or destination", e);
    } catch (IOException e) {
        logger.error("Could not read file " + sSourceFile, e);
    } catch (DocumentException e) {
        logger.error("Error creating iText Document", e);
    }
}

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);/*  w  ww.  j a v  a 2 s . c  o m*/
}