General help

PDF issues - cannot open PDF: error "file is damaged"

 
Picture of Steven Geggie
PDF issues - cannot open PDF: error "file is damaged"
 

I've verified that the files can open if saved on the hard drive.  I also have made sure that the config.php does not have any blank lines.

 

If a user has version 7 of Acrobat, everything works fine.  If users have a release prior to version 7, then we get the "file is damaged" error.

 

Has anyone else encountered such errors?  How did you resolve?  Why isn't the fix part of the core build in Moodle....(It seems like PDF's are a very popular resource).

 
Average of ratings: -
Picture of Iñaki Arenaza
Re: PDF issues - cannot open PDF: error "file is damaged"
Core developersDocumentation writersParticularly helpful MoodlersPlugin developers
Make sure you don't have any extra spaces or blank lines after the final '?>' line in your config.php file.

Saludos. Iñaki.
 
Average of ratings: -
Picture of Steven Geggie
Re: PDF issues - cannot open PDF: error "file is damaged"
 

I've done that and still the problems persist....I clear out my browser cache every time I test.

 

 

 
Average of ratings: -
Picture of Iñaki Arenaza
Re: PDF issues - cannot open PDF: error "file is damaged"
Core developersDocumentation writersParticularly helpful MoodlersPlugin developers
See if you can download (and save, not open directly) one of the problematic PDF files and open it with Wordpad.

You'll see a lot of garbage, but the first few character have to be '%PDF-' (without the quotes). If they are not, then something in Moodle is adding those few characters and "breaking" the files.

Saludos. Iñaki.
 
Average of ratings: -
Picture of Steven Geggie
Re: PDF issues - cannot open PDF: error "file is damaged"
 

Here are the first few lines from wordpad:


%PDF-1.3

%âãÏÓ

1 0 obj

<<

/Type /ExtGState

/SA false

/OP false

/HT /Default

>>

endobj

2 0 obj

<<

/Type /Halftone

/HalftoneType 1

/HalftoneName (Default)

/Frequency 60

/Angle 45

/SpotFunction /Round

>>

endobj

4 0 obj

<<

/Type /XObject

/Subtype /Image

/Name /Im1

/Width 3400

/Height 4416

/BitsPerComponent 1

/ColorSpace /DeviceGray

/Length 45737

/Filter /CCITTFaxDecode

/DecodeParms <</K -1 /Columns 3400 /BlackIs1 false>>>>

stream

 
Average of ratings: -
Picture of Iñaki Arenaza
Re: PDF issues - cannot open PDF: error "file is damaged"
Core developersDocumentation writersParticularly helpful MoodlersPlugin developers
Humm, it looks good. I've seen reports in the past of people having similar issues due to 'extra' character before de '%PDF' signature. But yours seems perfectly good.

I suspect the byteserving code might be causing the trouble. Can you add a line like this to your config.php file and test again:

    $CFG->disablebytserving = true;

Saludos. Iñaki.
 
Average of ratings: -
Picture of Steven Geggie
Re: PDF issues - cannot open PDF: error "file is damaged"
 
I tried this and the errors remained.
 
Average of ratings: -
Picture of Iñaki Arenaza
Re: PDF issues - cannot open PDF: error "file is damaged"
Core developersDocumentation writersParticularly helpful MoodlersPlugin developers
I've run out of ideas sad

We are using lots of PDF files with Acrobat Reader 5.x and 6.x and we are not having a single problem with them. ????

Saludos. Iñaki.
 
Average of ratings: -
Picture of Ken Wilson
Re: PDF issues - cannot open PDF: error "file is damaged"
 
Maybe the file is damaged at the end of the PDF. One way to determine if you have a complete PDF file is to edit the file with Notepad (or equivalent) and see if it ends with %%EOF.

Adobe's official line on this is: "If Acrobat or Adobe Reader displays the downloaded file, but won't display it on the web, the web server has a problem serving the PDF file. Contact the webmaster of the site from which you downloaded the PDF file." - really helpful!

Is this error throughout your moodle site on all computers? If so can you post a link to one of the documents for us to try out?

Ken
 
Average of ratings: -
Picture of Petr Skoda
Re: PDF issues - cannot open PDF: error "file is damaged"
Core developersDocumentation writersPlugin developers

IMO Moodle code is ok, but your apache configuration is incorrect - gzip compressions is turned on for all browsers and files served by your server which is definitely wrong.

I managed to replicate it on my test server, the problem appeared when I enabled gzip compression for all files. Please tell your server admin to fix the configuration, more info can be found here: http://httpd.apache.org/docs/2.0/mod/mod_deflate.html. Please report here if it helped, thanks wink



skodak
 
Average of ratings: -
Picture of Fatema Siddiqua
Re: PDF issues - cannot open PDF: error "file is damaged"
 

Hi, I am also facing the same problems after migrating site to a new Linux server. I checked the PDF files after downloading, n found them correct bt no PDF and other uploaded files like IMS content packages are not displaying on the moodle site. Also added the line "$CFG->disablebyteserving=true;"

But problem still exist. Please help me to sortout the problems.

apache config file is attached...

Thanks & Regards!

 
Average of ratings: -
Picture of Ken Task
Re: PDF issues - cannot open PDF: error "file is damaged"
Particularly helpful Moodlers

You've been reading a very old thread and the suggestion concerning deflate being the culprit, might be true, but have had no issues similar.

Since you've transferred the site to a Linux server, was the old site Windows? If former server was Windows, did you use the moodle code from Windows or install fresh Moodle code (matching version) from the .tar.gz files.  Copying over your config.php file, of course.

In your httpd.conf find this line:

LoadModule deflate_module modules/mod_deflate.so

and comment it out.  Put a # character in front. 

Check your .htaccess file if you have one for re-write rules related to PDF files.

From /var/www/html/ as root user:

fgrep '.pdf' .htaccess

You may NOT have an .htaccess file and that's ok.

Restart your apache server: /sbin/service httpd restart

Check error logs:  tail /var/log/httpd/error_log

For any errors on restart.  Try your PDF links.

And a comment about your config ...

Set ServerSignature to off

No sense in giving more information than is needed on 404's.

Also, at the very bottom comment out all the settings you've opened for virtual servers.  Doesn't really appear you are running virtuals and they are not needed since you are running moodle from /var/www/html/

Add a # in front of:

NameVirtualHost *:80

    DocumentRoot /var/www/html
    ServerName 10.32.2.1

Document root is already defined and one doesn't need ServerName to be an IP address.  If your firewall allows port 80 Apache (httpd) will respond to any request of a browser to the server's IP address.

'spriit of sharing', Ken

 
Average of ratings: -
Picture of Fatema Siddiqua
Re: PDF issues - cannot open PDF: error "file is damaged"
 

Thank You Sir for your kind reply..I have corrected my httpd.conf now...But problem is not yet solved. I migrated site from windows PC where i developed it using xampp server. I again checked other PDF files and found them damaged..what should i do now..to recover them all again because uploading all the content is going to kill me definitely sad

I am using the same code and did't found any .htaccess file. The damaged file downloaded from moodle after migration is attached...

Thanks & Regards..

 
Average of ratings: -
Picture of Steven Singer
Re: PDF issues - cannot open PDF: error "file is damaged"
 

Hi All,

I wonder if anyone has made headway with this issue. I have a Windows 2003 server running a number of moodle instances. I have started to get the same error regarding "cannot open PDF: error file is damaged".

The interesting thing is that this only occurs for my 1.63 instances. When uploading and viewing the same document via a 1.53 site there is no corrupt messages. What is different that could affect the way that this file is sent up to the server with 1.63?? I upgraded from 1.53 site to 1.63.

I have tried Acrobat reader 6.0 and 7.0, uploading the file both sides of the firewall, macs and pcs. File size of the pdf seems irrelevant.

What could I look at with the setting or installs that seems to be damaging or corrupting the pdf. By the way the PDF opens fine when downloaded to the computer and opened by double clicking. So the file itself is unlikely to be damaged. It is the process of opening in Moodle that is the issue.

Windows 2003
MySQL 4.1.16nt
PHP 4..13

Moodle Version: 1.6.3 (2006050530)

Any advice much appreciated.

Kind regards

Steve

 
Average of ratings: -
Picture of Petr Skoda
Re: PDF issues - cannot open PDF: error "file is damaged"
Core developersDocumentation writersPlugin developers
Hi!

Could you please upload one PDF into your site files area and send me a link and test account by email?

thanks smile
 
Average of ratings: -
Picture of Petr Skoda
Re: PDF issues - cannot open PDF: error "file is damaged"
Core developersDocumentation writersPlugin developers
Hi again,

after noticing that you have created an account for me I have tested the pdf files and all work fine for me. Could you please send me some more info on how to reproduce it.

thanks
 
Average of ratings: -
ETHz
Re: PDF issues - cannot open PDF: error "file is damaged"
Plugin developers

this version of adobe acrobat reader doesnt "usually" read non english letters file names. also sometimes it makes troubles with spaces.

please make sure to check file names andput them in numbering or so

 
Average of ratings: -
Picture of Guillermo Ärcega
Re: PDF issues - cannot open PDF: error "file is damaged"
 
Sup mates.,

Im workin with moodle 1.8.x., and we have same problem., i got all resources in pdf., in X estructure, and the students could see them in same page.

In the 34 pcs we have to teach (a LAN conection) 32 PC`s works fine., and 2 couldnt open pfd, "--- action aborted will exit of the browser--"., then appear a link., you cliked and yes it open the pdf., bout in 8 - 12 secs., its close by himself. (wtf!!!)

All Pcs have FIREFOX 3.0.10, ACROBAT READER 9.10., WIN XP SP2 ... moodle 1.8.X

HOPE some one answer how to spell out the devil of those 2 PCS., ;o

CHEERS
 
Average of ratings: -