In SharePoint 2013 i was convert the .doc and .docx document to PDF.
when we are converting to PDF in document library we are storing some field values like ContractID, DocumentType.
converting .docx document to PDF that time ContractID, DocumentType is stored in Document Library.
But when converting .doc document to PDF list time ContractID, DocumentType is not stored in Document Library.
Here is my code :
Document.cs
SPQuery oQry = new SPQuery();
oQry.Query = "<Where><And><Eq><FieldRef Name='ContractID' /><Value Type='Lookup'>" + ContractID + "</Value></Eq><Eq><FieldRef Name='ID' /><Value Type='Counter'>" + DocID + "</Value></Eq></And></Where>";
oQry.ViewAttributes = "Scope='RecursiveAll'";
SPListItemCollection ocol = oDocLib.GetItems(oQry);
//SPListItem oTempItem = olist.GetItemById(ContractID);
SPListItem oTempItem = ocol[0];
string url = string.Empty;
string FileUrl = oTempItem.Url;
int fileExtPos = FileUrl.LastIndexOf(".");
if (fileExtPos >= 0)
url = FileUrl.Substring(0, fileExtPos);
SPFile oFile = oTempItem.File;
oFile.Web.AllowUnsafeUpdates = true;
// oFile.MoveTo(oFile.ParentFolder + "/" + docName+".pdf", true);
// oTempItem.File.MoveTo(url + ".pdf", true);
//still this step in oFile ContractID is there.(oFile.MoveTo(url + ".pdf", //true);)
//in this step while converting pdf ContractID become null.
oFile.MoveTo(url + ".pdf", true);
oFile.SaveBinary(data1);
oFile.Update();
}
}
});
}
catch (Exception ex)
{
ex.ToString();
}
}
why that contractID become null please someone tell me. Thanks in Advance.