Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchPC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
In pdfmake, put pageBreak: 'before' on the node that must start a new page, or pageBreak: 'after' on the node that must finish the current page. For data-driven documents, use the document-level pageBreakBefore callback. Angular 8 does not change this API; it hosts the pdfmake document definition and calls pdfMake.createPdf().
The basic Angular 8 implementation
Build your normal pdfmake document definition, then attach the break to the relevant content object. The following example forces each section to begin on a fresh page:
const docDefinition = {
content: [
{ text: 'Customer summary', style: 'header' },
{ text: 'Invoice details', pageBreak: 'before' },
{ text: 'Terms and conditions', pageBreak: 'before' }
]
};
pdfMake.createPdf(docDefinition).download('report.pdf');
pageBreak: 'before' belongs to the node that should move. It does not belong to the preceding paragraph. If the current node should end the page instead, use pageBreak: 'after':
const docDefinition = {
content: [
{ text: 'Summary', pageBreak: 'after' },
{ text: 'Details' }
]
};
Wire pdfmake into an Angular 8 component
Install pdfmake in the Angular workspace, import its browser build and virtual font file, then create the document in a component or service. Angular is only the host here; the page-break properties are interpreted by pdfmake.
#1 Best Overall
npm install pdfmake
A component can be structured like this:
import { Component } from '@angular/core';
import * as pdfMake from 'pdfmake/build/pdfmake';
import * as pdfFonts from 'pdfmake/build/vfs_fonts';
(pdfMake as any).vfs = (pdfFonts as any).pdfMake.vfs;
@Component({
selector: 'app-report',
template: '<button (click)="download()">Download report</button>'
})
export class ReportComponent {
download(): void {
const docDefinition = {
content: [
{ text: 'Customer summary', style: 'header' },
{
text: 'This first block remains on the opening page unless it naturally flows.'
},
{ text: 'Invoice details', pageBreak: 'before', style: 'sectionTitle' },
{ text: 'Line items and totals appear here.' },
{ text: 'Terms and conditions', pageBreak: 'before', style: 'sectionTitle' },
{ text: 'Payment and delivery terms appear here.' }
],
styles: {
header: { fontSize: 20, bold: true, margin: [0, 0, 0, 12] },
sectionTitle: { fontSize: 16, bold: true, margin: [0, 0, 0, 8] }
}
};
(pdfMake as any).createPdf(docDefinition).download('report.pdf');
}
}
Depending on the TypeScript configuration and the installed pdfmake typings, a project may need a local declaration or a cast to any, as shown. That typing workaround does not alter the document-definition syntax.
Choose the break that matches the layout rule
| Requirement | Use | Where it is evaluated |
|---|---|---|
| Always start a section on a new page | pageBreak: 'before' |
On the section’s first node |
| Always end a block before the next node | pageBreak: 'after' |
On the block that must finish the page |
| Break only when pagination conditions are met | pageBreakBefore |
At document-definition level |
| Start a table section on a new page | pageBreak: 'before' |
On the heading or table node that begins the section |
Use one approach for each rule. A fixed break is predictable; a callback is appropriate when the decision depends on what remains on the current page.
Insert breaks between generated sections
When content comes from an array, construct the nodes first and attach a break to each section heading after the first. This keeps the rule explicit and avoids trying to calculate page numbers yourself.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Fix the driver behind crashes, sound loss and screen glitches3Clear out junk files and repair common Windows errorsconst sections = data.map((section: any, index: number) => ({
stack: [
{
text: section.title,
style: 'sectionTitle',
...(index === 0 ? {} : { pageBreak: 'before' })
},
{ text: section.description },
{
ul: section.items
}
]
}));
const docDefinition = {
content: sections,
styles: {
sectionTitle: { fontSize: 16, bold: true, margin: [0, 0, 0, 8] }
}
};
(pdfMake as any).createPdf(docDefinition).download('sections.pdf');
The break is attached to the top-level section stack, so its heading and following content move together. If you put the property only on the heading inside a more complex structure, the rest of the section can still paginate independently.
Use pageBreakBefore for conditional pagination
For generated documents, pdfmake exposes a document-level callback. It receives the current node and arrays describing the nodes around the page boundary. Returning true inserts a break before that current node.
Rank #2
const docDefinition = {
content: sections,
pageBreakBefore: (
currentNode: any,
followingNodesOnPage: any[],
nodesOnNextPage: any[],
previousNodesOnPage: any[]
) => {
return currentNode.headlineLevel === 1 &&
followingNodesOnPage.length === 0;
}
};
This example requests a break before a level-one headline when no following nodes fit on the current page. The callback is evaluated while pdfmake lays out the document, so it can respond to available space rather than a fixed item index. The callback contract is: if pageBreakBefore returns true, a page break is added before currentNode.
Give nodes the metadata your predicate needs:
const content = [
{ text: 'Introduction', headlineLevel: 1 },
{ text: 'Introductory paragraph.' },
{ text: 'Results', headlineLevel: 1 },
{ text: 'Results paragraph.' }
];
Keep the predicate narrow. A rule that returns true for every heading can create excessive blank space, while a rule that examines only text cannot reliably know how much room remains.
Recommended Free Tools
Page breaks with tables
To begin a table section on a new page, put pageBreak: 'before' on the section heading or on the table node itself:
const docDefinition = {
content: [
{ text: 'Invoice line items', pageBreak: 'before', style: 'sectionTitle' },
{
table: {
headerRows: 1,
widths: ['*', 'auto', 'auto'],
body: [
[ 'Description', 'Qty', 'Amount' ],
[ 'Consulting', '2', '$400' ],
[ 'Support', '1', '$120' ]
]
},
layout: 'lightHorizontalLines'
}
]
};
Set headerRows: 1 so the first row is treated as the table header and repeated on following pages. If the table header must stay with at least some rows when the table starts near the bottom of a page, add keepWithHeaderRows to the table definition:
const tableNode = {
table: {
headerRows: 1,
keepWithHeaderRows: 1,
widths: ['*', 'auto'],
body: [
[ 'Item', 'Total' ],
[ 'First item', '$50' ],
[ 'Second item', '$75' ]
]
}
};
A section-level break controls where the table begins; repeated headers and keepWithHeaderRows control how that table behaves when it spans later pages.
Rank #3
Common mistakes and fixes
The break is on the wrong node
Symptom: the preceding paragraph moves, but the intended heading does not start a page. Fix: move pageBreak: 'before' to the heading, table, or section stack that must move.
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →The property is spelled or cased incorrectly
Use the exact camel-case property pageBreak and the values 'before' or 'after'. A value such as 'Before' is not the documented form.
A callback never creates a break
Ensure pageBreakBefore is alongside content in the document definition, not nested inside a content node. Log or inspect currentNode.headlineLevel and return a real boolean. The callback must return true for the nodes that should move.
The heading is stranded at the bottom
A fixed break before every heading is the simplest solution when each section must start on a fresh page. If only stranded headings should move, use pageBreakBefore and examine the pagination arrays, as in the conditional example.
Table headings disappear on later pages
Set headerRows to the number of header rows in the table. Add keepWithHeaderRows when the first data rows should remain with the header instead of leaving a header alone at a page boundary.
Rank #4
The download call fails in Angular
Check that the browser build and virtual font file are imported and assigned before calling createPdf. If TypeScript reports missing declarations, add the project’s pdfmake type declarations or use a narrowly scoped cast, rather than changing the page-break syntax.
Unexpected blank pages appear
Inspect combinations of adjacent pageBreak: 'after' and pageBreak: 'before'. Two forced boundaries around the same transition can intentionally create an empty page. Remove the redundant property and regenerate the PDF.
Reliability and layout checks
- Test with short and long versions of every section. A break that looks correct with one paragraph can expose a heading or table boundary when the content grows.
- Keep page-break rules in the document-definition builder, not in Angular template markup. That makes generated and manually authored sections follow the same pagination path.
- For long tables, verify repeated headers and the behavior of the first few rows on a new page.
- Use the fixed properties when the requirement is absolute; use the callback when the requirement depends on available space.
- Do not assume a page-break rule controls every nested child. Put it on the node that represents the complete unit you want moved.
Pdfmake is a client/server-side JavaScript PDF generator. Angular 8 supplies the browser-side component or service; the same document-definition page-break fields remain the source of truth.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Or skip the browser setup
If your actual task is to produce a clean visual capture of a web report, dashboard, or rendered documentation page rather than assemble a PDF definition in Angular, ScreenshotNeo can return a screenshot or PDF from one request. It removes cookie-consent banners, newsletter popups and chat widgets before capture; bot checks, blank pages and failed loads are not billed. Its MCP server exposes take_screenshot, get_page_info and capture_pdf to Claude, Cursor and other MCP clients.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
cURL:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
Python:
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
Node.js:
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
See the ScreenshotNeo API documentation for request options. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000. Create a free ScreenshotNeo account.
FAQ
Can I combine pageBreak and pageBreakBefore?
Yes. A fixed break can handle a mandatory section boundary while the callback handles conditional headings elsewhere. Avoid overlapping rules that force the same boundary twice.
Does Angular 8 need a special page-break directive?
No. Page breaks are pdfmake document-definition properties. Angular only creates the definition and invokes the pdfmake API.
Can a page break be added after a nested stack?
Attach the property to the stack or other node that represents the whole group. This moves the complete group instead of only one child inside it.
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →Frequently Asked Questions
Can I combine pageBreak and pageBreakBefore?
Yes. Use a fixed break for mandatory boundaries and the callback for conditional headings, while avoiding duplicate rules for the same transition.
Does Angular 8 need a special page-break directive?
No. Angular hosts the pdfmake document definition; pdfmake evaluates the page-break properties.
Can a page break be added after a nested stack?
Yes. Put the property on the stack or other node representing the complete group so the group moves together.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

