Persits Software, Inc. Knowledge Base Articles

The file is damaged and could not be repaired error

Problem Description

When trying to open a PDF document created by AspPDF or AspPDF.NET in Acrobat Reader (versions 6 or 7), the following error message may be displayed by the viewer application:

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

This usually occurs when the SaveHttp method is used to create the document.


If a script calls the SaveHttp method, this script cannot contain any HTML tags as they get appended to the data stream generated by SaveHttp and corrupt the PDF document produced by it.

You can determine if your PDF document has been corrupted by viewing it in WordPad or any other text editor. The following box shows a typical case of HTML-tag corruption. The mark %%EOF designating the end of the PDF document should be at the very bottom of the file, yet in this case it is followed by HTML tags that migrated to the PDF document from the script that produced it:

0 8
0000000000 65535 f 
0000000015 00000 n 
0000000064 00000 n 
0000000121 00000 n 
0000000196 00000 n 
0000000303 00000 n 
0000000451 00000 n 
0000002257 00000 n 
<</Size 8
/Root 1 0 R
/Info 3 0 R
/ID [<E76815C92D2F945FB2666B3D14F26FE1> 
<div style="border-style:solid;">
	<form name="frm" action="file.asp" method="post">
		<input type="hidden" value="r" name="hidAction">
		<table width="600" border="0">

Acrobat 8+ is known to be more resistant to this type of corruption than previous versions of Adobe Acrobat, and it may not report an error even if the PDF document is corrupted. It is therefore a good idea to test documents generated by your application for corruption using older versions of Adobe Acrobat.

For more information about the SaveHttp method, and to see the ASP/ASP.NET code samples, please refer to Section 3.2 of the AspPDF User Manual.