There was an error opening this document. the file is damaged and could not

Dear all, I am simpley reading pdf file & producing to browser with this servlet
( which i got this from same forum)
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class Isotest2 extends HttpServlet
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, java.io.IOException
//String file = request.getParameter("file");
String file = new String("d:/xyz.pdf");
if (file != null)
File f = new File(file);
if (f.isDirectory())
//Do something that identifies the file as a directory...
} else
//otherwise, open a stram, and begin the download...
InputStream input = new FileInputStream(f);
response.setContentType("application/pdf");
response.setBufferSize(8192);
response.setHeader("Content-Disposition","attachment; filename=\"" + f.getName() + "\"");
OutputStream output = response.getOutputStream();
int count = -1;
byte[] buffer = new byte[8192];
while((count=input.read(buffer))!= -1)
output.write(buffer, 0, count-1);
output.close();
input.close();
but it is unable to open pdf file giving error
"There was an error opening this document. the file is damaged and could not be reapired"
what is the problem? [ PDF  file is not damaged !]
pls help me out
thanks

Probably because you aren't writing the last byte read every time through the while loop.

Similar Messages

  • How to deal with "There was an error opening this document, the file is damaged and could not be"

    Hello, everyone:
    I open one pdf document with Adobe Reader 9.3, but it appeared that "There was an error opening this document, the file is damaged and could not be repaired".. and I found that another several pdf document in the same folder that I have not opened for a long time is also "damaged and could not be repaired".
    But in the same folder, other documents of different types are ok, does that mean there is something wrong with my hard drive?
    Has anyone else run into this issue or have any suggestions?
    Thank you very much

    It could be that the directory is damaged. It could be that at one time you had a virus that did damage, it is hard to say. Do you have a good backup?

  • Acrobat 11 there was an error opening this document. the file is damaged and could not be repaired

    we are receiving an error when opening certain pdfs saying "there was an error opening this document. the file is damaged and could not be repaired"
    i've tried a few things to fix this issue with no luck
    tried on a brand new windows 7 install without any added software like anti-virus software, etc
    tried on my home pc (I forwarded the document from my work pc to my home pc and still receiving the same error)
    don't think it's anything related to the computers, thinking it's more an issue with the pdf. i've tried the basics like deleting temp files from IE, going to %temp% and deleting that out, doing an acrobat repair, trying in reader instead of acrobat, updating users from acrobat 10 to 11, and still receiving the same issue. the odd thing is, some people can open this document and some receive the error. the other thing is i've tried alternative pdf programs with no avail, same errors from those as well
    i work on the helpdesk with one other person  for the company and not sure what else we can try
    don't think this is a pc issue - tried on pcs in the company, home pcs, personal pcs and all get this error
    got to be an issue with either the pdf, or the way its being sent
    i did reach out to OUR e-mail team here (lotus notes admin) and they've ruled out anything as far as an encryption causing the conflict may go, so notes isn't the issue either
    would it be possible it's on the persons end that's sending the file?

    Unfortunately, CR 10.5 is not supported on WIN 2012 Server. See this wiki for more details. In order to work in a supported environment you will have to upgrade to CR 2008 Service pack 7, or SAP Crystal Reports, developer version for Microsoft Visual Studio (2010 / 2012 / 2013).
    - Ludek
    Senior Support Engineer AGS Product Support, Global Support Center Canada
    Follow us on Twitter

  • Which version doesn't produce this error: "there was an error opening this document. the file is damanged and could not be repaired"?

    This error message occasionally occurs with Acrobat 5 on XP 2.  However the same files can be opened with Acrobat 6.0.4 on Win98(se2).
         "There was an error opening this document. the file is damanged and could not be repaired."
    I'd like ot upgrade 5 on my XP system, but have read many posts complaining about the same error with newer versions.
    Is there a version that never produces this error on files that aren't actually damaged? And has anyone figured out what produces this error? (The posts I've seen suggest solutions that don't seem to work.)
    Thanks.
    Ellen

    Thanks, Prasanth.
    I've read posts about this problem happening on all versions, and wanted to see if it was least likely to happen in one version.
    I just need the basic function - the ability to read a pdf file.
    Of course, it seems to be a problem only for some, and there's no way of knowing the extent, so I will try an upgrade or two.
    Ellen

  • Message'there was an error opening this document.The file cannot be found'

    Using xp home and when I click to download the pdf file, it will give 3 options been 'open'/'save'/?. When I choose the 'open' option, it will give me the above message "there was an error opening this document.The file cannot be found"
    owever if I choose to "save" and I will be able to open the file and read it. In this pc its using Adobe Reader 8.1.2 with a patch. It was working fine prior to this sudden occurance of the error.
    Strangely I have another pc with the same specification, I was able to choose "open" and be able to read the file. Can anyone help to resolve the issue by using the "open' option instead of "save, then open". Greateful for your prompt response.

    Fyi, in addition to my earlier post, the other pc is using Adobe 8.1.1 and no other patch. I was trying to find 8.1.1 version but could not find a trust worthy site to load from. Do you think the error caused by using the 8.1.2 version? Thanks

  • "there was an error opening this document the root object is missing or invalid" adobe reader 9

    I get the following message every time I try an open some of my saved PDF files in Adobe Reader 9
    "there was an error opening this document. the root object is missing or invalid."
    these files are not down loaded from a website, they are files I greated some time back and I have not opened in a while.
    I am runing window XP and this dos not happen with all my PDF files.
    can you help.
    James

    Sounds like the files are corrupt. Time to restore them from a good backup.

  • Error saying "There was an error opening this document, the filename, directory name, or volume label syntax is correct"

    At my work we uses Macs to prepare PDF’s and the create folders to archive and print them. Other areas of work use PC’s to review these PDF. When they go to review these folders there is a small black dot which appears under random characters in the folder name and when they try and open the file an error message saying “There was an error opening this document, the filename, directory name, or volume label syntax is correct”. On the PC they can delete the name and rename the folder and the error disappears. If anyone can shed some light on this it would be greatly appreciated.  If I was to have a guess I think its most likely an error with character recognition between the MAC and PC.  Any help would be great , thank you 

    See if this helps on the charachters...
    http://averstak.tripod.com/fatdox/names.htm

  • There was an error opening this document. Adobe Reader XI

    Win Xp, Sp 3. When converting a word-dokument  with Acrobat Elements 7.05 the immediately opening in Adobe Reader XI fails with several of the "well known" messages "There was an error opening this document. File not found" and "There was an error opening this document. Access denied" (translated from Danish).
    The fix by setting this registry entry:
    [HKEY_CURRENT_USER\Software\Adobe\Acrobat Reader\11.0\Privileged]
    "bProtectedMode"=dword:00000000
    seems to help. But is that a sane solution?

    Hi P.Allan,
    By making the registry setting entry:
    [HKEY_CURRENT_USER\Software\Adobe\Acrobat Reader\11.0\Privileged]
    "bProtectedMode"=dword:00000000
    Reader will become unsecure.
    Please make it back to 00000001 to make Reader more secure.
    Also, please let me know the following:
    1) Is the converted PDF got saved?
    2) If yes, please let know the path where it get saved?
    3) If yes, can the converted PDF file be opened in ReaderXI from next time?
    Thanks
    Shakti

  • When I attempt to open a PDF file I saved from a website, I get the message "There was an error opening this document. The file is damaged and could not be repaired." Is there any way to correct this problem?

    When I attempt to open a PDF file I saved from a website using Safari, I get the message "There was an error opening this document. The file is damaged and could not be repaired." When I save the same PDF file using FireFox it opens up immediately. Is there any way to correct this problem with Safari?

    Back up all data.
    Triple-click the line of text below to select it, the copy the selected text to the Clipboard (command-C):
    /Library/Internet Plug-ins
    In the Finder, select
    Go ▹ Go to Folder
    from the menu bar, or press the key combination shift-command-G. Paste into the text box that opens (command-V), then press return.
    From the folder that opens, remove any items that have the letters “PDF” in the name. You may be prompted for your login password. Then quit and relaunch Safari, and test.
    The "Silverlight" web plugin distributed by Microsoft can also interfere with PDF display in Safari, so you may need to remove it as well, if it's present.
    If you still have the issue, repeat with this line:
    ~/Library/Internet Plug-ins
    If you don’t like the results of this procedure, restore the items from the backup you made before you started. Relaunch Safari again.

  • With OSX10.7.5 and Adobe Reader 11.0.02 when I try to open a PDF downloaded from the web I get 'There was an error opening this document. This file is damaged and could not be repaired. Preview will not open either. Older PDFs OK.

    I am running OS X 10.7.5 and Adobe Reader 11.0.02. In the last few days I have been unable to open PDF's downloaded from the web. Reader gives the error message 'There was an error opening this document. The file is damaged and could not be repaired'. Removing Reader and trying to use Preview to open these files give the error 'Preview cannot open this file. It may be damaged or use a file format that Preview doesn't recognise' (or something like that). Downloading the same files with Reader removed from my Mac Preview opens the files OK.
    I was recently prompted to update Adobe software but did not note exactly what the update was nor when it was done.
    Reader and Preview will both open PDFs I downloaded a week ago. Reader will also open files downloaded on another Mac running OS X 10.0.0 and copied to my Mac. Any ideas?

    Back up all data.
    Triple-click the line of text below to select it, the copy the selected text to the Clipboard (command-C):
    /Library/Internet Plug-ins
    In the Finder, select
    Go ▹ Go to Folder
    from the menu bar, or press the key combination shift-command-G. Paste into the text box that opens (command-V), then press return.
    From the folder that opens, remove any items that have the letters “PDF” in the name. You may be prompted for your login password. Then quit and relaunch Safari, and test.
    The "Silverlight" web plugin distributed by Microsoft can also interfere with PDF display in Safari, so you may need to remove it as well, if it's present.
    If you still have the issue, repeat with this line:
    ~/Library/Internet Plug-ins
    If you don’t like the results of this procedure, restore the items from the backup you made before you started. Relaunch Safari again.

  • "There was an error opening this document. The filename, directory name, or volume label syntax is i

    "There was an error opening this document. The filename, directory name, or volume label syntax is incorrect."
    I tried different versions, no avail.
    I think it has to do with the password somehow, but I do not know. I can copy the files from the web folder to my desktop and they open fine (after entering the password AGAIN), but I can not open them directly form the web folder - it does not ask for the password again, just pops up the error.
    Adobe's support really upset me (insert explicative here) by keeping me on the phone for 20 min, collecting all sorts of information about me (not the problem) with some lady who barely spoke English, just to tell me to go to the website. No surprise they need to charge for tech support, customer service is doing everything but "service". I hate companies that do this. I am thinking of using another PDF reader, I have heard good things about them. Check
    http://en.wikipedia.org/wiki/List_of_PDF_software
    Has anyone ever been able to find a fix? I can not find anything on this site.

    Howdy, Moritz!
    Thanks for the suggestion, but this is not an issue of filename and language conflicts, at least in my environment. I highly doubt that's the root cause of this issue.
    The PDF files in my tests have all had very simple names, such as 123.pdf and test.pdf, as well as more complicated names with spaces in them. Nothing about the files contains anything outside of the English language, including the content and filenames.
    From everything I've been able to determine, this is a WebDAV-related security issue that affects programs like Acrobat Reader. I know for a fact that MS's KB892211 WebDAV patch doesn't create the issue, however MS's update to that 892211 patch DOES create the issue. As I've outlined earlier in this thread, my extensive testing has proven this more than once.
    At this point, I haven't been able to accurately uninstall the update to 892211 after the update has been installed. And, as far as I can tell, the update to 892211 comes down from MS as a Office and/or Windows Update component. So, everyone has it, the uninstaller doesn't work, and there's no documentation detailing what registry entries are being changed when the update to 892211 is installed.
    My ultimate goal is to bring a test machine to the point just before the update to 892211 goes on, fire up the Registry, Process, and File monitors on my test box, and install the 892211 update. This should give me an accurate picture of what I need to restore in order to rid the machine of the update to 892211.
    Until Microsoft officially fixes the issue, I am not totally sure how this will be resolved. I've ceased my work on the issue for now since copying the PDF file from the WebDAV share to the user's desktop gets the user what they wanted in the first place - the ability to open the PDF file!
    Maybe, once some other projects slow down a bit, I might get back to creating a solution, but it's going to be a "hack" no matter which way you slice it. I'd much rather MS spend their time creating the solution. If I have to do it, my fee to MS will be quite HIGH! :*)
    George B.

  • There was an error opening this document.  The file is damaged and could not be repaired.

    Good Day all
    When busy doing internet banking on www.absa.co.za and I try to print a confirmation, I get the following error message: "C:\Documents and Settings\%user profile%\Local Settings\Temporary Internet Files\Content.IE5\%folder name%\%file name%.pdf
    Could not open file.
    File not found."
    I've managed to locate the actual file that it's looking for, but when I try and open the file using either Adobe or Foxit Reader, I get the following error message: "There was an error opening this document. The file is damaged and could not be repaired."
    I've un-installed Adobe and installed version 9.1 for this particular user. This happened a while ago and then an un-installation and re-installation of Adobe solved the issue. This time, unfortunately, it didn't. I then un-installed Adobe and tried again, UNSUCCESSFULLY. So I loaded Foxit Reader, also without any success.
    If there's anyone out there who could possibly help, please do so... It's extremely urgent.
    Please find the errors attached as well.
    Regards,
    ME

    I contacted the company and they asked me to try using another browser, which I did... and using FireFox worked
    thanks for the help ʇɐb ɹəuəllıʍ
    cheers!

  • When I try to open up a PDF document, i get the following error message: "There was an error opening this document. The network path was not found" AArrgh please help as I need to open up my documents. Thanks.

    When I open up a PDF Document all i get is an error message saying: "There was an error opening this document. The network path was not found" I dont know how to fix this, so looking for some advice please, as I really need o open up my documents.
    Thank for any help.

    The documents I’m trying to read are already saved on my computer, under various different headings, I know that we have a server, so I only assume these documents are saved on here, as I said before I’m not good with all this techno stuff. I do my work each week ( on a payroll system) and save the documents for each company, they automatically go to the correct place. I never request for them to be saved in a certain place ( well not that I’m aware of) . I then on occasions need to open up this information, it is then that I can’t read or open the documents. We do have a tech help, but they are off sick until the 5th Jan, hence me trying to work out if I can fix this problem through this help site. Its ADOBE Reader that I’m trying to use.

  • Trouble opening pdf's - I have received several pdf's from a friend via e-mail (Thunderbird). Some of them open just fine but others give me the message: "There was an error opening this document. The file is damaged and could not be repaired."

    Trouble opening pdf's - I have received several pdf's from a friend via e-mail (Thunderbird). Some of them open just fine but others give me the message: "There was an error opening this document. The file is damaged and could not be repaired." My friend made sure that the files in question opened without issue on his computer (a PC). Further, I was able to open one of these "damaged" files on my Android phone, but I cannot open them on the Macbook Air. Any help would be greatly appreciated.

    Back up all data.
    Triple-click the line of text below to select it, the copy the selected text to the Clipboard (command-C):
    /Library/Internet Plug-ins
    In the Finder, select
    Go ▹ Go to Folder
    from the menu bar, or press the key combination shift-command-G. Paste into the text box that opens (command-V), then press return.
    From the folder that opens, remove any items that have the letters “PDF” in the name. You may be prompted for your login password. Then quit and relaunch Safari, and test.
    The "Silverlight" web plugin distributed by Microsoft can also interfere with PDF display in Safari, so you may need to remove it as well, if it's present.
    If you still have the issue, repeat with this line:
    ~/Library/Internet Plug-ins
    If you don’t like the results of this procedure, restore the items from the backup you made before you started. Relaunch Safari again.

  • Keep getting the following error message There was an error opening this document. The file is damaged and could not be repaired.

    I keep getting the following message when trying to open a PDF I know nothing wrong with the file as it opens fine on other devices ?
    "There was an error opening this document. The file is damaged and could not be repaired."

    No its not zipped
    Brian Blackstock
    [email protected]
    Office Australia  +61 7 54537982
    Office South Africa +27 11 423 2701
    Mobile South Africa +27 796924094
    Mobile Australia +61 400797124
    www.atoll.co.za
    www.elematicsa.co.za

Maybe you are looking for