By Tmanagement on
Hi all,
Is it possible to theme the output of pdfview? At the moment this module is only placing the text in a standard font in a pdf file and is placing the author on it (which I dont want and is also not visible on the website itself)
So basically two questions:
1. is it possible to theme the output of pdfview?
2. How can you get rid of the author in the pdfview output?
Comments
please file a support request at pdfview
but the answer is yes, there are many theme functions,
--
The news is Now Public | Drupal development: making the world better, one patch at a time. | please donate
--
Drupal development: making the world better, one patch at a time. | A bedroom without a teddy is like a face without a smile.
how do you file a support
how do you file a support request at pdfview? If you click on the support forum at that pdfview page you are redirected to the generall support forum from drupal.org
any tips or answers?
pdfview view without author
I modified the pdfview.module file (basically deleted a few lines of code) so that it doesn't print the author name and publication date in the pdf file anymore. This is what I did:
1. Open pdfview.module in any text editor (i used dreamweaver)
2. delete lines 199 to 219 which is this following set of code:
/**
* Renders an author line
* @ingroup themeable
*/
function theme_pdfview_author(&$pdf, $author) {
$pdf->SetFont(PDF_FONT_NAME_MAIN,'BI', PDF_FONT_SIZE_MAIN);
$pdf->MultiCell(0, 5, t('By %author', array('%author' => $author)), 0, 'L', 0);
return $pdf;
}
/**
* Renders a publication date
* @ingroup themeable
*/
function theme_pdfview_published(&$pdf, $timestamp) {
$published = format_date($timestamp, 'small');
$pdf->SetFont('', '', PDF_FONT_SIZE_MAIN);
$pdf->MultiCell(0, 5, t('Published: %date', array('%date' => $published)), 0, 'L', 0);
$pdf->Ln(5);
return $pdf;
}
3. delete lines 170 and 171:
$pdf = theme('pdfview_author', $pdf, $author);
$pdf = theme('pdfview_published', $pdf, $node->created);
4. Save file and save new module configuration using admin -> modules -> save configuration.
not a good method
arindamghatak794 you should not overwrite the code in a module...
as the funtion is a theme_ function, you can overwrite it by redeclaring it on a template.php file on your template folder.
To do the same thing without changing module code I did that in my template.php
function phptemplate_pdfview_node(&$pdf, $node) {
$pdf->AddPage();
$pdf = theme('pdfview_title', $pdf, $node->title);
# $author = strip_tags(theme('username', $node));
# $pdf = theme('pdfview_author', $pdf, $author);
# $pdf = theme('pdfview_published', $pdf, $node->created);
if (node_hook($node, 'view')) {
node_invoke($node, 'view');
}
else {
$node = node_prepare($node);
}
node_invoke_nodeapi($node, 'view');
$content = drupal_render($node->content);
$content = pdfview_check_images($content);
$pdf->SetFont(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN);
$pdf = theme('pdfview_html', $pdf, $content);
return $pdf;
}
As you can see, I just copy / paste the function in the pdfview.module and rename it with phptemplate instead of theme in a template.php file.
Then I comment line about the author and it works.
Yes, this is certainly a
Yes, this is certainly a better way of doing it. Thanks! Changing the .module files can cause problems during upgrades (if you are going to upgrade it sometime in the future that is). Someone below asked the question about where to paste the above code...well, go to the themes directory and then go to your current themes directory (say, bluemarine or whatever you are using). You will find a template.pl.php file where you can just paste the above code that zmove has given.
www.MyResearchFunds.com
The World's Fastest Growing Network of Researchers
How to theme pdfview?
Could you maybe elaborate on that a bit? Is this done within tcpdf? within drupal? within pdfview.module? Coupla hints on theming might be nice here! I know I'd like a footer with the URL of the original node, for example.
Great module, BTW. Just got it up and working and I think it will be popular on my site.
--
great module
Hi ztnews,
As an aside, the pdfview is a superb module. Good work to whoever pulled it together.
It could do with a settings page though...although I believe that is a work in progress.
I found theming the PDF files a little tricky. I haven't gone through the full TCPDF documentation yet to work out how it works but, here's some observations that might help others:
THEMING PDF NODE OUTPUT FROM CCK NODES
PDFVIEW ignores any content-name.tpl.php layout files you have setup.
A work around is to use the contemplate.module to customise the theming of nodes, which PDFVIEW does pick up on.
THEMING PDF FULL PAGE OUTPUT FROM CCK NODES
I haven't worked out how to theme full pages in a simple fashion, but, I'm guessing that it might be easier to have a settings page for the module, where users can insert their header & footer for the generated PDF files and specificy which node types the "create PDF" link appears on.
I hope that helps others. The contemplate.module is another great little module, by the way - especially for setting up custom node templates from within Drupal - and appears to work well with PDFview.
Dub
Currently in Switzerland working as an Application Developer with UBS Investment Bank...using Drupal 7 and lots of swiss chocolate
How did you do it?
Did you do anything special to make pdfview pickup the contemplate layout? My contemplate configuration has no impact on pdfview output for cck nodes.