Converting a Ruby file into a word file ie (docx file) for PDF, we have for Shrimp Mani but the word file GEMI I am trying to convert my HTML file to a word file so that it is editable for the user. What should I do in that case? I was planning to convert that file into a word file whether it would be possible or not
Using the rail: In initializers / mime_types.rb: Mime :: type. Registrar 'app / vnd.ms-word' ,: msword In your controller:
You want to export the show action: < Pre> def show @item = item. Paragraph parameter [: id] answer_ what to do. Format | Format.html # show.html.erb format.xml {Render: xml = & gt; @item} format.msword {set_header ('msword', "#{@item.title}.doc")} format.pdf present: pdf = & gt; 'Coming soon ...', Layout = & gt; P_type <'[CacheControl'] ['Content-Dispos'] = "Attachment; File Name = \" # {'} 'as the' Xls' header ['content-WWW]] as DEF set_header (p_type, filename) Filename} \ "" type [type] "type '] =" app / vnd.ms-excel; Charset = UTF-8 '] [' content-type '] = "header / [vide.ms-word]; charset = UTF-8" header [' content-dispute '] = "attachment; filename = \" # {file Name} \ "header ['cache-control'] = '' end end define a show now. Mmsword .rb # you use any template handler like hamb etc. . normal ERB template like normal HTML
Mime :: type. Registrar 'app / vnd.ms-word' ,: msword In your controller:
You want to export the show action: < Pre>
def show @item = item. Paragraph parameter [: id] answer_ what to do. Format | Format.html # show.html.erb format.xml {Render: xml = & gt; @item} format.msword {set_header ('msword', "#{@item.title}.doc")} format.pdf present: pdf = & gt; 'Coming soon ...', Layout = & gt; P_type <'[CacheControl'] ['Content-Dispos'] = "Attachment; File Name = \" # {'} 'as the' Xls' header ['content-WWW]] as DEF set_header (p_type, filename) Filename} \ "" type [type] "type '] =" app / vnd.ms-excel; Charset = UTF-8 '] [' content-type '] = "header / [vide.ms-word]; charset = UTF-8" header [' content-dispute '] = "attachment; filename = \" # {file Name} \ "header ['cache-control'] = '' end end
define a show now. Mmsword .rb # you use any template handler like hamb etc. .
normal ERB template like normal HTML
No comments:
Post a Comment