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

jcnventura’s picture

Status: Active » Postponed (maintainer needs more info)

Hi,

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

firfin’s picture

ah 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!

jcnventura’s picture

I 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.

firfin’s picture

I 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.

jcnventura’s picture

Status: Postponed (maintainer needs more info) » Fixed

No problem.. Can I assume your problem is solved then?

firfin’s picture

Looks like it. Thanks again!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

allentseng’s picture

Version: 6.x-1.8 » 6.x-1.12
Status: Closed (fixed) » Active

Hello,

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 ??

allentseng’s picture

Status: Active » Closed (fixed)

Never mind, I clear the cache. It works now.