You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by Richard King <ri...@allfinanz.com> on 2007/01/05 18:43:34 UTC

Adding ttf font to a PDF using FOP 0.92 beta

Hi all,
I wish to add a font via java rather than a configuration file.
I have tried the below code.  How do I include the metrics info?
Does anyone know how to add a font without using the "setUserConfig(<File>)" method?

            FopFactory fopFactory = FopFactory.newInstance();
            FOUserAgent userAgent = fopFactory.newFOUserAgent();

            PDFRenderer pdfrenderer = new PDFRenderer();
            pdfrenderer.setUserAgent(userAgent);
            FontInfo fontinfo = new FontInfo();
            fontinfo.addFontProperties("Wingdings","Wingdings","normal", Font.NORMAL);
            pdfrenderer.setupFontInfo(fontinfo);
            userAgent.setRendererOverride(pdfrenderer);

            out = new java.io.FileOutputStream(fopOutputDir + fileRoot + ".pdf");
            out = new java.io.BufferedOutputStream(out);
            Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, userAgent, out);

            Source xsltSrc = new StreamSource(fopDirectory + xslName);
            TransformerFactory transformerFactory = TransformerFactory.newInstance();
            Transformer transformer = transformerFactory.newTransformer(xsltSrc);

Cheers,
Richard

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Re: Adding ttf font to a PDF using FOP 0.92 beta

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
The stuff isn't really designed to be set up this way, but maybe you can
get some ideas by looking at:
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontSetup.java?view=markup

On 05.01.2007 18:43:34 Richard King wrote:
> Hi all,
> I wish to add a font via java rather than a configuration file.
> I have tried the below code.  How do I include the metrics info?
> Does anyone know how to add a font without using the "setUserConfig(<File>)" method?
> 
>             FopFactory fopFactory = FopFactory.newInstance();
>             FOUserAgent userAgent = fopFactory.newFOUserAgent();
> 
>             PDFRenderer pdfrenderer = new PDFRenderer();
>             pdfrenderer.setUserAgent(userAgent);
>             FontInfo fontinfo = new FontInfo();
>             fontinfo.addFontProperties("Wingdings","Wingdings","normal", Font.NORMAL);
>             pdfrenderer.setupFontInfo(fontinfo);
>             userAgent.setRendererOverride(pdfrenderer);
> 
>             out = new java.io.FileOutputStream(fopOutputDir + fileRoot + ".pdf");
>             out = new java.io.BufferedOutputStream(out);
>             Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, userAgent, out);
> 
>             Source xsltSrc = new StreamSource(fopDirectory + xslName);
>             TransformerFactory transformerFactory = TransformerFactory.newInstance();
>             Transformer transformer = transformerFactory.newTransformer(xsltSrc);
> 
> Cheers,
> Richard



Jeremias Maerki


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org