How to create link with PDF download?

纵饮孤独 提交于 2021-02-11 14:56:29

问题


I have locally installed Orbeon Forms CE 2017.2.201712300816-CE and I would like to create view which will serve pdf document generated from xforms form.

All my files are in orbeon/WEB-INF/resources/apps/test/ directory.

When I go to URL http://localhost:8080/orbeon/test/ I see error message: "Orbeon Forms - Page Not Found We are sorry, but the resource you have requested is not available on this server. ".

What I'm doing wrong? How can I fix it?

My files:

page-flow.xml

<controller xmlns="http://www.orbeon.com/oxf/controller" matcher="regexp">
    <page path="/test/" view="pdf.xpl"/>
    <epilogue url="oxf:/config/epilogue.xpl"/>
</controller>

pdf.xpl

<!--
  Copyright (C) 2011 Orbeon, Inc.

  This program is free software; you can redistribute it and/or modify it under the terms of the
  GNU Lesser General Public License as published by the Free Software Foundation; either version
  2.1 of the License, or (at your option) any later version.

  This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
  without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  See the GNU Lesser General Public License for more details.

  The full text of the license is available at http://www.gnu.org/copyleft/lesser.html
  -->
<p:config xmlns:p="http://www.orbeon.com/oxf/pipeline"
        xmlns:xs="http://www.w3.org/2001/XMLSchema"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:oxf="http://www.orbeon.com/oxf/processors"
        xmlns:xi="http://www.w3.org/2001/XInclude"
        xmlns:xforms="http://www.w3.org/2002/xforms"
        xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"
        xmlns:ev="http://www.w3.org/2001/xml-events">

    <p:param type="output" name="data"/>

    <!-- Prepare XForms to use noscript mode, with static appearance -->
    <p:processor name="oxf:xslt">
        <p:input name="config">
            <xsl:transform version="2.0">
                <xsl:import href="oxf:/oxf/xslt/utils/copy.xsl"/>
                <xsl:template match="xforms:model">
                    <xsl:copy>
                        <xsl:attribute name="xxforms:readonly-appearance">static</xsl:attribute>
                        <xsl:apply-templates select="@* | node()"/>
                        <xforms:bind nodeset="//*" readonly="true()"/>
                    </xsl:copy>
                </xsl:template>
            </xsl:transform>
        </p:input>
        <p:input name="data" href="pdf.xhtml"/>
        <p:output name="data" id="xforms"/>
    </p:processor>

    <!-- Run XForms engine, which gives us XHTML -->
    <p:processor name="oxf:pipeline">
        <p:input name="config" href="/ops/pfc/xforms-epilogue.xpl"/>
        <p:input name="data" href="#xforms"/>
        <p:input name="model-data"><null xsi:nil="true"/></p:input>
        <p:output name="xformed-data" id="xformed-data"/>
    </p:processor>

    <!-- Prepare XHTML before conversion to PDF -->
    <p:processor name="oxf:xslt">
        <p:input name="config">
            <xsl:transform version="2.0">
                <xsl:import href="oxf:/oxf/xslt/utils/copy.xsl"/>
                <!-- Filter out scripts as they won't be used -->
                <xsl:template match="*:script"/>
                <!-- Remove noscript element, to remove warning that scripts are not supported -->
                <xsl:template match="*:noscript"/>
                <!-- Remove xforms-initially-hidden class on the form, normally removed by the script -->
                <xsl:template match="*:form">
                    <xsl:copy>
                        <xsl:attribute name="class" select="string-join(tokenize(@class, ' ')[. != 'xforms-initially-hidden'], ' ')"/>
                        <xsl:apply-templates select="@* except @class | node()"/>
                    </xsl:copy>
                </xsl:template>
                <!-- Remove all prefixes because Flying Saucer doesn't like them -->
                <xsl:template match="*">
                    <xsl:element name="{local-name()}">
                        <xsl:apply-templates select="@* | node()"/>
                    </xsl:element>
                </xsl:template>
            </xsl:transform>
        </p:input>
        <p:input name="data" href="#xformed-data"/>
        <p:output name="data" id="xhtml-data"/>
    </p:processor>

    <!-- Run Flying Saucer on the XHTML to get PDF -->
    <p:processor name="oxf:xhtml-to-pdf">
        <p:input name="data" href="#xhtml-data"/>
        <p:output name="data" ref="data"/>
    </p:processor>

</p:config>

pdf.xhtml

<?xml version="1.0"?>
<html 
  xmlns="http://www.w3.org/1999/xhtml" 
  xmlns:xf="http://www.w3.org/2002/xforms">
<head></head>
<body>
  <div style="max-width: 900px; margin: 0 auto;">
    This should be PDF.
  </div>
</body>
</html>

orbeon.log

2018-08-06 21:07:43,038 INFO  lifecycle  - event: {"request": "18", "session": "AD33D43367512176B3CB5DDDA4B830F9", "source": "limiter", "message": "start: nofilter", "path": "/test/", "method": "GET"}
2018-08-06 21:07:43,039 DEBUG URLGenerator  - OXF Protocol: Using ResourceManager for key /config/properties-prod.xml
2018-08-06 21:07:43,039 DEBUG URLGenerator  - OXF Protocol: Using ResourceManager for key /config/properties-internal.xml
2018-08-06 21:07:43,045 DEBUG URLGenerator  - OXF Protocol: Using ResourceManager for key /config/properties-base.xml
2018-08-06 21:07:43,046 DEBUG URLGenerator  - OXF Protocol: Using ResourceManager for key /config/properties-xforms.xml
2018-08-06 21:07:43,046 DEBUG URLGenerator  - OXF Protocol: Using ResourceManager for key /config/properties-form-runner.xml
2018-08-06 21:07:43,046 DEBUG URLGenerator  - OXF Protocol: Using ResourceManager for key /config/properties-form-builder.xml
2018-08-06 21:07:43,046 DEBUG URLGenerator  - OXF Protocol: Using ResourceManager for key /config/properties-local.xml
2018-08-06 21:07:43,047 DEBUG URLGenerator  - OXF Protocol: Using ResourceManager for key /config/properties-local-prod.xml
2018-08-06 21:07:43,047 DEBUG properties  - Not reloading properties because they have not changed.
2018-08-06 21:07:43,047 DEBUG auth  - using `Container` method
2018-08-06 21:07:43,047 DEBUG auth  - usernameOpt: `None`, roles: `None`
2018-08-06 21:07:43,047 WARN  auth  - not setting credentials headers because credentials are not found
2018-08-06 21:07:43,047 INFO  lifecycle  - event: {"request": "18", "session": "AD33D43367512176B3CB5DDDA4B830F9", "source": "service", "message": "start: handle"}
2018-08-06 21:07:43,047 INFO  ProcessorService  - /test/ - Received request
2018-08-06 21:07:43,047 DEBUG URLGenerator  - OXF Protocol: Using ResourceManager for key /org/orbeon/oxf/xml/schemas/pipeline.rng
2018-08-06 21:07:43,048 DEBUG URLGenerator  - OXF Protocol: Using ResourceManager for key /config/prologue-servlet.xpl
2018-08-06 21:07:43,048 DEBUG URLGenerator  - OXF Protocol: Using ResourceManager for key /org/orbeon/oxf/xml/schemas/aggregator.rng
2018-08-06 21:07:43,057 DEBUG ConcreteChooseProcessor  - Choose: taking otherwise branch at line 25, column 40 of oxf:/config/prologue-servlet.xpl
2018-08-06 21:07:43,057 DEBUG URLGenerator  - OXF Protocol: Using ResourceManager for key /org/orbeon/oxf/xml/schemas/page-flow-controller.rng
2018-08-06 21:07:43,057 DEBUG URLGenerator  - OXF Protocol: Using ResourceManager for key /page-flow.xml
2018-08-06 21:07:43,057 DEBUG PageFlowControllerProcessor  - processing page/service {controller: "oxf:/page-flow.xml", method: "GET", path: "/test/"}
2018-08-06 21:07:43,057 DEBUG PageFlowControllerProcessor  - processing route {route: "PageOrServiceRoute(PageOrServiceElement(None,/([^/]+)/.*,/([^/]+)/.*,None,Some(apps/${1}/page-flow.xml),None,org.orbeon.dom.tree.ConcreteElement@1ea06e3 [Element: <page uri: http://www.orbeon.com/oxf/controller attributes: [org.orbeon.dom.tree.ConcreteAttribute@117b4e6 [Attribute: name path value "/([^/]+)/.*"], org.orbeon.dom.tree.ConcreteAttribute@1b83b9f [Attribute: name model value "apps/${1}/page-flow.xml"], org.orbeon.dom.tree.ConcreteAttribute@f734ae [Attribute: name public-methods value "#all"]]/>] userData: line 31, column 85 of oxf:/page-flow.xml,<function1>,<function1>,true),<function1>)"}
2018-08-06 21:07:43,058 DEBUG URLGenerator  - OXF Protocol: Using ResourceManager for key /org/orbeon/oxf/xml/schemas/pipeline.rng
2018-08-06 21:07:43,058 DEBUG URLGenerator  - OXF Protocol: Using ResourceManager for key /ops/pfc/xforms-xml-submission.xpl
2018-08-06 21:07:43,058 DEBUG URLGenerator  - OXF Protocol: Using ResourceManager for key /org/orbeon/oxf/xml/schemas/request-config.rng
2018-08-06 21:07:43,061 DEBUG ConcreteChooseProcessor  - Choose: taking otherwise branch at null
2018-08-06 21:07:43,062 DEBUG URLGenerator  - OXF Protocol: Using ResourceManager for key /ops/pfc/rewrite.xsl
2018-08-06 21:07:43,062 DEBUG URLGenerator  - OXF Protocol: Using ResourceManager for key /org/orbeon/oxf/xml/schemas/url-generator-config.rng
2018-08-06 21:07:43,062 DEBUG URLGenerator  - OXF Protocol: Using ResourceManager for key /org/orbeon/oxf/xml/schemas/xslt-transformer-config.rng
2018-08-06 21:07:43,063 DEBUG URLGenerator  - OXF Protocol: Using ResourceManager for key /org/orbeon/oxf/xml/schemas/attributes-config.rng
2018-08-06 21:07:43,063 DEBUG URLGenerator  - OXF Protocol: Using ResourceManager for key /org/orbeon/oxf/xml/schemas/aggregator.rng
2018-08-06 21:07:43,063 DEBUG URLGenerator  - Config found: org.orbeon.oxf.processor.generator.URLGenerator$ConfigURIReferences@2981c7
2018-08-06 21:07:43,063 DEBUG URLGenerator  - Config found: org.orbeon.oxf.processor.generator.URLGenerator$ConfigURIReferences@2981c7
2018-08-06 21:07:43,063 DEBUG URLGenerator  - OXF Protocol: Using ResourceManager for key /apps/test/page-flow.xml
2018-08-06 21:07:43,070 DEBUG URLGenerator  - Config found: org.orbeon.oxf.processor.generator.URLGenerator$ConfigURIReferences@2981c7
2018-08-06 21:07:43,070 DEBUG URLGenerator  - Config found: org.orbeon.oxf.processor.generator.URLGenerator$ConfigURIReferences@2981c7
2018-08-06 21:07:43,076 DEBUG URLGenerator  - Config found: org.orbeon.oxf.processor.generator.URLGenerator$ConfigURIReferences@2981c7
2018-08-06 21:07:43,076 DEBUG URLGenerator  - Config found: org.orbeon.oxf.processor.generator.URLGenerator$ConfigURIReferences@2981c7
2018-08-06 21:07:43,077 DEBUG URLGenerator  - Config found: org.orbeon.oxf.processor.generator.URLGenerator$ConfigURIReferences@2981c7
2018-08-06 21:07:43,077 DEBUG URLGenerator  - Config found: org.orbeon.oxf.processor.generator.URLGenerator$ConfigURIReferences@2981c7
2018-08-06 21:07:43,077 DEBUG URLGenerator  - OXF Protocol: Using ResourceManager for key /org/orbeon/oxf/xml/schemas/page-flow-controller.rng
2018-08-06 21:07:43,078 DEBUG PageFlowControllerProcessor  - processing page/service {controller: "oxf:/apps/test/page-flow.xml", method: "GET", path: "/test/"}
2018-08-06 21:07:43,078 DEBUG PageFlowControllerProcessor  - processing route {route: "PageOrServiceRoute(PageOrServiceElement(None,/test/,/test/,None,None,Some(pdf.xpl),org.orbeon.dom.tree.ConcreteElement@1bf3914 [Element: <page uri: http://www.orbeon.com/oxf/controller attributes: [org.orbeon.dom.tree.ConcreteAttribute@876b67 [Attribute: name path value "/test/"], org.orbeon.dom.tree.ConcreteAttribute@48c89c [Attribute: name view value "pdf.xpl"]]/>] userData: line 2, column 41 of oxf:/apps/test/page-flow.xml,<function1>,Set(GET, HEAD),true),<function1>)"}
2018-08-06 21:07:43,078 DEBUG URLGenerator  - OXF Protocol: Using ResourceManager for key /org/orbeon/oxf/xml/schemas/pipeline.rng
2018-08-06 21:07:43,078 DEBUG URLGenerator  - OXF Protocol: Using ResourceManager for key /ops/pfc/xforms-xml-submission.xpl
2018-08-06 21:07:43,084 DEBUG URLGenerator  - OXF Protocol: Using ResourceManager for key /org/orbeon/oxf/xml/schemas/request-config.rng
2018-08-06 21:07:43,089 DEBUG ConcreteChooseProcessor  - Choose: taking when branch with test: /step-type = 'view' at null
2018-08-06 21:07:43,089 DEBUG URLGenerator  - OXF Protocol: Using ResourceManager for key /org/orbeon/oxf/xml/schemas/url-generator-config.rng
2018-08-06 21:07:43,089 DEBUG URLGenerator  - Config found: org.orbeon.oxf.processor.generator.URLGenerator$ConfigURIReferences@19489e
2018-08-06 21:07:43,089 DEBUG URLGenerator  - Config found: org.orbeon.oxf.processor.generator.URLGenerator$ConfigURIReferences@19489e
2018-08-06 21:07:43,089 DEBUG URLGenerator  - OXF Protocol: Using ResourceManager for key /apps/test/pdf.xpl
2018-08-06 21:07:43,112 DEBUG URLGenerator  - Config found: org.orbeon.oxf.processor.generator.URLGenerator$ConfigURIReferences@19489e
2018-08-06 21:07:43,112 DEBUG URLGenerator  - Config found: org.orbeon.oxf.processor.generator.URLGenerator$ConfigURIReferences@19489e
2018-08-06 21:07:43,112 DEBUG URLGenerator  - Config found: org.orbeon.oxf.processor.generator.URLGenerator$ConfigURIReferences@19489e
2018-08-06 21:07:43,112 DEBUG URLGenerator  - Config found: org.orbeon.oxf.processor.generator.URLGenerator$ConfigURIReferences@19489e
2018-08-06 21:07:43,112 DEBUG URLGenerator  - Config found: org.orbeon.oxf.processor.generator.URLGenerator$ConfigURIReferences@19489e
2018-08-06 21:07:43,113 DEBUG URLGenerator  - Config found: org.orbeon.oxf.processor.generator.URLGenerator$ConfigURIReferences@19489e
2018-08-06 21:07:43,113 DEBUG URLGenerator  - OXF Protocol: Using ResourceManager for key /org/orbeon/oxf/xml/schemas/pipeline.rng
2018-08-06 21:07:43,114 DEBUG URLGenerator  - OXF Protocol: Using ResourceManager for key /org/orbeon/oxf/xml/schemas/pipeline.rng
2018-08-06 21:07:43,114 DEBUG URLGenerator  - OXF Protocol: Using ResourceManager for key /ops/pfc/xforms-epilogue.xpl
2018-08-06 21:07:43,115 DEBUG URLGenerator  - OXF Protocol: Using ResourceManager for key /org/orbeon/oxf/xml/schemas/xslt-transformer-config.rng
2018-08-06 21:07:43,115 DEBUG URLGenerator  - OXF Protocol: Using ResourceManager for key /org/orbeon/oxf/xml/schemas/attributes-config.rng
2018-08-06 21:07:43,115 DEBUG URLGenerator  - OXF Protocol: Using ResourceManager for key /apps/test/pdf.xhtml
2018-08-06 21:07:43,121 DEBUG URLGenerator  - OXF Protocol: Using ResourceManager for key /oxf/xslt/utils/copy.xsl
2018-08-06 21:07:43,122 DEBUG URLGenerator  - OXF Protocol: Using ResourceManager for key /org/orbeon/oxf/processor/serializer/legacy-serializer-config.rng
2018-08-06 21:07:43,122 DEBUG URLGenerator  - OXF Protocol: Using ResourceManager for key /org/orbeon/oxf/xml/schemas/xslt-transformer-config.rng
2018-08-06 21:07:43,122 DEBUG URLGenerator  - OXF Protocol: Using ResourceManager for key /org/orbeon/oxf/xml/schemas/attributes-config.rng
2018-08-06 21:07:43,122 DEBUG URLGenerator  - OXF Protocol: Using ResourceManager for key /oxf/xslt/utils/copy.xsl
2018-08-06 21:07:43,122 DEBUG ConcreteChooseProcessor  - Choose: taking when branch with test: not(/*/@xsi:nil = 'true') at null
2018-08-06 21:07:43,122 DEBUG URLGenerator  - OXF Protocol: Using ResourceManager for key /org/orbeon/oxf/xml/schemas/pipeline.rng
2018-08-06 21:07:43,123 DEBUG URLGenerator  - OXF Protocol: Using ResourceManager for key /config/epilogue.xpl
2018-08-06 21:07:43,123 DEBUG URLGenerator  - OXF Protocol: Using ResourceManager for key /org/orbeon/oxf/xml/schemas/request-config.rng
2018-08-06 21:07:43,125 DEBUG ConcreteChooseProcessor  - Choose: taking when branch with test: /request/container-type = 'servlet' at line 57, column 31 of oxf:/config/epilogue.xpl
2018-08-06 21:07:43,125 DEBUG URLGenerator  - OXF Protocol: Using ResourceManager for key /org/orbeon/oxf/xml/schemas/pipeline.rng
2018-08-06 21:07:43,125 DEBUG URLGenerator  - OXF Protocol: Using ResourceManager for key /config/epilogue-servlet.xpl
2018-08-06 21:07:43,139 DEBUG URLGenerator  - OXF Protocol: Using ResourceManager for key /org/orbeon/oxf/xml/schemas/pipeline.rng
2018-08-06 21:07:43,139 DEBUG URLGenerator  - OXF Protocol: Using ResourceManager for key /ops/pfc/xforms-epilogue.xpl
2018-08-06 21:07:43,141 DEBUG ConcreteChooseProcessor  - Choose: taking when branch with test: /document[@xsi:type] at line 52, column 36 of oxf:/config/epilogue-servlet.xpl
2018-08-06 21:07:43,141 DEBUG URLGenerator  - OXF Protocol: Using ResourceManager for key /org/orbeon/oxf/processor/serializer/http-serializer-config.rng
2018-08-06 21:07:43,143 INFO  ProcessorService  - /test/ - Timing: 96
2018-08-06 21:07:43,146 INFO  lifecycle  - event: {"request": "18", "session": "AD33D43367512176B3CB5DDDA4B830F9", "source": "service", "message": "end: handle", "time": "96 ms"}
2018-08-06 21:07:43,146 INFO  lifecycle  - event: {"request": "18", "session": "AD33D43367512176B3CB5DDDA4B830F9", "source": "limiter", "message": "end: nofilter", "time": "108 ms"}

来源:https://stackoverflow.com/questions/51631930/how-to-create-link-with-pdf-download

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!