0

I was uploading documents to sharepoint custom list.The file will save in Attachement COlumn.But when i try to open Pdf it shows failed to open PDF.When i try to open Word document it shows we are sorry we found problem with its content.

How can i open PDF and Word Documents in My sharepoint 2013 server.

I tried to activate this feature(Open Documents in Client Applications by Default) But still the documents Are not Opening ?

Error Messages :

enter image description here

When i was click the Link Report(!).pdf i was getting following error. enter image description here

For word Document i was getting following error.

enter image description here

7
  • It really looks like your document content (binary content) is corrupted. Are you 100% they're OK before you upload them as attachments?
    – Evariste
    Commented Jan 5, 2017 at 9:54
  • I was get the Document from sharepoint Library. when i click the document in sharepoint Library It will get download and i will save the Document. If i open the document with no issues Documents are opening.
    – Elina
    Commented Jan 5, 2017 at 10:29
  • I was get the Document from sharepoint Library And i move the document to other web application site Custom List.
    – Elina
    Commented Jan 5, 2017 at 10:29
  • I use this code to save the document in attachment column: SPAttachmentCollection attachmentCollection = oListItem.Attachments; Byte[] attachmentContent; attachmentContent = new Byte[oDocItem.File.Length]; if (attachmentCollection != null) { attachmentCollection.Add(oDocItem.File.Name.ToString(), attachmentContent); }
    – Elina
    Commented Jan 5, 2017 at 10:32
  • Look at your code: your attachmentContent is simply never filled with the file binary! So your attachments are just... full of 0!
    – Evariste
    Commented Jan 5, 2017 at 10:36

1 Answer 1

2

Your files really look damaged/corrupted. Maybe something on the line does edit/replace their binary content.
For instance, don't you have a proxy along the line that may intercept the files and change them on the fly?
Or custom code (such as an HTTP Handler) deployed on the server?

Can you download the file (not open) on your disk: thencheck its size, and open it in Notepad to see how the actual content looks like.

[EDIT]
After you posted the code you use to upload attachments, the problem becomes clear: you wrongly upload the files. You never get the source file content to inject it to the target. This obviously results in files with the correct size but that are absolutely empty.
The correct code would look like (one line to replace the entire code block you posted):

oListItem.Attachments.Add(oDocItem.File.Name, oDocItem.File.OpenBinary());
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.