Hi,
I am using a print_pdf.tpl.php in my mytheme dir. It is a slight rewrite from the print.tpl.php file. This works, extra html statements get into the pdf. So the file is being used correctly.
However, in the file I also have defined a version of theme_print_pdf_tcpdf_content() . For testing purposes I have only changed the first line in the function:
function phptemplate_print_pdf_tcpdf_content(&$pdf, &$html, $font) {
// set content font
$pdf->setFont($font[0], $font[1], 35);
This does not seem to have any effect on the output.
I have tried renaming it to mytheme_print_pdf_tcpdf_content without success.
Where should I place themeable functions?
P.S. I am trying to redefine the functions because I need total control over tcpdf's functions. The resulting pdfs will be used in printing. The translation of html/css to PDF is just not precise enough. I have done this before using pdfview. Is redefining the theme_ functions the correct way to do this or am I barking up the wrong tree?
Comments
Comment #1
jcnventuraHi,
Have you registered the function with hook_theme()?
As to using the theme functions, that's what they're there for, so indeed that's the correct way of doing it.
João
Comment #2
firfin commentedah yes .. hook_theme() , that is probably what is missing.
It goes in the same file right? I can just copy and modify it from your print_pdf.module?
I will try it out tomorrow evening, time for bed now. Thank you for your answers and the great module!
Comment #3
jcnventuraI think that in the case of a phptemplate_print_pdf_tcpdf_content() function, you should create the phptemplate_hook function(). This should usually reside in the phptemplate.module.
Other than that, you can mostly copy the existing implementation of the function.
Comment #4
firfin commentedI am still very new at drupal templating but unfortunately I couldn't find phptemplate.module nor phptemplate_hook.
I did try to place my phptemplate_print_pdf_tcpdf_content in template.php instead of print_pdf.tpl.php . And that did the trick. There is probably something in the theme I am using (which is converted from D5.)
Anyway, placing my themeable functions in template.php instead of print_pdf.tpl.pdf did the trick.
Thanks again for your help and suggestions. I really pointed me in helpful directions.
Comment #5
jcnventuraNo problem.. Can I assume your problem is solved then?
Comment #6
firfin commentedLooks like it. Thanks again!
Comment #8
allentseng commentedHello,
My drupal version is 6.17, and I try to put mytheme_print_pdf_tcpdf_content in template.php. but it's not work. I read through print_pdf/print_pdf.module and found hook_theme has already been implemented.
Question is for drupal 6.x, mytheme_print_pdf_tcpdf_content in template.php is right way to override original print_pdf_tcpdf_content function ??
Comment #9
allentseng commentedNever mind, I clear the cache. It works now.