I'm trying to email a .pdf in landscape format. I've been using the WickedPdf.new.pdf_from_string method to attempt to do this. Even though I specify landscape format, the emailed PDF is in portrait.
If someone could show me a way to accomplish this, I'd be most appreciative.
Mailer:
class ProjectMailer < ActionMailer::Base
def email_mindmap_process(project, user, unused_list_items_column1, unused_list_items_column2)
@project = project
@user = user
mail(:subject => "You've received a MindMap from #{@user.email}!", :to => @project.destination_email) do |format|
format.pdf do
attachments["#{@project.title}.pdf"] = WickedPdf.new.pdf_from_string(render_to_string(:pdf => "MindMap", :template => 'projects/show.pdf.html.erb', :orientation => 'Landscape', :locals => {:project => @project, :user => @user }))
end
end
end
end
Controller:
def email_mindmap_process
@project = Project.find(params[:id])
@user = current_user
begin
ProjectMailer.email_mindmap_process(@project, @user, @unused_list_items_column1, @unused_list_items_column2).deliver
flash[:notice] = "We have emailed your MindMap to #{@project.destination_email}"
rescue Net::SMTPAuthenticationError, Net::SMTPServerBusy, Net::SMTPSyntaxError, Net::SMTPFatalError, Net::SMTPUnknownError => e
flash[:error] = "There was a problem emailing #{@project.destination_email}. Please double-check the address"
end
end