LoginSignup
0
3

More than 3 years have passed since last update.

wkhtmltopdfで解像度を指定する

Last updated at Posted at 2021-01-21

htmlファイルをインプットにPDFへ変換してくれるwkhtmltopdfですが、解像度を指定しないデフォルトの状態だと1px未満単位で描画されません。
例えばhtmlで1.9pxの線はpdfに1pxとして描画されます。
pdfに1px未満の描画をさせるためには「-d」または「--dpi」をオプションに96以上の値を指定する必要があります。
0.1px単位で描画するには960を0.01px単位で描画する場合は9600を指定します。
詳しくはこちら

htmlファイル

10.9pxの枠線
border10.9px.png

dpiオプション無しでPDFへ変換

image.png

dpi=960でPDFへ変換

image.png

変換後のPDFを比べると枠線の太さが異なるのがわかると思います。

0
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
3