vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.6 Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=194)
-   -   Show Thread Enhancements - Download Thread as PDF (https://vborg.vbsupport.ru/showthread.php?t=151637)

magnus 07-06-2007 10:00 PM

Download Thread as PDF
 
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!

magnus 07-07-2007 09:32 PM

Reserved.

jasculs 07-07-2007 10:20 PM

What do I do with these?

* html2ps (link)
* ps2pdf (link)

I'm not sure where to put them and I couldn't quite understand the installation instruction.

magnus 07-07-2007 10:26 PM

Quote:

Originally Posted by jasculs (Post 1285413)
What do I do with these?

* html2ps (link)
* ps2pdf (link)

I'm not sure where to put them and I couldn't quite understand the installation instruction.

The applications html2ps and ps2pdf are both dependencies of this modification. If they're not already present on your system, they will need to be downloaded, compiled and installed. These utilities are not vBulletin related, they have absolutely nothing to do with vBulletin.

Chances are, if you're using a shared hosting account, these are already installed. Before trying to install them, I would just attempt to run the modification first and see if they're already present.

FleaBag 07-07-2007 10:46 PM

I have printthread completely removed for SEO purposes. This is just the alternative I've been waiting for! Thanks. :)

Barakat 07-08-2007 12:27 AM

all the time :- safe mode effect .

Quote:

Warning: unlink() [function.unlink]: SAFE MODE Restriction in effect. The script whose uid is 583 is not allowed to access /tmp/thread5918aSSCNI owned by uid 48 in /threadtopdf.php on line 179
HTML_ToPDF Error: html2ps [/usr/bin/html2ps] not executable
dont we have a way to prevent it .

Hornstar 07-08-2007 12:28 AM

This really looks like a good feature for any forums. Thanks for releasing, will test it out shortly.
Thanks.

ssslippy 07-08-2007 02:58 AM

Quote:

Originally Posted by Barakat (Post 1285476)
all the time :- safe mode effect .

dont we have a way to prevent it .

Unfortunally your host has safe mode. You would need to contact them to resolve this issue.

Quantnet 07-08-2007 03:14 AM

installed this and html2ps but still have the error
HTML_ToPDF Error: html2ps [/usr/bin/local/html2ps] not executable

I changed the path in /includes/class_threadtop.php to /usr/bin/local/html2ps to no avail

This mod requires the use a direct access to their server. What about those on shared hosting ?

magnus 07-08-2007 03:53 AM

A few friends of mine run vBulletin sites on shared hosting and they were able to use this modification no problem. Really, it's hit or miss with some shared hosting providers.

The html2ps error you're receiving is claiming the binary isn't set to executable. What are the permissions? Did you install from source or did you use a package (ie. rpm, deb)?

A simple chmod 755 should fix it (provided you have rights to do that).

Quantnet 07-08-2007 04:14 AM

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 ?

soletrader 07-08-2007 05:17 AM

anyone have the link to the older version of this hack?

ragtek 07-08-2007 05:35 AM

Quote:

Originally Posted by FleaBag (Post 1285443)
I have printthread completely removed for SEO purposes. This is just the alternative I've been waiting for! Thanks. :)

this is unnecessary.

this link is marked with
HTML Code:

rel="nofollow"
so the bots aren't indexing it and so you woun't have double content

SuperTaz 07-08-2007 06:16 AM

Is there a screenshot of this?

Lizard King 07-08-2007 08:33 AM

Quote:

Originally Posted by ragtek (Post 1285581)
this is unnecessary.

this link is marked with
HTML Code:

rel="nofollow"
so the bots aren't indexing it and so you woun't have double content

Every search engine bot doesn't rely on rel="nofollow" .

ragtek 07-08-2007 08:43 AM

hm
i havnt heard that before, but ok
have to belive you, because i'm not very interessted in this subject/topic(don't know how to say for that)

in my eyes i make a site for the people and not for the bots.... but back to topic

and isn't it right that google can look pdf files to?
so wount it be double content?

irantk 07-08-2007 09:49 AM

HTML_ToPDF Error: html2ps [/usr/bin/html2ps] not executable ???????????????????????

FleaBag 07-08-2007 10:07 AM

As my firend says, not all engines use the attribute. Also, while Google not double listing content in this way, other engines may do so - and Google will not take kindly to you have duplicate content indexed elsewhere (at least, this is what I believe). I also have no desire to allow a printable thread, if they wish to print the thread so much they can print the normal page (or now, use this).

Also, I intend to allow only members access to this - so no duplicate content issues there.

projectego 07-08-2007 12:57 PM

Awesome! :D

[high]* projectego clicks install[/high]

magnus 07-08-2007 01:50 PM

Quote:

Originally Posted by Warden-B- (Post 1285608)
Is there a screenshot of this?

Uh, a screenshot of what a PDF file looks like? :confused:

magnus 07-08-2007 01:57 PM

Quote:

Originally Posted by Quantnet.org (Post 1285548)
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.

Paul M 07-08-2007 02:01 PM

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.

Paul M 07-08-2007 05:29 PM

Quote:

Originally Posted by Paul M (Post 1285813)
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. :cool:

theFAILURE 07-08-2007 05:42 PM

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.

rjmjr69 07-08-2007 07:11 PM

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?

nebu 07-08-2007 07:16 PM

pdf convertion is fine, but i have no pics ...
neither avatars nor images/smilies :(

magnus 07-08-2007 07:21 PM

Quote:

Originally Posted by nebu (Post 1286057)
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.

nebu 07-08-2007 07:23 PM

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 :(

nebu 07-10-2007 05:38 AM

can u upload the old version again plz?
the old works .....

Tralala 07-10-2007 02:21 PM

Quote:

Originally Posted by theFAILURE (Post 1285988)
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.

magnus 07-10-2007 07:54 PM

Yea, I'm trying to rework this modification to make it a bit easier for those on shared hosts who don't necessarily have access to server configs.

This was just a quick attempt to fill a requested need. We'll see what develops.

nebu 07-11-2007 09:11 AM

thx :)

testebr 07-11-2007 09:26 AM

Which to real need of having a topic in pdf?

magnus 07-11-2007 10:44 AM

Quote:

Originally Posted by testebr (Post 1288233)
Which to real need of having a topic in pdf?

There's plenty of uses for a modification such as this. For instance, if you run a technical site many times a thread will be one of your best sources of information. So, rather than printing it out you can simply save the thread in PDF format for reference purposes -- so if you ever need it again, the information is readily available.

Or, perhaps, you run a gaming site. Often threads will contain game hints, tips, walkthroughs or the like. Again, you can just save the thread to PDF and have it available at your fingertips.

The list goes on and on. However, if you cannot fathom a use for your site then perhaps this modification isn't for you.

Quantnet 07-14-2007 09:58 AM

any development on this, magnus ?

magnus 07-16-2007 01:29 PM

On this one, no. I'm trying to achieve the same results w/o the need for any non-standard unix binaries. There are a few ways to do it, but unforunately, they're not nearly as efficient. But, I do have a couple things in the works -- hopefully a viable solution will fall into place soon.

Simon Moon 07-25-2007 03:12 AM

I have installed this on a new forum (not visible to the public yet) and it gives me a blank pdf. It clearly is a pdf though, but it is empty, just no content at all. I have vBSEO installed, could that interfere in some way?

magnus 07-25-2007 11:33 AM

Quote:

Originally Posted by Simon Moon (Post 1300791)
I have installed this on a new forum (not visible to the public yet) and it gives me a blank pdf. It clearly is a pdf though, but it is empty, just no content at all. I have vBSEO installed, could that interfere in some way?

In your vBSEO settings, make sure "Rewrite Printthread URLs" is set to No.

Simon Moon 07-25-2007 03:08 PM

I tried that, doesn't work though. It still shows a completely empty PDF.

Looking a bit deeper, does it have problems with basedir restrictions?
Safe mode is off, but basedir is limited to the public html directory.

magnus 07-25-2007 03:42 PM

Quote:

Originally Posted by Simon Moon (Post 1301271)
I tried that, doesn't work though. It still shows a completely empty PDF.

Looking a bit deeper, does it have problems with basedir restrictions?
Safe mode is off, but basedir is limited to the public html directory.

There is PHPs open_basedir, if "/usr/local/bin/" (or wherever you've placed your html2ps binary) is not within the allowed path, then php scripts won't be able to access the file.


All times are GMT. The time now is 06:25 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01501 seconds
  • Memory Usage 1,895KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (2)bbcode_html_printable
  • (7)bbcode_php_printable
  • (17)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete