Wiki

Clone wiki

satchmo / PdfCreation

PDF Creation

Background : In September 2008 some users/developers expressed their unhappiness with the existing print solution which uses trml2pdf.py. some alternatives are mentioned. This page is a collection of the approaches used and might be a base for further discussion.

Current (as of Sept. 2008) approach

The templates for the documents used are stored as <DOCUMENTNAME>.rml in SITE/templates/pdf, where SITE is the name of the Django project (aka the root for your project). These are standard Django templates, where all tags can and should be used (eg. translation or currency formating).

During the creation the template is then first rendered and then translated to pdf with the help of trml2pfdf.

 pdf = trml2pdf.parseString(smart_str(t.render(c)))

Pros

  • RML allows very detailed and exact positioning of text and formatting
  • Standard templates can be used '''Cons'''
  • RML is another mark-up language to learn and remember
  • There is an existing automatic translation from SXW (Old Open Office Format). This creates a lot of crappy formatting boilerplate and makes the resulting RML almost unreadable (->unmaintainable).
  • The pdf-creation is somehow slow - this is annoying specially when done inside a work flow where customers are involved.

Workaround for some of above limitations

At [http://www.pal-pad.com] the following approach to reduce the cons mentioned is used. (RML Template and document.py <- module used for printing attached).

  • RML is only used for the core data (Address, order data, payment specifics).
  • After the invoice is generated it is as ''raw'' pdf available. ''raw'' means there is no company data whatsoever around.
  • For use in the fulfilment process the ''raw'' pdf is simply printed (b/w Lase, no colour) on the standard (preprinted) business paper. In our case SCRIBUS [http://www.scribus.net] is used to create the pdfs with the printer (in 600 DPI set-up).
  • For use in on-line processing, for example to automatically send the order confirmation and terms (which are easily one page of very small text) to the customer, the same virtual business paper is used. This time just one exported with 90 DPI from SCRIBUS). The ''raw'' pdf is virtually printed on the business paper by merging. This is done with with the pdftk (pdf tool kit [http://www.accesspdf.com/pdftk]).
  • To speed up the send process and to give the users a fast response experience a extra thread is spawned for sending, this approach can be used also for the printing if necessary.

Other approaches NOT using trml2pdf

This is the result of a short investigation into the web - there might be much more solutions around.

  • Appy framework to create odts/pdf/doc/rf/txt. [http://appyframework.org]. The approach for creating the template is similar to GENSHI.

Updated

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.