使用JDOM处理XML数据之PDF篇(二) (转)

使用JDOM处理XML数据之PDF篇(二) (转)[@more@]  使用J dom处理 XML数据之PDF篇(二)

XML文件的代码和microsoft-com:Office:office" />

.NET/Develop/read_article.ASP?id=20733">http://www.csdn.net/Develop/read_article.asp?id=20733 相同

格式转换的xslT-FO文件的代码如下:

watchlist.pdf.xsl

<?xml version="1.0"?>

  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

  version="1.0"

  xmlns:fo="http://www.w3.org/1999/XSL/Format"

>

  root xmlns:fo="http://www.w3.org/1999/XSL/Format">

  <!-- defines page layout --&gt

   

   

      page-height="29.7cm"

      page-width="21cm"

      margin-top="1.5cm"

      margin-bottom="2cm"

      margin-left="2.5cm"

      margin-right="2.5cm">

     

     

     

   

   

    <!-- defines the content --&gt

   

   

     

      font-size="10pt"

      font-family="serif"

      line-height="14pt" >

      Watch List - Customer #select="./quote-list/customer/@id"/>

     

   

   

     

    font-family="sans-serif"

  font-weight="bold"

    line-height="26pt"

    space-after.optimum="12pt"

    background-color="blue"

    color="white"

    text-align="center">

    Your Stock Watch List

       

     

    font-family="sans-serif"

  font-weight="bold"

    line-height="18pt"

    space-after.optimum="10pt"

    start-indent="10pt">

    Hello,

   

   

    font-family="sans-serif"

  font-style="italic"

    line-height="18pt"

    space-after.optimum="10pt"

    start-indent="15pt">

    Prices were obtained at on

   

   

   

   

   

     

    line-height="14pt"

    font-family="sans-serif">

     

       

        SYMBOL

       

       

        COMPANY NAME

       

       

        SHARE PRICE

       

       

     

   

    line-height="16pt"

    font-family="sans-serif">

   

     

     

     

     

     

     

     

     

     

     

     

     

     

    $

     

     

     

   

   

     

   

   

 

最后我们在一个JSP文件中来调用这个Javabean:

pdfWriter.jsp

  String aa=getservletContext().getRealPath("/")+"J2EE_xml";

  String fileName="watchlist.xml";

  String trace=aa+fileName;

  String styleName="watchlist.pdf.xsl";

  String styleTrace=aa+styleName;

  String resultName="aa.pdf";

  String resultTrace=aa+resultName;

  XML.PDFWriter PDFWriter  = new  XML.PDFWriter(); 

  try {

  PDFWriter.createPDFFromXML(styleTrace,trace, resultTrace);

  } catch (Exception e) {

  System.out.println(e.getMessage());

  }

%>

aa.pdf就是格式化后的结果。

到现在使用XML数据的三种方式都介绍过了:

直接读取:http://www.csdn.net/Develop/read_article.asp?id=20720

使用XSLT转化成HTML:http://www.csdn.net/Develop/read_article.asp?id=20733

和这篇里介绍的使用XSL-FO转化成二进制格式。


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10752043/viewspace-962027/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/10752043/viewspace-962027/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值