Package com.lowagie.text

Examples of com.lowagie.text.Chunk


            int style = f.getStyle();
            style &= ~LwgFont.UNDERLINE;
            style &= ~LwgFont.STRIKETHRU;
            f.setStyle(style);
        }
        Chunk space = new Chunk(" ", f);
        space.process(this);
        carriageReturn();
        leading = oldleading;
    }
View Full Code Here


    }
   
    private LwgPhrase composePhrase(String text, BaseFont ufont, Color color, float fontSize) {
        LwgPhrase phrase = null;
        if (extensionFont == null && (substitutionFonts == null || substitutionFonts.isEmpty()))
            phrase = new LwgPhrase(new Chunk(text, new LwgFont(ufont, fontSize, 0, color)));
        else {
            FontSelector fs = new FontSelector();
            fs.addFont(new LwgFont(ufont, fontSize, 0, color));
            if (extensionFont != null)
                fs.addFont(new LwgFont(extensionFont, fontSize, 0, color));
View Full Code Here

                    app.setGrayFill(0);
                else
                    app.setColorFill(textColor);
                app.beginText();
                for (int k = 0; k < phrase.size(); ++k) {
                    Chunk ck = (Chunk)phrase.get(k);
                    BaseFont bf = ck.getFont().getBaseFont();
                    app.setFontAndSize(bf, usize);
                    StringBuffer sb = ck.append("");
                    for (int j = 0; j < sb.length(); ++j) {
                        String c = sb.substring(j, j + 1);
                        float wd = bf.getWidthPoint(c, usize);
                        app.setTextMatrix(extraMarginLeft + start - wd / 2, offsetY - extraMarginTop);
                        app.showText(c);
View Full Code Here

     * @return Returns the Chunk.
     */
    public Chunk create(final String text, final String in1, final String in2,
            final String in3) {

        Chunk chunk = new Chunk(text);
        String tag = "idx_" + (indexcounter++);
        chunk.setGenericTag(tag);
        chunk.setLocalDestination(tag);
        Entry entry = new Entry(in1, in2, in3, tag);
        indexentry.add(entry);
        return chunk;
    }
View Full Code Here

     */
    public PdfOutline(PdfOutline parent, PdfAction action, Paragraph title, boolean open) {
        super();
        StringBuffer buf = new StringBuffer();
        for (Iterator i = title.getChunks().iterator(); i.hasNext(); ) {
            Chunk chunk = (Chunk) i.next();
            buf.append(chunk.getContent());
        }
        this.action = action;
        initOutline(parent, buf.toString(), open);
    }
View Full Code Here

     */
    public PdfOutline(PdfOutline parent, PdfDestination destination, Paragraph title, boolean open) {
        super();
        StringBuffer buf = new StringBuffer();
        for (Iterator i = title.getChunks().iterator(); i.hasNext(); ) {
            Chunk chunk = (Chunk) i.next();
            buf.append(chunk.getContent());
        }
        this.destination = destination;
        initOutline(parent, buf.toString(), open);
    }
View Full Code Here

                paragraph.add(Chunk.NEWLINE);
                paragraph.add(Chunk.NEWLINE);
                paragraph.add(Chunk.NEWLINE);
                paragraph.add(theLogo);

                Chunk institution = new Chunk("Swinburne University of Technology", new Font(Font.TIMES_ROMAN, 24, Font.BOLD));
                Chunk institution2 = new Chunk("(Sarawak Campus)", new Font(Font.TIMES_ROMAN, 24, Font.BOLD));
                paragraph.add(Chunk.NEWLINE);
                paragraph.add(Chunk.NEWLINE);
                paragraph.add(Chunk.NEWLINE);
                paragraph.add(institution);
                paragraph.add(Chunk.NEWLINE);
                paragraph.add(Chunk.NEWLINE);
                paragraph.add(institution2);

                Chunk theProjectDesc = new Chunk(projectDesc, new Font(Font.TIMES_ROMAN, 16, Font.BOLD));
                paragraph.add(Chunk.NEWLINE);
                paragraph.add(Chunk.NEWLINE);
                paragraph.add(Chunk.NEWLINE);
                paragraph.add(Chunk.NEWLINE);
                paragraph.add(theProjectDesc);

                Chunk theAuthor = new Chunk(author, new Font(Font.TIMES_ROMAN, 16, Font.NORMAL));
                paragraph.add(Chunk.NEWLINE);
                paragraph.add(Chunk.NEWLINE);
                paragraph.add(Chunk.NEWLINE);
                paragraph.add(theAuthor);

                String DATE_FORMAT_NOW = "MMMM yyyy";
                Calendar c = Calendar.getInstance();
                SimpleDateFormat dateFormatted = new SimpleDateFormat(DATE_FORMAT_NOW);
                String theDate = dateFormatted.format(c.getTime());
                Chunk date = new Chunk(theDate, new Font(Font.TIMES_ROMAN, 14, Font.NORMAL));
                paragraph.add(Chunk.NEWLINE);
                paragraph.add(Chunk.NEWLINE);
                paragraph.add(Chunk.NEWLINE);
                paragraph.add(Chunk.NEWLINE);
                paragraph.add(date);

                paragraph.setAlignment(Element.ALIGN_CENTER);
                doc.add(paragraph);
                doc.newPage();
            }

            // Add the table into the PDF file
            addTables(doc);

            doc.newPage();

            // Add the result graph into the PDF File
            Chunk graphName = new Chunk("The Result Graph", new Font(Font.TIMES_ROMAN, 18, Font.BOLD));
            Paragraph pGraph = new Paragraph();
            pGraph.add(graphName);
            doc.add(pGraph);
            doc.add(Chunk.NEWLINE);
View Full Code Here

                paragraph.add(Chunk.NEWLINE);
                paragraph.add(Chunk.NEWLINE);
                paragraph.add(Chunk.NEWLINE);
                paragraph.add(theLogo);

                Chunk institution = new Chunk("Swinburne University of Technology", new Font(Font.TIMES_ROMAN, 24, Font.BOLD));
                Chunk institution2 = new Chunk("(Sarawak Campus)", new Font(Font.TIMES_ROMAN, 24, Font.BOLD));
                paragraph.add(Chunk.NEWLINE);
                paragraph.add(Chunk.NEWLINE);
                paragraph.add(Chunk.NEWLINE);
                paragraph.add(Chunk.NEWLINE);
                paragraph.add(Chunk.NEWLINE);
                paragraph.add(institution);
                paragraph.add(Chunk.NEWLINE);
                paragraph.add(Chunk.NEWLINE);
                paragraph.add(institution2);

                Chunk theProjectDesc = new Chunk(projectDesc, new Font(Font.TIMES_ROMAN, 16, Font.BOLD));
                paragraph.add(Chunk.NEWLINE);
                paragraph.add(Chunk.NEWLINE);
                paragraph.add(Chunk.NEWLINE);
                paragraph.add(Chunk.NEWLINE);
                paragraph.add(Chunk.NEWLINE);
                paragraph.add(theProjectDesc);

                Chunk theAuthor = new Chunk(author, new Font(Font.TIMES_ROMAN, 16, Font.NORMAL));
                paragraph.add(Chunk.NEWLINE);
                paragraph.add(Chunk.NEWLINE);
                paragraph.add(Chunk.NEWLINE);
                paragraph.add(Chunk.NEWLINE);
                paragraph.add(Chunk.NEWLINE);
                paragraph.add(theAuthor);

                String DATE_FORMAT_NOW = "MMMM yyyy";
                Calendar c = Calendar.getInstance();
                SimpleDateFormat dateFormatted = new SimpleDateFormat(DATE_FORMAT_NOW);
                String theDate = dateFormatted.format(c.getTime());
                Chunk date = new Chunk(theDate, new Font(Font.TIMES_ROMAN, 14, Font.NORMAL));
                paragraph.add(Chunk.NEWLINE);
                paragraph.add(Chunk.NEWLINE);
                paragraph.add(Chunk.NEWLINE);
                paragraph.add(Chunk.NEWLINE);
                paragraph.add(Chunk.NEWLINE);
                paragraph.add(Chunk.NEWLINE);
                paragraph.add(date);

                paragraph.setAlignment(Element.ALIGN_CENTER);
                doc.add(paragraph);
                doc.newPage();
            }

            // Add the table into the PDF file
            addTables(doc);

            doc.newPage();

            // Add the result graph into the PDF File
            Chunk graphName = new Chunk("The Result Graph", new Font(Font.TIMES_ROMAN, 18, Font.BOLD));
            Paragraph pGraph = new Paragraph(graphName);
            doc.add(pGraph);

            for(int i = 0; i <= 6; i++)
            {
View Full Code Here

     *  document object
     */
    public void addTables(Document doc) {
        try {
            // Create the title for the data table
            Chunk theDataTable = new Chunk("The Data Table", new Font(Font.TIMES_ROMAN, 18, Font.BOLD));
            Paragraph pData = new Paragraph(theDataTable);
            pData.setAlignment(Element.ALIGN_CENTER);
            doc.add(pData);
            doc.add(Chunk.NEWLINE);

            // Generates the data table
            int rowNo = 5;
            PdfPTable dataTableHeader = new PdfPTable(rowNo);
            PdfPCell dataTblHeaderCell;

            Phrase pTemp = new Phrase("NODE", FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.BOLD));
            dataTblHeaderCell = new PdfPCell(pTemp);
            dataTblHeaderCell.setHorizontalAlignment(Element.ALIGN_CENTER);
            dataTableHeader.addCell(dataTblHeaderCell);
            pTemp = new Phrase("DEPTH"+"\n"+"(m)", FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.BOLD));
            dataTblHeaderCell = new PdfPCell(pTemp);
            dataTblHeaderCell.setHorizontalAlignment(Element.ALIGN_CENTER);
            dataTableHeader.addCell(dataTblHeaderCell);
            pTemp = new Phrase("MODULUS OF SUBGRADE REACTION"+"\n"+"(kN/m)", FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.BOLD));
            dataTblHeaderCell = new PdfPCell(pTemp);
            dataTblHeaderCell.setHorizontalAlignment(Element.ALIGN_CENTER);
            dataTableHeader.addCell(dataTblHeaderCell);
            pTemp = new Phrase("LATERAL SOIL MOVEMENTS"+"\n"+"(m)", FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.BOLD));
            dataTblHeaderCell = new PdfPCell(pTemp);
            dataTblHeaderCell.setHorizontalAlignment(Element.ALIGN_CENTER);
            dataTableHeader.addCell(dataTblHeaderCell);
            pTemp = new Phrase("LIMIT SOIL PRESSURE"+"\n"+"(kN/m²)", FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.BOLD));
            dataTblHeaderCell = new PdfPCell(pTemp);
            dataTblHeaderCell.setHorizontalAlignment(Element.ALIGN_CENTER);
            dataTableHeader.addCell(dataTblHeaderCell);

            PdfPCell dataTblCell;
           
            PdfPTable dataTable = new PdfPTable(rowNo);
            for (int i = 0; i <= data.getNumOfElements(); i++) {

                Phrase pNode = new Phrase(Integer.toString(i), FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.BOLD));
                dataTblCell = new PdfPCell(pNode);
                dataTblCell.setHorizontalAlignment(Element.ALIGN_CENTER);
                dataTable.addCell(dataTblCell);
                Phrase pPileNodeCoord = new Phrase(Double.toString(data.getPileNodeCoordinate(i)), FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.NORMAL));
                dataTblCell = new PdfPCell(pPileNodeCoord);
                dataTblCell.setHorizontalAlignment(Element.ALIGN_CENTER);
                dataTable.addCell(dataTblCell);
                Phrase pModOfSub = new Phrase(Double.toString(data.getModOfSubgradeReaction(i)), FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.NORMAL));
                dataTblCell = new PdfPCell(pModOfSub);
                dataTblCell.setHorizontalAlignment(Element.ALIGN_CENTER);
                dataTable.addCell(dataTblCell);
                Phrase pLateralSoilMov = new Phrase(Double.toString(data.getLateralSoilMovement(i)), FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.NORMAL));
                dataTblCell = new PdfPCell(pLateralSoilMov);
                dataTblCell.setHorizontalAlignment(Element.ALIGN_CENTER);
                dataTable.addCell(dataTblCell);
                Phrase pLimitSoilPress = new Phrase(Double.toString(data.getLimitSoilPressure(i)), FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.NORMAL));
                dataTblCell = new PdfPCell(pLimitSoilPress);
                dataTblCell.setHorizontalAlignment(Element.ALIGN_CENTER);
                dataTable.addCell(dataTblCell);
              
            }
            doc.add(dataTableHeader);
            doc.add(dataTable);
            doc.newPage();

            // Create the title for the result table
            Chunk theResultTable = new Chunk("The Result Table", new Font(Font.TIMES_ROMAN, 18, Font.BOLD));
            Paragraph pResult = new Paragraph(theResultTable);
            pResult.setAlignment(Element.ALIGN_CENTER);
            doc.add(pResult);
            doc.add(Chunk.NEWLINE);

View Full Code Here

        BufferedReader reader = new BufferedReader(new FileReader("notes.txt"));

        // Add the notes to the PDF file       
        if (exists) {
            doc.newPage();
            Chunk theNotes = new Chunk("Notes", new Font(Font.TIMES_ROMAN, 18, Font.BOLD));
            doc.add(new Paragraph(theNotes));
        }

        // Retreive the notes from the txt file and add it into the PDF file
        while ((line = reader.readLine()) != null && exists) {
View Full Code Here

TOP

Related Classes of com.lowagie.text.Chunk

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.