Skip to content

Images set to fit get cut off when they reach the end of the page - is there a solution in place? #1624

Open

Description

@freeseus

Question

Description

Not sure where this belongs - either a feature request or less likely, a bug...

I have a bunch of text on the pdf and then I immediately follow it with moveDown (with a value of 1). And then I insert 2 images (for testing purposes, they're both 3840px x 2160px).

The 2nd image gets cut off at the end of the page.

Is there an easy way to tell pdfkit to "move this image to a new page if there's not enough vertical white space for it to fit?"

The hacky solution is to put each image on a new page, but this isn't ideal.

Code sample

doc.image('images/image1,png', undefined, undefined, {fit: [575, 575]});
doc.image('images/image2,png', undefined, undefined, {fit: [575, 575]});

Your environment

  • pdfkit version: Latest
  • Node version: Latest
  • Browser version (if applicable): Chromium and Chromium variants
  • Operating System: Win 11

Activity

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

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