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 "J. de Hoop" <jo...@capgemini.com> on 2009/12/02 16:04:46 UTC

How to run (user)config.xml to add Fonts in embedded FOP 020.5 with PDF

Hi,

we are having problems with certain characters in PDF, resulting in #
(ÂăãÆæßČč¢ results in Â#ãÆæß##¢).

Within the (user)config.xml you can add Fonts, see code, but how to run it
from the XSQLFOPSerializer ????.
We copied the Arial Window fonts to Linux.

I tried several things but nothing worked, see code:

/**
* Tested with the FOP 0.20.3RC release from 19-Jan-2002
*/
public class XSQLFOPSerializer implements XSQLDocumentSerializer {
private static final String PDFMIME = "application/pdf";

public void serialize(Document doc, XSQLPageRequest env) throws Throwable {
try {

// First make sure we can load the driver
Driver FOPDriver = new Driver();

Logger logger = new ConsoleLogger(ConsoleLogger.LEVEL_DEBUG); // ipv. INFO
MessageHandler.setScreenLogger(logger);
FOPDriver.setLogger(logger);

// Some of FOP's messages appear to still use MessageHandler.
// MessageHandler.setOutputMethod(MessageHandler.NONE);
// Then set the content type before getting the reader/
env.setContentType(PDFMIME);

// Tried the following, but does not work !!!!

// String userConfig = "/u02/gba/tent/userconfig.xml";
// File userConfigFile;
// userConfigFile = new File(userConfig);
// Options options = new Options();
// options.loadUserconfiguration(userConfigFile); 

FOPDriver.setOutputStream(env.getOutputStream());
FOPDriver.setRenderer(FOPDriver.RENDER_PDF);
FOPDriver.render(doc);
} catch (Exception e) {
e.printStackTrace(System.err);
}
}
}


userconfig.xml
 <entry>
 <key>fontBaseDir</key>
 <value>/usr/share/fonts/ttf</value>
 </entry>

<fonts>
 
    <font-triplet name="Arial" style="normal" weight="normal"/>
    <font-triplet name="ArialMT" style="normal" weight="normal"/>
 
 
    <font-triplet name="Arial" style="normal" weight="bold"/>
    <font-triplet name="ArialMT" style="normal" weight="bold"/>
 
 
    <font-triplet name="Arial" style="italic" weight="normal"/>
    <font-triplet name="ArialMT" style="italic" weight="normal"/>
 
 
    <font-triplet name="Arial" style="italic" weight="bold"/>
    <font-triplet name="ArialMT" style="italic" weight="bold"/>
 



Keywords:

FOP 020.5
XML2HTML / PDF
XSQLFOP
Embedded in ADF (fop.jar)
Linux

-- 
View this message in context: http://old.nabble.com/How-to-run-%28user%29config.xml-to-add-Fonts-in-embedded-FOP-020.5-with-PDF-tp26610373p26610373.html
Sent from the FOP - Users mailing list archive at Nabble.com.


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


Re: How to run (user)config.xml to add Fonts in embedded FOP 020.5 with PDF

Posted by Pascal Sancho <pa...@takoma.fr>.
Hi,

FOP 0.20.x is no longer maintained. I strongly suggest you to upgrade to 
latest release (FOP 0.95).
However, in your config file,  I don't see any <font> element (under 
fonts), like this:

<fonts>
  <font metrics-file="metric_file.xml" kerning="yes" 
embed-file="font_file_pfb_or_ttf">
    <font-triplet name="font_name" style="normal_or_italic" 
weight="normal_bold_or_100-900"/>
  </font>
</fonts>

Note that with FOP 0.20.x, you need to make xml metrics files with 
appropriate tool in FOP distribution.

J. de Hoop a écrit :
> Hi,
>
> we are having problems with certain characters in PDF, resulting in #
> (ÂăãÆæßČč¢ results in Â#ãÆæß##¢).
> Within the (user)config.xml you can add Fonts, see code, but how to run it
> from the XSQLFOPSerializer ????.
> We copied the Arial Window fonts to Linux.
> I tried several things but nothing worked, see code:
> /**
> * Tested with the FOP 0.20.3RC release from 19-Jan-2002
> */
> public class XSQLFOPSerializer implements XSQLDocumentSerializer {
> private static final String PDFMIME = "application/pdf";
> public void serialize(Document doc, XSQLPageRequest env) throws Throwable {
> try {
> // First make sure we can load the driver
> Driver FOPDriver = new Driver();
> Logger logger = new ConsoleLogger(ConsoleLogger.LEVEL_DEBUG); // ipv. INFO
> MessageHandler.setScreenLogger(logger);
> FOPDriver.setLogger(logger);
> // Some of FOP's messages appear to still use MessageHandler.
> // MessageHandler.setOutputMethod(MessageHandler.NONE);
> // Then set the content type before getting the reader/
> env.setContentType(PDFMIME);
> // Tried the following, but does not work !!!!
> // String userConfig = "/u02/gba/tent/userconfig.xml";
> // File userConfigFile;
> // userConfigFile = new File(userConfig);
> // Options options = new Options();
> // options.loadUserconfiguration(userConfigFile);
> FOPDriver.setOutputStream(env.getOutputStream());
> FOPDriver.setRenderer(FOPDriver.RENDER_PDF);
> FOPDriver.render(doc);
> } catch (Exception e) {
> e.printStackTrace(System.err);
> }
> }
> }
>
> userconfig.xml
>  <entry>
>  <key>fontBaseDir</key>
>  <value>/usr/share/fonts/ttf</value>
>  </entry>
> <fonts>
>     <font-triplet name="Arial" style="normal" weight="normal"/>
>     <font-triplet name="ArialMT" style="normal" weight="normal"/>
>     <font-triplet name="Arial" style="normal" weight="bold"/>
>     <font-triplet name="ArialMT" style="normal" weight="bold"/>
>     <font-triplet name="Arial" style="italic" weight="normal"/>
>     <font-triplet name="ArialMT" style="italic" weight="normal"/>
>     <font-triplet name="Arial" style="italic" weight="bold"/>
>     <font-triplet name="ArialMT" style="italic" weight="bold"/>
>
> Keywords:
> FOP 020.5
> XML2HTML / PDF
> XSQLFOP
> Embedded in ADF (fop.jar)
> Linux

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