From my point of view, is better to leave the writing position unaffected, if a field is empty or excluded from display.

So you have to make this check in drawContent function before the call of SetX, SetY functions.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

castawaybcn’s picture

I second this behaviour too, in my case some fields are not displayed (which is the intended behaviour if they are empty) but views pdf does take that invisible field as the last writing position, which results in strange results when positioning fields relatively.
I can submit a pdf showing this behaviour in case my explanation was not clear enough.

And thanks for such a great module, btw.

ltrain’s picture

I second it as well. I have a content type with optional fields. But if they are left empty, I don't want the PDF content to leave empty space.

I'm trying to alter views_pdf_template.php -

I have tried several things, including at line 344

$this->SetX($x);
$this->SetY($y);

$this->renderRow($x, $y, $row, $options, $view, $key);

I have changed to:

if ($view->field[$key]) {

$this->SetX($x);
$this->SetY($y);

$this->renderRow($x, $y, $row, $options, $view, $key);

}

To check whether the field is empty. And it makes no difference. Can someone point me in the right direction?

Thanks

ltrain’s picture

This works:

if ($view->field[$key]->theme($row)) {

$this->SetX($x);
$this->SetY($y);

$this->renderRow($x, $y, $row, $options, $view, $key);

}
ltrain’s picture

I would submit a patch, but 6.x-1.x-dev isn't listed on the Version control page. Is 6.x-1.x-dev the current release?

ltrain’s picture

Version: 6.x-1.x-dev » 6.x-1.0
FileSize
666 bytes

Here is the patch for 6.x-1.0

ltrain’s picture

This patch is to be used with drush make (a default strip of -p0).

castawaybcn’s picture

worked wonderfully, thanks a lot @lollypic!

glynster’s picture

Same problem exists in Drupal 7 I have applied the fix but no luck for me. Any ideas?

Simon Georges’s picture

Version: 6.x-1.0 » 7.x-1.x-dev
Category: feature » bug
Status: Active » Patch (to be ported)

Committed, thanks!
Moving to 7.x-1.x.

glynster’s picture

Great news.

Simon Georges’s picture

Status: Patch (to be ported) » Needs review
FileSize
624 bytes

Patch for 7.x-1.x, for those wanting to help test the module.

killua99’s picture

Priority: Normal » Critical
Status: Needs review » Needs work

This patch have to be commited. Putting in needs works, and make a review on it.

killua99’s picture

Priority: Critical » Major
Status: Needs work » Fixed
killua99’s picture

Priority: Major » Normal

Status: Fixed » Closed (fixed)

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