Package com.lowagie.text.pdf

Examples of com.lowagie.text.pdf.BaseFont


            document.open();
            // step4
           
            // make a PdfTemplate with the vertical text
            PdfTemplate template = writer.getDirectContent().createTemplate(20, 20);
            BaseFont bf = BaseFont.createFont("Helvetica", "winansi", false);
            String text = "Vertical";
            float size = 16;
            float width = bf.getWidthPoint(text, size);
            template.beginText();
            template.setRGBColorFillF(1, 1, 1);
            template.setFontAndSize(bf, size);
            template.setTextMatrix(0, 2);
            template.showText(text);
View Full Code Here


                    document,
                    new GfrFileOutputStream("com.lowagie.examples.fonts.styles.FixedFontWidth.pdf"));
            // step 3
            document.open();
            // step 4
            BaseFont bf = BaseFont.createFont("Helvetica", "winansi", false, false, null, null);
            int widths[] = bf.getWidths();
            for (int k = 0; k < widths.length; ++k) {
                if (widths[k] != 0)
                    widths[k] = 1000;
            }
            bf.setForceWidthsOutput(true);
            document.add(new Paragraph("A big text to show Helvetica with fixed width.", new LwgFont(bf)));
        }
        catch (Exception de) {
            de.printStackTrace();
        }
View Full Code Here

      p.add(new Chunk("red", red));
      document.add(p);
      p = new Paragraph("Violets are ");
      p.add(new Chunk("blue", blue));
      document.add(p);
      BaseFont bf = FontFactory.getFont(FontFactory.COURIER).getCalculatedBaseFont(false);
      PdfContentByte cb = writer.getDirectContent();
      cb.beginText();
      cb.setColorFill(new Color(0x00, 0xFF, 0x00));
      cb.setFontAndSize(bf, 12);
      cb.showTextAligned(PdfContentByte.ALIGN_CENTER, "Grass is green", 250, 700, 0);
View Full Code Here

         cb.lineTo(400, 600);
         cb.stroke();

         // we construct a font
         //BaseFont bf = BaseFont.createFont("c:\\windows\\fonts\\arialuni.ttf", BaseFont.IDENTITY_H, true);
         BaseFont bf = BaseFont.createFont("c:\\windows\\fonts\\comic.ttf", BaseFont.IDENTITY_H, true);
         LwgFont ft = new LwgFont(bf, 12);
         // This is the text:
         String text = "\u0623\u0648\u0631\u0648\u0628\u0627, \u0628\u0631\u0645\u062c\u064a\u0627\u062a \u0627\u0644\u062d\u0627\u0633\u0648\u0628 + \u0627\u0646\u062a\u0631\u0646\u064a\u062a :";
         LwgPhrase center = new LwgPhrase(text + " Center", ft);
         ColumnText.showTextAligned(cb, PdfContentByte.ALIGN_CENTER, center, 250, 700, 0, PdfWriter.RUN_DIRECTION_RTL, 0);
View Full Code Here

            table.writeSelectedRows(0, -1, 100, 600, writer.getDirectContent());
            document.newPage();
           
            table = new LwgPdfPTable(4);
            float fontSize = 12;
            BaseFont bf = BaseFont.createFont("Helvetica", "winansi", false);
            table.getDefaultCell().setPaddingTop(bf.getFontDescriptor(BaseFont.ASCENT, fontSize) - fontSize + 2);
            table.getDefaultCell().setBorder(LwgRectangle.NO_BORDER);
            for (int k = 0; k < 500 * 4; ++k) {
                if (k == 0) {
                    table.getDefaultCell().setColspan(4);
                    table.getDefaultCell().setHorizontalAlignment(LwgElement.ALIGN_CENTER);
View Full Code Here

            PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("righttoleft.pdf"));
            // step 3
            document.open();
            // step 4
            PdfContentByte cb = writer.getDirectContent();
            BaseFont bf = BaseFont.createFont("c:\\windows\\fonts\\times.ttf", BaseFont.IDENTITY_H, true);
            LwgFont f2 = new LwgFont(bf, 24, LwgFont.NORMAL, Color.BLUE);
            float llx = 100;
            float lly = 100;
            float urx = 500;
            float ury = 800;
View Full Code Here

            PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("vertical.pdf"));
            int idx = 0;
            document.open();
            PdfContentByte cb = writer.getDirectContent();
            for (int j = 0; j < 2; ++j) {
                BaseFont bf = BaseFont.createFont("KozMinPro-Regular", encs[j], false);
                cb.setRGBColorStroke(255, 0, 0);
                cb.setLineWidth(0);
                float x = 400;
                float y = 700;
                float height = 400;
View Full Code Here

           
            // step 3: we open the document
            document.open();
           
            // step 4: we add content to the document
            BaseFont bfComic = BaseFont.createFont("c:\\windows\\fonts\\comic.ttf", BaseFont.WINANSI, BaseFont.EMBEDDED);
            LwgFont font = new LwgFont(bfComic, 12);
            String text1 = "quick brown fox jumps";
            String text2 = " over ";
            String text3 = "the lazy dog";
            document.add(new Paragraph(text1, font));
            document.add(new Paragraph("width: " + bfComic.getWidthPoint(text1, 12)));
            document.add(new Paragraph("ascent: " + bfComic.getAscentPoint(text1, 12)));
            document.add(new Paragraph("descent: " + bfComic.getDescentPoint(text1, 12)));
            document.add(new Paragraph("height: " + (bfComic.getAscentPoint(text1, 12) - bfComic.getDescentPoint(text1, 12))));
            document.add(new Paragraph(text2, font));
            document.add(new Paragraph("width: " + bfComic.getWidthPoint(text2, 12)));
            document.add(new Paragraph("ascent: " + bfComic.getAscentPoint(text2, 12)));
            document.add(new Paragraph("descent: " + bfComic.getDescentPoint(text2, 12)));
            document.add(new Paragraph("height: " + (bfComic.getAscentPoint(text2, 12) - bfComic.getDescentPoint(text2, 12))));
            document.add(new Paragraph(text3, font));
            document.add(new Paragraph("width: " + bfComic.getWidthPoint(text3, 12)));
            document.add(new Paragraph("ascent: " + bfComic.getAscentPoint(text3, 12)));
            document.add(new Paragraph("descent: " + bfComic.getDescentPoint(text3, 12)));
            document.add(new Paragraph("height: " + (bfComic.getAscentPoint(text3, 12) - bfComic.getDescentPoint(text3, 12))));
            document.add(new Paragraph(text1 + text2 + text3, font));
            document.add(new Paragraph("width: " + bfComic.getWidthPoint(text1 + text2 + text3, 12)));
            document.add(new Paragraph("ascent: " + bfComic.getAscentPoint(text1 + text2 + text3, 12)));
            document.add(new Paragraph("descent: " + bfComic.getDescentPoint(text1 + text2 + text3, 12)));
            document.add(new Paragraph("height: " + (bfComic.getAscentPoint(text1 + text2 + text3, 12) - bfComic.getDescentPoint(text1 + text2 + text3, 12))));
        }
        catch(DocumentException de) {
            System.err.println(de.getMessage());
        }
        catch(IOException ioe) {
View Full Code Here

              //You should always embed TrueType fonts.
              renderer.getFontResolver().addFont(files[0].getAbsolutePath(), BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
              log.info("Added font: " + files[0].getAbsolutePath());

              //Get font family name from the BaseFont object. All this work just to get font family name
              BaseFont font = BaseFont.createFont(files[0].getAbsolutePath(), BaseFont.IDENTITY_H , BaseFont.NOT_EMBEDDED);
              fontFamilyName = TrueTypeUtil.getFamilyName(font);
             
              if (!fontFamilyName.equals("")) {
                //Wrap DIV with font family name around the content of the blog entry
                author = "<div style=\"font-family: " + fontFamilyName + ";\">" + author + "</div>";
View Full Code Here

            /** The headertable. */
            PdfPTable table = new PdfPTable(2);
            /** A template that will hold the total number of pages. */
            PdfTemplate tpl = writer.getDirectContent().createTemplate(100, 100);
            /** The font that will be used. */
            BaseFont helv = null;
            try
            {
                helv = BaseFont.createFont("Helvetica", BaseFont.WINANSI, false);
            }
            catch (DocumentException e)
            {
            }
            catch (IOException e)
            {
            }
            PdfContentByte cb = writer.getDirectContent();
            cb.saveState();
            // write the headertable
            table.setTotalWidth(document.right() - document.left());
            table.writeSelectedRows(0, -1, document.left(), document.getPageSize().height() - 50, cb);
            // compose the footer
            String text = "Page " + writer.getPageNumber();
            float textSize = helv.getWidthPoint(text, 12);
            float textBase = document.bottom() - 20;
            cb.beginText();
            cb.setFontAndSize(helv, 12);
            float adjust = helv.getWidthPoint("0", 12);
            cb.setTextMatrix(document.right() - textSize - adjust, textBase);
            cb.showText(text);
            cb.endText();
            cb.addTemplate(tpl, document.right() - adjust, textBase);
            cb.saveState();
View Full Code Here

TOP

Related Classes of com.lowagie.text.pdf.BaseFont

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.