file download jquery pdf download htaccess
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
(function ($) {
Drupal.behaviors.nerolac = {
attach: function (context, settings) {
if (window.location.href.indexOf("mpdfdown") > -1)
{
var path = settings.nerolac.pdf_path;
downloadURL(path);
}
}
};
})(jQuery);
function downloadURL(url) {
var hiddenIFrameID = 'hiddenDownloader',
iframe = document.getElementById(hiddenIFrameID);
if (iframe === null) {
iframe = document.createElement('iframe');
iframe.id = hiddenIFrameID;
iframe.style.display = 'none';
document.body.appendChild(iframe);
}
iframe.src = url;
}
;
/*
function getCookie(cname) {
var name = cname + "=";
var decodedCookie = decodeURIComponent(document.cookie);
var ca = decodedCookie.split(';');
for(var i = 0; i <ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}*/ //download pdf on page load
$file_uri = file_build_uri('meeting_pdf/' . 'meeting_report.pdf');
$pdf =file_create_url($file_uri);
drupal_add_js(array('nerolac' => array('pdf_path' =>$pdf)), array('type' => 'setting'));
drupal_add_js(drupal_get_path('module', 'nerolac') . '/js/download_pdf.js');
<FilesMatch "\.(?i:pdf)$">
AddType application/octet-stream pdf
ForceType application/octet-stream
</FilesMatch>
# <Files *.*>
# ForceType application/octet-stream
# Header set Content-Disposition attachment
# </Files>