Skip to content

Setting a font does not persist to new page #1739

Description

@bricka

Bug Report

Description of the problem

When I set a font (in this case, Helvetica-Bold), the font is not retained after a new page is created. This makes it very difficult to write a lot of text at once.

Code sample

https://github.com/bricka/pdfkit-font-new-page-reproduction

const fs = require('fs');
const PDFDocument = require('pdfkit');

const doc = new PDFDocument({ font: 'Helvetica' });

doc.pipe(fs.createWriteStream('test.pdf'));

doc.font('Helvetica-Bold');

doc.text('Text on first page');

doc.addPage();

doc.text('Text on second page: should be bold');

doc.end();

Your environment

  • pdfkit version: 0.19.1
  • Node version: 26.2.0
  • Browser version (if applicable): N/A
  • Operating System: Arch Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions