xmlgraphics-fop-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From 김주민 <jm...@kdn.com>
Subject I want to ask you for encoding in FOP process
Date Wed, 06 Sep 2000 04:50:37 GMT
Hi.. 
I see Fop Process   http://xml.apache.org/fop .

I want to make pdf file with XML and XSL.

that is,.. XML + XSL ---> FO(flow object) --->PDF

but i don't know that how encoding of Korean Language.

Problem is Korean Language encoding at   FO--> PDF process(FOP)

XML and XSL encoded euc-kr.
FO  is right changed.
but PDF translation broked Korean language.
Please, how resolve?


I am very sorry that i can speak English a little.
and hope for you answer.




This is XML file,XSL file and program-source.

XML file-->
=============================================
<?xml version="1.0" encoding="euc-kr"?>
<?xml-stylesheet type="text/xsl" href="Transmittal_return_html.xsl"?>
<CTS_CORRESP>
 <CORRESP>
  <COR_SERIAL>1234</COR_SERIAL>
  <USER_NAME>BUMHAN1</USER_NAME>
  <REAL_NAME>범한사용자</REAL_NAME>
  <FROM_DEPT>개발부</FROM_DEPT>
  <FROM_COMPANY>BUMHAN</FROM_COMPANY>
  <FROM_COMPANY_NAME>범한주식회사</FROM_COMPANY_NAME>
  <FROM_COMPANY_ADDR>경남 창원시 팔용동 12/14 123</FROM_COMPANY_ADDR>
  <R_USER_NAME>AE1</R_USER_NAME>
  <R_REAL_NAME>홍길동</R_REAL_NAME>
  <TO_DEPT>울진5&amp;6호기 설계부서</TO_DEPT>
  <TO_COMPANY>KOPEC</TO_COMPANY>
  <T0_COMPANY_NAME>한국전력기술주식회사</T0_COMPANY_NAME>
  <TO_COMPANY_ADDR>경기도 용인시 용인동 123-123</TO_COMPANY_ADDR>
  <FROM_TRANSMITTAL_NO>YS301-3503</FROM_TRANSMITTAL_NO>
  <FROM_TRANSMITTAL_DATE>20000801</FROM-SUBMITTAL_DATE>
  <TO_TRANSMITTAL_NO>E231-3503</TO_TRANSMITTAL_NO>
  <TO_SUBMITTAL_DATE>20000810</TO_SUBMITTAL_DATE>

      <PROJECT_NAME>울진5&amp;6호기</PROJECT_NAME>
      <SPEC_NO>spec1</SPEC_NO>
      <ETC>technical sepcification</ETC>
  <REMARKS>See ATTACH</REMARKS>

      <CDRL> 
       <T_SERIAL>4052</T_SERIAL>
       <PROJECT_DOC_NO>E231-CL-A01-01</PROJECT_DOC_NO>
       <SUPPLIER_DOC_NO>5010-CL-A01-01</SUPPLIER_DOC_NO>
      <PAGE>10</PAGE>
       <REV_NO>1</REV_NO>
       <QTY_TYPE>5P</QTY_TYPE>
       <TITLE>DRAWING AND DATA SUBMITTAL SCHEDULE</TITLE>
       <SOURCE_FILE>문서1.doc</SOURCE_FILE>
       <FOR_R>X</FOR_R>
       <FOR_I></FOR_I>
       <RS>2</RS>
      </CDRL>
      <CDRL> 
         <T_SERIAL>4053</T_SERIAL>
       <PROJECT_DOC_NO>E231-CL-A01-02</PROJECT_DOC_NO>
       <SUPPLIER_DOC_NO>5010-CL-A01-02</SUPPLIER_DOC_NO>
         <PAGE>5</PAGE> 
       <REV_NO>1</REV_NO>
       <QTY_TYPE>5P</QTY_TYPE>
       <TITLE>DRAWING AND DATA SUBMITTAL SCHEDULE detail_1</TITLE>
       <SOURCE_FILE>문서1_세부내용1.ppt</SOURCE_FILE>
       <FOR_R></FOR_R>
       <FOR_I>X</FOR_I>
       <RS>2</RS>
      </CDRL>
 
      <CC>
       <REFERENCER>AE2</REFERENCER>
       <REF_REAL_NAME>설계담당2</REF_REAL_NAME>
      </CC>
      <CC><REFERENCER>AE3</REFERENCER>
       <REF_REAL_NAME>설계담당3</REF_REAL_NAME>
      </CC> 

 </CORRESP>
</CTS_CORRESP>


XSL file-->
=============================================
<?xml version="1.0" encoding="euc-kr"?>
<xsl:style-sheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
   xmlns:fo="http://www.w3.org/1999/XSL/Format"
   result-ns="fo" indent-result="yes">
<xsl:template match="/">
 <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
  <fo:layout-master-set>
   <fo:simple-page-master page-master-name="1">
    <fo:region-body margin-top="3cm" margin-left="1cm" margin-right="1cm" margin-bottom="1cm"/>
   </fo:simple-page-master>  
  </fo:layout-master-set>
  <fo:page-sequence>
   <fo:sequence-specification>
    <fo:sequence-specifier-single page-master-name="1" />
   </fo:sequence-specification>
   <xsl:apply-templates select="CTS_CORRESP/CORRESP" />
  </fo:page-sequence>
 </fo:root>
</xsl:template>
<xsl:template match="CTS_CORRESP/CORRESP" >
 <fo:flow>
  <fo:block font-size="15pt" text-align="centered" space-after.optimum="20pt">
   SUPPLIER'S TRANSMITTAL
  </fo:block>
  <fo:table table-width="18.5cm" height="4cm">
   <fo:table-column column-width="6cm" />
   <fo:table-column column-width="6.5cm" />
   <fo:table-column column-width="6cm" />
   <fo:table-body>
    <fo:table-row line-height="0.8cm">
     <fo:table-cell border-style="solid" border-color="black" border-width="1pt">
      <fo:block font-size="8pt" start-indent="2pt" line-height="10pt">
       From : <xsl:value-of select="REAL_NAME" />
      </fo:block>
      <fo:block font-size="8pt" start-indent="25pt" line-height="10pt">
       <xsl:value-of select="FROM_COMPANY" />
      </fo:block>
      <fo:block font-size="8pt" start-indent="25pt" line-height="10pt">
       <xsl:value-of select="FROM_COMPANT_ADDR" />
      </fo:block>
      <fo:block font-size="8pt" space-before.optimum="10pt" start-indent="2pt" line-height="10pt">
       Supplier
      </fo:block>
      <fo:block font-size="8pt" start-indent="2pt" line-height="10pt">
       Transmittal No. : <xsl:value-of select="FROM_TRANSMITTAL_NO" />
      </fo:block>
      <fo:block font-size="8pt" start-indent="2pt" line-height="10pt">
       Date : <xsl:value-of select="FROM_SUBMITTAL_DATE" />
      </fo:block>
     </fo:table-cell>
     <fo:table-cell>
      <fo:block font-size="8pt" line-height="10pt" start-indent="5pt">
       To : <xsl:value-of select="R_REAL_NAME" />
      </fo:block>
      <fo:block font-size="8pt" line-height="10pt" start-indent="15pt">
       <xsl:value-of select="TO_COMPANY" />
      </fo:block>
      <fo:block font-size="8pt" line-height="10pt" start-indent="15pt">
       <xsl:value-of select="TO_COMPANY_ADDR" />
      </fo:block>
      <fo:block font-size="8pt" space-before.optimum="10pt" start-indent="2pt" line-height="10pt">
       Project Name : <xsl:value-of select="PROJECT_NAME" />
      </fo:block>
      <fo:block font-size="8pt" start-indent="2pt" line-height="10pt">
       Spec No. : <xsl:value-of select="SPEC_NO" />
      </fo:block>      
     </fo:table-cell>
     <fo:table-cell border-style="solid" border-color="black" border-width="1pt">
      <xsl:for-each select="CC" >
       <fo:block font-size="8pt" start-indent="2pt" line-height="10pt">
        CC:<xsl:value-of select="REFERENCER" />
       </fo:block>
       <fo:block font-size="8pt" start-indent="10pt" line-height="10pt" space-after.optimum="3pt">
        <xsl:value-of select="REF_REAL_NAME" />
       </fo:block>
      </xsl:for-each>      
     </fo:table-cell>
    </fo:table-row>
   </fo:table-body>
  </fo:table>
  <fo:block space-after.optimum="2.62cm" />
  
  <fo:block-container width="15cm" height="22pt" top="4.8cm" position="absolute">
   <fo:block font-size="8pt" line-height="10pt">
    The following listed documents are submitted in accordance with 
   </fo:block>
   <fo:block font-size="8pt" line-height="10pt">
    <xsl:value-of select="ETC" />
   </fo:block>   
   <fo:display-rule line-tickness="2pt" length="1cm" />
  </fo:block-container>
  <fo:block-container width="5cm" height="0.6cm" 
     border-color="black" border-style="solid" border-width="1pt" 
     top="6cm" position="absolute">
   <fo:block font-size="8pt">
    DOCUMENT NUMBER
   </fo:block>
  </fo:block-container>  
  <fo:block-container width="4cm" height="0.6cm" 
     border-color="black" border-style="solid" border-width="1pt" 
     top="6.6cm" position="absolute">
   <fo:block font-size="8pt">
    Project Doc. No.(PNS)
   </fo:block>
  </fo:block-container>  
  <fo:block-container width="4cm" height="0.6cm" 
     border-color="black" border-style="solid" border-width="1pt" 
     top="7.2cm" position="absolute">
   <fo:block font-size="8pt">
    Supplier's Doc. No.
   </fo:block>
  </fo:block-container>  
  <fo:block-container width="1cm" height="1.2cm" 
     border-color="black" border-style="solid" border-width="1pt" 
     top="6.6cm" left="4cm" position="absolute">
   <fo:block font-size="8pt">
    Page
   </fo:block>
  </fo:block-container>
  <fo:block-container width="0.75cm" height="1.8cm" 
     border-color="black" border-style="solid" border-width="1pt" 
     top="6cm" left="5cm" position="absolute">
   <fo:block font-size="8pt">
    Rev. 
   </fo:block>
  </fo:block-container>
  <fo:block-container width="0.75cm" height="1.8cm" 
     border-color="black" border-style="solid" border-width="1pt" 
     top="6cm" left="5.75cm" position="absolute">
   <fo:block font-size="8pt">
    QTY
   </fo:block>
   <fo:block font-size="8pt">
    &amp;
   </fo:block>
   <fo:block font-size="8pt">
    TYPE
   </fo:block>
  </fo:block-container>
  <fo:block-container width="10cm" height="1.8cm" 
     border-color="black" border-style="solid" border-width="1pt" 
     top="6cm" left="6.5cm" position="absolute">
   <fo:block font-size="8pt">
    DOCUMENT TITLE
   </fo:block>
  </fo:block-container>
  <fo:block-container width="1cm" height="0.6cm" 
     border-color="black" border-style="solid" border-width="1pt" 
     top="6cm" left="16.5cm" position="absolute">
   <fo:block font-size="8pt">
    FOR
   </fo:block>
  </fo:block-container>
  <fo:block-container width="0.5cm" height="1.2cm" 
     border-color="black" border-style="solid" border-width="1pt" 
     top="6.6cm" left="16.5cm" position="absolute">
   <fo:block font-size="8pt">
    R
   </fo:block>
  </fo:block-container>
  <fo:block-container width="0.5cm" height="1.2cm" 
     border-color="black" border-style="solid" border-width="1pt" 
     top="6.6cm" left="17cm" position="absolute">
   <fo:block font-size="8pt">
    I 
   </fo:block>
  </fo:block-container>
  <fo:block-container width="0.81cm" height="1.8cm" 
     border-color="black" border-style="solid" border-width="1pt" 
     top="6cm" left="17.5cm" position="absolute">
   <fo:block font-size="8pt">
    RS
   </fo:block>
  </fo:block-container>
  <fo:table height="15cm" table-width="300pt" 
    space-after.optimum="0pt" border-color="black" border-style="solid" border-width="1pt"
end-indent="1pt">
  
   <fo:table-column column-width="4cm" />
   <fo:table-column column-width="1cm" />
   <fo:table-column column-width="0.75cm" />
   <fo:table-column column-width="0.75cm" />
   <fo:table-column column-width="10cm" />
   <fo:table-column column-width="0.5cm" />
   <fo:table-column column-width="0.5cm" />
   <fo:table-column column-width="0.81cm" />
   <fo:table-body>   
    <xsl:for-each select="CDRL">
     <fo:table-row space-after.optimum="0pt" >
      <fo:table-cell line-height="0.5cm" border-color="black" border-style="solid" border-width="1pt">
       <fo:block font-size="8pt" line-height="0.6cm">
        <xsl:value-of select="PROJECT_DOC_NO" />
       </fo:block>
       <fo:block-container width="10pt" height="1pt">
        <fo:display-rule line-tickness="1pt" length="10pt" end-indent="2pt"/>
       </fo:block-container>
       <fo:block  font-size="8pt" line-height="0.6cm">
        <xsl:value-of select="SUPPLIER_DOC_NO" />
       </fo:block>
      </fo:table-cell>       
      <fo:table-cell border-color="black" border-style="solid" border-width="1pt">
       <fo:block font-size="8pt" >
        <xsl:value-of select="PAGE" />
       </fo:block>
      </fo:table-cell>
      <fo:table-cell border-color="black" border-style="solid" border-width="1pt">
       <fo:block font-size="8pt">
        <xsl:value-of select="REV_NO" />
       </fo:block>
      </fo:table-cell>
      <fo:table-cell border-color="black" border-style="solid" border-width="1pt">
       <fo:block font-size="8pt" >
        <xsl:value-of select="QTY_NO" />
       </fo:block>
      </fo:table-cell>
      <fo:table-cell border-color="black" border-style="solid" border-width="1pt">
       <fo:block font-size="8pt" >
        <xsl:value-of select="TITLE" />
       </fo:block>
      </fo:table-cell>
      <fo:table-cell border-color="black" border-style="solid" border-width="1pt">
       <fo:block font-size="8pt" >
        <xsl:value-of select="FOR_R" />
       </fo:block>
      </fo:table-cell>
      <fo:table-cell border-color="black" border-style="solid" border-width="1pt" >
       <fo:block font-size="8pt" >
        <xsl:value-of select="FOR_I" />
       </fo:block>
      </fo:table-cell>
      <fo:table-cell border-color="black" border-style="solid" border-width="1pt">
       <fo:block font-size="8pt" >
        <xsl:value-of select="RS" />
       </fo:block>
      </fo:table-cell>      
     </fo:table-row>
    </xsl:for-each>   
   </fo:table-body>
  </fo:table>
  <fo:block-container border-color="black" border-width="1pt" border-style="solid"
    width="12cm" height="2.78cm" top="20.09cm" position="absolute">
   <fo:block font-size="8pt">
    Remark:
   </fo:block>
  </fo:block-container>
  <fo:block-container border-color="black" border-width="1pt" border-style="solid"
    width="6.3cm" height="1.39cm" top="20.09cm" left="12cm" position="absolute">
   <fo:block font-size="8pt">
    A/E's Signature
   </fo:block>
  </fo:block-container>
  <fo:block-container border-color="black" border-width="1pt" border-style="solid"
    width="6.3cm" height="1.39cm" top="21.48cm" left="12cm" position="absolute">
   <fo:block font-size="8pt">
    Name / Signature
   </fo:block>
  </fo:block-container>  
 </fo:flow>
</xsl:template>
</xsl:style-sheet>


program-source------>
=============================================
import java.net.*;
import java.io.*;
import org.apache.fop.apps.*;
import org.w3c.dom.*;
import oracle.xml.parser.v2.*;

public class Transform{
 
 DOMParser parser;

 public XMLDocument parsing(XMLDocument xmlDoc, String xslFileName) throws Exception{

  parser = new DOMParser();
  XMLDocument xslDoc = null;
  XMLDocument xml = xmlDoc;
  XMLDocument out = null;

  parser = new DOMParser();
  parser.setPreserveWhitespace(true);

  URL xslURL = createURL(xslFileName);
  parser.parse(xslURL);
  xslDoc = parser.getDocument();

  XSLStylesheet xsl = new XSLStylesheet(xslDoc, xslURL);

  XSLProcessor processor = new XSLProcessor();
  processor.showWarnings(true);
  processor.setErrorStream(System.err);

  DocumentFragment result = processor.processXSL(xsl, xml);
  
  out = new XMLDocument();

  out.appendChild(result);
  out.setEncoding("euc-kr");

  return out;
 }

 public URL createURL(String fileName){

  URL url = null;

     try{
         url = new URL(fileName);
  }catch (MalformedURLException ex){ 
    File f = new File(fileName);
   try{
    String path = f.getAbsolutePath();
                String fs = System.getProperty("file.separator");
    if (fs.length() == 1){
              char sep = fs.charAt(0);
        if (sep != '/')
      path = path.replace(sep, '/');
     if (path.charAt(0) != '/')
      path = '/' + path;
    }
    path = "file://" + path;
    url = new URL(path);
   }catch (MalformedURLException e){
             System.out.println("Cannot create url for: " + fileName);
             System.exit(0);
      }
  }
        return url;
 }

 public static String kscTOiso(String str) {
  try {
   str = new String(str.getBytes("8859_1"), "ksc5601");
  }catch(UnsupportedEncodingException e){
   System.err.println(e.getMessage());
  }
  return str;
 }

 public static String isoTOksc(String str) {
  try {
   str = new String(str.getBytes("KSC5601"), "8859_1");
  }catch(UnsupportedEncodingException e) {
   System.err.println(e.getMessage());
  }
  return str;
 }
 
 public XMLDocument xmlParse(String xmlFileName) throws Exception{
  
  parser = new DOMParser();
        parser.setPreserveWhitespace(true);
  
  URL xmlURL = createURL(xmlFileName);
        parser.parse(xmlURL);
        XMLDocument xml = parser.getDocument();
  
  return xml;
 }

 public void createPDF(XMLDocument out){
  try{
   Driver driver = new Driver();
            String version = Version.getVersion();
            
            driver.setRenderer("org.apache.fop.render.pdf.PDFRenderer", version);
            driver.addElementMapping("org.apache.fop.fo.StandardElementMapping");
            driver.addElementMapping("org.apache.fop.svg.SVGElementMapping");
            driver.setWriter(new PrintWriter(new FileWriter("transmittal.pdf")));
   driver.buildFOTree(out);
            driver.format();
            driver.render();
  }catch (Exception e) {
            System.err.println("FATAL ERROR: " + e.getMessage());
            System.exit(1);
        }
    }

 public void createHTML(XMLDocument out) throws Exception{
  
  out.print(System.out);

  FileWriter fwriter = new FileWriter("Transmittal_html.html",false);
  BufferedWriter bwriter = new BufferedWriter(fwriter);
  PrintWriter pwriter = new PrintWriter(bwriter);
  
  out.print(pwriter);
  
 }

 public static void main(String args[]){
     
  try{
      if (args.length != 2){
   System.err.println("Usage: java XSLSample xslfile xmlfile");
      System.exit(1);
        }
        String xslFileName = args[0];
  String xmlFileName = args[1];
        
     Transform tf = new Transform();
  XMLDocument xml = tf.xmlParse(xmlFileName);
  XMLDocument out = tf.parsing(xml,xslFileName);
  tf.createPDF(out);
//  tf.createHTML(out);
  }catch (Exception e){
   e.printStackTrace();
     }
 }
}








Mime
View raw message