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

How to add standalone pageBreak? #2794

Open
yurakhomitsky opened this issue Oct 3, 2024 · 0 comments
Open

How to add standalone pageBreak? #2794

yurakhomitsky opened this issue Oct 3, 2024 · 0 comments

Comments

@yurakhomitsky
Copy link

yurakhomitsky commented Oct 3, 2024

In my application, I'm dynamically building PDF content sections and I want after each section add a page break because the content itself doesn't know if it's the last to add a page break so a section needs to add a page break after all content is gathered.

But I add a page break with an empty text. I feel like it's a hack maybe I should modify the last element of the content to add a pageBreak there? What is the best way to add a pageBreak to signify a new page without providing empty content?

public getContent(): Content[] {
    if (!this.config.includedInPrint) {
      return [];
    }
    const content = this.pdfContent.map((content) => content.getContent());

    if (this.config.pageBreak) {
      content.push({ text: '', pageBreak: 'after' });
    }

    return [{ text: this.title, style: ['header', 'primaryColor'] }, ...content];
  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant