bookcreator Plugin (former pdfbook)

Compatible with DokuWiki

2009-12-25c "Lemming"

plugin Allow to select some pages and create a book (PDF or text)

Last updated on
2010-04-19
Provides
Syntax, Action

Similar to dw2pdf, odt

Tagged with books, export, pdf

Description

The bookcreator plugin allow to select some pages from wiki and export to create a little book PDF or text (like a similar function of Wikipedia)

The component for syntax, displays the list of pages selected for exporting and manage selections; the component for action, handle the selection by a add/removing pages, show a toolbar (like a similar toolbar of Wikipedia).

On the list of selected pages, You can use drag and drop to change the order, save your selection for restore in a second time or share with other users.

At this moment only available Italian, French, English and German language, but it's easy to add you own language.

To work, this plugin needs cookies; the PDF export required dw2pdf plugin; the TEXT ONLY export required text plugin.

Usage

To use this plugin, use these two simple ways:

~~BOOK~~

or

~~ARCHIVEBOOK:number&sort~~

in the page 'wiki:ebook' (create it first).

With ~~BOOK~~ You can show and manage your list of selected pages

  • Reset all selection
  • Exclude a page from list
  • View the excluded pages and “include” them back
  • Create the PDF book on selected pages
  • Create a printable version of selected pages
  • Extract only text of selected pages
  • Drag and drop to change exporting order of page (use Tool-Man JavaScript library )
  • Set a title for the PDF document
  • Save and restore selections on a specific namespace (use ACL's rights)


With ~~ARCHIVEBOOK:number&sort~~ You can show a list of saved selections (books) anywhere into your wiki

  • Restore a selection to manage/export again
  • sort by date/title
  • show only first number selections

Optionally you can specify the number of selections to display and the order. Default is 10 items ordered by date (first last updated). Each of selection is linked to book's page for it.

Installation

To add or remove a page to selection, you simply need to call the page passing it a ”do=addtobookPHP argument. The easiest way to implement this is to add a button or similar somewhere in your template design.

Default template

Use the following to add another button in the upper or bottom button row of the default template1)

<form class="button" method="get" action="<?php wl($ID)?>">
  <div class="no">
    <input type="submit" value="Add/Remove selection" class="button" />
    <input type="hidden" name="do" value="addtobook" />
    <input type="hidden" name="id" value="<?php echo $ID?>" />
  </div>
</form>

Monobook

When using the template ”monobook for DokuWiki”, to have an Add/Remove link, in /user/tabs.php, use this code

//pdfbook plugin: add/remove selection
if (file_exists(DOKU_PLUGIN."bookcreator/action.php") &&
    !plugin_isdisabled("bookcreator")){
    $_monobook_tabs["tab-bookcreator"]["text"] = "Add/Remove to selection";
    $_monobook_tabs["tab-bookcreator"]["href"] = wl(getID(), array("do" => "addtobook"), false, "&");
}

Version history

  • 2010-04-19 (current)
    • add support for ARCHIVE mode
    • rewritten part of code to avoid conflict with other scripts
    • support for use ACL's permissions on pages and book's namespace
  • 2010-04-15
    • some bugs removed (thanks to Karl for tips)
    • allow set wich user's group can save/remove selections
    • hide list of selections if empty
  • 2010-04-15
    • allow to export selection to a text only version (text plugin required)
    • solved problems with cache system
  • 2010-04-14
    • admin side configuration
    • toolbar like Wikipedia “Book creator”
    • support for “Help page
    • allow to set a title for the PDF document (see dw2pdf update)
    • allow to save and restore selections
    • allow to export selection to a printable version

Changing the order of wiki pages

To change the order of wiki pages in your book, simply move the pages in the list. To do so, hover over the page title to move, click and drag it to the new location. Release the mouse button to finish moving the page to its new location.

Saving books

Format of stored book pages: when you save a book, it is stored in the format shown below.

====== MyBookName ======
  * [[:first_pages]]
  * [[:second_page]]
  * .....
  * [[:last_page]]

You can also manually create a book from scratch by using the same format. To create a book from scratch, start a new page such as wiki:ebook:mybookname (default). The namespace can be changed at admin side configuration.

Discussion

There's always room for improvement. If you're able to add any contributions to make pdfbook better, please let me know or discuss your thoughts right here (please use ===== Level 2 Headlines ===== to open a new “thread”/issue and ---- (five dashes, horizontal rule) to structure it when needed).

Problem with Firefox

Bookcreator is the perfect plugin for the needs of one of my sites. Unfortunately, it refuses to work when I use Firefox, and I have apparently the same problem with other Mozilla-like browsers. The resulting book is always empty. The exact same selection gives me a book with other browsers. Does anybody have the same problem ?
- Last version of Dokuwiki, Vector template.
Thanks Michel


Problems with Drag and Drop

Hi - this is the plugin I searched long time for; but I got a Problem with drag and drop - i cant drag a site on wiki:ebook; FF Console says:

listeners[i] ist not a function

and afterwards

newTopLeftOffset is undefinded

If this works, I'll hack some cli stuff, to do an export with cron.

Im Using the Arctic Template.

Thx

I've problems too with Drag and Drop with IE8, it appears an “Invalid argument” on line 122 in drag.js file. It runs ok if I change “var originalZIndex = ToolMan.css().readStyle(this.element, 'z-index');” to “var originalZIndex = this.element.style.zIndex;”. I suppose it's necessary redo the code in css.js file.
— lluís(ma) 2011/01/07

Call-time pass-by-reference has been deprecated

I got this Problem:

Warning: Call-time pass-by-reference has been deprecated; If you would like to pass it by reference, modify the declaration of search(). If you would like to enable call-time pass-by-reference, you can set allow_call_time_pass_reference to true in your INI file in /www/wiki/lib/plugins/bookcreator/syntax.php on line 374

and in syntax.php exist no allow_call_time_pass_reference. How should I modify the declaration of search ()?

Command line PDF export

I have made a few PDF books and it works fine. I need to save them on a regular basis to keep the PDF versions of the books updated. Is it possible to make the export from command line? Regards Jonas

wiki:ebook

if you use acl's then set the acl-permissions for this page to “change”

Compatibility to other templates

I use simple-template. When you install the plugin it completely breaks the css-layout. In your first release everything worked fine with the template-thing. (Maybe there are some more incompatibilities with other plugins) - 20100420; deshi

I have try my plugin on “simple” template, and is all right. Wich version of DokuWiki You use ? Dou you have cleared the cache ?
mluigi 2010/04/21 15:58
I have the same problem using the latest stable version of Dokuwiki. All the links to lib/exe/css.php in the header return empty. This happens with all the templates (even default) and I cleared the cache multiple times. Any hints why this could happen? — yodahomeyodahome

2010/12/07 16:16
Ok, after installing on a vanilla dokuwiki (still losing the stylesheets) I started commenting out several lines in the extension to find the problem. Turns out there's some weird bug in the german lang.php. If you replace this with the english lang.php, css comes back. Maybe something wrong with the enconding? After copying the translation lines one by one into the english lang.php in de/ book creator now works like charm with german translation. I guess other languages work fine. — yodahomeyodahome

2010/12/08 15:38

Firefox

With IE8 I seem to be able to select any page, but in firefox the number of pages you can select is limited (±20) when selecting more then it's max it replaces those pages with the new ones..

(How) Could this error be solved??

— Theo 18/05/2010

Error in 2010-04-19 with German lang

Hi, I've got some trouble with that plugin in my wiki. There is an errormessage:

Warning: Cannot modify header information - headers already sent by (output started at /'serverpath'/wiki/lib/plugins/bookcreator/lang/de/lang.php:1) 

This message dissapears if I change lang to en. I use “Lemming C” with monobook template, but I got the same error while switch back to default template.

I just convertet lang.php to utf8-without BOM, now it works fine for me

Dutch translations

For the settings.php:

<?php
/**
 * Dutch language strings for the Pdfbook Plugin
 *
 */
 
$lang['toolbar']             = 'Toon toolbar';
$lang['toolbar_o_never']     = "Nooit";
$lang['toolbar_o_always']    = "Altijd";
$lang['toolbar_o_noempty']   = "Wanneer er niets geselecteerd is";
 
$lang['save_namespace']      = 'Namespace waar selecties opgeslagen worden'; 
 
$lang['book_page']           = 'Wiki pagina waar het boek getoond wordt';
$lang['help_page']           = 'Wiki pagina waar informatie en instructies staan';
 
$lang['skip_ids']            = 'Toon geen toolbar op de volgende pagina\'s';
 
 
//Setup VIM: ex: et ts=2 enc=utf-8 :

And for the lang.php:

<?php
 
$lang['bookcreator_nocookies']       = "Er zijn nog geen pagina's geselecteerd. Controleer of je browser cookies accepteerd en probeer het opnieuw.";
$lang['bookcreator_empty']           = "Er zijn nog geen pagina's geselecteerd.";
$lang['bookcreator_toprint']         = "Geselecteerde pagina's";
$lang['bookcreator_removed']         = "Pagina's verwijderd uit de selectie";
 
$lang['bookcreator_reserconfirm']    = "Wilt u inderdaad de selectie verwijderen ?";
$lang['bookcreator_reset']           = "Verwijder selectie";
 
$lang['bookcreator_include']         = "Toevoegen aan selectie";
$lang['bookcreator_remove']          = "Verwijder pagina uit selectie";
$lang['bookcreator_export']          = "Exporteer selectie";
$lang['bookcreator_create']          = "Exporteer";
 
$lang['bookcreator_exportpdf']       = "Exporteer selectie naar PDF";
$lang['bookcreator_exportprint']     = "Printbare versie";
$lang['bookcreator_exporttext']      = "Alleen tekst";
 
$lang['bookcreator_title']           = "Titel van het document (optioneel)";
 
$lang['bookcreator_pageadded']       = "Pagina toevoegen aan selectie";
$lang['bookcreator_pageremoved']     = "Pagina verwijderen uit selectie";
 
$lang['bookcreator_addpage']         = "Pagina toevoegen";
$lang['bookcreator_removepage']      = "Verwijder pagina";
$lang['bookcreator_showbook']        = "Toon boek ";
 
$lang['bookcreator_pages']           = "pagina/s";
$lang['bookcreator_help']            = "Help";
 
$lang['bookcreator_toolbar']         = "Book creator";
 
$lang['bookcreator_saveselection']   = "Selectie opslaan";
$lang['bookcreator_needtitle']       = "titel niet gegeven";
$lang['bookcreator_saved']           = "Succesvol opgeslagen in";
$lang['bookcreator_deleted']         = "Succesvol verwijderd";
 
$lang['bookcreator_save']            = "Opslaan";
$lang['bookcreator_listselections']  = "Selectie opgeslagen";
 
$lang['bookcreator_delselection']    = "Verwijder opgeslagen selectie";
$lang['bookcreator_showpage']        = "Toon pagina";
$lang['bookcreator_loadselection']   = "Laad opgeslagen selectie";
 
$lang['bookcreator_confirmdel']      = "Weet u zeker dat u deze selectie uit het archief wilt verwijderen?";
$lang['bookcreator_confirmload']     = "Weet u zeker dat u deze selectie wilt opslaan en de huidige selectie wilt overschrijven?";

Grtz, Theo

print.css

To prevent the printing of the toolbar..

.dokuwiki div.bookcreator__panel { display: none }
.dokuwiki div.bookcreator__ { display: none }

Spanish translations

settings.php

<?php
/**
 * Spanish language strings for the bookcreator Plugin
 *
 * @author  Luigi Micco <l.micco@tiscali.it>
 */
 
 
$lang['toolbar']             = 'Mostrar la barra';
$lang['toolbar_o_never']     = "Nunca";
$lang['toolbar_o_always']    = "Siempre";
$lang['toolbar_o_noempty']   = "Cuando no esté vacía";
 
$lang['save_namespace']      = 'Namespace donde guardar la selección'; 
 
$lang['book_page']           = 'Página donde mostrar el libro';
$lang['help_page']           = 'Página de ayuda';
 
$lang['skip_ids']            = 'No mostrar la barra cuando el ID contiene';
 
//Setup VIM: ex: et ts=2 enc=utf-8 :

lang.php

<?php
/**
 * Spanish language strings for the bookcreator Plugin
 *
 * @author  Luigi Micco <l.micco@tiscali.it>
 */
 
$lang['bookcreator_nocookies']       = "La lista está vacía. Verifique que su explorador permite el uso de cookies y vuelva a intentarlo.";
$lang['bookcreator_empty']           = "La lista está vacía.";
$lang['bookcreator_toprint']         = "Páginas seleccionadas";
$lang['bookcreator_removed']         = "Páginas eliminadas de la selección";
 
$lang['bookcreator_reserconfirm']    = "Realmente quiere eliminar la selección ?";
$lang['bookcreator_reset']           = "Eliminar selección";
 
$lang['bookcreator_include']         = "Añadir a la selección";
$lang['bookcreator_remove']          = "Eliminar de la selección";
$lang['bookcreator_export']          = "Exportar selección";
$lang['bookcreator_create']          = "Exportar";
 
$lang['bookcreator_exportpdf']       = "Exportar selección a PDF";
$lang['bookcreator_exportprint']     = "Versión imprimible";
$lang['bookcreator_exporttext']      = "Solo texto";
 
$lang['bookcreator_title']           = "Título del documento (opcional)";
 
$lang['bookcreator_pageadded']       = "Página añadida a la selección";
$lang['bookcreator_pageremoved']     = "Página eliminada de la selección";
 
$lang['bookcreator_addpage']         = "Añadir esta página al libro";
$lang['bookcreator_removepage']      = "Eliminar esta página del libro";
$lang['bookcreator_showbook']        = "Mostrar, modificar libro";
 
$lang['bookcreator_pages']           = "página/s";
$lang['bookcreator_help']            = "Ayuda";
 
$lang['bookcreator_toolbar']         = "Creación de libros";
 
$lang['bookcreator_saveselection']   = "Guardar selección";
$lang['bookcreator_needtitle']       = "Debe asignar un título";
$lang['bookcreator_saved']           = "Selecciones guardadas correctamente";
$lang['bookcreator_deleted']         = "Selecciones eliminadas correctamente";
 
$lang['bookcreator_save']            = "Guardar";
$lang['bookcreator_listselections']  = "Lista de selección guardada";
 
$lang['bookcreator_delselection']    = "Eliminar selección guardada";
$lang['bookcreator_showpage']        = "Mostrar página";
$lang['bookcreator_loadselection']   = "Cargar selección guardada";
 
$lang['bookcreator_confirmdel']      = "¿Realmente quiere eliminar esta selección del archivo?";
$lang['bookcreator_confirmload']     = "¿Realmente quiere cargar esta selección, remplazando las páginas seleccionadas actualmente?";

Czech translations (cs)

settings.php

<?php
/**
 * Czech language strings for the BookCreator Plugin
 *
 * @author  Jakub Jirutka <jakub@jirutka.cz>
 */
 
$lang['toolbar']             = 'Zobrazit panel nástrojů';
$lang['toolbar_o_never']     = "Nikdy";
$lang['toolbar_o_always']    = "Vždy";
$lang['toolbar_o_noempty']   = "Pokud výběr není prázdný";
 
$lang['save_namespace']      = 'Jmenný prostor pro uložené výběry (knihy)';.
 
$lang['book_page']           = 'Stránka knihy (musí obsahovat ~~BOOK~~)';
$lang['help_page']           = 'Stránka nápovědy';
 
$lang['skip_ids']            = 'Nezobrazovat panel nástrojů, pokud ID stránky obsahuje';

lang.php

<?php
/**
 * Czech language strings for the BookCreator Plugin
 *
 * @author  Jakub Jirutka <jakub@jirutka.cz>
 */
 
$lang['bookcreator_nocookies']       = "Nemáte vybrané žádné stránky. Zkontrolujte, zda máte ve svém prohlížeči povolené cookies a zkute to znovu.";
$lang['bookcreator_empty']           = "Nemáte vybrané žádné stránky.";
$lang['bookcreator_toprint']         = "Vybrané stránky";
$lang['bookcreator_removed']         = "Stránky odebrané z výběru";
 
$lang['bookcreator_reserconfirm']    = "Opravdu chcete smazat výběr?";
$lang['bookcreator_reset']           = "Smazat výběr";
 
$lang['bookcreator_include']         = "Přidat do výběru";
$lang['bookcreator_remove']          = "Odebrat z výběru";
$lang['bookcreator_export']          = "Export výběru";
$lang['bookcreator_create']          = "Export";
 
$lang['bookcreator_exportpdf']       = "PDF";
$lang['bookcreator_exportprint']     = "Tisknutelná verze";
$lang['bookcreator_exporttext']      = "Pouze text";
 
$lang['bookcreator_title']           = "Název dokumentu (nepovinný)";
 
$lang['bookcreator_pageadded']       = "Stránka byla přidána do výběru";
$lang['bookcreator_pageremoved']     = "Stránka byla odebrána z výběru";
 
$lang['bookcreator_addpage']         = "Přidat stránku do knihy";
$lang['bookcreator_removepage']      = "Odebrat stránku z knihy";
$lang['bookcreator_showbook']        = "Zobrazit/upravit knihu";
 
$lang['bookcreator_pages']           = "stránka/y";
$lang['bookcreator_help']            = "Nápověda";
 
$lang['bookcreator_toolbar']         = "Knihař";
 
$lang['bookcreator_saveselection']   = "Uložení výběru";
$lang['bookcreator_needtitle']       = "by měl mít název";
$lang['bookcreator_saved']           = "Výběr byl úspěšně uložen";
$lang['bookcreator_deleted']         = "Výběr byl úspěšně odebrán";
 
$lang['bookcreator_save']            = "Uložit";
$lang['bookcreator_listselections']  = "Uložené výběry";
 
$lang['bookcreator_delselection']    = "Odstranit uložený výběr";
$lang['bookcreator_showpage']        = "Zobrazit stránku";
$lang['bookcreator_loadselection']   = "Načíst uložený výběr";
 
$lang['bookcreator_confirmdel']      = "Opravdu chcete odstranit tento výběr?";
$lang['bookcreator_confirmload']     = "Opravdu chcete načíst tento výběr a nahradit všechny aktuálně vybrané stránky?";

Group bookmarks to namspace

I am searching for an option to group bookmarks to Section / Chapter e.g. namespsaces. Due the fact that the each wiki page with H1 starts at level 0. I would like to have a better overview with huge number of pages in my pdf. Regards, Tom 6/4/10

Latex Issue

The bookcreator don't fetch the latex images created by latex plugin. any ideas? — markumanmarkuman

2011/01/17 12:00

more flexible syntax

the “book page” syntax is very restrictive and don't work with links created from the editor “internal link button”

To “flexify” this, you can edit the file ”/plugin/bookcreator/syntax.php” and replace by this on line 164-188:

                $select= rawWiki($this->getConf('save_namespace').":".$_POST['page']);
                $lines = explode("\n", $select);
                $nr = count($lines);
                $titleRegex = "/^\\s*={3,6}\\s*([^=]*)\\s*={3,6}\\s*$/";
                $linkRegex = "/^.*\\[\\[:?([^|\\]]*)[^\\]]*\\]\\].*$/";
 
                for($n=0; $n<$nr; $n++) {
                  if (trim($lines[$n]) == '') continue;
 
                  if (!$title && preg_match($titleRegex, $lines[$n])){
                    $title = preg_replace($titleRegex, "$1", $lines[$n]);
                  } else if(preg_match($linkRegex, $lines[$n])){
                    $list[$n] = preg_replace($linkRegex, "$1", $lines[$n]);
                    $renderer->doc .= '
  <script type="text/javascript"><!--//--><![CDATA[//><!-- 
  book_changePage(\'bookcreator['.$list[$n].']\', 1, new Date(\'July 21, 2099 00:00:00\'), \'/\');
  //--><!]]></script>';
                    $i++;
                  }
                }

pdf files

Is it possible to embed pdf files in the book ? Would be very nice to be able to do so. Thank you.

Michel, 23-05-2011


ISSUE: handle non-english(utf-8) file name

If the file name is english, everything is OK. But when I try to add a page with Chinese file name, I get 400 Bad Request error. I checked the cookies stored, and find that cookie name is:

bookcreator[topic:linux-parallel:intel„ÑhÕh‰Å]

I think that's where the error comes.

I modified some JavaScript in the code and use urlencoded string in cookies. It seems that the problem is solved. You can check the code here

Update to the new DokuWiki release? Please! :)

Could you please make an update to the new Version of the dokuwiki “Rincewind”. I would pay fot it 50$, for your worktime. Thank you :)

https://github.com/lainme/bookcreator

Don't pay too much attention to the compatibility info on top of the page (there's no automatism which checks the plugins and then changes the compatibility info). Did you installed it under a Rincewind release and tested it? — M. S.M. S.
lupo49

DE / NRW / Sauerland
2011/06/28 22:30
Yes, but it didn´t work as it should. I can add some pages to the Plugin, but it isn´t posible to make a book out of them.
I think the problem is in the dw2pdf plugin: I have make a little test and dw2pdf go wrong on complex pages under Rincewind release
mluigimluigi

Benevento - Italy
2011/06/29 09:10

Not Scaling Well

Building larger books doesn't work well. After adding about 40 pages, the bookmarks begin to break down. Somewhere between 40 and 80 pages, the page goes blank after about a minute and the httpd logs show an Error 500. Would this be a timeout or memory issue that could be resolved with a configuration change?

Particulars are: MacOSX 10.4, Apache 1.3.41, Rincewind, dw2pdf plugin dated 2011-06-12.

Problems downloading files

While uploading files still works and they are'nt corrupted on the filesystem, downloading them reproducable failed, saying file is corrupt. Testet with xlsx- and png-files. System is OpenSuSE 11.3.

Problem with large book

I created a book of 82 pages (counting according to the toolbar), and tried to download the pdf file. This however was disliked by the server that spit out the following error code:

Bad Request

Your browser sent a request that this server could not understand.

Size of a request header field exceeds server limit.

This is due to the large number of cookies set by bookcreator. Any suggestions how to bypass this error?

Bypass: Save the book (“Save Selection”), delete all dokuwiki-cookies, log back in and load saved the book. You have lost some cookies and now it might work (depending on no. of pages in your book, though),

TOC would be great

Bookcreation works realy fine for me, but I have not figured out yet how to get a table of contents into the book

1) In /lib/tpl/default/main.php, there are two divs that contain some buttons: <div class=“bar” id=“bar__top”> and <div class=“bar” id=“bar__bottom”>. Just insert the HTML code inside one of the two divs (left or right)
plugin/bookcreator.txt · Last modified: 2012/02/06 08:51 by 193.159.216.47
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 3.0 Unported
Imprint Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki
WikiForumIRCBugsGitXRefTranslate