I’m attempting to have fancybox display a pdf in a iframe, right now it currently just downloads the pdf to the users computer, I’d like to have it viewable in the browser inside the modal/fancybox.
current view is:
<% for issue in @issues %>
<tr>
<td><%= issue.date %></td>
<td><%= link_to "view pdf", issue.pdf_url, :class => "fancybox" %>
<td><%= link_to "Show", issue %></td>
<td><%= link_to "Edit", edit_issue_path(issue) %></td>
<td><%= link_to "Destroy", issue, :confirm => 'Are you sure?', :method => :delete %></td>
</tr>
<% end %>
I figure there is a way i could use the google doc viewer found here but i’m not entirely sure how i would create the link? and how would i test locally since the viewer would obviously not be able see the pdf if i’m running from a localhost.
What solutions are available for rails? I’d like to host the pdfs locally.
Also is there a way to use rmagick to generate a png or jpg of the 1st page to use as a preview?
Update:
I went ahead and tried using this as my link however it pulls an error.
<%= link_to "view pdf", 'http://docs.google.com/gview?url=#<%= issue.pdf_url %>', :class => "fancybox" %>
error is
/app/views/issues/index.html.erb:10: syntax error, unexpected $undefined, expecting ')'
...);@output_buffer.safe_concat('\', :class => "fancybox" %>
... ^
you cant use erb code inside erb.
Use as following:
url encode issue.pdf_url