Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.6 > vBulletin 3.6 Add-ons
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Download Thread as PDF Details »»
Download Thread as PDF
Version: 1.0.1, by magnus magnus is offline
Developer Last Online: Feb 2012 Show Printable Version Email this Page

Category: Show Thread Enhancements - Version: 3.6.7 Rating:
Released: 07-06-2007 Last Update: 07-06-2007 Installs: 78
Uses Plugins Template Edits
Additional Files  
No support by the author.

Keywords: SHOWTHREAD, PDF, Abobe, export, download, thread

Description:
Allows you to download an entire thread in PDF format, viewable in any PDF viewer such as Adobe Acrobat or Foxit Reader.

Details:
Previously, there was a modification that performed this task however that modification is no longer supported and the backend used was seriously out-of-date and suffered from quite a few bugs. I've gone ahead and created this modification around an entirely different backend, one which works quickly and flawlessly.

Requirements:
  • PHP Version 4.0.4 or greater
  • html2ps (link)
  • ps2pdf (link)

Notes:
Please note, these prerequesits may already be installed on your system. If you're unsure, simply install the modification and upon usage it will inform you if something is missing.

If you happen to be fortunate enough to be using Debian, the above requirements can be installed with the following packages:
Code:
# apt-get install html2ps
Code:
# apt-get install gs-common

[hr]-[/hr]
Usage:
Under "Thread Tools", simply select "Download as PDF" which will be located under "Show Printable Version". Easy, eh?

[hr]-[/hr]
Installation:
  1. Download and unzip the pdfthread101.zip archive.
  2. Upload necessary files to their respective locations.
  3. Import the product-pdfthread.xml via the Product Manager.
  4. ???
  5. Profit!

Notes:
All template modifications are made automatically. They attach to pretty common text locations, so modified styles shouldn't* be a problem.

[hr]-[/hr]
Comments:
As with all my hacks, this modification is provided free of charge. However, if you find this product useful and have money burning a hole in your pocket, feel free to make a small donation, I won't mind.. really.

Version History:
  • 1.0.1 - Initial release, here's to hoping...

Currently Known Bugs:
  • None

* Please note that this modification was developed on a forum with a userbase of 1 (myself). I've tested it for basic functionality but I cannot guarantee functionality or behavior on your forum. So, please -- make backups before installing this product!

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #22  
Old 07-08-2007, 01:57 PM
magnus's Avatar
magnus magnus is offline
 
Join Date: Apr 2002
Location: Miami, FL
Posts: 1,107
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Quantnet.org View Post
i'm on a VPS so i have full control over my server. Here is the step i used

wget http://user.it.uu.se/~jan/html2ps-1.0b5.tar.gz
tar xvfz html2ps-1.0b5.tar.gz
cd html2ps-1.0b5
./install

Click yes and set directory..it get installed in /usr/local/bin/

cd /usr/local/bin/
chmod 755 html2p*


Still the same error...did i chmod correctly ? What do i miss ?
The developer states that error is:
Quote:
that is a problem of not having html2ps on your server (or it being in a different path). You'll need to install it in your home directory most likely if you do not have root access on the server
So, that being said.. can you execute html2ps from your shell?
Quote:
# whereis html2ps
html2ps: /usr/bin/html2ps /usr/X11R6/bin/html2ps /usr/bin/X11/html2ps /usr/share/man/man1/html2ps.1.gz
Quote:
# html2ps -v
html2ps version 1.0 beta5
Also, this was mentioned on the same topic by the author:
Quote:
There is PHPs open_basedir, if "/usr/local/bin/" is not within the allowed path, then php scripts won't be able to access the file.

Also check your php.ini file to see if anything has been defined in the directive 'disable_functions'
You may want to try locating html2ps within your webroot, seeing if that will work.
Reply With Quote
  #23  
Old 07-08-2007, 02:01 PM
Paul M's Avatar
Paul M Paul M is offline
 
Join Date: Sep 2004
Location: Nottingham, UK
Posts: 23,748
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I now have this working but several problems needed to be overcome;

The required ghostscript and html2ps were not installed on my server so I had to get them and install them (without 'jasper', whatever that is).

Once installed I got the execution errors and noticed that default path in the class file was wrong - they installed to /usr/local/bin/ (not /usr/bin/) so I had to edit the class file.

Despite fixing this I still got the "not executable" errors, this was quickly traced to php open_basdir kicking in and preventing apache from accessing the binaries - so I had to update php settings.

Once all this was done, the pdf conversion started to work - however, I was only getting one page, not the whole thread. This took a bit of degugging, during which I found some unnecessary code in the threadtopdf.php file. Having removed the unnecessary perpage stuff from the file, I found that even though the code was building the whole thread, once I used it properly, the pdf file was still only one page, with the perpage stuff I had removed.

After much head scratching about how this was impossible I did some packet tracing to see what was going on and found the culprit - VBSEO. I had Rewrite Printthread URLs set to 'Yes' and this was somehow interferring with the way the this mod works, causing the pdf output to be built from printthread.php, and not threadtopdf.php - once I disabled the url rewrite on print threads, the mod started outputting the pdf correctly.

I still have one minor issue - the header image is missing from the threads, but this is not important.


FYI; I removed the following code in threadtopdf.php as perpage stuff is not needed ;
PHP Code:
$vbulletin->input->clean_array_gpc('r', array(
    
'perpage'    => TYPE_UINT,
    
'pagenumber'=> TYPE_UINT
)); 
PHP Code:
    // split thread over pages if necessary
    
$countposts $db->query_first_slave("
        SELECT COUNT(*) AS total
        FROM " 
TABLE_PREFIX "post AS post
        WHERE threadid=
$threadinfo[threadid] AND visible=1
    "
);
    
$totalposts $countposts['total'];

    
$vbulletin->GPC['perpage'] = sanitize_maxposts($totalposts);
    
$maxperpage sanitize_maxposts(-1);

    if (
$vbulletin->GPC['pagenumber'] < 1)
    {
        
$vbulletin->GPC['pagenumber'] = 1;
    }

    
$startat = ($vbulletin->GPC['pagenumber'] - 1) * $vbulletin->GPC['perpage'];

    
$pagenav construct_page_nav($vbulletin->GPC['pagenumber'], $vbulletin->GPC['perpage'], $totalposts'threadtopdf.php?' $vbulletin->session->vars['sessionurl'] . "t=$threadinfo[threadid]"'&amp;pp=' $vbulletin->GPC['perpage']);
    
// end page splitter 
I also edited the SQL to this ;
PHP Code:
    $posts $db->query_read_slave("
        SELECT post.*,post.username AS postusername,user.username
        FROM " 
TABLE_PREFIX "post AS post
        LEFT JOIN " 
TABLE_PREFIX "user AS user USING(userid)
        WHERE post.threadid=
$threadid AND post.visible=1
        ORDER BY dateline 
$postorder
    "
); 

There is also a premissions problem - you cannot pdf threads unless they are viewable by guests, and also a slight error in the url build as well.

I think I have fixed these problems locally, but need to test them, and I have to go out now for a few hours.
Reply With Quote
  #24  
Old 07-08-2007, 05:29 PM
Paul M's Avatar
Paul M Paul M is offline
 
Join Date: Sep 2004
Location: Nottingham, UK
Posts: 23,748
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Paul M View Post
There is also a premissions problem - you cannot pdf threads unless they are viewable by guests, and also a slight error in the url build as well.

I think I have fixed these problems locally, but need to test them, and I have to go out now for a few hours.
JFYI - I've changed the following in threadtopdf.php

PHP Code:
    $htmlFile $vbulletin->options['bburl'] . '/threadtopdf.php?t=' $threadid '&amp;pdf=1'
to

PHP Code:
    $htmlFile $vbulletin->options['bburl'] . '/threadtopdf.php?t=' $threadid
and

PHP Code:
$forumperms fetch_permissions($threadinfo['forumid']);
if (!(
$forumperms $vbulletin->bf_ugp_forumpermissions['canview']) OR !($forumperms $vbulletin->bf_ugp_forumpermissions['canviewthreads']))
{
    
print_no_permission();
}
if (!(
$forumperms $vbulletin->bf_ugp_forumpermissions['canviewothers']) AND ($threadinfo['postuserid'] != $vbulletin->userinfo['userid'] OR $vbulletin->userinfo['userid'] == 0))
{
    
print_no_permission();
}

if (
$threadinfo['open'] == 10)
{
    
exec_header_redirect('threadtopdf.php?' $vbulletin->session->vars['sessionurl_js'] . "t=$threadinfo[pollid]");
}

// check if there is a forum password and if so, ensure the user has it set
verify_forum_password($foruminfo['forumid'], $foruminfo['password']); 
to

PHP Code:
if ($threadinfo['open'] == 10)
{
    
exec_header_redirect('threadtopdf.php?' $vbulletin->session->vars['sessionurl_js'] . "t=$threadinfo[pollid]");
}

if (
$_SERVER['SERVER_ADDR'] != IPADDRESS
{
    
$forumperms fetch_permissions($threadinfo['forumid']);
    if (!(
$forumperms $vbulletin->bf_ugp_forumpermissions['canview']) OR !($forumperms $vbulletin->bf_ugp_forumpermissions['canviewthreads']))
    {
        
print_no_permission();    
    }
    if (!(
$forumperms $vbulletin->bf_ugp_forumpermissions['canviewothers']) AND ($threadinfo['postuserid'] != $vbulletin->userinfo['userid'] OR $vbulletin->userinfo['userid'] == 0))
    {
        
print_no_permission();
    }

// check if there is a forum password and if so, ensure the user has it set
    
verify_forum_password($foruminfo['forumid'], $foruminfo['password']);

Apart from the missing images, I now have a fully operational Thread > PDF (on my test forum).

If I decide to make this live I will probably do custom templates instead of using the printthread templates.
Reply With Quote
  #25  
Old 07-08-2007, 05:42 PM
theFAILURE's Avatar
theFAILURE theFAILURE is offline
 
Join Date: Jan 2005
Posts: 141
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Some of the threads on my site are between 50 to 300 pages long, and are basically stories you read from beginning till end. Mostly all of them have audio and photos as well.

It's nice to have the members logged in and reading the stories, instead of downloading the PDF file then getting logging out.

While reading the threads, it also entices members to post in the thread. While logged out reading PDF files this may not happen.
Reply With Quote
  #26  
Old 07-08-2007, 07:11 PM
rjmjr69's Avatar
rjmjr69 rjmjr69 is offline
 
Join Date: Jan 2007
Location: Southie
Posts: 876
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I get this error when trying am I missing something?

http://www.isosdcftp.com/forums/thre...hp?t=370&pdf=1

If I'm missing those files you posted a link to where do I install those?
Reply With Quote
  #27  
Old 07-08-2007, 07:16 PM
nebu nebu is offline
 
Join Date: Sep 2006
Posts: 73
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

pdf convertion is fine, but i have no pics ...
neither avatars nor images/smilies
Reply With Quote
  #28  
Old 07-08-2007, 07:21 PM
magnus's Avatar
magnus magnus is offline
 
Join Date: Apr 2002
Location: Miami, FL
Posts: 1,107
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by nebu View Post
pdf convertion is fine, but i have no pics ...
neither avatars nor images/smilies
You're not supposed to. It's a PDF of the "View Printable Version" output.
Reply With Quote
  #29  
Old 07-08-2007, 07:23 PM
nebu nebu is offline
 
Join Date: Sep 2006
Posts: 73
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

i overwrited my "old" version (2 days old) with the new one.
it works fine with the old one, but now i get this error message with the new one
"HTML_ToPDF Error: html2ps [/usr/bin/html2ps] not executable"

i have no root access and i dont know what to do
Reply With Quote
  #30  
Old 07-10-2007, 05:38 AM
nebu nebu is offline
 
Join Date: Sep 2006
Posts: 73
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

can u upload the old version again plz?
the old works .....
Reply With Quote
  #31  
Old 07-10-2007, 02:21 PM
Tralala's Avatar
Tralala Tralala is offline
 
Join Date: Jan 2006
Posts: 1,207
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by theFAILURE View Post
Some of the threads on my site are between 50 to 300 pages long, and are basically stories you read from beginning till end. Mostly all of them have audio and photos as well.

It's nice to have the members logged in and reading the stories, instead of downloading the PDF file then getting logging out.

While reading the threads, it also entices members to post in the thread. While logged out reading PDF files this may not happen.

And yet, on the other hand, there are forums with lots of technical information and support shared. Admins might wish to allow their users to be able to locally archive and search this information. Users might feel "safer" knowing they're able to save a long, informative thread to their own computers... should the forum be down or the thread get removed.

Think of vb.org, for example. There have been instances where a hack author leaves, or a mod is removed... in that case, the support thread with all he answers go "poof!" as well. As a forum admin who might be running one of those mods, the ability to save the thread for my own reference later on would be VERY much appreciated.


That said... I, for one, am appreciative that magnus has coded this and is sharing it with us all. Looking forward to seeing improvements, if they are planned. I would like to see the option for images (inline as well as smilies) to be included, if that's possible.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 08:50 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.06540 seconds
  • Memory Usage 2,369KB
  • Queries Executed 25 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (2)bbcode_code
  • (7)bbcode_php
  • (8)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete