Created
October 28, 2014 13:20
-
-
Save kou/0600a16c7b7f519d49ef to your computer and use it in GitHub Desktop.
Rabbit theme to keep ratio in PDF
This file contains hidden or 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
set_background("black") | |
match(SlideElement) do |slides| | |
slides.each do |slide| | |
raw_page = slide.instance_variable_get(:@page).instance_variable_get(:@page) | |
width, height = raw_page.size | |
width_ratio = canvas.width.to_f / width.to_f | |
height_ratio = canvas.height.to_f / height.to_f | |
unless width_ratio == height_ratio | |
if width_ratio > height_ratio | |
width_margin = canvas.width - (width * height_ratio) | |
slide.margin_left = width_margin / 2 | |
slide.margin_right = width_margin / 2 | |
else | |
height_margin = canvas.height - (height * width_ratio) | |
slide.margin_top = height_margin / 2 | |
slide.margin_bottom = height_margin / 2 | |
end | |
end | |
end | |
end | |
include_theme("pdf") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment