Topic: Creating PDF documents from data held in blob field


We've got a rails app, ree-1.8.7-2012.02, rails2.3.10, that we've been saving pdf documents into the mysql database.

Like so in the controller

file = params[:document][:file_data]
if !file.blank?
fileData =
fileSize = file.size
fileType = file.content_type
fileName = file.original_filename
@document ={:file_data => fileData,
:file_size => fileSize,
:content_type => fileType,
:file_name => fileName,
:description => params[:document][:description]}))

Excuse the lack of indenting, just wanted to show you how we've done and the fields we have.

We've run into a couple of problems with this method, which I'll probably be returning to this forum in order to try and resolve, but for now my first task is to create all the pdf files from the data.

We're going to be using the filestore for the documents from now on.

Anyone got any ideas or know of any tools I can use to create all of the actual PDF's?

Any help, always appreciated.

Re: Creating PDF documents from data held in blob field

Document.all().each do |d|,"w") { |f| f.write(d.fileData) }

Last edited by BradHodges (2012-05-03 13:24:59)

Joe got a job, on the day shift, at the Utility Muffin Research Kitchen, arrogantly twisting the sterile canvas snout of a fully charged icing anointment utensil.