Search code examples
ruby-on-railswkhtmltopdfwicked-pdf

The HTML document file type (text / html) is not supported wicked pdf


I try to export a pdf with gem wicked_pdf but no show correct the pdf , if I tried to open this file , show me a message The HTML document file type (text / html) is not supported

this is my controller

 def cuadro_pago_proveedores_tiempo

    authorize :reporte, :cuadro_pago_proveedores_tiempo?
    respond_to do |format|
      format.js
      format.pdf {render template: '/reportes/pdf/pago_proveedores_tiempo'}
    end  
  end

This is my gemfile

gem 'wicked_pdf' gem 'wkhtmltopdf-binary'

And my file /reportes/pdf/pago_proveedores_tiempo

<h1>Hi is a demo</h1>

My link to open this file is this

<%= link_to  "hola", "/reportes/" + tipo_reporte +".pdf" %>

When tipo_reporte is the param with name the report

Can you help me?


Solution

  • I add the name of the file with pdf: in controller

    this solved my problem

    def cuadro_pago_proveedores_tiempo
    
        authorize :reporte, :cuadro_pago_proveedores_tiempo?
        respond_to do |format|
          format.js
          format.pdf {render template: '/reportes/pdf/pago_proveedores_tiempo', pdf: "NameOfThePDF"}
        end  
      end