Loading ...
Sorry, an error occurred while loading the content.
 

Re: [XSL-FO] How to get vietnamese in PDF out using Jfor

Expand Messages
  • Dao Xuan Nam
    Hi all, Here is a method to generate a PDF document using FOP. The userconfig.xml is modified to use arial.xml and arial.ttc. Notes that I have use font arial
    Message 1 of 6 , Feb 26, 2004
      Hi all,

      Here is a method to generate a PDF document using FOP. The userconfig.xml is
      modified to use arial.xml and arial.ttc. Notes that I have use font arial in
      the style sheet template.

      =============================================
      public void generatePDF(File xslTemplate, File xmlDataFile, File
      outputFile)
      throws IOException, FOPException, TransformerException {

      Driver driver = new Driver();

      Logger logger = new NullLogger();
      driver.setLogger(logger);
      MessageHandler.setScreenLogger(logger);
      driver.setLogger(logger);

      driver.setRenderer(Driver.RENDER_PDF);

      File foFile = null;

      OutputStream out = null;
      FileInputStream fin = null;
      try {
      out = new java.io.FileOutputStream(outputFile);
      driver.setOutputStream(out);

      foFile = merge(xslTemplate, xmlDataFile);
      fin = new FileInputStream(foFile);
      driver.setInputSource(new InputSource(fin));

      driver.run();
      } catch (IOException ioe) {
      throw ioe;
      } catch (TransformerException te) {
      throw te;
      } finally {
      if (out != null) try {
      out.close();
      } catch (IOException e) {
      }
      if (fin != null) try {
      fin.close();
      } catch (IOException e) {
      }
      }
      }
      ===================================

      THEN, I CONFIGURED FONTS IN THE conf\userconfig.xml

      ===================================
      <configuration>

      <!--

      baseDir: normally the base directory is the directory where the fo file is

      located. if you want to specify your own, uncomment this entry.

      This value can also be a URL. Actually, the value is converted to

      a URL.

      -->

      <entry>

      <key>baseDir</key>

      <value>C:\DocsOnGoing\Doing\fop</value>

      </entry>

      <!--

      fontBaseDir: Similar to baseDir, except that this value is used for fonts.
      If

      it isn't specified, the value from baseDir is used.

      -->

      <entry>

      <key>fontBaseDir</key>

      <value>C:\WINNT\Fonts</value>

      </entry>

      <!--

      <fonts>

      <!--

      <font metrics-file="arialb.xml" kerning="yes" embed-file="arialb.ttf">

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

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

      </font>

      <font metrics-file="ariali.xml" kerning="yes" embed-file="ariali.ttf">

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

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

      </font>

      <font metrics-file="arialbi.xml" kerning="yes" embed-file="arialbi.ttf">

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

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

      </font>

      -->

      <!-- Example Japanese fonts

      <font metrics-file="C:\DocsOnGoing\Doing\fop\conf\msgothic.xml"
      embed-file="D:\winnt\font\msgothic.ttc" kerning="yes">

      <font-triplet name="Gothic" style="normal" weight="normal"/>

      <font-triplet name="Gothic" style="normal" weight="bold"/>

      <font-triplet name="Gothic" style="italic" weight="normal"/>

      <font-triplet name="Gothic" style="italic" weight="bold"/>

      </font>


      <font metrics-file="msmincho.xml" embed-file="Cyberbit.ttf" kerning="yes">

      <font-triplet name="Mincho" style="normal" weight="normal"/>

      <font-triplet name="Mincho" style="normal" weight="bold"/>

      <font-triplet name="Mincho" style="italic" weight="normal"/>

      <font-triplet name="Mincho" style="italic" weight="bold"/>

      </font>

      -->

      <font metrics-file="file:///c:/DocsOnGoing/Doing/fop/conf/arial.xml"
      kerning="yes" embed-file="file://C:/\WINNT/Fonts/arial.ttf">

      <font-triplet name="Arial" style="normal" weight="normal"/>

      </font>

      </fonts>

      </configuration>

      ===================================
      ----- Original Message -----
      From: "Eliot Kimber" <ekimber@...>
      To: <XSL-FO@yahoogroups.com>
      Sent: Thursday, February 26, 2004 12:08 AM
      Subject: Re: [XSL-FO] How to get vietnamese in PDF out using Jfor


      > Dao Xuan Nam wrote:
      >
      > > Hi Eliot,
      > >
      > > This is problem related to font configuration (conf\userconfig.xml). But
      I
      > > have done all steps as suggestion from FOP user. I found it seem have no
      > > effect with new setting.
      > > I am wondering if my work is correct?
      >
      > What does your font specification look like in your FO? Can you send me
      > a small FO sample to check (I'm interested in part because Vietnamese is
      > a language I haven't worked with yet but I have clients who produce
      > Vietnamese documents so I want to make sure I understand any issues
      > there might be).
      >
      > I do not use FOP and have never tried to configure fonts for it so I
      > can't speak to the correctness of your font configuration.
      >
      > Cheers,
      >
      > Eliot
      > --
      > W. Eliot Kimber
      > Professional Services
      > Innodata Isogen
      > 9030 Research Blvd, #410
      > Austin, TX 78758
      > (512) 372-8122
      >
      > eliot@...
      > www.innodata-isogen.com
      >
      >
      >
      >
      > Yahoo! Groups Links
      >
      >
      >
      >
      >
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.