Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#7 | views_pdf_1508820_6_empty_font_size.patch | 898 bytes | Simon Georges |
#2 | user_certificates-9.pdf | 1.41 MB | ontwerphuis |
views_pdf_no_table_data.pdf | 19.56 KB | njcheng |
Comments
Comment #1
njcheng CreditAttribution: njcheng commentedAh! It appears to come from line 450 of views_pdf_template.php:
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.
Comment #2
ontwerphuis CreditAttribution: ontwerphuis commentedHi 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
Comment #3
gillarf CreditAttribution: gillarf commentedSame here - if this is causing the problem, surely this is an easy fix?
Comment #4
alyssaengleson@aimclear.com CreditAttribution: alyssaengleson@aimclear.com commentedI 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
Comment #5
2phaI changed it to:
$font_size = isset($options['text']['font_size']) ? $options['text']['font_size'] : $this->defaultFontSize ;
Comment #6
saturnino CreditAttribution: saturnino commentedOk that's worked for me.
thank you !
Comment #7
Simon Georges CreditAttribution: Simon Georges commentedFor those who are looking for automated installation using drush make, I'm proposing the following patch. Please review.
Comment #8
lsolesen CreditAttribution: lsolesen commentedThis patch fixed the problem for me #1794450: Line items not shown on the pdf
Comment #9
ram4nd CreditAttribution: ram4nd commented#7 worked for me. Thank you. I wonder when views_pdf module gets patched with this.
Comment #10
garphy CreditAttribution: garphy commentedI would have both tested !isset() and empty() avoid possible warnings about an uninitialized array key. However, #7 does the trick.
Comment #11
Simon Georges CreditAttribution: Simon Georges commentedFrom 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()
.Comment #12
garphy CreditAttribution: garphy commentedIndeed ! Thanks for clarifying this point :) I'll go tidy up some if() :)
Comment #13
Simon Georges CreditAttribution: Simon Georges commentedCommitted to 1.x-dev version. Everybody, thanks for all your suggestions and reviews!