PDF Generation, what is wrong with my code

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

PDF Generation, what is wrong with my code

JohnBampton
Hi all,  I am trying to follow the government forms example to create a pdf.

Three parts below,  I need a trigger added to generate the pdf and any help with the errors in my pipeline or pdf model code.  Do I need a page flow code and if so what is that meant to be?

Please help, I am stuck!

Code for form:

<xhtml:html xmlns:xforms="http://www.w3.org/2002/xforms"
            xmlns:f="http://orbeon.org/oxf/xml/formatting" xmlns:xhtml="http://www.w3.org/1999/xhtml"
            xmlns:xxforms="http://orbeon.org/oxf/xml/xforms" xmlns:xi="http://www.w3.org/2001/XInclude"
            xmlns:xxi="http://orbeon.org/oxf/xml/xinclude" xmlns:xs="http://www.w3.org/2001/XMLSchema"
            xmlns:widget="http://orbeon.org/oxf/xml/widget" xmlns:ev="http://www.w3.org/2001/xml-events"
            xmlns:xdt="http://www.w3.org/2005/xpath-datatypes" xmlns:xbl="http://www.w3.org/ns/xbl"
            xmlns:fr="http://orbeon.org/oxf/xml/form-runner" lang="en">
    <xhtml:head>
        <xforms:model id="main-model">
            <xforms:instance id="data-instance">
                <data>
                    <item>
                        <insuredname></insuredname>
                    </item>
                </data>
            </xforms:instance>
            <xforms:instance id="data-template">
                <al>
                    <name></name>
                </al>
            </xforms:instance>
            <xforms:bind nodeset="instance('data-instance')/item/al/name" required="true()" />
           
              <xforms:submission id="save-submission" ref="instance('data-instance')"
                    action="/exist/rest/db/orbeon/test/test.xml"
                    method="put" replace="none">
                <xforms:message ev:event="xforms-submit-error" level="modal">An error occurred while submitting the form! </xforms:message>
           </xforms:submission>
        </xforms:model>
    </xhtml:head>
    <xhtml:body>
        <xhtml:p>
            <xforms:input id="insuredname" ref="item/insuredname" incremental="true" class="input" navindex="1">
                <xforms:label class="fixed-width">Insured Name</xforms:label>
                <xforms:alert>Insured Name is required</xforms:alert>
            </xforms:input>
        </xhtml:p>
        <xhtml:table>
            <xhtml:tr>
                <xhtml:td>
                    <xforms:trigger appearance="minimal">
                        <xforms:label>Add additional location</xforms:label>
                         <xforms:insert ev:event="DOMActivate" context="instance('data-instance')/item" nodeset="item/al"
                                      at="1" position="before" origin="instance('data-template')"/>
                    </xforms:trigger>
                </xhtml:td>
            </xhtml:tr>
            <xforms:repeat nodeset="item/al" id="al-repeat">
                <xhtml:tr>
                    <xhtml:td colspan="2">
                        <xforms:trigger appearance="minimal">
                            <xforms:delete ev:event="DOMActivate" context="instance('data-instance')" nodeset="item/al"
                                           at="index('al-repeat')"/>
                            <xforms:label>Delete</xforms:label>
                        </xforms:trigger>
                    </xhtml:td>
                </xhtml:tr>
                <xhtml:tr>
                    <xhtml:td>
                        <xforms:input id="alname" ref="name" incremental="true" class="input">
                            <xforms:label class="fixed-width">Name</xforms:label>
                            <xforms:alert>Name is required</xforms:alert>
                        </xforms:input>
                    </xhtml:td>
                </xhtml:tr>
            </xforms:repeat>
        </xhtml:table>
          <xhtml:div>
          <xforms:submit submission="save-submission" appearance="full">
                <xforms:label>Submit Request</xforms:label>
            </xforms:submit> 
         </xhtml:div> 
    </xhtml:body>
</xhtml:html>

Pipeline code:

<?xml version="1.0" encoding="utf-8"?>
<p:pipeline xmlns:p="http://www.orbeon.com/oxf/pipeline"
    xmlns:oxf="http://www.orbeon.com/oxf/processors"
    xmlns:xforms="http://www.w3.org/2002/xforms">

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

   
    <p:processor name="oxf:xforms-submission">
        <p:input name="submission">
            <xforms:submission serialization="none" method="get"
                                action="/exist/rest/db/orbeon/test/test.xml"/>
        </p:input>
        <p:input name="request" href="#instance"/>
        <p:output name="response" id="document"/>
    </p:processor>
   
   
    <p:processor name="oxf:pdf-template">
        <p:input name="data" href="#document"/>
        <p:input name="model" href="#instance#xpointer(doc('pdf-model.xml')"/>
        <p:output name="data" ref="data"/>
    </p:processor>

</p:pipeline>


PDF MODEL

<?xml version="1.0" encoding="utf-8"?><config xmlns:dmv="http://orbeon.org/oxf/examples/dmv">
    <template href="oxf:/apps/forms/forms/DMV-14/dmv14.pdf" show-grid="false"/>

    <group ref="/*" font-pitch="15.9" font-family="Courier" font-size="14">
        <field left="435" top="750.2" size="10"
               value="item/insuredname"/>
    </group>
</config>
Reply | Threaded
Open this post in threaded view
|

Re: PDF Generation, what is wrong with my code

JohnBampton
Can anyone help me!?


JohnBampton wrote
Hi all,  I am trying to follow the government forms example to create a pdf.

Three parts below,  I need a trigger added to generate the pdf and any help with the errors in my pipeline or pdf model code.  Do I need a page flow code and if so what is that meant to be?

Please help, I am stuck!

Code for form:

<xhtml:html xmlns:xforms="http://www.w3.org/2002/xforms"
            xmlns:f="http://orbeon.org/oxf/xml/formatting" xmlns:xhtml="http://www.w3.org/1999/xhtml"
            xmlns:xxforms="http://orbeon.org/oxf/xml/xforms" xmlns:xi="http://www.w3.org/2001/XInclude"
            xmlns:xxi="http://orbeon.org/oxf/xml/xinclude" xmlns:xs="http://www.w3.org/2001/XMLSchema"
            xmlns:widget="http://orbeon.org/oxf/xml/widget" xmlns:ev="http://www.w3.org/2001/xml-events"
            xmlns:xdt="http://www.w3.org/2005/xpath-datatypes" xmlns:xbl="http://www.w3.org/ns/xbl"
            xmlns:fr="http://orbeon.org/oxf/xml/form-runner" lang="en">
    <xhtml:head>
        <xforms:model id="main-model">
            <xforms:instance id="data-instance">
                <data>
                    <item>
                        <insuredname></insuredname>
                    </item>
                </data>
            </xforms:instance>
            <xforms:instance id="data-template">
                <al>
                    <name></name>
                </al>
            </xforms:instance>
            <xforms:bind nodeset="instance('data-instance')/item/al/name" required="true()" />
           
              <xforms:submission id="save-submission" ref="instance('data-instance')"
                    action="/exist/rest/db/orbeon/test/test.xml"
                    method="put" replace="none">
                <xforms:message ev:event="xforms-submit-error" level="modal">An error occurred while submitting the form! </xforms:message>
           </xforms:submission>
        </xforms:model>
    </xhtml:head>
    <xhtml:body>
        <xhtml:p>
            <xforms:input id="insuredname" ref="item/insuredname" incremental="true" class="input" navindex="1">
                <xforms:label class="fixed-width">Insured Name</xforms:label>
                <xforms:alert>Insured Name is required</xforms:alert>
            </xforms:input>
        </xhtml:p>
        <xhtml:table>
            <xhtml:tr>
                <xhtml:td>
                    <xforms:trigger appearance="minimal">
                        <xforms:label>Add additional location</xforms:label>
                         <xforms:insert ev:event="DOMActivate" context="instance('data-instance')/item" nodeset="item/al"
                                      at="1" position="before" origin="instance('data-template')"/>
                    </xforms:trigger>
                </xhtml:td>
            </xhtml:tr>
            <xforms:repeat nodeset="item/al" id="al-repeat">
                <xhtml:tr>
                    <xhtml:td colspan="2">
                        <xforms:trigger appearance="minimal">
                            <xforms:delete ev:event="DOMActivate" context="instance('data-instance')" nodeset="item/al"
                                           at="index('al-repeat')"/>
                            <xforms:label>Delete</xforms:label>
                        </xforms:trigger>
                    </xhtml:td>
                </xhtml:tr>
                <xhtml:tr>
                    <xhtml:td>
                        <xforms:input id="alname" ref="name" incremental="true" class="input">
                            <xforms:label class="fixed-width">Name</xforms:label>
                            <xforms:alert>Name is required</xforms:alert>
                        </xforms:input>
                    </xhtml:td>
                </xhtml:tr>
            </xforms:repeat>
        </xhtml:table>
          <xhtml:div>
          <xforms:submit submission="save-submission" appearance="full">
                <xforms:label>Submit Request</xforms:label>
            </xforms:submit> 
         </xhtml:div> 
    </xhtml:body>
</xhtml:html>

Pipeline code:

<?xml version="1.0" encoding="utf-8"?>
<p:pipeline xmlns:p="http://www.orbeon.com/oxf/pipeline"
    xmlns:oxf="http://www.orbeon.com/oxf/processors"
    xmlns:xforms="http://www.w3.org/2002/xforms">

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

   
    <p:processor name="oxf:xforms-submission">
        <p:input name="submission">
            <xforms:submission serialization="none" method="get"
                                action="/exist/rest/db/orbeon/test/test.xml"/>
        </p:input>
        <p:input name="request" href="#instance"/>
        <p:output name="response" id="document"/>
    </p:processor>
   
   
    <p:processor name="oxf:pdf-template">
        <p:input name="data" href="#document"/>
        <p:input name="model" href="#instance#xpointer(doc('pdf-model.xml')"/>
        <p:output name="data" ref="data"/>
    </p:processor>

</p:pipeline>


PDF MODEL

<?xml version="1.0" encoding="utf-8"?><config xmlns:dmv="http://orbeon.org/oxf/examples/dmv">
    <template href="oxf:/apps/forms/forms/DMV-14/dmv14.pdf" show-grid="false"/>

    <group ref="/*" font-pitch="15.9" font-family="Courier" font-size="14">
        <field left="435" top="750.2" size="10"
               value="item/insuredname"/>
    </group>
</config>
Reply | Threaded
Open this post in threaded view
|

Re: PDF Generation, what is wrong with my code

JohnBampton
In reply to this post by JohnBampton
Can anyone out there help me?  Alessandro maybe?


JohnBampton wrote
Hi all,  I am trying to follow the government forms example to create a pdf.

Three parts below,  I need a trigger added to generate the pdf and any help with the errors in my pipeline or pdf model code.  Do I need a page flow code and if so what is that meant to be?

Please help, I am stuck!

Code for form:

<xhtml:html xmlns:xforms="http://www.w3.org/2002/xforms"
            xmlns:f="http://orbeon.org/oxf/xml/formatting" xmlns:xhtml="http://www.w3.org/1999/xhtml"
            xmlns:xxforms="http://orbeon.org/oxf/xml/xforms" xmlns:xi="http://www.w3.org/2001/XInclude"
            xmlns:xxi="http://orbeon.org/oxf/xml/xinclude" xmlns:xs="http://www.w3.org/2001/XMLSchema"
            xmlns:widget="http://orbeon.org/oxf/xml/widget" xmlns:ev="http://www.w3.org/2001/xml-events"
            xmlns:xdt="http://www.w3.org/2005/xpath-datatypes" xmlns:xbl="http://www.w3.org/ns/xbl"
            xmlns:fr="http://orbeon.org/oxf/xml/form-runner" lang="en">
    <xhtml:head>
        <xforms:model id="main-model">
            <xforms:instance id="data-instance">
                <data>
                    <item>
                        <insuredname></insuredname>
                    </item>
                </data>
            </xforms:instance>
            <xforms:instance id="data-template">
                <al>
                    <name></name>
                </al>
            </xforms:instance>
            <xforms:bind nodeset="instance('data-instance')/item/al/name" required="true()" />
           
              <xforms:submission id="save-submission" ref="instance('data-instance')"
                    action="/exist/rest/db/orbeon/test/test.xml"
                    method="put" replace="none">
                <xforms:message ev:event="xforms-submit-error" level="modal">An error occurred while submitting the form! </xforms:message>
           </xforms:submission>
        </xforms:model>
    </xhtml:head>
    <xhtml:body>
        <xhtml:p>
            <xforms:input id="insuredname" ref="item/insuredname" incremental="true" class="input" navindex="1">
                <xforms:label class="fixed-width">Insured Name</xforms:label>
                <xforms:alert>Insured Name is required</xforms:alert>
            </xforms:input>
        </xhtml:p>
        <xhtml:table>
            <xhtml:tr>
                <xhtml:td>
                    <xforms:trigger appearance="minimal">
                        <xforms:label>Add additional location</xforms:label>
                         <xforms:insert ev:event="DOMActivate" context="instance('data-instance')/item" nodeset="item/al"
                                      at="1" position="before" origin="instance('data-template')"/>
                    </xforms:trigger>
                </xhtml:td>
            </xhtml:tr>
            <xforms:repeat nodeset="item/al" id="al-repeat">
                <xhtml:tr>
                    <xhtml:td colspan="2">
                        <xforms:trigger appearance="minimal">
                            <xforms:delete ev:event="DOMActivate" context="instance('data-instance')" nodeset="item/al"
                                           at="index('al-repeat')"/>
                            <xforms:label>Delete</xforms:label>
                        </xforms:trigger>
                    </xhtml:td>
                </xhtml:tr>
                <xhtml:tr>
                    <xhtml:td>
                        <xforms:input id="alname" ref="name" incremental="true" class="input">
                            <xforms:label class="fixed-width">Name</xforms:label>
                            <xforms:alert>Name is required</xforms:alert>
                        </xforms:input>
                    </xhtml:td>
                </xhtml:tr>
            </xforms:repeat>
        </xhtml:table>
          <xhtml:div>
          <xforms:submit submission="save-submission" appearance="full">
                <xforms:label>Submit Request</xforms:label>
            </xforms:submit> 
         </xhtml:div> 
    </xhtml:body>
</xhtml:html>

Pipeline code:

<?xml version="1.0" encoding="utf-8"?>
<p:pipeline xmlns:p="http://www.orbeon.com/oxf/pipeline"
    xmlns:oxf="http://www.orbeon.com/oxf/processors"
    xmlns:xforms="http://www.w3.org/2002/xforms">

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

   
    <p:processor name="oxf:xforms-submission">
        <p:input name="submission">
            <xforms:submission serialization="none" method="get"
                                action="/exist/rest/db/orbeon/test/test.xml"/>
        </p:input>
        <p:input name="request" href="#instance"/>
        <p:output name="response" id="document"/>
    </p:processor>
   
   
    <p:processor name="oxf:pdf-template">
        <p:input name="data" href="#document"/>
        <p:input name="model" href="#instance#xpointer(doc('pdf-model.xml')"/>
        <p:output name="data" ref="data"/>
    </p:processor>

</p:pipeline>


PDF MODEL

<?xml version="1.0" encoding="utf-8"?><config xmlns:dmv="http://orbeon.org/oxf/examples/dmv">
    <template href="oxf:/apps/forms/forms/DMV-14/dmv14.pdf" show-grid="false"/>

    <group ref="/*" font-pitch="15.9" font-family="Courier" font-size="14">
        <field left="435" top="750.2" size="10"
               value="item/insuredname"/>
    </group>
</config>
Reply | Threaded
Open this post in threaded view
|

Re: PDF Generation, what is wrong with my code

Alessandro Vernet
Administrator
In reply to this post by JohnBampton
John,

JohnBampton wrote
Hi all,  I am trying to follow the government forms example to create a pdf.

Three parts below,  I need a trigger added to generate the pdf and any help with the errors in my pipeline or pdf model code.  Do I need a page flow code and if so what is that meant to be?
I recommend you create a simple/minimal app that shows what you are trying to do, going as far as you can. Then zip up the content of the directory for your app, attach  it to a message here, and let us know what works and doesn't work in the code you have done so far. (It is much easier to help when we are talking about actual code rather than concepts.)

Alex
Reply | Threaded
Open this post in threaded view
|

Re: PDF Generation, what is wrong with my code

JohnBampton
Hi,

thanks for your reply.  See that attached set of files.

Basically i need a trigger/button to run the pdf model code in the xhtml file.  I am not sure if I have all the correct files needed to create the pdf.  I think I am missing a file as well, not sure what that should be but I have been stuck on this for about a week. sample.zip

Regards,

John.


Alessandro Vernet wrote
John,

JohnBampton wrote
Hi all,  I am trying to follow the government forms example to create a pdf.

Three parts below,  I need a trigger added to generate the pdf and any help with the errors in my pipeline or pdf model code.  Do I need a page flow code and if so what is that meant to be?
I recommend you create a simple/minimal app that shows what you are trying to do, going as far as you can. Then zip up the content of the directory for your app, attach  it to a message here, and let us know what works and doesn't work in the code you have done so far. (It is much easier to help when we are talking about actual code rather than concepts.)

Alex
Reply | Threaded
Open this post in threaded view
|

Re: PDF Generation, what is wrong with my code

Alessandro Vernet
Administrator
John,

JohnBampton wrote
Basically i need a trigger/button to run the pdf model code in the xhtml file.  I am not sure if I have all the correct files needed to create the pdf.  I think I am missing a file as well, not sure what that should be but I have been stuck on this for about a week. sample.zip
One thing you are missing in this app is the page flow. So I started by putting in a page-flow.xml which just contains: http://pastie.org/614249.

Next, since you are using the oxf:pdf-template processor, you need a PDF template to start with. This processor isn't documented, but you can read about the high level principles in the Form Builder documentation here: http://wiki.orbeon.com/forms/doc/user-guide/form-builder-user-guide#TOC-PDF-generation and you can see how it is used in the code of Form Runner (see the file print-pdf-template.xpl). I hope this will help a bit,

Alex
Reply | Threaded
Open this post in threaded view
|

Re: PDF Generation, what is wrong with my code

JohnBampton
Hi Alessandro,

I am missing the  trigger/button in my xhtml code to run the pdf document.  Can you please provide this?!

I tried copying from the government forms example but i get and error.

Regards,

John.


Alessandro Vernet wrote
John,

JohnBampton wrote
Basically i need a trigger/button to run the pdf model code in the xhtml file.  I am not sure if I have all the correct files needed to create the pdf.  I think I am missing a file as well, not sure what that should be but I have been stuck on this for about a week. sample.zip
One thing you are missing in this app is the page flow. So I started by putting in a page-flow.xml which just contains: http://pastie.org/614249.

Next, since you are using the oxf:pdf-template processor, you need a PDF template to start with. This processor isn't documented, but you can read about the high level principles in the Form Builder documentation here: http://wiki.orbeon.com/forms/doc/user-guide/form-builder-user-guide#TOC-PDF-generation and you can see how it is used in the code of Form Runner (see the file print-pdf-template.xpl). I hope this will help a bit,

Alex