I am using Views PDF to create a PDF printout of numerous nodes created by a user. I have set the margins to top:2in,left/right:.5in,bottom:4.5in. The top and bottom margins are to accommodate the template file's header and footer display and the bottom margin is also being used to force a new page creation after a certain number of nodes is reached in the list. It would of course be easier to have this value be set someplace else but I cannot find that option with this module if it exists.

The problem: when an additional page is created the list starts at the default top of the page and does not use the value entered in the PDF Page Options.

The expectation: The value set in the PDF Page Options would be applied to each page no matter how many pages get created for each PDF

Comments

cybermache’s picture

Title:PDF Page: PDF Page Options - Margins only applied to first page» Should margins be default for PDF table position?
Component:Code» User interface
Category:bug» feature

Okay so I think this was a case confusion of definition. There's a subtle difference between margins and table positions that wasn't initially apparent. Changing the table position (X,Y) to match the page margin (T,R,B,L) correctly displayed the layout on the following pages.

I'm not sure if changing the way this is administered would make things better. It certainly would make things easier. Perhaps in the PDF Page: Style options the Y and X position values use the PDF Page: PDF Page Options: Margins unless you enter a value in the field provided.

FreeAndEasy’s picture

Version:6.x-1.x-dev» 7.x-1.0
Component:User interface» Code
Category:feature» bug

This seems to be a bug.
The code-author didn't want this to happen:

// Determine the last writting y coordinate, if we are on a new
    // page we need to reset it back to the top margin.
    if ($this->lastWritingPage != $this->getPage() OR ($this->y + $this->bMargin) > $pageDim['hk']) {
      $last_writing_y_position = $this->tMargin;
    }
    else {
      $last_writing_y_position = $this->y;
    }

(from line 263 in views_pdf_template.php)

Simon Georges’s picture

Version:7.x-1.0» 7.x-1.x-dev

Triaging.

jibize’s picture

    // Determine the last writting y coordinate, if we are on a new
    // page we need to reset it back to the top margin.
    if ($this->lastWritingPage != $this->getPage() OR ($this->y + $this->bMargin) > $pageDim['hk']) {
      $last_writing_y_position = $this->tMargin;
    }
    else {
      $last_writing_y_position = $this->y;
    }

It looks like the variable $last_writing_y_position is reset to 0 each time a field with the option "Exclude from display" goes through the condition, which results (in my tests) in the value of the top margin not being respected, it also seems that this is for the same reason that an include view field built with fields "Excluded from display" is being displayed at the top of the page rather than in the flow of the page.

jibize’s picture

Looking a little bit more into this, I think the problem could be that the default $options['position']['object'] is set to nothing, meaning that fields excluded from display will have their coordinates relative to the Page and will therefore reset the Last Writing Position to 0. Attached is a patch that default the position object to the Last Writing Position so Fields set to "exclude from display" won't change the coordinates. I'm not totally sure of what this change implies so maybe someone could shed the light here?

jibize’s picture

Status:Active» Needs review

Changing status to needs review

killua99’s picture

Priority:Normal» Critical
Status:Needs review» Reviewed & tested by the community

Exist a patch to handle this issues and others. Please see #2032189: Multiple issue fixing in a single patch and review others issues patch.

This is RTBC, and ready to apply.

killua99’s picture

Priority:Critical» Normal
Status:Reviewed & tested by the community» Needs review
StatusFileSize
new377 bytes

This is the patch with the current dev version.

killua99’s picture

Status:Needs review» Fixed

And committed. Thanks jibize

Please open a new issue in case.

Status:Fixed» Closed (fixed)

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