How to render format in pdf in rails

后端 未结 5 917
长情又很酷
长情又很酷 2020-12-10 17:50

I want the the table to be displayed in pdf format .

we are using

format.html
format.json{render json: @user}

et

5条回答
  •  没有蜡笔的小新
    2020-12-10 18:16

    I think this might help [ https://github.com/mileszs/wicked_pdf ]

    You will always be able to use like format.pdf as long as your route supports .:format part. So just use that to capture the request for pdf. Then render the pdf using wicked_pdf.

    The basic usage is showing there as below

    def controller_action
        ... ... ...
        ... ... ...
        format.pdf do
            render :pdf => "file_name"
        end
    end
    

    Here is another article might help to understand the usage.

提交回复
热议问题