1. use adobe pdf writer
or
2.study pdf spec, and you write a pdf writer.

解决方案 »

  1.   

    http://expert.csdn.net/Expert/topic/1122/1122318.xml?temp=.6446039
      

  2.   

    去sun的网站看看,好像以前看见过一个pdf的集成开发包
      

  3.   

    用程序实现:
    http://wh2fo.sourceforge.net/
    把doc转换为pdf文件使用程序做的话要好几步,你可以看看这里,我把.fo文件可以转换为 pdf文件,ibm网站上也有的你找一下吧还有就是到apache的fop站点看看,那里很祥细的
      

  4.   

    谢谢,关于word文档使用wh2fo应该是可行的。
    但excel呢?现在有好多的文书是用excel写的,如何转换为PDF呢?请多指教。
    另:iText似乎不能实现doc、xls向pdf的转换,如果可行的话,可否给出样例或相关的说明文档?
      

  5.   

    用FOP就可以的,具体可以上TOMCAT站点上去找对应的工程
      

  6.   

    转化成PDF文档啊,前些日子在ibm 的developerwork上有类似文章,你看看老在程序员杂志上作广告的红樱风软件,好象就是把各种格式文档转化为PDF的,不过要钱吧???
      

  7.   

    请问hanty(大智若鱼) :
    What is FOP?
    It can be used to render an XML file containing XSL formatting objects into a page layout.
    The main target is PDF but other rendering targets are supported, such as AWT, PCL, text
    and direct printing.这是fop文挡上写的,问题是如何将xls转换成XML file containing XSL formatting objects呢?
    有没有样例,或相关的文档资料?谢过了先。
      

  8.   

    Web:     www.intrapdf.com  pdf2ht14   看看这个软件可不可以  我也不敢保证呀  你是叫王凯吗
      

  9.   

    看看例子!!
    import java.io.*;import javax.servlet.*;
    import javax.servlet.http.*;import org.xml.sax.InputSource;
    import org.xml.sax.XMLReader;import org.apache.fop.apps.Driver;
    import org.apache.fop.apps.Version;
    import org.apache.fop.apps.XSLTInputHandler;
    import org.apache.fop.messaging.MessageHandler;import org.apache.avalon.framework.logger.ConsoleLogger;
    import org.apache.avalon.framework.logger.Logger;
    public class FopServlet extends HttpServlet {
        public static final String FO_REQUEST_PARAM = "fo";
        public static final String XML_REQUEST_PARAM = "xml";
        public static final String XSL_REQUEST_PARAM = "xsl";
        Logger log = null;    public void doGet(HttpServletRequest request,
                          HttpServletResponse response) throws ServletException {
            if (log == null) {
                log = new ConsoleLogger(ConsoleLogger.LEVEL_WARN);
                MessageHandler.setScreenLogger(log);
            }
            try {
                String foParam = request.getParameter(FO_REQUEST_PARAM);
                String xslParam="/Fop/glossary.xsl";
                String xmlParam="/Fop/glossary.xml";
                if (foParam != null) {
                    File fofile = new File(foParam);
                    FileInputStream file = new FileInputStream(fofile);
                    renderFO(new InputSource(file), response);
                } else if ((xmlParam != null) && (xslParam != null)) {
                    XSLTInputHandler input =
                      new XSLTInputHandler(new File(xmlParam),
                                           new File(xslParam));
                    renderXML(input, response);
                } else {
                    PrintWriter out = response.getWriter();
                    out.println("<html><head><title>Error</title></head>\n"+
                                "<body><h1>FopServlet Error</h1><h3>No 'fo' "+
                                "request param given.</body></html>");
                }
            } catch (ServletException ex) {
                throw ex;
            }
            catch (Exception ex) {
                throw new ServletException(ex);
            }
        }
        public void renderFO(InputSource foFile,
                             HttpServletResponse response) throws ServletException {
            try {
                ByteArrayOutputStream out = new ByteArrayOutputStream();            response.setContentType("application/pdf");            Driver driver = new Driver(foFile, out);
                driver.setLogger(log);
                driver.setRenderer(Driver.RENDER_PDF);
                driver.run();            byte[] content = out.toByteArray();
                response.setContentLength(content.length);
                response.getOutputStream().write(content);
                response.getOutputStream().flush();
            } catch (Exception ex) {
                throw new ServletException(ex);
            }
        }
        public void renderXML(XSLTInputHandler input,
                              HttpServletResponse response) throws ServletException {
            try {
                ByteArrayOutputStream out = new ByteArrayOutputStream();            response.setContentType("application/pdf");            Driver driver = new Driver();
                driver.setLogger(log);
                driver.setRenderer(Driver.RENDER_PDF);
                driver.setOutputStream(out);
                driver.render(input.getParser(), input.getInputSource());            byte[] content = out.toByteArray();
                response.setContentLength(content.length);
                response.getOutputStream().write(content);
                response.getOutputStream().flush();
            } catch (Exception ex) {
                throw new ServletException(ex);
            }
        }}
      

  10.   

    Fop/glossary.xsl";
    <?xml version="1.0" encoding="utf-8"?>
    <xsl:stylesheet
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:fo="http://www.w3.org/1999/XSL/Format"
    version="1.0">

    <xsl:template match="glossary">
    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"> <fo:layout-master-set>    <fo:simple-page-master master-name="all"
    page-height="11.5in" page-width="8.5in"
            margin-top="1in" margin-bottom="1in" 
            margin-left="0.75in" margin-right="0.75in">
    <fo:region-body margin-top="1in" margin-bottom="0.75in"/>
    <fo:region-before extent="0.75in"/>
    <fo:region-after extent="0.5in"/>
    </fo:simple-page-master> </fo:layout-master-set> <fo:page-sequence master-reference="all" format="i">    <!-- header with running glossary entries -->
        <fo:static-content flow-name="xsl-region-before">
    <fo:block text-align="start" 
    font-size="10pt" font-family="serif" line-height="1em + 2pt">
        <fo:retrieve-er retrieve-class-name="term"
    retrieve-boundary="page"
    retrieve-position="first-starting-within-page"/>
    <fo:leader leader-alignment="reference-area" leader-pattern="dots"
    leader-length="4in"/>
        <fo:retrieve-er retrieve-class-name="term"
    retrieve-boundary="page"
    retrieve-position="last-ending-within-page"/>
          </fo:block>
        </fo:static-content>     <fo:static-content flow-name="xsl-region-after">
    <fo:block text-align="start" 
    font-size="10pt" font-family="serif" line-height="1em + 2pt">
    Page (<fo:page-number/>)
          </fo:block>
        </fo:static-content>     <fo:flow flow-name="xsl-region-body">
    <xsl:apply-templates select="term-entry"/>
    </fo:flow>
    </fo:page-sequence>
    </fo:root>
    </xsl:template><xsl:template match="term-entry">
    <fo:block text-align="start" font-size="12pt" font-family="sans-serif">
    <xsl:apply-templates select="term"/>
    <xsl:apply-templates select="definition"/>
    </fo:block>
    </xsl:template><xsl:template match="term">
    <fo:block color="blue" space-before.optimum="3pt"><fo:er
    er-class-name="term"><xsl:value-of select="."/></fo:er>
    <xsl:value-of select="."/>
    </fo:block>
    </xsl:template><xsl:template match="definition">
    <fo:block text-align="start" start-indent="2em">
    <xsl:value-of select="."/>
    </fo:block>
    </xsl:template></xsl:stylesheet>具体看看这:FOP API
      

  11.   

    <?xml version="1.0"?>
    <glossary>
    <term-entry>
    <term>basic-link</term>
    <definition>The fo:basic-link is used for representing the start resource
    of a simple link.</definition>
    </term-entry>
    <term-entry>
    <term>bidi-override</term>
    <definition>The fo:bidi-override inline formatting object is used where
    it is necessary to override the default Unicode-bidirectionality
    algorithm direction for different (or nested) inline scripts in
    mixed-language documents.</definition>
    </term-entry>
    <term-entry>
    <term>block</term>
    <definition>The fo:block formatting object is commonly used for formatting
    paragraphs, titles, headlines, figure and table captions, etc.</definition>
    </term-entry>
    <term-entry>
    <term>block-container</term>
    <definition>The fo:block-container flow object is used to generate a
     block-level reference-area.</definition>
    </term-entry>
    <term-entry>
    <term>character</term>
    <definition>The fo:character flow object represents a character that is
     mapped to a glyph for presentation.</definition>
    </term-entry>
    <term-entry>
    <term>color-profile</term>
    <definition>Used to declare a color profile for a stylesheet.</definition>
    </term-entry>
    <term-entry>
    <term>conditional-page-master-reference</term>
    <definition>The fo:conditional-page-master-reference
     is used to identify a page-master that is to be used when the conditions
     on its use are satisfied.</definition>
    </term-entry>
    <term-entry>
    <term>declarations</term>
    <definition>Used to group global declarations for a stylesheet.</definition>
    </term-entry>
    <term-entry>
    <term>external-graphic</term>
    <definition>The fo:external-graphic flow object is used for a graphic
     where the graphics data resides outside of the XML result tree in the
     fo namespace.</definition>
    </term-entry>
    <term-entry>
    <term>float</term>
    <definition>The fo:float serves two purposes. It can be used so that during the
     normal placement of content, some related content is formatted into a
     separate area at beginning of the page (or of some following page) where
     it is available to be read without immediately intruding on the reader.
     Alternatively, it can be used when an area is intended to float to one
     side, with normal content flowing alongside.</definition>
    </term-entry>
    <term-entry>
    <term>flow</term>
    <definition>The content of the fo:flow formatting object is a sequence
    of flow objects that provides the flowing text content that is distributed
    into pages.</definition>
    </term-entry>
    <term-entry>
    <term>footnote</term>
    <definition>The fo:footnote is used to produce a footnote citation and the
    corresponding footnote.</definition>
    </term-entry>
    <term-entry>
    <term>footnote-body</term>
    <definition>The fo:footnote-body is used to generate the content of the
    footnote.</definition>
    </term-entry>
    <term-entry>
    <term>initial-property-set</term>
    <definition>The fo:initial-property-set specifies formatting properties
    for the first line of an fo:block.</definition>
    </term-entry>
    <term-entry>
    <term>inline</term>
    <definition>The fo:inline formatting object is commonly used for
    formatting a portion of text with a background or enclosing it in a
    border.</definition>
    </term-entry>
    <term-entry>
    <term>inline-container</term>
    <definition>The fo:inline-container flow object is used to generate an
    inline reference-area.</definition>
    </term-entry>
    <term-entry>
    <term>instream-foreign-object</term>
    <definition>The fo:instream-foreign-object flow object is used for an
    inline graphic or other "generic" object where the object data resides
    as descendants of the fo:instream-foreign-object.</definition>
    </term-entry>
    <term-entry>
    <term>layout-master-set</term>
    <definition>The fo:layout-master-set is a wrapper around all masters used
    in the document.</definition>
    </term-entry>
    <term-entry>
    <term>leader</term>
      

  12.   

    <definition>The fo:leader formatting object is used to generate leaders
    consisting either of a rule or of a row of a repeating character or
    cyclically repeating pattern of characters that may be used for connecting
    two text formatting objects.</definition>
    </term-entry>
    <term-entry>
    <term>list-block</term>
    <definition>The fo:list-block flow object is used to format a list.</definition>
    </term-entry>
    <term-entry>
    <term>list-item</term>
    <definition>The fo:list-item formatting object contains the label and the
    body of an item in a list.</definition>
    </term-entry>
    <term-entry>
    <term>list-item-body</term>
    <definition>The fo:list-item-body formatting object contains the content
    of the body of a list-item.</definition>
    </term-entry>
    <term-entry>
    <term>list-item-label</term>
    <definition>The fo:list-item-label formatting object contains the content
    of the label of a list-item; typically used to either enumerate, identify,
    or adorn the list-item's body.</definition>
    </term-entry>
    <term-entry>
    <term>er</term>
    <definition>The fo:er is used in conjunction with fo:retrieve-er
    to produce running headers or footers.</definition>
    </term-entry>
    <term-entry>
    <term>multi-case</term>
    <definition>The fo:multi-case is used to contain (within an fo:multi-switch)
    each alternative sub-tree of formatting objects among which the parent
    fo:multi-switch will choose one to show and will hide the rest.</definition>
    </term-entry>
    <term-entry>
    <term>multi-properties</term>
    <definition>The fo:multi-properties is used to switch between two or more
    property sets that are associated with a given portion of content.</definition>
    </term-entry>
    <term-entry>
    <term>multi-property-set</term>
    <definition>The fo:multi-property-set is used to specify an alternative
    set of formatting properties that, dependent on a User Agent state, are
    applied to the content. </definition>
    </term-entry>
    <term-entry>
    <term>multi-switch</term>
    <definition>The fo:multi-switch wraps the specification of alternative
    sub-trees of formatting objects (each sub-tree being within an
    fo:multi-case), and controls the switching (activated via fo:multi-toggle)
    from one alternative to another. </definition>
    </term-entry>
    <term-entry>
      

  13.   

    <term>multi-toggle</term>
    <definition>The fo:multi-toggle is used within an fo:multi-case to switch
    to another fo:multi-case.</definition>
    </term-entry>
    <term-entry>
    <term>page-number</term>
    <definition>The fo:page-number formatting object is used to represent the
    current page-number.</definition>
    </term-entry>
    <term-entry>
    <term>page-number-citation</term>
    <definition>The fo:page-number-citation is used to reference the
    page-number for the page containing the first normal area returned by the
    cited formatting object.</definition>
    </term-entry>
    <term-entry>
    <term>page-sequence</term>
    <definition>The fo:page-sequence formatting object is used to specify how
    to create a (sub-)sequence of pages within a document; for example, a
    chapter of a report. The content of these pages comes from flow children
    of the fo:page-sequence.</definition>
    </term-entry>
    <term-entry>
    <term>page-sequence-master</term>
    <definition>The fo:page-sequence-master specifies sequences of page-masters
    that are used when generating a sequence of pages.</definition>
    </term-entry>
    <term-entry>
    <term>region-after</term>
    <definition>This region defines a viewport that is located on the "after"
    side of fo:region-body region. </definition>
    </term-entry>
    <term-entry>
    <term>region-before</term>
    <definition>This region defines a viewport that is located on the "before"
    side of fo:region-body region.</definition>
    </term-entry>
    <term-entry>
    <term>region-body</term>
    <definition>This region specifies a viewport/reference pair that is located
    in the "center" of the fo:simple-page-master.</definition>
    </term-entry>
    <term-entry>
    <term>region-end</term>
    <definition>This region defines a viewport that is located on the "end"
    side of fo:region-body region.</definition>
    </term-entry>
    <term-entry>
    <term>region-start</term>
    <definition>This region defines a viewport that is located on the "start"
    side of fo:region-body region.</definition>
    </term-entry>
    <term-entry>
    <term>repeatable-page-master-alternatives</term>
    <definition>An fo:repeatable-page-master-alternatives specifies a
    sub-sequence consisting of repeated instances of a set of alternative
    page-masters. The number of repetitions may be bounded or potentially
    unbounded.</definition>
    </term-entry>
    <term-entry>
    <term>repeatable-page-master-reference</term>
    <definition>An fo:repeatable-page-master-reference specifies a sub-sequence
    consisting of repeated instances of a single page-master. The number of
    repetitions may be bounded or potentially unbounded.</definition>
    </term-entry>
    <term-entry>
    <term>retrieve-er</term>
    <definition>The fo:retrieve-er is used in conjunction with fo:er
    to produce running headers or footers.</definition>
    </term-entry>
    <term-entry>
    <term>root</term>
    <definition>The fo:root node is the top node of an XSL result tree. This
    tree is composed of formatting objects.</definition>
    </term-entry>
    <term-entry>
    <term>simple-page-master</term>
    <definition>The fo:simple-page-master is used in the generation of pages
    and specifies the geometry of the page. The page may be subdivided into
    up to five regions.</definition>
    </term-entry>
    <term-entry>
    <term>single-page-master-reference</term>
    <definition>An fo:single-page-master-reference specifies a sub-sequence
    consisting of a single instance of a single page-master.</definition>
    </term-entry>
    <term-entry>
    <term>static-content</term>
    <definition>The fo:static-content formatting object holds a sequence or a
    tree of formatting objects that is to be presented in a single region or
    repeated in like-named regions on one or more pages in the page-sequence.
    Its common use is for repeating or running headers and footers.</definition>
    </term-entry>
    <term-entry>
    <term>table</term>
    <definition>The fo:table flow object is used for formatting the tabular
    material of a table.</definition>
    </term-entry>
    <term-entry>
    <term>table-and-caption</term>
    <definition>The fo:table-and-caption flow object is used for formatting a
    table together with its caption.</definition>
    </term-entry>
    <term-entry>
    <term>table-body</term>
    <definition>The fo:table-body formatting object is used to contain the
    content of the table body.</definition>
    </term-entry>
    <term-entry>
    <term>table-caption</term>
    <definition>The fo:table-caption formatting object is used to contain
    block-level formatting objects containing the caption for the table only
    when using the fo:table-and-caption.</definition>
    </term-entry>
    <term-entry>
    <term>table-cell</term>
    <definition>The fo:table-cell formatting object is used to group content to
    be placed in a table cell.</definition>
    </term-entry>
    <term-entry>
    <term>table-column</term>
    <definition>The fo:table-column formatting object specifies characteristics
    applicable to table cells that have the same column and span.</definition>
    </term-entry>
    <term-entry>
    <term>table-footer</term>
    <definition>The fo:table-footer formatting object is used to contain the
    content of the table footer.</definition>
    </term-entry>
    <term-entry>
    <term>table-header</term>
    <definition>The fo:table-header formatting object is used to contain the
    content of the table header.</definition>
    </term-entry>
    <term-entry>
    <term>table-row</term>
    <definition>The fo:table-row formatting object is used to group table-cells
    into rows.</definition>
    </term-entry>
    <term-entry>
    <term>title</term>
      

  14.   

    <definition>The fo:title formatting object is used to associate a title with
    a given document. This title may be used by an interactive User Agent to
    identify the document. For example, the content of the fo:title can be
    formatted and displayed in a "title" window or in a "tool tip".</definition>
    </term-entry>
    <term-entry>
    <term>wrapper </term>
    <definition>The fo:wrapper formatting object is used to specify inherited
    properties for a group of formatting objects. It has no additional
    formatting semantics.</definition>
    </term-entry>
    </glossary>
      

  15.   

    顶!
    将xls,doc等文件转化为pdf文件的开发包!