Package com.lowagie.text

Examples of com.lowagie.text.Font


      final int style = computeStyle(attributes, pdfTextSpec);

      final Color paint = (Color) c.getStyleSheet().getStyleProperty(ElementStyleKeys.PAINT);
      // add chunks
      BaseFont baseFont = pdfTextSpec.getFontMetrics().getBaseFont();
      Font font = new Font(baseFont, size.floatValue(), style, paint);

      if (c.getOriginatingTextNode() instanceof RenderableReplacedContentBox)
      {
        RenderableReplacedContentBox content = (RenderableReplacedContentBox) c.getOriginatingTextNode();
        com.lowagie.text.Image image = imageHandler.createImage(content);
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

    titleL2BoldFont = FontFactory.getFont(fontLocal + "CALIBRIB.TTF", BaseFont.IDENTITY_H, BaseFont.EMBEDDED, 12);
    contentBoldFont = FontFactory.getFont(fontLocal + "CALIBRIB.TTF", BaseFont.IDENTITY_H, BaseFont.EMBEDDED, 9);
    contentNormalFont = FontFactory.getFont(fontLocal + "CALIBRI.TTF", BaseFont.IDENTITY_H, BaseFont.EMBEDDED, 8.5f);
    contentNormalGrayFont = FontFactory.getFont(fontLocal + "CALIBRI.TTF", BaseFont.IDENTITY_H, BaseFont.EMBEDDED, 8.5f);
    contentNormalGrayFont.setColor(128, 128, 128);
    Font f = FontFactory.getFont(fontLocal + "CALIBRI.TTF", BaseFont.IDENTITY_H, BaseFont.EMBEDDED, 12);
    headerFooterPageEvent = new CustomHeaderFooter(f.getBaseFont());


  }
View Full Code Here

                }
                for (PdfPCell pdfpCell : pdfpCells) {
                  if (pdfpCell != null) {
                    ArrayList<Chunk> cList = pdfpCell.getChunks();
                    for (Chunk chunk : cList) {
                      Font setFont = FontFactory.getFont(fontLocal + "CALIBRI.TTF", BaseFont.IDENTITY_H, BaseFont.EMBEDDED, 8.5f);
                      /*processChunkHtml(htmlStr, chunk, setFont);
                      htmlStr = htmlStr.replaceFirst(chunk.getContent(), "<span />");*/
                      setFont.setColor(chunk.getFont().getColor());
                      setFont.setSize(chunk.getFont().getSize());
                      setFont.setStyle(chunk.getFont().getStyle());
                      chunk.setFont(setFont);
                    }                   
                    pdfpCell.setBorderWidth(0.1f);
                    pdfpCell.setPadding(5);
                    pdfpCell.setVerticalAlignment(PdfPCell.ALIGN_CENTER);
                    pdfpCell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
                    //pdfpCell.setBackgroundColor(new Color(221,221,221));
                    if(style != null){
                      if(i < style.size()){
                        if(style.get(i) != null){
                          String bgColor = style.get(i).get(HtmlTableStyleParser.BACKGROUND);
                          if(bgColor != null){
                            pdfpCell.setBackgroundColor(HtmlTableStyleParser.hex2Rgb(bgColor));
                          }else{
                            bgColor = style.get(i).get(HtmlTableStyleParser.BACKGROUNDCOLOR);
                            if(bgColor != null){
                              pdfpCell.setBackgroundColor(HtmlTableStyleParser.hex2Rgb(bgColor));
                            }
                          }
                        }
                      }
                    }
                    i++;
                  }
                }
              }
            }   
            target.addElement(Chunk.NEWLINE);
            //tmpPhrase.add(element);
            //((PdfPTable)element).setSpacingBefore(5f);
            //target.addElement(element); 
            ((PdfPTable)element).setTotalWidth(width);
            ((PdfPTable)element).setLockedWidth(true);
            target.addElement(element);
          } else if (element instanceof Paragraph) {           
            if (font != null) {             
              ArrayList<Chunk> cList = ((Paragraph) element).getChunks();
              //((Paragraph) element).setAlignment(PdfPCell.ALIGN_CENTER);
              for (Chunk chunk : cList) {
                Font setFont = FontFactory.getFont(fontLocal + "CALIBRI.TTF", BaseFont.IDENTITY_H, BaseFont.EMBEDDED, 8.5f);
               
                processChunkHtml(htmlStr, chunk, setFont);
                htmlStr = replaceContent(htmlStr, chunk.getContent());
                /*htmlStr = htmlStr.replaceFirst(chunk.getContent(), "<span />");*/
                /*setFont.setColor(chunk.getFont().getColor());
                setFont.setSize(chunk.getFont().getSize());
                setFont.setStyle(chunk.getFont().getStyle());
                chunk.getAttributes();
                chunk.setFont(setFont);*/
              }         
            }           
            //tmpPhrase.add(element);
            target.addElement(element);
          } else if (element instanceof Phrase) {
            if (font != null) {
              ArrayList<Chunk> cList = ((Phrase) element).getChunks();
              for (Chunk chunk : cList) {
                Font setFont = FontFactory.getFont(fontLocal + "CALIBRI.TTF", BaseFont.IDENTITY_H, BaseFont.EMBEDDED, 8.5f);
                processChunkHtml(htmlStr, chunk, setFont);
                htmlStr = replaceContent(htmlStr, chunk.getContent());
                /*htmlStr = htmlStr.replaceFirst(chunk.getContent(), "<span />");*/
                /*setFont.setColor(chunk.getFont().getColor());
                setFont.setSize(chunk.getFont().getSize());
                setFont.setStyle(chunk.getFont().getStyle());
                chunk.setFont(setFont);*/
              }         
            }
            target.addElement(/*tmpPhrase*/element);
          } else if (element instanceof Chunk) {
            if (font != null) {
              Font setFont = FontFactory.getFont(fontLocal + "CALIBRI.TTF", BaseFont.IDENTITY_H, BaseFont.EMBEDDED, 8.5f);
              processChunkHtml(htmlStr, (Chunk)element, setFont);
              htmlStr = replaceContent(htmlStr, ((Chunk)element).getContent());
              /*htmlStr = htmlStr.replaceFirst(((Chunk)element).getContent(), "<span />");*/
              /*setFont.setColor(((Chunk) element).getFont().getColor());
              setFont.setColor(((Chunk) element).getFont().getColor());
              setFont.setSize(((Chunk) element).getFont().getSize());
              setFont.setStyle(((Chunk) element).getFont().getStyle());
              ((Chunk) element).setFont(setFont);*/   
            }
            //tmpPhrase.add(element);
           
            target.addElement(element);
          }else if(element instanceof com.lowagie.text.List){
            com.lowagie.text.List list = (com.lowagie.text.List)element;
            ArrayList<Chunk> cList = list.getChunks();
            for (Chunk chunk : cList) {
              Font setFont = FontFactory.getFont(fontLocal + "CALIBRI.TTF", BaseFont.IDENTITY_H, BaseFont.EMBEDDED, 8.5f);
              processChunkHtml(htmlStr, chunk, setFont);
              htmlStr = replaceContent(htmlStr, chunk.getContent());
              /*htmlStr = htmlStr.replaceFirst(chunk.getContent(), "<span />");*/
              /*setFont.setColor(chunk.getFont().getColor());
              setFont.setSize(chunk.getFont().getSize());
              setFont.setStyle(chunk.getFont().getStyle());
              chunk.getAttributes();
              chunk.setFont(setFont);*/
            }
            target.addElement(list);
          }else{
            Phrase p = new Phrase();
            p.add(element);
            ArrayList<Chunk> cList = p.getChunks();
            for (Chunk chunk : cList) {
              Font setFont = FontFactory.getFont(fontLocal + "CALIBRI.TTF", BaseFont.IDENTITY_H, BaseFont.EMBEDDED, 8.5f);
              processChunkHtml(htmlStr, chunk, setFont);
              htmlStr = replaceContent(htmlStr, chunk.getContent());
              /*htmlStr = htmlStr.replaceFirst(chunk.getContent(), "<span />");*/
              /*setFont.setColor(chunk.getFont().getColor());
              setFont.setSize(chunk.getFont().getSize());
 
View Full Code Here

        for (Element element : elist) {
          if (element instanceof Paragraph) {
            if (font != null) {
              ArrayList<Chunk> cList = ((Paragraph) element).getChunks();
              for (Chunk chunk : cList) {
                Font setFont = FontFactory.getFont(fontLocal + "CALIBRI.TTF", BaseFont.IDENTITY_H, BaseFont.EMBEDDED, 8.5f);
                setFont.setColor(chunk.getFont().getColor());
                setFont.setSize(chunk.getFont().getSize());
                setFont.setStyle(chunk.getFont().getStyle());
                chunk.setFont(setFont);
              }         
            }           
            target.add(element);
          } else if (element instanceof Phrase) {
            if (font != null) {
              ArrayList<Chunk> cList = ((Phrase) element).getChunks();
              for (Chunk chunk : cList) {
                Font setFont = FontFactory.getFont(fontLocal + "CALIBRI.TTF", BaseFont.IDENTITY_H, BaseFont.EMBEDDED, 8.5f);
                setFont.setColor(chunk.getFont().getColor());
                setFont.setSize(chunk.getFont().getSize());
                setFont.setStyle(chunk.getFont().getStyle());
                chunk.setFont(setFont);
              }         
            }
            target.add(element);
          } else if (element instanceof Chunk) {
            if (font != null) {
              Font setFont = FontFactory.getFont(fontLocal + "CALIBRI.TTF", BaseFont.IDENTITY_H, BaseFont.EMBEDDED, 8.5f);
              setFont.setColor(((Chunk) element).getFont().getColor());             
              setFont.setSize(((Chunk) element).getFont().getSize());
              setFont.setStyle(((Chunk) element).getFont().getStyle());
              ((Chunk) element).setFont(setFont);
            }
            target.add(element);
          } else if (element instanceof PdfPTable) {
            List<PdfPRow> rows = ((PdfPTable)element).getRows();
            List<Map<String,String>> style = HtmlTableStyleParser.getStyle(htmlStyle);
            int i = 0;
            for (PdfPRow pdfPRow : rows) {
              if (pdfPRow != null) {
                PdfPCell[] pdfpCells = pdfPRow.getCells();
                if (pdfpCells == null || pdfpCells.length == 0) {
                  continue;
                }
                for (PdfPCell pdfpCell : pdfpCells) {
                  if (pdfpCell != null) {
                    ArrayList<Chunk> cList = pdfpCell.getChunks();
                    for (Chunk chunk : cList) {
                      Font setFont = FontFactory.getFont(fontLocal + "CALIBRI.TTF", BaseFont.IDENTITY_H, BaseFont.EMBEDDED, 8.5f);
                      setFont.setColor(chunk.getFont().getColor());
                      setFont.setSize(chunk.getFont().getSize());
                      setFont.setStyle(chunk.getFont().getStyle());
                      chunk.setFont(setFont);
                    }                   
                    pdfpCell.setBorderWidth(0.1f);   
                    pdfpCell.setPadding(5);
                    pdfpCell.setVerticalAlignment(PdfPCell.ALIGN_CENTER);
                    pdfpCell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
                    if(style != null){
                      if(i < style.size()){
                        if(style.get(i) != null){
                          String bgColor = style.get(i).get(HtmlTableStyleParser.BACKGROUND);
                          if(bgColor != null){
                            pdfpCell.setBackgroundColor(HtmlTableStyleParser.hex2Rgb(bgColor));
                          }
                        }
                      }
                    }
                    i++;
                  }
                }
              }
            } 
            //((PdfPTable)element).setSpacingBefore(5f);
            ((PdfPTable)element).setTotalWidth(500);
            ((PdfPTable)element).setLockedWidth(true);
            target.add(Chunk.NEWLINE);
            target.add(element);
          }else{
            Paragraph p = new Paragraph();
            p.add((Element)element);
            ArrayList<Chunk> cList = p.getChunks();
            for (Chunk chunk : cList) {
              Font setFont = FontFactory.getFont(fontLocal + "CALIBRI.TTF", BaseFont.IDENTITY_H, BaseFont.EMBEDDED, 8.5f);
              setFont.setColor(chunk.getFont().getColor());
              setFont.setSize(chunk.getFont().getSize());
              setFont.setStyle(chunk.getFont().getStyle());
              chunk.setFont(setFont);
           
            target.add(element);
          }
        }       
View Full Code Here

    if (valueFont != null) {
      bf = valueFont;
    } else {
      bf = BaseFont.createFont(fontName, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
    }
    Font font = new Font(bf, fontSize, Font.NORMAL);

    String text = transform(value == null ? _sampleAttr.getString() : value,
            element.getChild("Type").getString(),
            element.getChild("Format") != null ? element.getChild("Format").getString() : null);
View Full Code Here

    public void addImage(java.awt.Image image, int alignment) throws IOException, DocumentException {
        addImage(Image.getInstance(image, null), alignment);
    }

    public void addParagraph(String text) throws DocumentException {
        addParagraph(text, new Font(Font.TIMES_ROMAN), ALIGN_LEFT, 0f, 0f);
    }
View Full Code Here

TOP

Related Classes of com.lowagie.text.Font

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.