How to convert PDF to Excel or CSV in Rails 4

前端 未结 3 2097
醉梦人生
醉梦人生 2021-01-06 15:43

I have searched a lot. I have no choice unless asking this here. Do you guys know an online convertor which has API or Gem/s that can convert PDF to Excel or CSV file?

3条回答
  •  半阙折子戏
    2021-01-06 16:18

    Ryan Bates covers csv exports in his rails casts > http://railscasts.com/episodes/362-exporting-csv-and-excel this might give you some pointers.

    Edit: as you now mention you need the raw data from an uploaded PDF, you could use JavaScript to read the PDF file and the populate the data into Ryan Bates' export method. Reading PDF's was covered excellently in the following question:

    extract text from pdf in Javascript

    I would imagine the flow would be something like:

    PDF new action
        user uploads PDF 
    
    PDF show action
        PDF is displayed
        JavaScript reads PDF
        JavaScript populates Ryan's raw data
        Raw data is exported with PDF data included 
    

提交回复
热议问题