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

未关闭
#1,624 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
35/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
停滞
技术栈
javascript
领域
tooling

调研方向

该 issue 未提供文件或测试入口;请先沿着布局流程追踪 doc.image 和 moveDown 调用。使用 fit [575,575] 配置两张 3840×2160 的图像来复现该情况,然后验证当剩余垂直空间不足时,第二张图像会移动到新页面。

由索引模型根据 Issue 内容生成。

描述

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
主要语言
JavaScript
星标
10.7k
派生
1.2k
平均合并
21 小时 41 分钟
30 天内合并 PR
27

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

foliojs/pdfkit 的其他 Issue

查看 foliojs/pdfkit 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。