|
|
Coded with WingIDE open-source license: http://www.wingide.com |
Contents
- CreatePdfDocument action
- PDFControl macro
- PDFIcon macro
- Defaults
-
Bugs
- v2.4.1:
- v2.3.6 and MoinMoin 1.5.8 using 'title file/image': 'module' object has no attribute 'exists' (fixed in v2.4.0)
- v2.3.6 ERR005 and ERR012 with latest PdfAction on (standalone) MoinMoin 1.6.x (resolved/invalid)
- v2.3.5: ERR017 with MonthCalendar Macro (fixed in v2.3.6)
- v2.3.4: Traceback after changing the Title and heading 1 as title (fixed in v2.3.5)
- v2.3.4+p1: Python crashes when no user logged in and no previous cookie is present (fixed in v2.3.5)
- v2.3.4: Can't use "JPEG big images" different from "None", wrong hmtldoc parameter form (fixed in v2.3.5)
- v2.3.4: AttributeError thrown for anonymous users if anonymous sessions are disabled (fixed in v2.3.5)
- v2.3.3: extra-dynamiccodeblock-break doesn't work (fixed in v2.3.4)
- v2.3.2: Standard Input Error on standalone server (fixed in v2.3.3)
- v2.3.1: Pictures missing for ACL protected pages (fixed in v2.3.2)
- v2.3.1: Surge protection interference (fixed in MoinMoin v1.7.1)
- v2.3.0: AttributeError (fixed in v2.3.1)
- v2.3.0: Wrong Author Name (fixed in v2.3.1)
- v2.2.0: Missing UTF-8 support
- v2.2.0: Cut-off code block (fixed in v2.3.0)
- v2.2.0: Missing Table Borders (fixed in v2.3.0)
- Feature requests
- Discussion
-
Troubleshooting
- Pictures missing in PDF
- Pictures missing in PDF (part 2)
- Pictures missing in PDF (part 3)
- Pictures missing in PDF (part 4) (applied in v2.3.2)
- New Page Tag
- Using the Frame macro
- "Book" style skips text before Heading 1 (works as designed)
- In listings eol sign unwanted
- output big images
- HelpOnAdmonitions
- Scale/Fit big images
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 change line 595 of CreatePdfDocument.py as follows:
#~ 'htmldoc_cmd': u'htmldoc', 'htmldoc_cmd': u'\progra~2\htmldoc\htmldoc',
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
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/FrontPage?action=CreatePdfDocument to see how it looks and works.
Defaults
The default settings are defined in CreatePdfDocument.py, search for self.default_values.
In particular, you can change the default page size with the 'size' setting, for instance; to make A4 the default size use:
self.default_values = {
...
'size': u'a4',
...
}
Note that the size is in lowercase; other settings are letter and universal.
Bugs
v2.4.1:
Hi, I tried 1.9.2.pre and got this failure, any ideas? pdfbug.txt
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.
I can confirm this issue with MoinMoin 1.5 working on a solution. -- RaphaelBossek 2009-06-09 21:07:45
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".
Could you please describe your call of MonthCalendar? A simple <<MonthCalendar(SampleUser,,12)>> is not enought to catch the problem. -- RaphaelBossek 2009-01-11 22:01:26
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)Hope you can reproduce this error. -- 92.104.202.214 2009-01-11 22:18:30
Please try this patched version CreatePdfDocument2_3_5+p1.py and give me your feedback. Thank you for your support. -- RaphaelBossek 2009-01-12 19:31:39
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 2009-01-12 20:39:10
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
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':
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 2009-01-11 15:59:10
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 CreatePdfDocument2_3_4+p2.py. Please retest this version. -- RaphaelBossek 2008-11-10 20:31:17
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 CreatePdfDocument2_3_4+p1.py and give me an feedback if it worked for you. -- RaphaelBossek 2008-11-10 06:56:07
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 2008-11-10 20:31:17
- 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 2009-01-11 15:57:06
- 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 2009-01-11 15:57:06 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 NoneThank you for this bug report. Could you please check CreatePdfDocument2_3_4+p1.py and give me an feedback if it worked for you. -- RaphaelBossek 2008-11-10 06:56:07
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
Thank you for this bug report. Fixed since v2.3.4. -- RaphaelBossek 2008-09-07 11:12:23
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 2008-07-09 17:43:25
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
I've prepared a new verion for testing. Could you please install the 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 2008-06-25 01:37:19
another error 'RedirectOutputRequest' object has no attribute 'form' ; see my traceback 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: CreatePdfDocument2_3_0+p2.py -- RaphaelBossek 2008-06-25 06:51:37
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 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 2008-06-26 16:19:10
I install it; see debug 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 2008-06-24 09:59:29
Will be fixed in version 2.3.1. Please try CreatePdfDocument2_3_0+p1.py in the meantime. -- RaphaelBossek 2008-06-25 01:37:19
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 2010-09-02 14:42:25
What about selecting the charset at the font tab. Did you tried that ? -- RaphaelBossek 2007-09-24 19:07:59
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 wikipublisher which uses latex-route. It would be nice to have support for moinmoin engine. -- GourD 2010-09-02 14:42:25
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 2008-06-23 21:09:23
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
Thank you for this bug report. This problem was fixed with version 2.3.0. -- RaphaelBossek 2008-06-23 21:09:23
Feature requests
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:
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 2010-09-02 14:42:25
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 2007-08-21 14:20:32
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 2009-01-11 15:29:18
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
To achive this in the best possible way I would prefer to use PythonPoint from ReportLab Open Source. HTMLDOC is only usefull for static pages but not for presentation where some smooth effects are needed. -- RaphaelBossek 2006-09-29 20:44:59
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 <!-- PDFSTART --> and <!-- PDFSTOP --> it's possible to define a region in TWiki's PDF generation plugin. For 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 2006-10-06 21:01:31 I use 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 2006-10-12 18:07:56
Wouldn't this be best achieved with the ReportLab Python PDF library aswell? Is it planned to exchange htmldoc with reportlab in the future? -- GisbertAmm 2006-11-17 09:05:22
Not from my side. Reimplementing HTMLDOC using 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 HTMLDOC has today. There are some other missing features which require my attention
-- RaphaelBossek 2006-11-17 12:56:04 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 2006-11-17 13:04:04
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 2006-11-17 14:12:30
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
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 2006-11-17 12:39:20
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 2006-11-21 13:21:41
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 2008-11-10 20:41:23
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:
Start CreatePdfDocument in debug mode, e.g. http://www.solutions4linux.de/wiki/FrontPage?action=CreatePdfDocument&generate=1&debug=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.
Start htmldoc --continuous myhtmlpage.html at your console and check the generated PDF document.
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 2006-10-07 15:58:40
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 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 2006-10-08 18:30:05
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 2006-10-08 22:42:05
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:
<VirtualHost 211.23.145.33:80 192.168.44.27:80>
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.
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 HTMLDOC's documentaion as mentioned before. -- RaphaelBossek 2006-10-09 18:17:39
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
The 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 2009-01-11 15:29:18
"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
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 2008-11-10 06:56:07
Ok, I see your point. Thank you. -- CristianoGozzini 2008-11-10
In listings eol sign unwanted
How can I remove the eol char?
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:
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.
Flip the page with the PDFControl macro. Put your image in between of <<PDFControl(MEDIA LANDSCAPE YES)>> and <<PDFControl(MEDIA LANDSCAPE NO)>>
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
