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.