Extension talk:PdfBook/Archive

Mediawiki 1.11.0
Version 0.0.3 didn't work anymore after an upgrade. I made a little fix to PdfBook.php around line 98 of PdfBook.php and it works again.

// while ($row = mysql_fetch_row($result)) { while ($row = $db->fetchRow($result)) {

Disclaimer. I don't know PHP for real, don't know mediawiki, don't know how to program. Just got it by inserting debug statements into PdfBook.php. Looks like mysql_fetch is censored somewhere now ;)

PS: To insert debug statements: $wgDebugLogFile = "/tmp/debug.log"; // file should be writable can be anywhere. wfDebug (.....);
 * In LocalSettings.php insert:
 * Anywhere in the code, insert

- Daniel (edutechwiki.unige.ch)

Empty file downloaded
Greetings Nad,

I have been trying to use your PDFBook Mediawiki extension since it may be a great solution to an issue I have.

I have installed HTMLDoc under "c:\pogram files" and can use it on its own to create PDF Books. I have also included the "PdfBook.php" in my "Local Settings.php" file.

The issue I am having is that when I select the link to export my category as a book and select to save or open the pdf file it has 0 bytes. So, the file is created with the correct name but with no data.

Is there something else I must do to ensure HTMLDoc.exe is actually being called by your extension? Is there a required directory that it needs to be in?

Any help would be appreciated!

Thanks!
 * You have to make sure that htmldoc is in your executable PATH so that it can execute from just typing "htmldoc" without needing to supply the full pathname no matter what current directory you're in. Another thing to check would be to comment out the "@unlink($file)" line and after saving a pdf, check if it's left a tmp file in the root of your images directory, which is the data sent to htmldoc. --Nad 00:35, 6 September 2007 (UTC)

Invalid PDF File
Nad,

Thanks for your quick response!

However, I am still having issues. The File is being created and has size to it....but Adobe Reader gives me the following error."

"There is an error opening this document. This file is damaged and cannot be repaired".

HTMLDoc seems to be quitting during the conversion job.

If I add the ".html" extension to the temp file and run HTMLDoc from the command line I can convert the temp html file manully over to a PDF file.

I then compare in Notepad the one I generated and the one your script creates and notice the PDF your script creates quites after pocessing a certain amount of lines.

I have your PDFExport Extension working just fine...so I was wondering what else it could be.

Any ideas?

Thanks!
 * How long is it taking to generate the PDF before quitting? 30 seconds? if that long it could be reaching max execution time? and how large is the PDF before it bails? --Nad 20:29, 6 September 2007 (UTC)

Nad,

It only writes about 18 lines to the .pdf file and takes a couple seconds for the file to generate. It doesn't appear to quit, it saves the file like it normally would however when I edit the file in notepad it is not complete (Stops after ~18 lines with Wordwrap on)

Like I stated before, I'm using your PDFExport Extension and it works great.

Let me know what you think      --136.182.158.153 21:29, 6 September 2007 (UTC)
 * When you run htmldoc manually passing the generated tmp file to it, are you using the exact same command and parameters that the extension uses? --Nad 21:51, 6 September 2007 (UTC)

continued...

Nad,

It only writes about 18 lines to the .pdf file and takes a couple seconds for the file to generate. It doesn't appear to quit, it saves the file like it normally would however when I edit the file in notepad it is not complete (Stops after ~18 lines with Wordwrap on)

If I change this line;

$cmd = "htmldoc -t pdf --charset iso-8859-1 $cmd $file";

to

$cmd = "htmldoc -t pdf --charset iso-8859-1 $cmd $file > test.pdf";

Then I get a test.pdf in my mediawiki root folder which works perfectly


 * You could try changing the htmldoc command to use passthru like Extension:Pdf Export - I had it like that on mine but had problems with the gzip encoding, but it may work better like that for you --Nad 21:55, 6 September 2007 (UTC)

images
Is there any possibility of getting images displayed in the pdf Book as well?. would be a fantastic improvement. Any workarounds? Martin
 * I'm working on it, I just can't get them to work currently. I'm checking out some of the solutions at Extension talk:Pdf Export too as that one uses htmldoc as well. --Nad 12:39, 12 September 2007 (UTC)

Same problem as section 2
I'm on Ubuntu Linux with Mediawiki 1.10. Htmldoc is in /usr/bin. I commented out the unlink command, and the temp file is empty (0 length).

I checked to be sure that my Apache user can run htmldoc -- it can. Unsure what I should try next.

By the way, your single-page export plugin works perfectly (even for images). So I know that htmldoc is not at fault here.
 * I didn't write the single page one, but the code seems pretty similar. I'll just have to see what differences there is in the code between this one and the single-page one. --Nad 22:28, 14 September 2007 (UTC)

Media wiki blank screen fix
I have have installed htmldoc on fedora c 4. yum install htmldoc. Then I installed the Pdf export extension and then mediawiki fails to run at all. I just get a blank screen. Which direction should I take?
 * Whats the details from the special:version page, and is there any content at all in the html source of the blank page? also did you install this extension (Pdf Book) or Extension:Pdf Export?) --Nad 22:34, 15 September 2007 (UTC)

--Johnp125 03:17, 16 September 2007 (UTC)

I installed the PdfBook.php extension. require_once("extnsions/PdfBook.php");

If I take this out the wiki works fine. I have installed several older versions of wiki thinking this might be the issue.

http://www.website.com/wiki/

http://www.website.com/wiki2/

http://www.website.com/wiki3/

none of them work with this extension.

I did a symbolic link for the /usr/bin/htmldoc program to /var/www/cgi-bin/ I made sure apache had access to the htmldoc program and symbolic link.

I just get a blank screen in wiki.

I would love to get this program to work as it is the best program to export by catagories.
 * It could be something to do with it being cgi rather than modphp, I don't have much experience with cgi, but you might want to check specifically if php is able to execute, it needs to be able to execute it directly from the naked "htmldoc" shell command with no preceding path information. You can check this by putting the following one-line php file in your wiki directory and requesting it (ensure its executable by web server):

If that doesn't output a whole bunch of information about htmldoc (like this), then you need to get that working first. You might find some info at http://www.easysw.com/htmldoc/docfiles/5-cgi.html relevent as it's got stuff to do with htmldoc and cgi. --Nad 03:23, 16 September 2007 (UTC)

--Johnp125 23:35, 16 September 2007 (UTC)

I know php is working. Are we using htmldoc in php or cgi-bin, because maybe I do not need to get it working as a cgi script.

Also in the code <?print `htmldoc --help`?> how are you refrencing htmldoc?

<?print `/usr/bin/htmldoc --help`?> maybe like this? would this help the test to work because I'm getting just htmldoc --help after I run this. So maybe it can't find it.

My htmldoc folder for fedora C4 is /usr/bin. My web folder is /var/www/html/. My cgi-bin folder is /var/www/cgi-bin with a alias of www.website.com/cgi-bin/
 * That's exactly what I'm talking about, you need to add htmldoc to your environment's PATH so that it is accessible without preceding it by any specific path information. Although /usr/bin should already be in path, so maybe there's another problem. The key issue is that you need to have htmldoc work simply by typing eg. "htmldoc --help" with no preceding path information. --Nad 00:44, 17 September 2007 (UTC)

--Johnp125 03:08, 17 September 2007 (UTC)

I'm not sure what I need to do to get it working. I have created symbolic links for the cgi-bin directory and the html directory. I'm have added the suggested settings in apache according to the htmldoc info. I know it's my httpd.conf file but not sure what I need to do to fix it. How did you get httpdoc working on your apache server? Maybe that would point me in the right direction. The htmldoc program works from any location but for apache you need a symbolic link.
 * This may be due to your cgi setup which I'm not familiar with; but I don't understand what Apache has to do with this? in my set up Apache has absolutely nothing to do with it, PHP is just executing a shell command, so as long as it can execute from shell with no problem, then it should be fine from PHP. --Nad 03:37, 17 September 2007 (UTC)

More Blank PDF files
--Johnp125 17:56, 17 September 2007 (UTC)

Ok the htmldoc --test works now but I'm getting blank pdf files like the error above.