A rough-but-functional rewrite of the Pdfview module for 4.7. Most of the original code has been replaced by ripped stuff from print.module, and the documentation has been updated to reflect the html2fpdf requirement, rather than fpdf.

Comments

sanduhrs’s picture

StatusFileSize
new10.47 KB

Theres a typo on line 60 of pdfview.module.
Changed your patch accordingly.

Would be great if pdfview could support book-type nodes.
It could use the output generated by the "printer-friendly version " version.

vg

tfejos’s picture

Couldnt' apply the patch.

$ cat pdfview_02.patch |patch
patching file CHANGELOG
patching file INSTALL
patching file README.txt
patching file pdfview.module
patch unexpectedly ends in middle of line
patch: **** malformed patch at line 333:

Can anyone send me a patched Pdfview for 4.7?

inteja’s picture

Same here. Malformed patch. Tried everything I could. Can some please redo the patch or post the already patched module?

inteja’s picture

Scrap that. pdfview_02.patch didn't work for me but pdfview_1.patch did.

urbanfalcon’s picture

Status: Needs work » Needs review
StatusFileSize
new9.81 KB

Updated against CVS. Works in 4.7 and, with this patch, can recursively print out not just book nodes but entire books (each node being on a separate page within the same pdf). Patch also introduces ability to show/hide link per node type in addition to access control via permissions. Tested and everything works on my end, but doesn't hurt to get a second opinion.

Tobias Maier’s picture

please follow the coding standards
http://drupal.org/node/318

especially this: http://drupal.org/node/539
your patch is hard to read because you replaced every double-space with tabs

remove the ?> at the end of the file

urbanfalcon’s picture

StatusFileSize
new9.5 KB

For the benefit of the community, I did a quick search + replace for tabs. Hopefully the patch still works...theoretically, it shouldn't have corrupted anything. Tabs vs. spaces is an endless debate, but tabs require less space in a file than multiple spaces (and thus obviously get my vote). To make everyone happy, I'll keep my copy (and my installation) streamlined with tabs...and hopefully search + replace will work for stuff like this.

darren oh’s picture

StatusFileSize
new9.24 KB

pdfview_3.patch did not work. I patched with pdfview_2.patch and generated a new diff according to the instructions in the handbook. I hope it's acceptable.

pancapangrawit’s picture

Cool, pdfview.module.patch works for me in 4.7 with php5.

May I ask: is there a way to configure the codepage or characterset? We use german texts and have a lot of Umlauts. They show up as:

TestArtikel für IME-Intern (rather than 'für')

Thanks for any help
Best
Rainer Schuetz

Luca Lenardi’s picture

StatusFileSize
new9.48 KB

This patch fixes some small bugs (for l12n and other small things) and also implements the support for phptemplate.
The 'pdfview_generate_page' is now a theme function so that users can modify it in template.php.

pancapangrawit’s picture

Was that latest patch supposed to do something about the "Umlauts" (üä etc)? If yes, it seems not to have done the job :-(. Could somebody give me a hint what to do in order to make german special characters (äöüÄÖÜß) work? In the html2pdf subdirectory I see all sorts of characterset-related files but I couldn't find any info how to solve my problem.

Thanks in advance for any help
Rainer

killes@www.drop.org’s picture

Rainer, this is sort of non-fixable unless you convert Drupal's output to latin1 before (which might break other stuff). PDF and utf-8 don't go together well.

pancapangrawit’s picture

thanks, killes

urbanfalcon’s picture

Priority: Normal » Critical

Two things I have found with this module:

1.) The pdfview output wasn't taking into account any filters. If you format all your pages to "talk like a pirate" you want to see pirate speak in your pdf, not a completely different body.

2.) There's no protection for pages containing PHP code. If you have a book page filtered to allow code and you save it out so that it runs and does whatever to display dynamic content...your user might think they can get that dynamic content output to PDF. However, what they get is a printout of your entire node body in pre-rendered PHP code. They can see every echo, and every password you may have been unlucky enough to use for external database connections. This is a serious security issue.

My fix for both was to turn this:

function pdfview_generate_page($pdf, $nid) {
	if (user_access('access content as pdf')) {	
		$node = node_load($nid);
		$body = $node->body;
		}

into:

function pdfview_generate_page($pdf, $nid) {
	if (user_access('access content as pdf')) {	
		$node = node_load($nid);
		$body = $node->body;
		
		$body = check_markup($body);
		if (strpos($body, "<?") && strpos($body, "?>")){
			$body = '<p align="center"><font color="red">**ERROR**</font></p><p align="center">This page contains executable PHP code.<br><br>It cannot by dynamically converted to PDF from <i>within the system</i> without posing a security risk.</p>';
			}

I'd like to see that the PHP code is actually rendered out the way the user experiences it on the actual page, but I haven't found a way to do that. The eval function is not reliable as there's no way to know the depth of the PHP code within the body.

Egon Bianchet’s picture

This one works with TCPDF, which supports UTF8 and many other things.

You have to download the PHP4 version, extract it in to the modules folder, and set the "K_PATH_MAIN" variable into tcpdf_php4/config/tcpdf_config.php

Egon Bianchet’s picture

I meant "into the module folder"

Egon Bianchet’s picture

StatusFileSize
new9.49 KB

D'oh

killes@www.drop.org’s picture

Egon, would you like to become the maintainer of this module? I wrote is quite some time ago but handed it to the librarian who seems to be not too interested anymore.

Egon Bianchet’s picture

Yes, I'd be happy to do it :-)

killes@www.drop.org’s picture

Ok, I've assigned the project node to you. IF you don't already have cvs access you will need to apply at http://drupal.org/cvs-account

Egon Bianchet’s picture

I sent an application months ago but I think it's still pending ...

killes@www.drop.org’s picture

I have fixed this.

Egon Bianchet’s picture

Status: Needs review » Fixed

Committed to HEAD

pancapangrawit’s picture

Coool!
Thanks a lot Egon and others.
Rainer

darren oh’s picture

Priority: Critical » Minor
Status: Fixed » Active

Pdfview does not yet appear in the list of 4.7 modules.

darren oh’s picture

Title: Pdfview: Rewrite for 4.7 compatability » Pdfview for 4.7
Egon Bianchet’s picture

Status: Active » Fixed
darren oh’s picture

Status: Fixed » Closed (fixed)