Class PdfBoxGraphics2DFontTextDrawer

    • Constructor Detail

      • PdfBoxGraphics2DFontTextDrawer

        public PdfBoxGraphics2DFontTextDrawer()
    • Method Detail

      • close

        public void close()
        Close / delete all resources associated with this drawer. This mainly means deleting all temporary files. You can not use this object after a call to close.

        Calling close multiple times does nothing.

        Specified by:
        close in interface AutoCloseable
        Specified by:
        close in interface Closeable
      • registerFont

        public void registerFont​(String fontName,
                                 InputStream fontStream)
                          throws IOException
        Register a font. If possible, try to use a font file, i.e. registerFont(String, File). This method will lead to the creation of a temporary file which stores the font data.
        Parameters:
        fontName - the name of the font to use. If null, the name is taken from the font.
        fontStream - the input stream of the font. This file must be a ttf/otf file! You have to close the stream outside, this method will not close the stream.
        Throws:
        IOException - when something goes wrong with reading the font or writing the font to the content stream of the PDF:
      • registerFont

        public void registerFont​(String fontName,
                                 File fontFile)
        Register a font.
        Parameters:
        fontName - the name of the font to use. If null, the name is taken from the font.
        fontFile - the font file. This file must exist for the live time of this object, as the font data will be read lazy on demand
      • registerFont

        public void registerFont​(File fontFile)
        Override for registerFont(null,fontFile)
        Parameters:
        fontFile - the font file
      • registerFont

        public void registerFont​(InputStream fontStream)
                          throws IOException
        Override for registerFont(null,fontStream)
        Parameters:
        fontStream - the font file
        Throws:
        IOException - when something goes wrong with reading the font or writing the font to the content stream of the PDF:
      • registerFont

        public void registerFont​(String name,
                                 org.apache.pdfbox.pdmodel.font.PDFont font)
        Register a font which is already associated with the PDDocument
        Parameters:
        name - the name of the font as returned by Font.getFontName(). This name is used for the mapping the java.awt.Font to this PDFont.
        font - the PDFont to use. This font must be loaded in the current document.
      • hasDynamicFontMapping

        protected boolean hasDynamicFontMapping()
        Returns:
        true if the font mapping is populated on demand. This is usually only the case if this class has been derived. The default implementation just checks for this.