Sphene Community Tools

Community

Copyright © 2007-2018 by Herbert Poul

You are not logged in.
Login
Register

Change Language:



AddThis Social Bookmark Button

A Django site.

Powered by Sphene Community Tools

PDF Generation

Wiki / PDFGeneration

The wiki in SCT allows you to generate PDF files on the fly from Wiki snips.

Please note tough, that this is still an experimental feature. It is quite resource expensive and might not be a good idea to be enabled on a high-traffic website.

1. General

The PDF generation works by taking the XHTML generated by the wiki (markdown) and use an XSLT to convert it into XSL-FO and finally generate a PDF out of this XSL-FO.

2. Requirements

So for this process, you will need an XSLT and XSL-FO processor.

3. Configuration

By default PDF generation is disabled. You need to explicitly enable and configure it.

As all SCT configuration the settings are all defined in settings.py by modifying the SPH_SETTING dictionary. The following settings are supported:

3.1. wiki_pdf_generation

Supported Values: True, 'loggedin', 'staff', False

3.2. wiki_pdf_generation_command

Defines the command which is executed to convert the XHTML file into a PDF file.

A typical value can look like the following:

SPH_SETTINGS['wiki_pdf_generation_command'] = \
    'export PATH=/opt/java/bin:$PATH ; /opt/fop/fop -xml %(srcfile)s -xsl ' + \
    os.path.join(SCT_ROOT_PATH, 'sphenecoll', 'sphene', 'contrib', \
    'misc', 'xsl', 'xhtml2fo.xsl') + ' -pdf %(destfile)s '

This command makes quite a few assumptions, so you need to modify it. Here is a short explanation:

3.3. wiki_pdf_generation_cachedir

This is the "cachedir" where generated PDF files (and .xhtml files) will be stored. (Default: /tmp/sct_pdf)

3.4. wiki_pdf_generation_static_filepath

For smileys to work (if you are including a board category in the wiki snip) you need to configure this setting. It should point to the static directory - communitytools/static/sphene within the SCT release / SCT repository.

4. Methods

The wiki snip contains a method 'pdf_enabled()' which will return True or False depending if PDF generation is enabled (for the current user).

An example usage would be (in a template like showSnip.html):

{% if snip.pdf_enabled %}<a href="{{ snip.get_absolute_pdfurl }}">Download PDF</a>{% endif %}

5. Considerations

The generation of PDF files using XSLT and XSL-FO is very performance expensive and can take a few seconds 100% CPU. Since PDF files are generated on the fly if they are not already cached (or if the wiki snip has changed since the last generation) - you should considering only enabling this feature for logged in users or staff.

6. Feedback

This is a experimental feature. So if you are planning on using it please let me know (in the board) what you think about it (performance and feature-wise), if it works for you - and how it could be improved - thanks.

Last Modified: 2007-06-10 22:22:12 by Herbert Poul - [ Snip Changes ] [ Wiki History ]

0 Comments

No comments yet.

Please login to create a new thread.



Powered by Sphene Community Tools