Commit d615a978 authored by Jérome Perrin's avatar Jérome Perrin

First checkin of PDF Form, a tool for filling PDF forms using TALES expressions.

Those PDF forms can be for example fiscal documents, pretty invoices generated
with scribus etc ...
There is still a huge issue : it depends on pdftk, a gcj compiled program that
does not work with mdk 10.0 zope. I'm investigating this, but it works with a
quick java program emulating pdftk's features. Read PDFForm.py for more info.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@3051 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 24be787b
This diff is collapsed.
...@@ -38,13 +38,13 @@ this_module = sys.modules[ __name__ ] ...@@ -38,13 +38,13 @@ this_module = sys.modules[ __name__ ]
document_classes = updateGlobals( this_module, globals(), permissions_module = Permissions) document_classes = updateGlobals( this_module, globals(), permissions_module = Permissions)
# Define object classes and tools # Define object classes and tools
import Form, FSForm, ListBox, MatrixBox, SelectionTool, ZGDChart, PDFTemplate, Report import Form, FSForm, ListBox, MatrixBox, SelectionTool, ZGDChart, PDFTemplate, Report, PDFForm
import PlanningBox import PlanningBox
import RelationField, ImageField, MultiRelationField import RelationField, ImageField, MultiRelationField
from Products.Formulator.FieldRegistry import FieldRegistry from Products.Formulator.FieldRegistry import FieldRegistry
from Products.Formulator import StandardFields, HelperFields from Products.Formulator import StandardFields, HelperFields
from Products.CMFCore.utils import registerIcon from Products.CMFCore.utils import registerIcon
object_classes = ( Form.ERP5Form, FSForm.ERP5FSForm, PDFTemplate.PDFTemplate, Report.ERP5Report) object_classes = ( Form.ERP5Form, FSForm.ERP5FSForm, PDFTemplate.PDFTemplate, Report.ERP5Report, PDFForm.PDFForm)
portal_tools = ( SelectionTool.SelectionTool, ) portal_tools = ( SelectionTool.SelectionTool, )
content_classes = () content_classes = ()
content_constructors = () content_constructors = ()
......
<dtml-var manage_page_header>
<dtml-var "manage_form_title(this(), _,
form_title='Add ERP5 PDF Form'
)">
<p class="form-help">
PDF Forms allows you to fill some pdf form with TALES, for example using values from ERP5.
</p>
<form action="addPDFForm" method="POST"
enctype="multipart/form-data" >
<table cellspacing="0" cellpadding="2" border="0">
<tr>
<td align="left" valign="top">
<div class="form-label">
Id
</div>
</td>
<td align="left" valign="top">
<input type="text" name="id" size="40" />
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
Title
</div>
</td>
<td align="left" valign="top">
<input type="text" name="title" size="40" />
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
Pdf File
</div>
</td>
<td align="left" valign="top">
<input type="file" name="pdf_file" size="40" />
</td>
</tr>
<tr>
<td align="left" valign="top">
</td>
<td align="left" valign="top">
<div class="form-element">
<input class="form-element" type="submit" name="submit"
value=" Add " />
<input class="form-element" type="submit" name="submit"
value=" Add and Edit " />
</div>
</td>
</tr>
</table>
</form>
<dtml-var manage_page_footer>
<h1 tal:replace="structure here/manage_page_header">Header</h1>
<h2 tal:define="manage_tabs_message options/manage_tabs_message
| request/manage_tabs_message
| nothing"
tal:replace="structure here/manage_tabs">Tabs</h2>
<form action="" method="post" tal:attributes="action request/URL1">
<input type="hidden" name=":default_method" value="doSettings"/>
<p class="form-help">
You can update the parameters for this PDFForm with the form below, it uses
TALES expressions for the following attributes : <br/>
<b>Page range</b> allows to limit the output for a given range of pages,
like "1-3"<br/>
<b>Display zero</b> allows you to control wether 0 values should be
displayed in this form.<br/>
<b>Cells</b> allows you to set the value of each cell.<br/>
</p>
<table width="100%" cellspacing="0" cellpadding="2" border="0">
<tr>
<td class="form-label">Page range</td>
<td><input type="text" name="__page_range__"
value="" tal:attributes="value here/getPageRangeTALES"></td>
</tr>
<tr>
<td class="form-label">Display zeros</td>
<td><input type="text" name="__display_zeros__"
value="" tal:attributes="value here/getDisplayZerosTALES"></td>
</tr>
<tr>
<td class="form-label">Cells</td>
<td>
<table border='1' width="80%" >
<tr><th>Cell name</th><th>TALES expression</th></tr>
<tal:block tal:define="cells here/getCellNames">
<!-- Allow the user to hide cells whose names ends in a,
common in the second page in french fiscal documents,
which is a verbatim copy of the first
NOTE: you have to add yourself omit_XXa_keys in the URL -->
<tr tal:repeat="cell python:request.get('omit_XXa_keys')
and filter(lambda name: str(name)[-1]!='a', cells)
or request.get('omit_XXb_keys', 1)
and filter(lambda name: str(name)[-1]!='b', cells)
or cells">
<td tal:content="cell">Cell Name</td>
<td>
<input type="text"
tal:attributes="name python:cell;
value python:here.getCellTALES(cell);"
size="100"
name="cellname"
value="cellvalue"/>
</td>
</tr>
</tal:block>
<table>
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-element">
<em tal:condition="here/wl_isLocked">Locked by WebDAV</em>
<input tal:condition="not:here/wl_isLocked"
class="form-element" type="submit"
name="doEditCells:method" value="Save Changes">
</div>
</td>
</tr>
</table>
</form>
<h1 tal:replace="structure here/manage_page_footer">Footer</h1>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment