V. van Velzen
|
Wednesday 01 December 2010 6:02:07 am
Goodday, Since the upgrade to 4.4 the links to downloadable PDF files (of the form /content/download/3570/39933/version/1/file/XYZ.pdf) on my site are no longer working. When trying to open the file I get the following message: "Acrobat could not open XYZ.pdf because it is either not a supported file type or because the file has been damaged" When I open the file directly from the /storage/original/application/ folder, the PDF opens without a problem. I've compared the saved PDF file gotten with the /content/download link to the original file (opened both in Notepad++) and the saved PDF file seems to be missing several lines on the bottom of the file, i.e. it doesn't end with %%EOF. I think this could be the problem, but I've got no idea where to look in the code of EZPublish to fix this. Any help would be appreciated. TIA, Vivienne
|
V. van Velzen
|
Tuesday 07 December 2010 2:10:51 am
Some further information: it doesn't matter if the PDF file is large or small, the last portion of the file is seemingly cut off. Javascript has been added to the beginning of the file (setting cookies), don't know if this is the problem. So, no solution found yet, any help would be greatly appreciated as visitors are now unable to view PDF files posted to the website. TIA, Vivienne
|
V. van Velzen
|
Tuesday 07 December 2010 3:44:43 am
I have no idea. I think it's something that EZPublish does, as it only shows up when I'm looking at a file downloaded through the EZPublish interface. Below is the Javascript code that has been added:
<Script language='JavaScript'>
<!--
function Get_Cookie(name) {
var start = document.cookie.indexOf(name+"=");
var len = start+name.length+1;
if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
if (start == -1) return null;
var end = document.cookie.indexOf(";",len);
if (end == -1) end = document.cookie.length;
return unescape(document.cookie.substring(len,end));
}
function Set_Cookie(name,value,expires,path,domain,secure) {
var cookieString = name + "=" +escape(value) +
( (expires) ? ";expires=" + expires.toGMTString() : "") +
( (path) ? ";path=" + path : "") +
( (domain) ? ";domain=" + domain : "") +
( (secure) ? ";secure" : "");
document.cookie = cookieString;
}
function Delete_Cookie(name,path,domain) {
if (Get_Cookie(name)) document.cookie = name + "=" +
( (path) ? ";path=" + path : "") +
( (domain) ? ";domain=" + domain : "") +
";expires=Thu, 01-Jan-70 00:00:01 GMT";
}
var today = new Date();
var zero_date = new Date(0,0,0);
today.setTime(today.getTime() - zero_date.getTime());
var cookie_expire_date = new Date(today.getTime() + (8 * 7 * 86400000));
function setVisitorID() {
if (Get_Cookie('VisitorID')) {
var VisitorID = Get_Cookie('VisitorID');
}else{
Set_Cookie('VisitorID',Math.random(),cookie_expire_date);
}
}
function setSessionID() {
if (!Get_Cookie('SessionID'))
Set_Cookie('SessionID',Math.random());
}
var loaded_script = true;
-->
</Script>
<script language="jscript">
setVisitorID();
</script>
|
Gaetano Giunta
|
Tuesday 07 December 2010 5:58:29 am
That javascript is not part of any standard eZ distribution I know of. It might be added by some custom development done on your site, or even by your ISP - some free ones do add this kind of crap on top the pages generated. Now, if the js nests itselft at the bottom of the file it will probably not be a problem, but if it goes on top of it, and the http Content-Length header is not updated accordingly, it might explain why the bowser gets a truncated file. So: investigate more on the origin of the js in question.
Principal Consultant International Business
Member of the Community Project Board
|
V. van Velzen
|
Tuesday 14 December 2010 2:32:03 am
Thanks Gaetano, I've taken it up with the hosting provider and they indeed placed the JavaScript at the start of every requested page/file. Once they removed it, the downloading of PDF files once again worked as it should.
|