||<#7bc041 style="text-align:center; " |2> {{attachment:coded_w_wing_medium.png}} || {i} Latest versions of [[attachment:ActionMarket/CreatePdfDocument2_4_2.py|CreatePdfDocument.py]] '''2.4.2''', [[attachment:MacroMarket/PDFIcon/PDFIcon1_1_0.py|PDFIcon.py]] '''1.1.0''', [[attachment:MacroMarket/PDFControl/PDFControl1_0_1.py|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. || <> = 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 [[http://www.htmldoc.org|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 [[attachment: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): . {{{ # -*- coding: iso-8859-1 -*- from MoinMoin.config.multiconfig import DefaultConfig class Config(DefaultConfig): createpdfdocument_defaultvalues = { 'htmldoc_cmd': u'\progra~2\htmldoc\htmldoc', } }}} = PDFControl macro = With HTML comments exist further control possibilities for [[http://www.htmldoc.org|HTMLDOC]]. The [[http://www.htmldoc.org/documentation.php/Comments.html#COMMENTS|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: [[attachment:MacroMarket/PDFControl/PDFControl1_0_1.py|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 {{{}}} 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 {{attachment: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: [[attachment:MacroMarket/PDFIcon/PDFIcon1_1_0.py|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: ||<#eeeeee style="text-align:center; ">'''Parameter''' ||<#eeeeee style="text-align:center; ">'''Values''' ||<#eeeeee style="text-align:center; ">'''Comment''' || ||`size` ||`legal`, `a4`, `letter`, `universal` ||''self-explanatory'' || ||`style` ||`book`, `webpage`, `continuous` ||The same as the menu || ||`format` ||`pdf11`, `pdf12`, `pdf13`, `pdf14` ||Identical with the PDF version format || ||`linkstyle` ||`underline`, `plain` ||''self-explanatory'' || ||`firstpage` ||`c1`, `p1`, `toc` ||`c1`=1st chapter, `p1`=1st page, `toc`=Contents || ||`pagemode` ||`outline`, `document`, `fullscreen` ||''self-explanatory'' || ||`pagelayout` ||`single`, `one`, `twoleft`, `tworight` ||`one`=One column, `twoleft`=Two column left, `tworight`=Two column right || 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'', re.IGNORECASE | re.DOTALL).sub(u'', html) # HTMLDOC workarround: There is no CSS support in HTMLDOC. - tablecolor = re.compile(r'') + tablecolor = re.compile(r']*?background-color: (#......).*?>') for match in tablecolor.finditer(html): html = html.replace(match.group(0), u'' % match.group(1), 1) }}} -- JonasZeiger <> == 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 ({{{ }}}). 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']*>', r'']: html = re.compile(spanmatch).sub(u'', html) + # HTMLDOC: Show empty table cells + html = re.compile(r'', re.IGNORECASE | re.DOTALL).sub(u' ', html) + # HTMLDOC: Does not support JavaScript. html = re.compile(r' 422 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 <> . Please try this patched version [[attachment:CreatePdfDocument2_3_5+p1.py]] and give me your feedback. Thank you for your support. -- RaphaelBossek <> * thanks it works now - without an error message... another trouble is that the MonthCalendar looks horrible (compared to the pre-/htmlview), but well this is for me at the moment not the problem / case. thanks! bye -- MarcelHäfner <> == 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 [[attachment:traceback.html]] idea how to fix it {{{#!diff --- a/CreatePdfDocument.py Sun Dec 21 11:25:31 2008 +0100 +++ b/CreatePdfDocument.py Sun Dec 21 11:28:33 2008 +0100 @@ -1667,7 +1667,7 @@ html = html.replace (foundref[0] + foundref[1], foundref[0] + base + foundref[1]) # Rename title of the document. - titletext_html = self.fixhtmlstr(wikiutil.escape(newtitle)) + titletext_html = self.fixhtmlstr(wikiutil.escape(self.values['titletext'])) html = re.compile(r'[^<]+').sub(u'%s' % titletext_html, html) if self.values['pageinfo'] == u'unchecked': }}} . Thank you for this bug report. If `Heading 1 as title` is checked but there is no heading in the document, the title from the form will be used. -- RaphaelBossek <> == v2.3.4+p1: Python crashes when no user logged in and no previous cookie is present (fixed in v2.3.5) == 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 . Thank you for this bug report. The problem seems to occurs with the CGI server. If fixed this in [[attachment:CreatePdfDocument2_3_4+p2.py]]. Please retest this version. -- RaphaelBossek <> . Now (with no user logged in and cookies cleared) it raises the error: "Could not find MOIN_SESSION cookie otherwise access to ACL protected attachments is prohibited." I verified the attachments are viewable to anonymous users, and there are no user restrictions/access lists configured. -- CristianoGozzini 2008-11-11 == 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 . Thank you for this bug report. Could you please check [[attachment:CreatePdfDocument2_3_4+p1.py]] and give me an feedback if it worked for you. -- RaphaelBossek <> . Hi again. If I select for example "100%", it does create a pdf now, instead of giving the aforementioned error, but the pdf has no images. It seems to be the same result as selecting "None". -- CristianoGozzini 2008-11-10 . Hmm, I can not reproduce the problem on my site. Did you checked possible reasons for missing pictures "Pictures missing in PDF" by ThomasGuest? Could you please check the MoinMoin log for ''access denied'' entries? Is there a possibility for me to get access to your site to make further tests with the debug advanced option? An URL would be helpful. -- RaphaelBossek <> . I think I got it: images were .bmp! I tested with .jpg and .png images, and it works for both. Another limitation of htmldoc, I assume? Two further points: * the {{{#!wiki caution [...] }}} macro is not properly rendered, it just display the text but not the icon nor the surrounding box. I assumed it was something about images. . Read about "HelpOnAdmonitions" in "Troubleshooting" section. -- RaphaelBossek <> * big images are not scaled to fit the page, is there a way to enable it? . Read about "Scale/Fit big images" in "Troubleshooting" section. -- RaphaelBossek <> Thank you very much. -- CristianoGozzini 2008-11-11 == 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 }}} . Thank you for this bug report. Could you please check [[attachment:CreatePdfDocument2_3_4+p1.py]] and give me an feedback if it worked for you. -- RaphaelBossek <> == 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 <> . Thank you for this bug report. Fixed since v2.3.4. -- RaphaelBossek <> == 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 . Thank you for this report. This issue is fixed in v2.3.3. -- RaphaelBossek <> == 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 <> == 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 [[attachment::AttributeError20080624.html]] bye -- MarcelHäfner <> . I've prepared a new verion for testing. Could you please install the [[attachment:CreatePdfDocument2_3_0+p1.py]] file and give me a feedback what happens. I think there is a configuration issue wich is catched in an early stage of initialisation: `No wiki configuration matching the URL found!` !CreatePdfDocument did not expect a problem at this early stage until now. -- RaphaelBossek <> . another error {{{ 'RedirectOutputRequest' object has no attribute 'form' }}}; see my traceback [[attachment:AttributeError_form.html]] (btw. I'm using a farmwiki in standalone mode, behind an apache/proxy) . Ok. The analysis of the code says that the initialisation fails due to a forbidden action. I've added some further checks. If I've done everything right you will see the `No wiki configuration matching the URL found!` error message sometime. Please try an another patch and give me a feedback: [[attachment:CreatePdfDocument2_3_0+p2.py]] -- RaphaelBossek <> . Now a PDF will be generated, but with the error text "No wiki configuration matching the URL found!" (if you click to "preview". You can try it out by ourself under http://lotek.heavy.ch/PageDictsExample?action=CreatePdfDocument (maybe the problem is related that the form give the wrong url for the html view; and that's why the htmldoc shows up this error message) . Interesting is, that if you use the direct link everything works (direct link: http://lotek.heavy.ch/PageDictsExample?action=CreatePdfDocument&generate=1) . I've extended the implementation a little bit to make it possible to collect further debug informations. Please install this new version [[attachment:CreatePdfDocument2_3_0+p3.py]]. Go to expert tab and enable debuging information. Generate a PDF document (which is not) and store the HTML output here so I'm able to check it. -- RaphaelBossek <> . (./) I install it; see debug [[attachment:debug260208.html]] and it works now! thanks, ya great! == 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 . bye -- MarcelHäfner <> . Will be fixed in version 2.3.1. Please try [[attachment:CreatePdfDocument2_3_0+p1.py]] in the meantime. -- RaphaelBossek <> * (./) Authorname is fixed with your test release == 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 <> . What about selecting the charset at the font tab. Did you tried that ? -- RaphaelBossek <> . Well, utf-8 is not supported in htmldoc-1.8.x, but it's planned for 1.9 which is somewhat stalled. I found out about [[http://wikipublisher.org|wikipublisher]] which uses latex-route. It would be nice to have support for moinmoin engine. -- GourD <> == 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. . Thank you for this bug report. This problem is fixed with version 2.3.0. -- 88.66.201.203 <> === 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 {{{ }}} instead of just {{{
}}}. My quick and dirty fix was to add an extra regex: {{{ html = re.compile(r'
').sub(u'
', html) # that's what I added: html = re.compile(r'
> . Thank you for this bug report. This problem was fixed with version 2.3.0. -- RaphaelBossek <> = Feature requests = == Header/Footer Logo == To support HTMLDOC's "logoimage" parameter, I suggest the following patch {{{#!diff --- CreatePdfDocument2_4_2.py 2011-11-07 19:11:44.142451205 +0100 +++ CreatePdfDocument.py 2011-11-07 18:55:54.354441018 +0100 @@ -553,6 +553,7 @@ 'tocfooterright': u'i', 'bodycolor': u'FFFFFF', 'bodyimage': u'', + 'logoimage': u'', 'textcolor': u'000000', 'linkcolor': u'0000E0', 'size': u'legal', @@ -634,7 +635,7 @@ u't': self._(u'Title'), u'T': self._(u'Time'), u'.': self._(u'Blank'), - # TODO: Not supported yet; u'l': self._(u'Logo image'), + u'l': self._(u'Logo image'), } self.valid_options[u'style'] = { u'webpage': self._(u'webpage'), @@ -864,6 +865,9 @@ 'label_bodyimage': self._(u'Body image'), 'help_bodyimage': self._(u'Enter the image file for the body (background). These file has to be an attachments!'), + + 'label_logoimage': self._(u'Logo image'), + 'help_logoimage': self._(u'Enter the image file for the header logo. This file has to be an attachments!'), 'label_textcolor': self._(u'Text color'), 'help_textcolor': self._(u'Enter the HTML color for the text.'), @@ -1271,6 +1275,11 @@ + + + + + @@ -1819,6 +1828,8 @@ value = attachment_fsname(value, self.request.page, self.request) elif opt == u'bodyimage': value = attachment_fsname(value, self.request.page, self.request) + elif opt == u'logoimage': + value = attachment_fsname(value, self.request.page, self.request) if opt in [u'style']: 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 <> For an idea how that can be done have a look at [[http://hg.moinmo.in/moin/extensions/file/766d8ba45f84/data/plugin/parser/text_x_mathtran.py#l73|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. 1. 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 <> 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 == TOC with underlined links == 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 <> . I'm sorry but this is how HTMLDOC works right now. I'm not able to change this for TOC. Maybe set the color of links to something like black would help here. But it's not a solution, I know. -- RaphaelBossek <> == Print pdf from a list of pages == 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 <> . To achive this in the best possible way I would prefer to use [[http://www.reportlab.org/python_point.html|PythonPoint]] from [[http://www.reportlab.org/|ReportLab Open Source]]. [[http://www.htmldoc.org|HTMLDOC]] is only usefull for static pages but not for presentation where some smooth effects are needed. -- RaphaelBossek <> == 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 . Using {{{}}} and {{{}}} it's possible to define a region in TWiki's PDF generation plugin. For [[http://www.htmldoc.org|HTMLDOC]] there is no such feature yet. So for this plugin too. I will consider this idear for one of the next releases. Patches are welcome ;-) -- RaphaelBossek <> . I use [[attachment:skip-one-region.diff]] to skip a fragment of HTML output (see it in action at http://wiki.mad.mw/Mercurial/NanoHowTo where the whole sidebar is omitted) I saved you 30 seconds of programming ;-) . Thank you for this patch. What should be done if someone interchange the order of {{{start}}} and {{{stop}}} ? What about multiple {{{start}}}-{{{stop}}} regions ? The name of the mark should also be changed to something more general. -- RaphaelBossek <> . Wouldn't this be best achieved with the [[http://www.reportlab.org/|ReportLab]] Python PDF library aswell? Is it planned to exchange `htmldoc` with `reportlab` in the future? -- GisbertAmm <> . Not from my side. Reimplementing [[http://www.htmldoc.org|HTMLDOC]] using [[http://www.reportlab.org/|ReportLab]] is not advantage for the enduser. I can be done for fun but I think it will take long time to achive the same quality as [[http://www.htmldoc.org|HTMLDOC]] has today. There are some other missing features which require my attention ;-) -- RaphaelBossek <> . No doubt about that. I didn't think of re-implementing htmldoc in the first place, rather of a Wiki formatter that outputs PDF. However, it is sort of re-inventing the wheel, that's right. I was just curious. -- GisbertAmm <> . Thanks Raphael for that great pdf feature! Pdf support was indeed missing in Moin. I do also think normal users are more likely to generate a copy of a wikipage in pdf than docbook. The only advantage I see in reimplementing pdf generation with !ReportLab in Python is maybe, that pdf generation than will become a built-in-standard feature of Moin with it's own menu item, which does not need an extra setup or downloading and hopefully correct compiling of source codes. That's a problem for me, since at the moment, I do not have a c compiler installed on my system. I have to ask someone to give me a hand in compiling htmldoc. -- OliverSiemoneit <> . Does the PdfAction now have the feature of creating PDFs of a whole tree or a chain of subpages? I see that the discussion above is from 2006. This would really a nice feature. Is there a workaround do do this? -- RalfGroß <> . Not yet and I do not know if ever. I did not spend one minute thing about how to implement this new feature. There are questions which need an answer: 1. How/Who define which pages should be generated ? (Thing about this two minutes and you will see it's not as simple as it may sound in the first second) . Starting multiple downloads within one HTTP session is not supported so the generated PDFs should be stored in one ZIP for download. . Open for suggestions and idears. -- RaphaelBossek <> == 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 <> . All CreatePdfDocument form default values can be set to alternative default values. Define the {{{createpdfdocument_defaultvalues}}} dictionary wihtin your conifugration file like in this example: {{{ createpdfdocument_defaultvalues = {u'size': u'a4', u'language': u'de_DE'} }}} . You have to know that the value of {{{language}}} will be to the value of {{{#langauge}}} defined on the site. For a overview of all definitions search withint the sources for {{{self.default_values}}}. Which values are valid is stored withtin an another dictionary called {{{self.valid_options}}}. Search for both if you like to change these. ''Sorry that I do not describe this more detailed on this side. I think I won't be able to keep this in sync over the time long.'' -- RaphaelBossek <> . How do I change the default format from `book` to `webpage`? I tried `u'style': u'webpage'` in the config but that has no effect. -- GisbertAmm <> . Sorry for this late answer (but I did not found your question). This problem is fixed in v2.4.3 or newer. Set `createpdfdocument_defaultvalues = {u'style': u'webpage'}` in your wiki configuration file as default value. -- RaphaelBossek <> = 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 . To find the problem process with following steps: 1. Start {{{CreatePdfDocument}}} in debug mode, e.g. http://www.solutions4linux.de/wiki/FrontPage?action=CreatePdfDocument&generate=1&debug=1 1. Check if the images are there and save the HTML page together with all related files on you harddisk. The borwser will relink everythink to your local directory structure so there is not internet connection needed to view the HTML document. 1. Start {{{htmldoc --continuous myhtmlpage.html}}} at your console and check the generated PDF document. 1. If the result is as you expect please make a new request without {{{&debug=1}}} and check yours web server access log if the picture's URL is refered. Give me a feedback about your investigation. -- RaphaelBossek <> . The error "You are not allowed to view this page" made me to change my {{{#acl AdminGroup:admin,read,write}}} to {{{#acl AdminGroup:admin,read,write All:read}}}. Now there was no error, and when I make a PDF the image is in the PDF if I change my ACL back to {{{#acl AdminGroup:admin,read,write}}} it is gone. The strange thing is everything else is in the document but not the image, so why do I need {{{All:read}}} for an image? -- AndreVanWeert . Which version of [[http://www.htmldoc.org|HTMLDOC]] are you using ? It's important to use 1.8.25 or newer to get acces for ACL protected pages. ActionMarket/PdfAction uses your MOIN ID to create a cookie for the access to the page as it will be you. Otherwise you get access denied. -- RaphaelBossek <> That Would be the case for my problem then, I use freebsd en just installed it from the port collection. I now see that the port collection version is;1.8.23, I will compile the last version by hand. Thanx for the help and information. -- 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 * As root add a second IP address: {{{/sbin/ifconfig eth0:0 211.23.145.33}}} * Add a route: {{{/sbin/route add -host 211.23.145.33 dev eth0:0}}} Adjust the apache settings accordingly: * {{{}}} This should give you pictures in PDFs behind firewalls.<
> -- ThomasGust <> == 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: {{{ Allow from mywiki.company.com Satisfy any ... (other auth lines here) }}} Now requests from the local machine (such as from htmldoc) are allowed. Adjust hostname as appropriate. -- 134.134.136.4 <> . Won't work in my setup?! If I'm puting these lines into the apache config the Kerberos auth stopped working in the browser and I only get an access denied in the wiki (All: attribute is set in the wiki, only known users are allowed to read/write). -- 213.23.91.62 <> == 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: {{{#!python def html2pdf(self, html): """Create a PDF document based on the current parameters.""" # Set environment variables for HTMLDOC os.environ['LANG'] = self.values[u'language'] os.environ['HTMLDOC_NOCGI'] = '1' # Determine UID to access ACL protected sites too (mandatory to download attached images). htmldocopts = [self.default_values['htmldoc_cmd'], "--cookies", "MOIN_ID=" + self.request.user.id, u'--no-duplex'] for key in [u'header', u'footer', u'tocheader', u'tocfooter']: self.values[key] = self.values.get(key + u'left', u'.') + self.values.get(key + u'middle', u'.') + self.values.get(key + u'right', u'.') ### add these 2 lines below if u'proxy' in self.default_values: htmldocopts += [u'--proxy', self.default_values[u'proxy']] permissions = [] for opt, value in self.values.items(): }}} Now restart your web server, the problem should be solved. This might outdate [[ActionMarket/CreatePdfDocument#PicturesmissinginPDF.28part2.29|Pictures missing in PDF (part 2)]] if you have a proxy in place. -- ThomasGust <> == New Page Tag == It would be nice to have something like a {{{ }}} so the PDF creator starts at a new page, the document layout would look nicer if you create a PDF from the html source. . Install the {{{PDFControl}}} macro to control the PDF processor. To create a new page write {{{[[PDFControl(NEW PAGE)]]}}} into your wiki site. Please refer to [[http://www.htmldoc.org|HTMLDOC]]'s documentaion as mentioned before. -- RaphaelBossek <> == Using the Frame macro == ''not sure if it's a PDFAction bug'' I'm using the [[ParserMarket/Frame|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 . The [[ParserMarket/Frame|Frame parser]] 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 <> == "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 <> . It's a ''disadvantage'' of HTMLDOC: http://www.htmldoc.org/documentation.php/Overview.html I do not like to workarround this. Please introduce yourself a heading. -- RaphaelBossek <> . Ok, I see your point. Thank you. -- CristianoGozzini 2008-11-10 == In listings eol sign unwanted == How can I remove the eol char? {{attachment: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 <> == 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. 1. Flip the page with the `PDFControl` macro. Put your image in between of `<>` and `<>` 1. Change the size of you page with the `PDFControl` macro. Put your image in between of `<>` and `<>` -- RaphaelBossek <> -- ReimarBauer <> == 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
%(help_bodyimage)s
%(help_logoimage)s
%(help_textcolor)s