Created
August 14, 2022 02:21
-
-
Save htsutsui/b6072174c2bd5f7ca09697473e5f751d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# frozen_string_literal: true | |
# Usage: pdfinfo input.pdf | ./pts2mm.rb | |
# This script converts "595.276 x 841.89 pts" to "210.00 x 297.00". | |
# 72pt = 1inch = 25.4 mm | |
print STDIN.read.scan(/(\S+) x (\S+)/).map { _1.map(&:to_f).map { |j| '%.2f' % (j / 72 * 25.4) }.join(' x ') + "\n" }.join | |
# Note: | |
# I created this script to calculate the scale for converting | |
# gimp-generated PDF to A4-sized PDF using pdfjam. However, I | |
# noticed that pdfjam scales the input PDF automatically to fit the | |
# output paper size. So the scale factor is relative to the | |
# automatically fitted size, which means that the scale factor of | |
# 1.0 indicates a full-size fit. Note that the input content is | |
# positioned at the center of the output PDF. | |
# | |
# `pdfjam --suffix converted --paper a4paper --scale 1.0 input.pdf` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment