We are using princely gem to generate pdf documents on our rails 4
app. For the last couple of days, the generated pdf is rendering in portrait mode instead of the specified landscape mode; this functionality has been working fine for years.
There have been some updates being done on the ruby/rails versions on the server, but nothing has been changed on the pdf generation code itself.
One interesting aspect is that the pdf is generated in landscape mode on the development server, when I test it locally on my machine(Mac). The same code generates pdf in portrait mode on the staging/production server (Linux).
Related code:
From Gemfile
gem 'rails', '4.2.5.1'
gem 'princely', git: "git@github.com:mbleigh/princely.git"
....
Pdf render code:
render :pdf => "ticket",
:template => "admin/tickets/print.pdf.erb",
:stylesheets => ["printpdf.css"]
app/assets/stylesheets/printpdf.css:
@page {
size: 8.5in 11in landscape;
margin: 5mm 5mm 5mm 5mm;
}
@page {
@bottom-right {
content: counter(page);
}
}
#pagebreak {
page-break-after: always;
}
Princely command executed (as shown in the log):
PRINCE XML PDF COMMAND
/usr/local/bin/prince --input=html --server --log=/Users/prakash/Projects/main_project/log/prince.log -s /Users/prakash/Projects/main_project/app/assets/stylesheets/printpdf.css --silent - -o -
Rails version was changed from 4.2.4
to 4.2.5.1
recently, and ruby version was changed from 2.2.0
to 2.3.0
. I rolled back both these changes on the staging server, but reverting neither of those changes fixes the portrait-instead-of-landscape issue.
Would appreciate any suggestions on where to look for the root cause of this problem, and how to fix it.