A proven solution to copy a PDF document to SharePoint document library is to use the CopyIntoItems web service. You will never regret your approach if you follow this path.
Here are the summary of steps for your coding..
1. convert the document into byte for easy transmission
FileStream fStream = File.OpenRead(fileName);
byte[] contents = new byte[fStream.Length];
fStream.Read(contents, 0, (int)fStream.Length);
fStream.Close();
byte[] contents = new byte[fStream.Length];
fStream.Read(contents, 0, (int)fStream.Length);
fStream.Close();
2. Add the web service reference of your SharePoint Server.
3. Create a Proxy of your SharePoint service
SharePointServerReference.CopySoapClient copy = new SharePointServerReference.CopySoapClient();
4. Call the final CopyIntoItems () service
uint result = copy.CopyIntoItems(fileName,
new string[] { strDestinationUrl },
myFieldInfoArray,
contents,
out myCopyResultArray);
new string[] { strDestinationUrl },
myFieldInfoArray,
contents,
out myCopyResultArray);
where
filename is the name of actual pdf file.
strDestinationUrl is the location of the document library where file will be uploaded.
myFieldInfoArray can be defined as follows:
copy.FieldInformation fields = new copy.FieldInformation();
copy.FieldInformation[] myFieldInfoArray = { fields };
filename is the name of actual pdf file.
strDestinationUrl is the location of the document library where file will be uploaded.
myFieldInfoArray can be defined as follows:
copy.FieldInformation fields = new copy.FieldInformation();
copy.FieldInformation[] myFieldInfoArray = { fields };
myCopyResultArray can be defined as follows:
copy.CopyResult myCopyResult1 = new copy.CopyResult();
copy.CopyResult[] myCopyResultArray = { myCopyResult1 };
Please find below url from MSDN for this entire activity for reference :
http://msdn.microsoft.com/en-us/library/copy.copy.copyintoitems(v=office.12).aspx
copy.CopyResult myCopyResult1 = new copy.CopyResult();
copy.CopyResult[] myCopyResultArray = { myCopyResult1 };
Please find below url from MSDN for this entire activity for reference :
http://msdn.microsoft.com/en-us/library/copy.copy.copyintoitems(v=office.12).aspx