In Views PDF 7.x-1.0-rc1 and 7.x-1.0-dev (with latest versions of all dependencies), I can easily get table headers for my columns to appear, but the table is never populated with data. However, depending on the number of rows returned by the view (which I can see via the page view), I get different numbers of pages in the PDF. Obviously it's printing something for each row, but never the actual text or data itself. Any ideas on how to troubleshoot? The resulting PDF is attached below.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

njcheng’s picture

Category: support » bug

Ah! It appears to come from line 450 of views_pdf_template.php:

    $font_size = !isset($options['text']['font_size']) ? $this->defaultFontSize : $options[\
'text']['font_size'] ;

The above code assume that $options['text']['font_size'] is not set, however it is set to an empty string.

I'm not sure, however, if it may be actually unset under certain conditions so until I hear from the module developer about the intended behavior before submitting a patch.

ontwerphuis’s picture

FileSize
1.41 MB

Hi I'm experiencing the same issue. I can see the pdf background with the lables but no data. How did you fix this ?

Thank you

gillarf’s picture

Same here - if this is causing the problem, surely this is an easy fix?

alyssaengleson@aimclear.com’s picture

Status: Active » Needs review

I was able to fix this by replacing:

$font_size = !isset($options['text']['font_size']) ? $this->defaultFontSize : $options['text']['font_size'] ;

with:

$font_size = !isset($options['text']['font_size']) ? $options['text']['font_size'] : $this->defaultFontSize ;

on line 450 of views_pdf_template.php

2pha’s picture

I changed it to:
$font_size = isset($options['text']['font_size']) ? $options['text']['font_size'] : $this->defaultFontSize ;

saturnino’s picture

Ok that's worked for me.
thank you !

Simon Georges’s picture

Version: 7.x-1.0-rc1 » 7.x-1.x-dev
Priority: Normal » Major
FileSize
898 bytes

For those who are looking for automated installation using drush make, I'm proposing the following patch. Please review.

lsolesen’s picture

Status: Needs review » Reviewed & tested by the community

This patch fixed the problem for me #1794450: Line items not shown on the pdf

ram4nd’s picture

#7 worked for me. Thank you. I wonder when views_pdf module gets patched with this.

garphy’s picture

I would have both tested !isset() and empty() avoid possible warnings about an uninitialized array key. However, #7 does the trick.

Simon Georges’s picture

From PHP doc: empty() does not generate a warning if the variable does not exist, empty() is essentially the concise equivalent to !isset($var) || $var == false. So I don't see the point in adding another !isset().

garphy’s picture

Indeed ! Thanks for clarifying this point :) I'll go tidy up some if() :)

Simon Georges’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 1.x-dev version. Everybody, thanks for all your suggestions and reviews!

Status: Fixed » Closed (fixed)

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