简体   繁体   中英

Render pdf with Rails

In my project, I want to somehow display a pdf file on the page. For this, I am trying to use the <object> tag. So far, so good, since the pdf lives in the /public folder in my Rails app.

The problem is that now I want the user to be able to display a pdf that is on his pc. I tried using Javascript to alter the <object> tag, but that does not work since Rails generates a new GET request to get the file, and the file is not on the server. Any ideas of how I can solve this?

I have tried using PDF.js, but it does not integrate well in the assets pipeline. Also, I would have to customize and hack the code to add some other functionalities, so PDF.js is kinda off the table (at least for now).

您可以使用wicked_pdf gem生成pdf,然后使用Google PDF查看器显示它

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM