tips:pdfexport:htmldoc
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tips:pdfexport:htmldoc [2009-10-31 19:15] – Changed the setup guide 90.184.79.243 | tips:pdfexport:htmldoc [2023-03-08 08:21] (current) – 2409:4070:4387:9f60:5d3e:e9b4:db59:c826 | ||
---|---|---|---|
Line 150: | Line 150: | ||
header(" | header(" | ||
</ | </ | ||
- | To retrieve images from the wiki server (relative links, hope that it won't cause security issues) (I had problems with PNG files, so I converted them into JPEG format). | + | To retrieve images from the wiki server (relative links, hope that it won't cause security issues) (I had problems with PNG files, so I converted them into JPEG format |
<code xml> | <code xml> | ||
$text = preg_replace("'< | $text = preg_replace("'< | ||
Line 535: | Line 535: | ||
$pdfmake_links = array(); | $pdfmake_links = array(); | ||
| | ||
- | | + | $pdfmake_recursion_level = 30; |
- | | + | |
$pdfmake_recursion_current = 0; | $pdfmake_recursion_current = 0; | ||
- | | + | // Now search for children. |
- | $text = pdfmake_children($text); | + | $text = pdfmake_children($text); |
- | | + | // And create the pdf |
- | pdfmake_inner($text); | + | pdfmake_inner($text); |
} | } | ||
function pdfmake_inner($text){ | function pdfmake_inner($text){ | ||
Line 554: | Line 553: | ||
# Convert text and toctitle to destination code-page | # Convert text and toctitle to destination code-page | ||
- | $text=iconv(" | + | $text=iconv(" |
# Change toctitle if needed | # Change toctitle if needed | ||
if ($conf[' | if ($conf[' | ||
Line 651: | Line 650: | ||
#convert using htmldoc | #convert using htmldoc | ||
- | $command = $conf[' | + | |
system($command); | system($command); | ||
system(" | system(" | ||
Line 660: | Line 660: | ||
header(" | header(" | ||
$fd = @fopen($filenameOutput," | $fd = @fopen($filenameOutput," | ||
+ | //Puke on error | ||
+ | if($fd == false) | ||
+ | { | ||
+ | print ' | ||
+ | exit; | ||
+ | } | ||
+ | |||
while(!feof($fd)){ | while(!feof($fd)){ | ||
echo fread($fd, | echo fread($fd, | ||
Line 680: | Line 687: | ||
$links = array(); | $links = array(); | ||
| | ||
- | | + | $pdfmake_recursion_current += 1; |
- | //will contain all subpages at the end. | + | //echo ' |
- | $innerText = ''; | + | //will contain all subpages at the end. |
- | + | $innerText = ''; | |
- | //find all links on page | + | |
- | $regex_pattern = "/< | + | //find all links on page |
- | preg_match_all($regex_pattern, | + | $regex_pattern = "/< |
+ | preg_match_all($regex_pattern, | ||
//The matching pairs will be listed in matches[1]. Sort these matches, so that subnamspaces comes before their parent namespaces. | //The matching pairs will be listed in matches[1]. Sort these matches, so that subnamspaces comes before their parent namespaces. | ||
- | sort($matches[1]); | + | |
- | for($i=0; $i< count($matches[1]); | + | for($i=0; $i< count($matches[1]); |
//extract the internal dokuwiki id of the subpage. This is needed to perform the rendering | //extract the internal dokuwiki id of the subpage. This is needed to perform the rendering | ||
$link = substr($matches[1][$i], | $link = substr($matches[1][$i], | ||
+ | // echo $link, '< | ||
//Dont add a page which has already been included | //Dont add a page which has already been included | ||
if(!in_array($link, | if(!in_array($link, | ||
- | | + | |
- | if(substr($link, | + | |
- | $innerText .= p_wiki_xhtml($link,'', | + | |
| | ||
- | | + | |
- | $pdfmake_links[] = $link; | + | $pdfmake_links[] = $link; |
- | $links[] = $link; | + | $links[] = $link; |
- | } | + | |
- | } | + | |
- | } | + | } |
//Recurse into the next level of internal links | //Recurse into the next level of internal links | ||
if($pdfmake_recursion_current < $pdfmake_recursion_level) { | if($pdfmake_recursion_current < $pdfmake_recursion_level) { | ||
+ | //echo " | ||
$innerText = pdfmake_children($innerText); | $innerText = pdfmake_children($innerText); | ||
} | } | ||
Line 732: | Line 741: | ||
===== Bug fixes ===== | ===== Bug fixes ===== | ||
Here follows a list of fixed bugs | Here follows a list of fixed bugs | ||
- | * 2009-10-31 | + | * 2009-10-31: |
* Fixed a bug in the command line which, on some pages, caused the PDF generation to fail. | * Fixed a bug in the command line which, on some pages, caused the PDF generation to fail. | ||
+ | * Fixed a bug with unconvertable UTF8 chars breaking pdf generation (chars like -> and <-) | ||
--- // | --- // | ||
Line 780: | Line 790: | ||
$filenameOutput=tempnam('',' | $filenameOutput=tempnam('',' | ||
</ | </ | ||
- | |||
====== HTMLDOC request ====== | ====== HTMLDOC request ====== | ||
I think that will be very useful if you can create a page with the list of wiki page to export and HTMLDOC export all these pages into a PDF file.\\ | I think that will be very useful if you can create a page with the list of wiki page to export and HTMLDOC export all these pages into a PDF file.\\ | ||
Line 794: | Line 803: | ||
So you can create pages from which you can extract a PDF file based on more wiki pages | So you can create pages from which you can extract a PDF file based on more wiki pages | ||
+ | |||
+ | **Check the** [[# | ||
===== Config problem with HTMLDOC variant ===== | ===== Config problem with HTMLDOC variant ===== | ||
Line 803: | Line 814: | ||
you have to declare all value in your '' | you have to declare all value in your '' | ||
+ | |||
+ | ===== Changes to the TOC ===== | ||
+ | |||
+ | Some recent changes in the core will break all the TOC-related code above, because [[https:// | ||
+ |
tips/pdfexport/htmldoc.1257012932.txt.gz · Last modified: 2009-10-31 19:15 by 90.184.79.243