SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Aug 2006
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    "The file is damaged and could not be repaired" when generating pdf

    This is not a question but may help if someone gets caught in the situation that I did.

    Scenario:
    I developed a php/mysql app about a year ago for a client. I am using fpdf to generate pdf formated reports. The app was running on 10 servers at 10 different sites with no problem.

    Last week I installed the app on a new server at an 11th site. Same base software, config, etc. However, the pdf output was intermittently producing the error "The file is damaged and could not be repaired" when displaying the output. This error would occur about 5 out of 6 times both when the output was displayed using the browser plugin and when downloaded and displayed using Abobe reader.

    The error occurred using IE and Firefox browsers on Windows. Netscape was no problem. All *nix browsers were fine.

    Problem:
    I found the problem to be a small programming error I made a year ago. I forgot to call exit in the php script after generating the pdf output. There was some following html in the php file that got appended to the pdf file after the EOF marker. Since there was no problem up until last week, I never noticed the error.

    I still have no idea why this worked sometimes. I'm guessing on the *nix systems the pdf viewer in use (not Adobe) ignores anything past the EOF marker. I have no clue for the Windows clients.

    Hope this is of some help to someone.

  2. #2
    SitePoint Wizard cmuench's Avatar
    Join Date
    Jul 2005
    Location
    At my computer
    Posts
    2,251
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Very good. Thanks for mentioning it. Very helpful to know.

  3. #3
    SitePoint Member
    Join Date
    Jun 2008
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The solution works with fpdf and ezpdf classes. Very Good!

  4. #4
    SitePoint Member
    Join Date
    Feb 2006
    Location
    Las Vegas, Nevada
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    danke shein! Appreciate the tip. i was getting quite aggravated.

    George M
    Chief Propeller-head
    Raster Media


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •