从画布转换为默认分辨率为 72 dpi 的 PDF 会导致页面大小不正确
我正在创建一个具有预定义尺寸(2505 像素宽度,3542 像素高度)的画布,这是 300 DPI 分辨率的 A4 纸的尺寸。
我正在使用 createPDFStream
将画布转换为 pdf (https://github .com/Automattic/node-canvas#canvascreatepdfstream)。输出的 PDF 很好,但我注意到页面大小
为 34,79 x 49,19 英寸(见下图),比普通 A4 纸大得多,这会导致一些问题线。
我注意到这是因为 createPDFStream
假设 PDF 的分辨率应为 72dpi,因为 2505px / 72dpi = 34,79 英寸
& 3542px / 72 dpi = 49.19 英寸
。我的问题是,是否有一种方法可以指定 createPDFStream
PDF 的分辨率应为 300dpi,以便我们获得正确的页面大小
。或者,如果有一个库可用于在不影响 300 DPI 图像质量的情况下更正页面大小
或DPI 设置
。
我尝试深入挖掘 node-canvas
来寻找解决方案,但我既找不到纠正 DPI 的方法,也找不到设置 72 DPI 假设的位置。
I am creating a canvas with predefined dimensions (2505px width, 3542px height) which are the dimensions for an A4 paper in 300 DPI resolution.
I am converting the canvas to pdf using createPDFStream
(https://github.com/Automattic/node-canvas#canvascreatepdfstream). The outputted PDF is good but I notice that the Page Size
is 34,79 x 49,19 inches (see image below), which is much larger than a regular A4 paper, which causes some problems further down the line.
I notice that this is because that createPDFStream
is assuming that the PDF should be in 72dpi, since 2505px / 72dpi = 34,79 inches
& 3542px / 72 dpi = 49,19 inches
. My question is if there is a way to specify to createPDFStream
that the PDF is supposed to be in 300dpi so that we get the correct Page Size
. Alternatively, if there is a library to use to correct the Page Size
or DPI settings
without compromising the 300 DPI image quality.
I tried digging deeply through the node-canvas
for a solution, but I could neither find a way to correct the DPI nor find the place where the 72 DPI assumption is set.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论