Examples of PDFont


Examples of org.apache.pdfbox.pdmodel.font.PDFont

        {
            doc = new PDDocument();

            PDPage page = new PDPage();
            doc.addPage( page );
            PDFont font = PDType1Font.HELVETICA_BOLD;

            PDPageContentStream contentStream = new PDPageContentStream(doc, page);
            contentStream.beginText();
            contentStream.setFont( font, 12 );
            contentStream.moveTextPositionByAmount( 100, 700 );
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.font.PDFont

            resources.put(mc1, enabled);
            resources.put(mc2, disabled);

            //Setup page content stream and paint background/title
            PDPageContentStream contentStream = new PDPageContentStream(doc, page, false, false);
            PDFont font = PDType1Font.HELVETICA_BOLD;
            contentStream.beginMarkedContentSequence(COSName.OC, mc0);
            contentStream.beginText();
            contentStream.setFont(font, 14);
            contentStream.moveTextPositionByAmount(80, 700);
            contentStream.drawString("PDF 1.5: Optional Content Groups");
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.font.PDFont

        {
            doc = new PDDocument();

            PDPage page = new PDPage();
            doc.addPage(page);
            PDFont font = createPDType1AfmPfbFont(doc, fontfile);

            PDPageContentStream contentStream = new PDPageContentStream(doc,
                    page);
            contentStream.beginText();
            contentStream.setFont(font, 12);
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.font.PDFont

        {
            // set font and size
            COSName fontName = (COSName)arguments.get(0);
            float fontSize = ((COSNumber)arguments.get(1)).floatValue();
            context.getGraphicsState().getTextState().setFontSize(fontSize);
            PDFont font = context.getResources().getFont(fontName);
            context.getGraphicsState().getTextState().setFont(font);
        }
    }
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.font.PDFont

    {
        PDGraphicsState state = getGraphicsState();
        PDTextState textState = state.getTextState();

        // get the current font
        PDFont font = textState.getFont();
        if (font == null)
        {
            LOG.warn("No current font, will use default");
            font = PDFontFactory.createDefaultFont();
        }

        float fontSize = textState.getFontSize();
        float horizontalScaling = textState.getHorizontalScaling() / 100f;
        float charSpacing = textState.getCharacterSpacing();

        // put the text state parameters into matrix form
        Matrix parameters = new Matrix(
                fontSize * horizontalScaling, 0, // 0
                0, fontSize,                     // 0
                0, textState.getRise());         // 1

        // read the stream until it is empty
        InputStream in = new ByteArrayInputStream(string);
        while (in.available() > 0)
        {
            // decode a character
            int before = in.available();
            int code = font.readCode(in);
            int codeLength = before - in.available();
            String unicode = font.toUnicode(code);

            // Word spacing shall be applied to every occurrence of the single-byte character code
            // 32 in a string when using a simple font or a composite font that defines code 32 as
            // a single-byte code.
            float wordSpacing = 0;
            if (codeLength == 1 && code == 32)
            {
                wordSpacing += textState.getWordSpacing();
            }

            // text rendering matrix (text space -> device space)
            Matrix ctm = state.getCurrentTransformationMatrix();
            Matrix textRenderingMatrix = parameters.multiply(textMatrix).multiply(ctm);

            // get glyph's position vector if this is vertical text
            // changes to vertical text should be tested with PDFBOX-2294 and PDFBOX-1422
            if (font.isVertical())
            {
                // position vector, in text space
                Vector v = font.getPositionVector(code);

                // apply the position vector to the horizontal origin to get the vertical origin
                textRenderingMatrix.translate(v);
            }

            // get glyph's horizontal and vertical displacements, in text space
            Vector w = font.getDisplacement(code);

            // process the decoded glyph
            saveGraphicsState();
            showGlyph(textRenderingMatrix, font, code, unicode, w);
            restoreGraphicsState();

            // calculate the combined displacements
            float tx, ty;
            if (font.isVertical())
            {
                tx = 0;
                ty = w.getY() * fontSize + charSpacing + wordSpacing;
            }
            else
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.font.PDFont

        PDDocument doc = null;
        try
        {
            doc = new PDDocument();

            PDFont font = PDType1Font.HELVETICA;
            PDPage page = new PDPage(PDRectangle.A4);
            page.setRotation(90);
            doc.addPage(page);
            PDRectangle pageSize = page.getMediaBox();
            float pageWidth = pageSize.getWidth();
            float fontSize = 12;
            float stringWidth = font.getStringWidth( message )*fontSize/1000f;
            float startX = 100;
            float startY = 100;
            PDPageContentStream contentStream = new PDPageContentStream(doc, page, false, false);
            // add the rotation using the current transformation matrix
            // including a translation of pageWidth to use the lower left corner as 0,0 reference
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.font.PDFont

                    "vulputate."
            };

            //Setup page content stream and paint background/title
            PDPageContentStream contentStream = new PDPageContentStream(doc, page, false, false);
            PDFont font = PDType1Font.HELVETICA_BOLD;
            contentStream.beginText();
            contentStream.moveTextPositionByAmount(50, 720);
            contentStream.setFont(font, 14);
            contentStream.drawString("Simple test document with text.");
            contentStream.endText();
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.font.PDFont

                page.setResources( resources );
            }

            //Setup page content stream and paint background/title
            PDPageContentStream contentStream = new PDPageContentStream(doc, page, false, false);
            PDFont font = PDType1Font.HELVETICA_BOLD;
            contentStream.setNonStrokingColor(Color.LIGHT_GRAY);
            contentStream.beginText();
            float fontSize = 96;
            contentStream.setFont(font, fontSize);
            String text = "OVERLAY";
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.font.PDFont

        PDDocument doc = null;
        try
        {
            doc = PDDocument.load( file );

            PDFont font = PDType1Font.HELVETICA_BOLD;
            float fontSize = 36.0f;

            for( PDPage page : doc.getPages() )
            {
                PDRectangle pageSize = page.getMediaBox();
                float stringWidth = font.getStringWidth( message )*fontSize/1000f;
                // calculate to center of the page
                int rotation = page.getRotation();
                boolean rotate = rotation == 90 || rotation == 270;
                float pageWidth = rotate ? pageSize.getHeight() : pageSize.getWidth();
                float pageHeight = rotate ? pageSize.getWidth() : pageSize.getHeight();
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.font.PDFont

        {
            doc = new PDDocument();

            PDPage page = new PDPage();
            doc.addPage(page);
            PDFont font = PDTrueTypeFont.loadTTF(doc, new File(fontfile));

            PDPageContentStream contentStream = new PDPageContentStream(doc,
                    page);
            contentStream.beginText();
            contentStream.setFont(font, 12);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.