I had this issue a while back, but didn’t find a solution. When opening pdf stored in SQLSVR from any browser, this error occurs:
“There was an error opening this document. The file is damaged and could not be repaired.”
Doc & rtf work. I’m using ASP.net 2005, framework 2x.
Document is being uploaded via FileUpload & btnClick event to pass
FileType, FileSize, FileContent to business layer/sp. The document is same size locally & in SQLSVR, so I don’t think it’s being truncated.
Download occurs when user clicks hyperlinkfield to view document in any browser. It’s during this time that pdf fails to open.
Any suggestions … ?
A+ BS MCSE OOP Security+ Web Developer
Get creative, not even.
'.End() 'raises System.Threading.ThreadAbortException
'trade off: close o/p vs appl failure
End With
Else
Alert(result)
End If
ElseIf hfRequestQueryString.Value =
"" Then
Else 'qs tainted
lblErr.Visible =
True
lblErr.Text =
"Sorry, data not available now. Please try again later."
End If
______Order class LoadDocument method
Public ReadOnly
Property LoadDocument(ByVal OrderID
As Integer)
As String
Get
Dim clsValidation
As New DLLR.Validation
Dim clsFormat
As New DLLR.Format
Dim result
As String =
"Data Base connection failure. Please try again later."
If clsValidation.Required(OrderID)
Then
mOrderID = OrderID
Else
result =
"`OrderID` not found"
GoTo ExitPoint
End If
Dim ds As DataSet
"spLoadDocument", _
New SqlParameter("@OrderID", mOrderID))
If ds.Tables.Count = 0
Then
result =
"spLoadDocument returned no rows. Data Base connection failure. Please try again later."
Else
If ds.Tables(0).Rows.Count = 1
Then
Select Case
CInt(ds.Tables(0).Rows(0).Item("result"))
Case 0
Hi, I think the pdf file might be damaged
or something. If necessary, you can try a utility called
Advanced PDF Repair to repair your PDF file. It works rather well for my corrupt PDF files. Hope this helps. Alan
maniac
Member
264 Points
94 Posts
“There was an error opening this document. The file is damaged and could not be repaired.”
Mar 07, 2007 01:52 PM|LINK
Gang:
I had this issue a while back, but didn’t find a solution. When opening pdf stored in SQLSVR from any browser, this error occurs:
“There was an error opening this document. The file is damaged and could not be repaired.”
Doc & rtf work. I’m using ASP.net 2005, framework 2x.
Document is being uploaded via FileUpload & btnClick event to pass FileType, FileSize, FileContent to business layer/sp. The document is same size locally & in SQLSVR, so I don’t think it’s being truncated.
Download occurs when user clicks hyperlinkfield to view document in any browser. It’s during this time that pdf fails to open.
Any suggestions … ?
Get creative, not even.
Haissam
All-Star
37421 Points
5632 Posts
Re: “There was an error opening this document. The file is damaged and could not be repaired.”
Mar 07, 2007 03:29 PM|LINK
We need to check your code in order to track it.
please post your code which is handling the file download
HC
MCAD.NET
| Blog |
maniac
Member
264 Points
94 Posts
Re: “There was an error opening this document. The file is damaged and could not be repaired.”
Mar 08, 2007 05:52 PM|LINK
HC:
Sorry for not replying sooner. EM notification not working from forum? I will check that shortly.
Thank you in advance for prompt professional reply, as always from this forum. MS ROCKS!!
______default.aspx.vb code (click link, get document)
If Request.QueryString("OrderID") <> "" Then 'qs present & no issue
Dim qsOrderIDControlNum As String = Request.QueryString("OrderID") 'only 1 qs Dim aSplitQS(1) As String 'doesn't chk val, 0 = OrderId; 1 = Control# (doc name)aSplitQS = qsOrderIDControlNum.Split(","c)
'c = delimiter Dim aSplitControlNumName(1) As String 'split Control# val @ nv pairaSplitControlNumName = aSplitQS(1).Split("="c)
Dim OrderId As Integer = Int(aSplitQS(0)) 'LoadDocument Dim result As String = Nothingresult = clsOrder.LoadDocument(OrderId) 'sp that retrieves document from SQLSVR
If result = "OK" Then With Page.Response.Clear()
.ContentType = clsOrder.ContentType
Page.Response.AddHeader(
"content-disposition", "filename=" & aSplitControlNumName(1)).OutputStream.Write(clsOrder.FileData, 0, clsOrder.FileSize)
'.End() 'raises System.Threading.ThreadAbortException 'trade off: close o/p vs appl failure End With ElseAlert(result)
End If ElseIf hfRequestQueryString.Value = "" Then Else 'qs taintedlblErr.Visible =
TruelblErr.Text =
"Sorry, data not available now. Please try again later." End If______Order class LoadDocument method
Public ReadOnly Property LoadDocument(ByVal OrderID As Integer) As String Get Dim clsValidation As New DLLR.Validation Dim clsFormat As New DLLR.Format Dim result As String = "Data Base connection failure. Please try again later." If clsValidation.Required(OrderID) ThenmOrderID = OrderID
Elseresult =
"`OrderID` not found" GoTo ExitPoint End If Dim ds As DataSetds = DLLR.DataAccess.ExecuteDataset(Data.CommandType.StoredProcedure,
"spLoadDocument", _ New SqlParameter("@OrderID", mOrderID)) If ds.Tables.Count = 0 Thenresult =
"spLoadDocument returned no rows. Data Base connection failure. Please try again later." Else If ds.Tables(0).Rows.Count = 1 Then Select Case CInt(ds.Tables(0).Rows(0).Item("result")) Case 0result =
"OK"mFileSize =
CInt(ds.Tables(0).Rows(0).Item("FileSize"))mFileData =
CType(ds.Tables(0).Rows(0).Item("FileData"), Byte())mContentType =
CStr(ds.Tables(0).Rows(0).Item("ContentType")) Case -1result =
"There is no legal document associated with this order." GoTo ExitPoint Case Elseresult =
"spLoadDocument failure. Data Base connection failure. Please try again later." GoTo ExitPoint End Select End If End IfExitPoint:
Return result End Get End Property______ Order class variables
Public ReadOnly Property ContentType() As String Get Return mContentType End Get End PropertyPublic ReadOnly Property FileData() As Byte()
Get Return mFileData End Get End PropertyPublic ReadOnly Property FileSize() As Integer
Get Return mFileSize End Get End PropertyGet creative, not even.
maniac
Member
264 Points
94 Posts
Re: “There was an error opening this document. The file is damaged and could not be repaired.”
Mar 09, 2007 01:00 PM|LINK
Gang:
Any suggestions .... EM is working.
Get creative, not even.
maniac
Member
264 Points
94 Posts
Re: “There was an error opening this document. The file is damaged and could not be repaired.”
Mar 09, 2007 01:49 PM|LINK
Gang:
Adobe diagnostic link
http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=328233
Still researching ...
Get creative, not even.
maniac
Member
264 Points
94 Posts
Re: “There was an error opening this document. The file is damaged and could not be repaired.”
Mar 09, 2007 03:27 PM|LINK
Gang:
Having server checked. Let you know after reconfigured.
Get creative, not even.
maniac
Member
264 Points
94 Posts
Re: “There was an error opening this document. The file is damaged and could not be repaired.”
Mar 09, 2007 06:39 PM|LINK
Gang:
Troubleshot via Adobe's checklist ... no luck
<div>Open IIS Manager, then navigate to APPL.
Right click APPL, properties.
</div> <div>Under HTTP headers, file types, add a new type.
</div> <div>For MIME type dialog box, please enter pdf
</div> <div>For MIME type text box, please enter application/pdf
Dunno ... must be code issue ...
I believe that Adobe, browser & server have been eliminated as causes.
</div>Get creative, not even.
maniac
Member
264 Points
94 Posts
Re: “There was an error opening this document. The file is damaged and could not be repaired.”
Mar 09, 2007 06:47 PM|LINK
Gang:
Does anybody know if there were a specific way that pdf's must be stored in DB?
Get creative, not even.
wsun2000@hot...
Member
12 Points
11 Posts
Re: “There was an error opening this document. The file is damaged and could not be repaired.”
Oct 17, 2007 07:16 PM|LINK
I had the same problem
The pdf I imported to database by using openrowset()
fyz
Member
4 Points
2 Posts
Re: “There was an error opening this document. The file is damaged and could not be repaired.”
May 06, 2008 02:08 PM|LINK