coded_w_wing_medium.png

{i} Latest versions of CreatePdfDocument.py 2.4.2, PDFIcon.py 1.1.0, PDFControl.py 1.0.1
/!\ Supported MoinMoin versions: 1.9, 1.8, 1.7, 1.6, 1.5
Copyright (C) 2006-2010 RaphaelBossek
Copyright (C) 2006 PascalBauermeister

Coded with WingIDE (http://www.wingide.com) open-source license.

Contents

  1. CreatePdfDocument action
  2. PDFControl macro
  3. PDFIcon macro
  4. Configuration and defaults
  5. Bugs
    1. v2.4.2: Don't destroy HTML when macro MiniPage is used for nested tables
    2. v2.4.2: Don't hide empty table cells
    3. v2.4.2: UTF-8 characters in Table-of-Content title
    4. v2.4.2: FastCGI: duplicate header 'Content-Type'
    5. v2.4.2: No images in PDF if they were created with {{drawing:xxx.adraw}} (under investigation)
    6. v2.4.1: Calling add_msg() after send_title(): no message can be added (under investigation)
    7. v2.4.1: Missing images (fixed in v2.4.2)
    8. v2.3.6 and MoinMoin 1.5.8 using 'title file/image': 'module' object has no attribute 'exists' (fixed in v2.4.0)
    9. v2.3.6 ERR005 and ERR012 with latest PdfAction on (standalone) MoinMoin 1.6.x (resolved/invalid)
    10. v2.3.5: ERR017 with MonthCalendar Macro (fixed in v2.3.6)
    11. v2.3.4: Traceback after changing the Title and heading 1 as title (fixed in v2.3.5)
    12. v2.3.4+p1: Python crashes when no user logged in and no previous cookie is present (fixed in v2.3.5)
    13. v2.3.4: Can't use "JPEG big images" different from "None", wrong hmtldoc parameter form (fixed in v2.3.5)
    14. v2.3.4: AttributeError thrown for anonymous users if anonymous sessions are disabled (fixed in v2.3.5)
    15. v2.3.3: extra-dynamiccodeblock-break doesn't work (fixed in v2.3.4)
    16. v2.3.2: Standard Input Error on standalone server (fixed in v2.3.3)
    17. v2.3.1: Pictures missing for ACL protected pages (fixed in v2.3.2)
    18. v2.3.1: Surge protection interference (fixed in MoinMoin v1.7.1)
    19. v2.3.0: AttributeError (fixed in v2.3.1)
    20. v2.3.0: Wrong Author Name (fixed in v2.3.1)
    21. v2.2.0: Missing UTF-8 support
    22. v2.2.0: Cut-off code block (fixed in v2.3.0)
      1. Examples
      2. System Configuration
    23. v2.2.0: Missing Table Borders (fixed in v2.3.0)
  6. Feature requests
    1. Header/Footer Logo
    2. Use of sendcache
    3. No need of external HTMLDOC application
    4. MathML Support
    5. Additional item for page header/footer
    6. TOC with underlined links
    7. Print pdf from a list of pages
  7. Discussion
    1. SinglePageSlideShow support
    2. PDF creation of entire tree
    3. Change HTMLDOC defaults in CreatePdfDocument form
  8. Troubleshooting
    1. Pictures missing in PDF
    2. Pictures missing in PDF (part 2)
    3. Pictures missing in PDF (part 3)
    4. Pictures missing in PDF (part 4) (applied in v2.3.2)
    5. New Page Tag
    6. Using the Frame macro
    7. "Book" style skips text before Heading 1 (works as designed)
    8. In listings eol sign unwanted
    9. output big images
    10. HelpOnAdmonitions
    11. Scale/Fit big images
    12. problems
    13. ideas

CreatePdfDocument action

Please download and rename this action plugin to CreatePdfDocument.py and install it as described in ActionMarket. If everything goes right you will see an additional menu entry in your more actions drop-down list.

This program uses the external HTMLDOC application you have to install yourself. For Debian/Ubuntu users: sudo apt-get install htmldoc

Windows users will have to compile the HTMLDOC application source or google for a Windows binary. One current source is http://htmldoc-binaries.org/ or you can download this copy HTMLDOC_1.8.27.msi. The installer does not add htmldoc to the system path so you will need to add the following configuration line in your MoinMoin configuration file e.g. farmconfig.py (Please refer to HelpOnConfiguration):

PDFControl macro

With HTML comments exist further control possibilities for HTMLDOC. The HTMLDOC documentation gives a nice overview about them.

To be able to add comments within the HTML document the PDFControl macro was developed. Latest version can be found here: PDFControl1_0_1.py

The usage is simple. To create a new page write [[PDFControl(NEW PAGE)]] within your page. NEW PAGE will be written as <!-- NEW PAGE --> within he document. In other words, PDFControl create HTML comments with support for preview mode.

PDFIcon macro

This macro makes it simple to generate PDF documents from a page by clicking. No further configuration is mandatory. Previously saved ##pdf settings are considered.

A picture is displayed on the right side of the screen. Place the [[PDFIcon]] macro in the line you intent to display the picture.

A picture called /icons/pdf.png has to exist. Download MacroMarket/PDFIcon/pdf_48x48.png if you are looking for an example. Otherwise overwrite the pdficon_imageurl configuration variable.

The [[PDFIcon]] macro can be downloaded here: PDFIcon.py

Take a look at http://www.solutions4linux.de/wiki/StartSeite?action=CreatePdfDocument to see how it looks and works.

Configuration and defaults

The default settings are defined in CreatePdfDocument.py. Search for self.default_values and self.valid_options for possible value combinations. Here some examples:

In particular, we want a A4 page size and the viewer should jump to the first chapter if the document is opened. Change your MoinMoin configuration file e.g. farmconfig.py as follows (Please refer to HelpOnConfiguration):

# -*- coding: iso-8859-1 -*-

from MoinMoin.config.multiconfig import DefaultConfig

class Config(DefaultConfig):

    createpdfdocument_defaultvalues = {
        'size': u'a4',
        'firstpage': u'p1',
    }

Bugs

v2.4.2: Don't destroy HTML when macro MiniPage is used for nested tables

When the macro MiniPage is used on a page (to implement nested tables), we have to use a more restrictive regexp to prevent destroying the HTML.

This patch fixes the issue:

--- CreatePdfDocument2_4_2.py   2015-06-18 17:51:36.000000000 +0200
+++ CreatePdfDocument2_4_2_with-dont-break-minipage-macro-in-tables.py  2016-01-20 10:42:26.810799906 +0100
@@ -1724,7 +1724,7 @@
             html = re.compile(r'<ul id="pagelocation">.*?</ul>', re.IGNORECASE | re.DOTALL).sub(u'', html)
             
             # HTMLDOC workarround: There is no CSS support in HTMLDOC.
-            tablecolor = re.compile(r'<td.*?background-color: (#......).*?>')
+            tablecolor = re.compile(r'<td[^>]*?background-color: (#......).*?>')
             for match in tablecolor.finditer(html):
                 html = html.replace(match.group(0), u'<td bgcolor="%s">' % match.group(1), 1)

-- JonasZeiger 2016-01-20 10:50:20

v2.4.2: Don't hide empty table cells

htmldoc don't show empty table cells. The attached patch fills empty cells a non-breaking space (&nbsp;). Thereby htmldoc won't suppress the cells now.

--- CreatePdfDocument.py.old    2012-04-27 09:44:21.042526000 +0200
+++ CreatePdfDocument.py        2014-11-04 12:23:34.642700000 +0100
@@ -1711,6 +1711,9 @@
             for spanmatch in [r'<span[^>]*>', r'</span>']:
                 html = re.compile(spanmatch).sub(u'', html)

+            # HTMLDOC: Show empty table cells
+            html = re.compile(r'<td></td>', re.IGNORECASE | re.DOTALL).sub(u'<td>&nbsp;</td>', html)
+
             # HTMLDOC: Does not support JavaScript.
             html = re.compile(r'<script type="text/javascript".*?</script>', re.IGNORECASE | re.DOTALL).sub(u'', html)

-- CarstenGrohmann 2014-11-04 18:10:38

v2.4.2: UTF-8 characters in Table-of-Content title

When I choose Swedish word as title (Innehåll" I get the fault below. It turns out that it is python execv that complains as can bee seen from apache error log "TypeError: execv() arg 2 must contain only strings". When I use only ascii character it works fine.


Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, webmaster@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.


v2.4.2: FastCGI: duplicate header 'Content-Type'

with a clean install of moinmoin 1.9.3, mod_fastcgi and CreatePDFDocument 2.4.2 I get the following message in the apache error-log:

FastCGI: comm with server "/opt/moin/wiki/server/moin.fcgi" aborted: error parsing headers: duplicate header 'Content-Type', ...

doing an strace on the thread shows the following result:

sendto(5, "Status: 200 OK\r\nContent-Type: text/html; charset=utf-8\r\nVary: Cookie, User-Agent, Accept-Language\r\nContent-Length: 466496\r\nContent-Type: application/pdf\r\nContent-Disposition: inline; filename=\""..., 364, 0, NULL, 0) = 364

So you see that Content-Type is really sent twice with different values (text/html first then application/pdf). I know it was working with an earlier version of moinmoin (1.5.6) and CreatePDFDocument (2.2.0).

Any ideas how to fix that?

As per 191AttachmentsProduceDuplicateHeaderErrorWithFastCGI the following construct should not get used:

request.headers.add(k,v)

Instead this should get used:

self.request.headers[k]= v

The following patch solves the issue:

--- CreatePdfDocument2_4_2.py      2011-06-27 03:48:54.000000000 -0700
+++ CreatePdfDocument.py     2011-06-27 04:52:12.000000000 -0700
@@ -1598,7 +1598,7 @@
                 self.request.emit_http_headers(pre19)
         else:
             for k,v in more_headers.items():
-                self.request.headers.add(k, v)
+                self.request.headers[k]= v


     def send_pdf(self, data):

-- MartinSperl 2011-06-27 09:33:39

v2.4.2: No images in PDF if they were created with {{drawing:xxx.adraw}} (under investigation)

Hi, I tried to make a PDF out of a page which had drawings (HelpOnDrawings) in it

{{drawing:test.adraw}}

Result: The image was not in the PDF. "Normal" images were correctly converted to the PDF. JosefMeier 2010-09-26 14:17:52

v2.4.1: Calling add_msg() after send_title(): no message can be added (under investigation)

Hi, I tried 1.9.2.pre and got this failure, any ideas? pdfbug.txt

v2.4.1: Missing images (fixed in v2.4.2)

We updated our wiki to MoinMoin 1.9.3 and CreatePdfDocument.py 2.4.1 (Debian lenny, python 2.5.2-15+lenny1) . Since then the PDF documents don't contain the images any more. Any ideas what to look for? -- RalfGroß 2010-09-14 07:16:39

v2.3.6 and MoinMoin 1.5.8 using 'title file/image': 'module' object has no attribute 'exists' (fixed in v2.4.0)

If I try using logo.png in title, I get AttributeError, with end of trace like this:

      /data/www/wiki/CreatePdfDocument.py in html2pdf (self=<MoinMoin.action.CreatePdfDocument.CreatePdfDocument instance at 0x84427cc>, html=u'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN...v id="pagebottom"></div>\n</div>\n</body>\n</html>\n\n')
   8.

      /data/www/wiki/CreatePdfDocument.py in attachment_fsname (attachment=u'logo.png', page=<MoinMoin.Page.Page instance at 0x834336c>, request=<MoinMoin.request.RequestCGI object at 0xb7dec54c>)

AttributeError

'module' object has no attribute 'exists'

    * args = ("'module' object has no attribute 'exists'",)
    * message = "'module' object has no attribute 'exists'"

Without title image works ok.

v2.3.6 ERR005 and ERR012 with latest PdfAction on (standalone) MoinMoin 1.6.x (resolved/invalid)

I've just installed this and get these errors:

Command:

htmldoc --cookies MOIN_ID=1234840003.53.23190 --no-duplex --tocheader .t. --bottom 0.50in --header t.D --left 1.00in --linkcolor 0000E0 --headfootsize 11.0 --textcolor 000000 --size a4 --pagelayout single --webpage --compression 0 --title --tocfooter ..i --charset iso-8859-1 --firstpage c1 --toclevels 3 --linkstyle underline --toctitle Contents --format pdf13 --headfootfont helvetica --fontsize 11.0 --fontspacing 1.2 --top 0.50in --headingfont helvetica --numbered --embedfonts --footer ./. --bodycolor FFFFFF --bodyfont times --browserwidth 680 --right 0.50in --pagemode outline --jpeg=0 --permission copy,print,modify,annotate -

returned:

ERR005: Unable to find "0"...
PAGES: 2
ERR012: Unable to write document file - Permission denied

Solution: htmldoc was trying to write to /var/tmp and didn't have permission. Fixed.

v2.3.5: ERR017 with MonthCalendar Macro (fixed in v2.3.6)

After installing the latest PdfAction Files on my MoinMoin 1.8.x I receive the following error:

Commandline:

/home/lotek/bin/htmldoc --cookies MOIN_ID=1164234067.18.4109 --no-duplex --cookies MOIN_SESSION=4nqhjqfd3993s_uo03txk8a9p05uq07v --tocheader .t. --bottom 0.50in --header t.D --left 1.00in --linkcolor 0000E0 --headfootsize 11.0 --textcolor 000000 --size a4 --pagelayout single --webpage --compression 0 --tocfooter ..i --charset iso-8859-1 --firstpage c1 --toclevels 3 --linkstyle underline --toctitle Inhaltsverzeichnis --format pdf13 --headfootfont helvetica --fontsize 11.0 --fontspacing 1.2 --top 0.50in --headingfont helvetica --numbered --embedfonts --footer ./. --bodycolor FFFFFF --bodyfont times --browserwidth 680 --right 0.50in --pagemode outline --jpeg=0 --permission copy,print,modify,annotate -

Error Message:

ERR017: Unknown style property "visibility"!

ERR017: Unknown style property "z-index"!

PAGES: 1
BYTES: 102696

The problem ocures only if you use the  <<MonthCalendar>>  Macro. Because of some "style property".

I believe that this HTML from the MoinMoin Macro creates the problem. Btw. I only use  <<MonthCalendar>> , nothing else:

<div id="infodiv" style="position:absolute; visibility:hidden; z-index:20; top:-999em; left:0px;"></div>

This HTML is generated by the Macro MonthCalendar.py arount 422:

    421 <script type="text/javascript" src="%s/common/js/infobox.js"></script>
    422 <div id="%s" style="position:absolute; visibility:hidden; z-index:20; top:-999em; left:0px;"></div>
    423 %s%s
    424 """ % (request.cfg.url_prefix_static, formatter.make_id_unique('infodiv'), tip_js, restable)
    425     return formatter.rawHTML(result)
Test Link

http://lotek.heavy.ch/test?action=CreatePdfDocument&generate=1

Hope you can reproduce this error. -- 92.104.202.214 2009-01-11 22:18:30

v2.3.4: Traceback after changing the Title and heading 1 as title (fixed in v2.3.5)

used MM version
1.8 devel
example page

http://moinmo.in/MoinAPI/Beispiele

traceback.html

idea how to fix it

   1 --- a/CreatePdfDocument.py      Sun Dec 21 11:25:31 2008 +0100
   2 +++ b/CreatePdfDocument.py      Sun Dec 21 11:28:33 2008 +0100
   3 @@ -1667,7 +1667,7 @@
   4                      html = html.replace (foundref[0] + foundref[1], foundref[0] + base + foundref[1])
   5 
   6              # Rename title of the document.
   7 -            titletext_html = self.fixhtmlstr(wikiutil.escape(newtitle))
   8 +            titletext_html = self.fixhtmlstr(wikiutil.escape(self.values['titletext']))
   9              html = re.compile(r'<title>[^<]+</title>').sub(u'<title>%s</title>' % titletext_html, html)
  10 
  11              if self.values['pageinfo'] == u'unchecked':

Hi. If a user is logged in it works. If, after that, the user logs out and no user is logged in, it still works. If then the cookies for the site are cleaned, and still no user is logged in (i.e. same situation as "first user for that browser is anonymous"), it crashes with the following output. -- CristianoGozzini 2008-11-10

v2.3.4: Can't use "JPEG big images" different from "None", wrong hmtldoc parameter form (fixed in v2.3.5)

Hi, with v2.3.4 I see a similar problem to "v2.3.2: Standard Input Error on standalone server (fixed in v2.3.3)", when "JPEG big images" is selected different from "None". The point seems to be the --jpeg option of htmldoc, which is required in the form --jpeg[=quality] instead of --jpeg [quality] (i.e. it lacks a "="). MoinMoin 1.7.1 with Apache2 on Ubuntu 8.10, and htmldoc 1.8.27.

htmldoc --cookies MOIN_ID=1217930306.89.54550 --no-duplex --cookies MOIN_SESSION=yc6q42uaqm40myfvk_y025tczeyjrtq4 --tocheader .t. --bottom 0.50in --header t.D --left 1.00in --linkcolor 0000E0 --headfootsize 11.0 --textcolor 000000 --size legal --pagelayout single --webpage --compression 0 --title --tocfooter ..i --charset iso-8859-1 --firstpage c1 --toclevels 3 --linkstyle underline --toctitle Indice --format pdf13 --headfootfont helvetica --fontsize 11.0 --fontspacing 1.2 --top 0.50in --headingfont helvetica --numbered --embedfonts --footer ./. --bodycolor FFFFFF --bodyfont times --browserwidth 680 --right 0.50in --pagemode outline --jpeg 100 --permission copy,print,modify,annotate -

returned:

ERR005: Unable to find "100"...
PAGES: 2
BYTES: 203951

-- CristianoGozzini 2008-11-05

v2.3.4: AttributeError thrown for anonymous users if anonymous sessions are disabled (fixed in v2.3.5)

Under the section where cookies are looked for, it is possible throw an exception on at least 1.7.2 if anonymous_session_lifetime is not set in config. The exception derives from:  for cookie in self.request.headers.get('cookie', None).split(';'):  which fails because there is no cookie in the header. I've made a quick fix by wrapping this in a try. Not sure if you'd prefer something more elegant, but here's a patch anyways :-)

@@ -1765,9 +1765,13 @@
             cookie = "MOIN_SESSION=" + self.request.cookie.get("MOIN_SESSION").value
         else:
             # Backward compatibility before MoinMoin 1.7
-            for cookie in self.request.headers.get('cookie', None).split(';'):
-                if cookie[:13] == "MOIN_SESSION=":
-                    break
+            try:
+                for cookie in self.request.headers.get('cookie', None).split(';'):
+                    if cookie[:13] == "MOIN_SESSION=":
+                        break
+            except AttributeError:
+               self.error_msg(u'Could not find MOIN_SESSION cookie otherwise access to ACL protected attachments is prohibited.')
+               return None
         if not cookie[:13] == "MOIN_SESSION=":
             self.error_msg(u'Could not find MOIN_SESSION cookie otherwise access to ACL protected attachments is prohibited.')
             return None

v2.3.3: extra-dynamiccodeblock-break doesn't work (fixed in v2.3.4)

It's possible to set extra-dynamiccodeblock-break: u'unchecked', in the global wiki config, but it will ignored. A good workaround is to set extra-dynamiccodeblock-breakchar: u'', instead.

Note: There is a typo in label_extra-dynamiccodeblock-break in the word "character".

CarstenGrohmann 2008-07-21 22:14:50

v2.3.2: Standard Input Error on standalone server (fixed in v2.3.3)

On a standalone server moin (windows XP, moin 1.7), there seems to be an issue with standard input to htmldoc. The following error message is generated (Note that generation of PDF works fine if htmldoc is called with a "real" html filename:

htmldoc --cookies MOIN_ID=1158834680.6.34914 --no-duplex --cookies MOIN_SESSION=638247fd29ed2d176c38f4b69b30f2e5 --tocheader .t. --bottom 0.50in --header t.D --left 1.00in --linkcolor 0000E0 --headfootsize 11.0 --textcolor 000000 --size legal --pagelayout single --webpage --compression 0 --title --tocfooter ..i --charset iso-8859-1 --firstpage c1 --toclevels 3 --linkstyle underline --toctitle Inhaltsverzeichnis --format pdf13 --headfootfont helvetica --fontsize 11.0 --fontspacing 1.2 --top 0.50in --headingfont helvetica --numbered --embedfonts --footer ./. --bodycolor FFFFFF --bodyfont times --browserwidth 680 --right 0.50in --pagemode outline --jpeg 0 --permission copy,print,modify,annotate -

returned:

ERR005: Unable to find "0"...

ERR005: Unable to find "0"...

PAGES: 2

BYTES: 157887

ThomasKieselstein 2008-07-09

v2.3.1: Pictures missing for ACL protected pages (fixed in v2.3.2)

PDF documents do not contain any pictures which are attached to the page if the page is not readeable to everybody. This problem occur with MoinMoin 1.6 and newer. I'm working already on this issue. -- RaphaelBossek 2008-07-05 17:16:25

v2.3.1: Surge protection interference (fixed in MoinMoin v1.7.1)

If surge protection (HelpOnConfiguration/SurgeProtection) is enabled it may occur that you will missing pictures in your PDF document. To solve this issue FeatureRequests/SurgeProtectionOutOfServiceForLocalhostRequests was created and need a change on moin's sure protection function.

/!\ In the meantime the surge protection has to be disabled to get a valid PDF document.

v2.3.0: AttributeError (fixed in v2.3.1)

I receive an AttributeError with

'RedirectOutputRequest' object has no attribute 'output_string'

Using MoinMoin 1.7.0; see the traceback :AttributeError20080624.html

bye -- MarcelHäfner 2008-06-24 09:56:56

v2.3.0: Wrong Author Name (fixed in v2.3.1)

If you use the CreatePDF 2.3.0 the Authorname is displayed with self: before, like:

Self:MarcelHäfner

Using MoinMoin 1.7

v2.2.0: Missing UTF-8 support

I've found out another problem which you cannot solve - htmldoc does not support utf-8 encoding and by looking at current development pace, it's not very certain when it will :( otoh, having utf-8 suport is a must when writing manuals in different languages. -- GourD 2024-12-29 01:31:21

v2.2.0: Cut-off code block (fixed in v2.3.0)

Last line of a code sequence will suppressed if the closing code tab is on the last code line.

Examples

Line 1 of 2: Two lines normally but this line is only shown in the PDF
Line 2 of 2

Line 1 of 3
line 2 of 3
line 3 of 3: This line will never shown in a PDF

Line 1 of 2: This example works fine
Line 2 of 2: so it can used as a workaround

System Configuration

Moin Moin
MoinMoin Diagnosis
======================

Release 1.5.7
Revision release
Python version 2.5 (r25:51908, Feb  9 2007, 18:33:34)
[GCC 3.2.3 20030502 (Red Hat Linux 3.2.3-52)]
Python installed to /f30fsd1/cam3/unixwiki/python-2.5
PyXML is NOT installed
HTMLDOC
Version 1.8.27

v2.2.0: Missing Table Borders (fixed in v2.3.0)

I had a little Problem with missing Table Borders with CreatePdfDocument.py (2.2.0). Some of the Tables looked like  <table style="width: 90%"> instead of just <table>. My quick and dirty fix was to add an extra regex:

html = re.compile(r'<table>').sub(u'<table border="1" cellpadding="5">', html)
# that's what I added:
html = re.compile(r'<table ').sub(u'<table border="1" cellpadding="5" ', html)

It worked for me but I guess there's a better way to fix this, the Problem is I don't know any python. -- PhilippHoefflin 2008-03-03 17:30:20

Feature requests

To support HTMLDOC's "logoimage" parameter, I suggest the following patch

   1 --- CreatePdfDocument2_4_2.py   2011-11-07 19:11:44.142451205 +0100
   2 +++ CreatePdfDocument.py        2011-11-07 18:55:54.354441018 +0100
   3 @@ -553,6 +553,7 @@
   4              'tocfooterright': u'i',
   5              'bodycolor': u'FFFFFF',
   6              'bodyimage': u'',
   7 +            'logoimage': u'',
   8              'textcolor': u'000000',
   9              'linkcolor': u'0000E0',
  10              'size': u'legal',
  11 @@ -634,7 +635,7 @@
  12              u't': self._(u'Title'),
  13              u'T': self._(u'Time'),
  14              u'.': self._(u'Blank'),
  15 -            # TODO: Not supported yet; u'l': self._(u'Logo image'),
  16 +            u'l': self._(u'Logo image'),
  17          }
  18          self.valid_options[u'style'] = {
  19              u'webpage': self._(u'webpage'),
  20 @@ -864,6 +865,9 @@
  21 
  22              'label_bodyimage': self._(u'Body image'),
  23              'help_bodyimage': self._(u'Enter the image file for the body (background). These file has to be an attachments!'),
  24 +
  25 +            'label_logoimage': self._(u'Logo image'),
  26 +            'help_logoimage': self._(u'Enter the image file for the header logo. This file has to be an attachments!'),
  27 
  28              'label_textcolor': self._(u'Text color'),
  29              'help_textcolor': self._(u'Enter the HTML color for the text.'),
  30 @@ -1271,6 +1275,11 @@
  31          <td>%(help_bodyimage)s</td>
  32      </tr>
  33      <tr>
  34 +        <td class="label"><label>%(label_logoimage)s</label></td>
  35 +        <td class="content"><input type="text" size="30" name="logoimage" value="%(logoimage)s" /></td>
  36 +        <td>%(help_logoimage)s</td>
  37 +    </tr>
  38 +    <tr>
  39          <td class="label"><label>%(label_textcolor)s</label></td>
  40          <td class="content"><input type="text" size="6" name="textcolor" value="%(textcolor)s" /></td>
  41          <td>%(help_textcolor)s</td>
  42 @@ -1819,6 +1828,8 @@
  43                  value = attachment_fsname(value, self.request.page, self.request)
  44              elif opt == u'bodyimage':
  45                  value = attachment_fsname(value, self.request.page, self.request)
  46 +            elif opt == u'logoimage':
  47 +                value = attachment_fsname(value, self.request.page, self.request)
  48 
  49              if opt in [u'style']:
  50                  htmldocopts += [u'--' + value]

Use of sendcache

Can you cache the created pdf file by action sendcache. I have it currently on a wiki were one creates pdf documents with 200 pages. -- ReimarBauer 2010-05-11 16:59:08 For an idea how that can be done have a look at extensions/text_x_mathtran.py#l73

No need of external HTMLDOC application

Native PDF support whould be appreciated.

Libraries to implement native PDF support for MoinMoin; prefered toolkit first:

  1. http://www.reportlab.org/python_point.html - The ReportLab Toolkit is a cross platform Python source package. Performance can be accelerated by compiling some extra code written in C; this is recommended but not required.

  2. http://www.jagpdf.org/ - JagPDF is a free, open source library for generating PDF documents.

MathML Support

Would it be too hard to add MathML support when creating pdf documents? I modified my local moinmoin installation to support MathML (as described in MathMlSupport ), but it does not render equations when converting to pdf. It just shows $$..some equation here ...$$. -- IgorMiletic 2024-12-29 01:31:21

On their webpage either. Let's try $$x^5$$

Additional item for page header/footer

Is it possible to add a new item for the header and footer parameter? There are title, author, date, time, chapter and so on, but I'm missing something like the name of the wiki (the wiki identity, e.g. "Wiki of department xyz") as customized via sitename-variable in 'wikiconfig.py'?
And second, is there a possibility to change the revision-number displayed on the title-page of the pdf document? I'm looking for a leading text like "Version_" or "revision number_" (both with a trailing space instead of the '_' to separate the string from the plain revision number). -- JoergUrbanski 2007-09-25

One other suggestion: I don't think the toc in the pdf needs to be blue and underlined. People will figure out that the links are hot (besides they have the pdf bookmarks). When printed, the underlines will look ugly. Thanks! -- 216.110.85.132 2007-08-21 14:20:32

Good macro. Suggestion to improve: people would be print a page and his subpages.

Discussion

SinglePageSlideShow support

Do you see a chance to get this working together with the SinglePageSlideShow. Each slide on it's own pdf page? So it could become a pdf slide show. -- ReimarBauer 2006-09-29 19:35:12

PDF creation of entire tree

Is there a way to generate the pdf for an entire topic and its subtopics? TWiki has an addon that does this: http://twiki.org/cgi-bin/view/Plugins/GenPDFAddOn

Change HTMLDOC defaults in CreatePdfDocument form

I'd like to change some of the defaults within the form. E.g. the paper size should be set to A4 for us instead of US Letter and the language to de_DE instead of en_US (IIRC). How can this be achieved? BTW: Shouldn't the language be taken from the browser settings? -- GisbertAmm 2006-11-17 09:10:36

Troubleshooting

Pictures missing in PDF

When I greate a attachment:image008.jpg the picture will not be in the pdf document, when I use a externel link I have that picture in the pdf? -- AndreVanWeert

Pictures missing in PDF (part 2)

If you're behind a NATting firewall, you'll get only PDFs without pictures. And due to timeouts this will take quite some time.
Here is a workaround for this problem (for Linux - sorry, I have no clue how to set up an IP alias on Windows): If you're accessing your MoinMoin wiki via IP address (e.g. http://211.23.145.33/moin/PrintThat) then just establish the external address as second IP address for your NIC.
E.g. Your external address is: 211.23.145.33 and your internal: 192.168.44.27

Adjust the apache settings accordingly:

This should give you pictures in PDFs behind firewalls.
-- ThomasGust 2007-07-04 12:49:31

Pictures missing in PDF (part 3)

We use Apache NTLM authentication. The action does not know about this and can not reproduce the login, so htmldoc is not able to retrieve images. To solve this issue, I added the following to Apache's config:

<Location /mywiki>
 Allow from mywiki.company.com
 Satisfy any
 ...
 (other auth lines here)
</Location>

Now requests from the local machine (such as from htmldoc) are allowed. Adjust hostname as appropriate. -- 134.134.136.4 2007-08-20 17:18:08

Pictures missing in PDF (part 4) (applied in v2.3.2)

In the rare case that your server needs a http proxy to access pictures in your document you need to patch CreatePdfDocument.py
E.g. you want to pdf a page which contains  {{http://code.google.com/opensource/ghop/2007-8/images/ghoplogo.jpg}}  but due to a firewall the server(!) (i.e. dochtml) needs to use a proxy to access the picture link.

To solve this add a proxy key with the http://IPADDRESS:PORT-value to createpdfdocument_defaultvalues in your wikiconfig.py:

    # PDF creation options ----------------------------------------------
    createpdfdocument_defaultvalues = {u'size': u'a4', u'language': u'fi_FI',
                                       u'proxy': u'http://192.168.44.250:3128' }

In CreatePdfDocument.py add the 2 lines as depicted below:

   1     def html2pdf(self, html):
   2         """Create a PDF document based on the current parameters."""
   3         # Set environment variables for HTMLDOC
   4         os.environ['LANG'] = self.values[u'language']
   5         os.environ['HTMLDOC_NOCGI'] = '1'
   6         # Determine UID to access ACL protected sites too (mandatory to download attached images).
   7         htmldocopts = [self.default_values['htmldoc_cmd'], "--cookies", "MOIN_ID=" + self.request.user.id, u'--no-duplex']
   8 
   9         for key in [u'header', u'footer', u'tocheader', u'tocfooter']:
  10             self.values[key] = self.values.get(key + u'left', u'.') + self.values.get(key + u'middle', u'.') + self.values.get(key + u'right', u'.')
  11 
  12         ### add these 2 lines below
  13         if u'proxy' in self.default_values:
  14             htmldocopts += [u'--proxy', self.default_values[u'proxy']]
  15 
  16         permissions = []
  17         for opt, value in self.values.items():

Now restart your web server, the problem should be solved. This might outdate Pictures missing in PDF (part 2) if you have a proxy in place. -- ThomasGust 2008-07-02 14:38:40

New Page Tag

It would be nice to have something like a  <!-- PDFA4 -->  so the PDF creator starts at a new page, the document layout would look nicer if you create a PDF from the html source.

Using the Frame macro

not sure if it's a PDFAction bug

I'm using the Frame parser and when I generate a PDF, It doesn't really work. When I create a Frame of width 20%, background color red and alignment on the right, in the PDF file, I have a frame of width 20%, color red, but aligned on the left. -- EricVeirasGalisson

"Book" style skips text before Heading 1 (works as designed)

Hi, if the style "book" is chosen, any text before the first heading is not included in the pdf (while fox example with "continuous" style it's correctly included). MoinMoin 1.7.1 with Apache2 on Ubuntu 8.10, and htmldoc 1.8.27.

-- CristianoGozzini 2008-11-06

That is by design. This allows having table of contents - and other information that is only relevant when browsed from an HTML browser, e.g. links - not to interfere with the PDF output. Table of contents with proper page numbers is solved by HTMLDOC during the export.

This should be kept this way. - 2008-11-08

You write Have at least one heading. My suggestion: Take the title of the page as H1 if none exists. -- ThiloPfennig 2006-09-13 08:59:37

In listings eol sign unwanted

How can I remove the eol char?

listings.png

You can switch it off in the Extra config section "Use a para character for line breaks".

output big images

I have big png images why is JPEG handled different to other image files?

HelpOnAdmonitions

HelpOnAdmonitions uses uses CSS which are not supported by HTMLDOC. Which HTML elements HTMLDOC supports can be found here http://www.htmldoc.org/documentation.php/GeneralUsage.html. -- RaphaelBossek 2009-01-11 15:29:18

Scale/Fit big images

To fit big images to your page site exists three solutions:

  1. You can use the Browser width setting at Page tab. Set here the width of your images (max 1200) to scale them down to fit page borders.

  2. Flip the page with the PDFControl macro. Put your image in between of <<PDFControl(MEDIA LANDSCAPE YES)>> and <<PDFControl(MEDIA LANDSCAPE NO)>>

  3. Change the size of you page with the PDFControl macro. Put your image in between of <<PDFControl(MEDIA SIZE A3)>> and <<PDFControl(MEDIA SIZE A4)>>

-- RaphaelBossek 2009-01-11 15:57:06 -- ReimarBauer 2010-09-14 07:09:38

problems

/!\ The current version copies all MOIN_SESSION_* cookies of a browser to the htmldoc cmdstr. It should select the one of the wiki. e.g.

 MOIN_SESSION_8081_ROOT
 MOIN_SESSION_8080_ROOT

ideas

instead of self.request.form['action'] = ['print'] you can may be use self.request.form['action'] = ['content'] and define the header, without the need to replace or insert something

MoinMoin: ActionMarket/PdfAction (last edited 2016-01-20 09:50:31 by JonasZeiger)