I am receiving a PDF file in base64 form. I want to show it in a new tab. I tried this -
This is my controller code for sending the data back to browser
send_data Base64.decode64(params[:base64_file]), :type => 'application/pdf', :filename => "#{params[:name]}.pdf", :disposition => "inline"
View file :
<a href='<%= show_pdf_url({:pdf_body => pdf_body, :name => "download.pdf" %>' target='_blank'>
But it throws 'Request entity too large' error.
Tried to change it to post request by -
<a href='#' class='pdf-download'/>
and calling -
$('.pdf-download').on('click', function(event){
var get_all_admin = jQuery(this);
var w = window.open('about:blank');
w.document.body.appendChild(w.document.createElement('iframe')).src = 'data:application/octet-stream;base64,${get_all_admin.data("base64_file")}';
but it does nothing, and end up loading the same page in new tab.
Help me out, I am stuck here.