I am getting the following error message on both 7.x-1.1 and 7.x-1.x-dev when I use tokens in the header or footer. Has this been fixed yet? It's a major problem when printing multiple reports that require personalised headers, etc.

Fatal error: Call to a member function tokenize_value() on a non-object in /home/admin/public_html/sites/all/modules/views/handlers/views_handler_area_text.inc on line 105

#28 drupalpdffix.JPG64.09 KBtheaxe
Members fund testing for the Drupal project. Drupal Association Learn more


killua99’s picture

Version: 7.x-1.1 » 7.x-1.x-dev
Priority: Critical » Normal

You're sure it's 100% views_pdf problem?

Which version of views, views_pdf (you open the issue on the 1.1 but asking) which version of token?

The error say views/handlers/views_handler_area_text.inc.

I'll take a look but looks like it's not views_pdf problem.

JohnM2’s picture

Hi - many thanks for the quick response. I am currently using the 7.x-1.x developer version although I started with version 7.x-1.1. The module itself is working well and produces PDFs from views with no trouble. The issue is related to using PDF Templates within Views_PDF (I am only using the Leading PDF Template) and tokens in either the header or footer Global Text areas. When I set the 'Use replacement tokens from the first row' to on and then add a token from the 'Replacement Patterns' I get this error. The settings work fine in Views it is just when I run PDF Page that there is a problem. I hope this is helpful.

JohnM2’s picture

Hi. Any news on a fix for this problem? It is quite important that we can use the token feature within Views PDF. Thanks, John

killua99’s picture

Can you attach a txt file with the views export code to try it out in my dev stuff. Thanks

Actually I'm full focus on the v2 but if this can be done easly I'll provide a small patch really point to your problem to solve your issue.

JohnM2’s picture

Thanks for the quick response. This is all I am doing...

1. Place the following in Global: Text area

[description] , [title]

2. Check 'Use replacement tokens from the first row'
3. Click on 'View PDF Page'

Error message shown every time....

Fatal error: Call to a member function tokenize_value() on a non-object in /home/admin/public_html/sites/all/modules/views/handlers/views_handler_area_text.inc on line 105

I have done this on half a dozen different reports and they all show the same error.

Everything works fine without the 'Use replacement tokens from the first row' box checked. It's only when you check this box that the error happens.

All works fine in the Views Screen with tokens.

killua99’s picture

Ok in my fast look at the error it say: Fatal error: Call to a member function tokenize_value() on /home/admin/public_html/sites/all/modules/views/handlers/views_handler_area_text.inc

I'll take a look at the code if I use that function or we do some call to that function. I'll let you know later. But the error is in views module file and not in views_pdf ones. I'll take a look stay tuned.

JohnM2’s picture

Any news yet on solving this problem? I am about to start using Views PDF and need tokens working in the header and footer areas of reports to really get the most out of this excellent module.

killua99’s picture

Well I'm working on see what's going on with all the issue. Nothing yet sorry :(

gustavo983’s picture

Hi, I'm having this problem too.
I have a list of flagged users grouped by the node and I'm trying to use token to print the title of that node as header.
I got the same error.
Thanks for this incredible module.

JohnM2’s picture

Hi, Any news yet on a fix for this bug? We need to start using Views PDF with our Views reports - at the moment I still can't add headings from tokens. This is now getting quite urgent. Can anyone throw any light on what's going wrong? From reading gustavo983's post above, I am obviously not the only user having problems with this.

JohnM2’s picture

How are you getting on with resolving this issue? Is there a patch available we can use?
Thanks, John

quantos’s picture

I just ran into this too. Great module though Killua. To be more specific about the error, you only need to tick the "Use replacement tokens from the first row" in the Global:Text Area interface (once saved) to generate the error. I.E. You don't actually need to add any replacement tokens first to get an error.

With me I also don't get display error message, I just get a completely blank document i.e. inspect source and there's absolutely nothing there at all. The same pdf view without replacement tokens gives me the following:

<embed width="100%" height="100%" name="plugin" src="http://licdl.quantos.co.uk/patient/10/discharge-pdf" type="application/pdf">

I'm using 7.x-1.1.

Sorry I can be more precise.

JohnM2’s picture

Is this bug sorted yet? It is a real drawback not being able to use tokens in the headers and footers of reports. Could we have an update on developments? Thanks.

Paul Lomax’s picture

This is something to do with the way the style plugin is set up.

$value = $this->view->style_plugin->tokenize_value($value, 0);

If you inspect the object style_plugin is null which is why it throws an error.

I managed to get round it by creating a new area handler and manually loading in the objects needed to populate it. Which is far from ideal.

This module seems to bypass all the normal views theming which makes it very difficult to alter the output in any other way.

killua99’s picture

Issue summary: View changes
Status: Active » Needs work

Yes this module have legacy code. I'm working on a next version.

Please think I'm doing this on my free time, and the only reward I receive is a "thanks" for this, that I looove.

Anyways, I've to figure out how to solve or do a ugly patch to allow tokens in the v 1.x because I'm writing good code in the v 2.x ...

If someone can pass some ugly patch that allow use token I'll push it.

fubarhouse’s picture

Is there a version of views PDF which has resolved this issue since your last comment?

alibama’s picture

still getting this error with the latest version

squarecandy’s picture

I fixed this with the following patch to views:

Simply replace line 104 of view_handler_area_text.inc with this:

if ($this->options['tokenize'] && is_object($this->view->style_plugin)) {

Please test and comment on the patch in the views project. This is not something that can be solved by changing the views_pdf code.

squarecandy’s picture

Well, my above patch is not really a great solution - just skips token processing altogether so you still get a PDF and not a WSOD. An improvement but not a final solution...

squarecandy’s picture

I've ended up eliminating the [page_number] token from the footer of my PDFs for now, which is sad.
What happened between 7.x-1.0 and 7.x-1.4 that would have caused this to stop working? It was working before and now it's not working.

vegansupreme’s picture

I can't get headers to work at all in 7.x-1.0. Maybe it needs PHP 5.3?
The OP complained about there being a problem in 7.x-1.1. So if headers were working in 1.0, and not in 1.1, that helps to narrow down the code changes. You're sure tokens in headers were working in 7.x-1.0, not beta, or rc1?

killua99’s picture

If we don't get any answer from @squarecandy We should move this to V2.

Or find a fast solution to it.

vegansupreme’s picture

I spent several hours trying to get this working, but couldn't figure it out. I haven't been able to fully untangle the code flow between views and views PDF. Looks like there's a variable or array that's not being set. I think it's here $this->view->style_plugin I haven't figured out a fast solution.

manoloka’s picture

Hi there,

No solution for this yet? I'm using views_pdf 7.x-1.5 and getting the same error

Fatal error: Call to a member function tokenize_value() on null in /home/mysite/www/sites/all/modules/views/handlers/views_handler_area_text.inc on line 105

I tried solution in 18# and while I stop getting the error I can not use tokens at all.

coreteamvn’s picture

I am building an invoice showing the transactions of the past month. Using a browser, when accessing the page view via invoicing/vendorID for the VIEW pdf page the results & pagination (token) are showing up when one embeds a Global view as a field (and set the output to 1 of the PDF view).

When one uses the Rules Saving pdf action module this approach does not work unfortunately.

coreteamvn’s picture

using this module https://www.drupal.org/project/rules_download (instead of the rules action included with this excellent module) also saves the pdf. one needs to enter the path to the view of the pdf page to save the pdf.

fakir22’s picture

Same error here, too bad :(

theaxe’s picture

Priority: Normal » Critical
Status: Needs work » Fixed
64.09 KB

Hello, well the fix is:

File: /views_pdf/views_pdf_plugin_display.inc
Method: execute($path_to_store_pdf = '', $destination = 'I')
Add inside this method at the beginning: $this->view->build();

Status: Fixed » Closed (fixed)

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