Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different footer heights per page #479

Closed
lifeisfoo opened this issue Jan 10, 2016 · 4 comments
Closed

Different footer heights per page #479

lifeisfoo opened this issue Jan 10, 2016 · 4 comments

Comments

@lifeisfoo
Copy link
Contributor

I've a document with different headers and footers for every page, generally the first header and the last footer are bigger that the others.

I've used a function for the header and the footer properties in order to have different content per page, but seems that their height is statically defined in the object pageMargins.

Is it possible to create a pdf with fluid header and footer height using pdfmake?

@lifeisfoo
Copy link
Contributor Author

Looking at the source code seems that with a small tweak, this could be possible:

Change the LayoutBuilder.prototype.addDynamicRepeatable function in this way:

if (node) {
     var currentMargins = this.pageMargins.slice();
     if (node.height) {
          currentMargins[3] = node.height;       
     }
      var sizes = sizeFunction(this.writer.context().getCurrentPage().pageSize, currentMargins);
      //...
    }

Then, create the document object:

var myDoc = {
    footer: footer: function(currentPage, pageCount) {
        if(currentPage == pageCount) {
            return {
                text: "Last page\nWith nice ending text :)",
                alignment: 'center',
                height: 100
            }
      } else {
        return currentPage.toString() + ' of ' + pageCount; 
      }
    },
//...
}

Am I right?

@dcrystalj
Copy link

Try to make pull request?

@max-yu
Copy link

max-yu commented Jul 27, 2016

seems this change is not enough.

@liborm85
Copy link
Collaborator

duplicate: #368

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants