Convert list item attachment from docx to pdf using Word Automation Services
I have been trying to convert List Item attachments from docx to pdf using word automation services, it works in a normal document library but when I use the list attachment it throws a null reference error.
var settings = new ConversionJobSettings();
settings.OutputFormat = Microsoft.Office.Word.Server.Conversions.SaveFormat.PDF;
var conversion = new ConversionJob("Word Automation Services", settings);
conversion.UserToken = SPContext.Current.Site.UserToken;
var wordFile = SPContext.Current.Site.RootWeb.Url + "/" + wordForm.Url;
var pdfFile = wordFile.Replace(".docx", ".pdf");
conversion.AddFile(wordFile, pdfFile);
conversion.Start();
Using reflector I was able to see my problem lies in Microsoft.Office.Word.Server.FolderIterator.cs where it uses SPFile.Item which returns NULL
internal void CheckSingleItem(SPFile inputFile, SPFile outputFile)
Microsoft.Office.Word.Server.Log.TraceTag(0x67337931, Microsoft.Office.Word.Server.Log.Category.ObjectModel, Microsoft.Office.Word.Server.Log.Level.Verbose, "OM: FolderIterator start a single item: source='{0}'; dest='{1}'", new object[] { inputFile.Url, outputFile.Url });
Stopwatch stopwatch = Microsoft.Office.Word.Server.Log.StartPerfStopwatch();
try
this.CheckInputFile(inputFile.Item);
this.CheckOutputFile(outputFile.Url);
Is there any way to get around this?
Hi Qfroth,
According to your description, my understanding is that when you use word automation service to convert Word to PDF for list item attachment, it throws the null reference error.
I suggest you can create an event receiver and convert the word to memory stream like below:
private byte[] ConvertWordToPDF(SPFile spFile, SPUserToken usrToken)
byte[] result = null;
try
using (Stream read = spFile.OpenBinaryStream())
using (MemoryStream write = new MemoryStream())
// Initialise Word Automation Service
SyncConverter sc = new SyncConverter(WORD_AUTOMATION_SERVICE);
sc.UserToken = usrToken;
sc.Settings.UpdateFields = true;
sc.Settings.OutputFormat = SaveFormat.PDF;
// Convert to PDF
ConversionItemInfo info = sc.Convert(read, write);
if (info.Succeeded)
result = write.ToArray();
catch (Exception ex)
// Do your error management here.
return result;
Here is a detailed code demo for your reference:
Word to PDF Conversion using Word Automation Service
Best Regards
Zhengyu Guo
TechNet Community Support
Similar Messages
-
Convert dotx or docx to pdf with Word Automation Service failed
Hello everybody,
After search on the internet, I'm looking for a solution to this issue.
I wrote this code for a document conversion in a visual studio 2010 workflow:
string wordAutomationServiceName = "Word Automation Service";
ConversionJobSettings jobSettings = new ConversionJobSettings();
jobSettings.OutputFormat = SaveFormat.PDF;
ConversionJob job = new ConversionJob(wordAutomationServiceName, jobSettings);
job.UserToken = workflowProperties.Site.UserToken;
job.AddFile(workflowProperties.WebUrl + "/" + file.Url,
workflowProperties.WebUrl + "/" + file.Url.Replace(".docx", ".pdf"));
job.Start();
URLs are corrects and the word document exists.
The problem is when the job is executed, I have errors in SharePoint logs:
11/18/2011 09:24:15.87 w3wp.exe (0x1BC4) 0x1CA0 Word Automation Services
Office Viewing Architecture 9rte Medium Request received for document 00000001-0001-10e2-80af-d08c970b9892, format: , numberInQueue: 0, request id ba03fb58-55b2-4c6c-b1ca-20fad3b11585
00000001-0001-10e2-80af-d08c970b9892
11/18/2011 09:24:15.87 w3wp.exe (0x1BC4) 0x1CA0 Word Automation Services
Office Viewing Architecture c7ld Medium AppManager.BeginProcessRequest adding request to queue 00000001-0001-10e2-80af-d08c970b9892
11/18/2011 09:24:15.88 w3wp.exe (0x1BC4) 0x1CA0 Word Automation Services
Timer Job g27p Medium Local Controller '71cf62b9-c34c-46c4-9828-55de2d5f5ac0':
In Progress: <http://site/Contracts/docsettest/contracttest.dotx> downloaded and queued locally 00000001-0001-10e2-80af-d08c970b9892
11/18/2011 09:24:15.88 w3wp.exe (0x1BC4) 0x17C0 Word Automation Services
Configuration g6xc Medium Item 00000001-0001-10e2-80af-d08c970b9892: Assigned to
local worker process: 1D64 (7524; worker id = cce33245-48b9-4b0d-afcd-e3218845d81a) 00000001-0001-10e2-80af-d08c970b9892
11/18/2011 09:24:15.88 w3wp.exe (0x1BC4) 0x1CA0 SharePoint Foundation
Monitoring b4ly Medium Leaving Monitored Scope (ExecuteWcfServerOperation).
Execution Time=23.6994391735768 2fd2393d-f36d-49a1-bfdf-737aefc8659a
11/18/2011 09:24:15.88 w3wp.exe (0x1BC4) 0x211C Word Automation Services
Office Viewing Architecture vipp Medium AppWorker:cce33245-48b9-4b0d-afcd-e3218845d81a initializing for request ba03fb58-55b2-4c6c-b1ca-20fad3b11585
00000001-0001-10e2-80af-d08c970b9892
11/18/2011 09:24:15.88 w3wp.exe (0x1BC4) 0x211C Word Automation Services
Office Viewing Architecture vipr Monitorable AppWorker:cce33245-48b9-4b0d-afcd-e3218845d81a worker call failed System.ServiceModel.CommunicationObjectAbortedException: The
communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it has been Aborted. Server stack trace: at System.ServiceModel.Channels.CommunicationObject.ThrowIfDisposedOrNotOpen()
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage
methodCall, ProxyOperationRuntime operation) at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message) Exception rethrown at [0]: at System.Runtime.Re...
00000001-0001-10e2-80af-d08c970b9892
11/18/2011 09:24:15.88* w3wp.exe (0x1BC4) 0x211C Word Automation Services
Office Viewing Architecture vipr Monitorable ...moting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&
msgData, Int32 type) at Microsoft.Office.Web.Conversion.Framework.Remoting.IAppChannelCallback.Initialize(WorkerRequest request, FileItem fileItem) at Microsoft.Office.Web.Conversion.Framework.AppWorker.ProcessRequest(ConversionRequest
request). Worker name WordAutomationServices, Document 00000001-0001-10e2-80af-d08c970b9892 00000001-0001-10e2-80af-d08c970b9892
11/18/2011 09:24:15.88 w3wp.exe (0x1BC4) 0x211C Word Automation Services
Service g281 Medium Local Controller '71cf62b9-c34c-46c4-9828-55de2d5f5ac0':
Failure: <http://site/Contracts/docsettest/contracttest.dotx> not uploaded to <http://site/Contracts/docsettest/contracttest.pdf> (65543) 00000001-0001-10e2-80af-d08c970b9892
11/18/2011 09:24:15.90 w3wp.exe (0x1BC4) 0x211C Word Automation Services
Office Viewing Architecture c78j Unexpected AppWorker:cce33245-48b9-4b0d-afcd-e3218845d81a ProcessRequestDone() received error response WorkerException, restarting the worker
00000001-0001-10e2-80af-d08c970b9892
11/18/2011 09:24:15.90 w3wp.exe (0x1BC4) 0x211C Word Automation Services
Office Viewing Architecture b1qa Medium Shutting down process with force processId: 7524 belonging to AppWorker cce33245-48b9-4b0d-afcd-e3218845d81a
00000001-0001-10e2-80af-d08c970b9892
11/18/2011 09:24:15.91 w3wp.exe (0x1BC4) 0x1CA0 Word Automation Services
Configuration g6xb Medium Local Controller '71cf62b9-c34c-46c4-9828-55de2d5f5ac0':
Local worker process exited: 1D64 (7524); exit time = 11/18/2011 09:24:15
11/18/2011 09:24:15.91 w3wp.exe (0x1BC4) 0x1CA0 Word Automation Services
Configuration d0md Medium App 'Word Automation Service': Deleting temp directory
'C:\Windows\TEMP\wdsrv\21659d2e-c634-46a2-9585-b4cd1398f64c\odsibdmm.cmv\1D64'
11/18/2011 09:24:15.92 w3wp.exe (0x1BC4) 0x211C Word Automation Services
Office Viewing Architecture xpre Medium Removing worker cce33245-48b9-4b0d-afcd-e3218845d81a, thread: 216 00000001-0001-10e2-80af-d08c970b9892
11/18/2011 09:24:15.92 w3wp.exe (0x1BC4) 0x211C Word Automation Services
Office Viewing Architecture f2yg Medium CreateSandBoxedProcessWorker() is called 00000001-0001-10e2-80af-d08c970b9892
11/18/2011 09:24:15.93 w3wp.exe (0x1BC4) 0x211C Word Automation Services
Office Viewing Architecture b10e Medium Created desktop: Service-0x0-3eaf55d$\Microsoft Office Isolated Environment 00000001-0001-10e2-80af-d08c970b9892
11/18/2011 09:24:15.93 w3wp.exe (0x1BC4) 0x211C Word Automation Services
Office Viewing Architecture 2brt Medium AppWorker:89d80fff-43ec-459e-9d95-5ed8b67f20bb worker process is started Exe: WordServerWorker.exe Args: /id 89d80fff-43ec-459e-9d95-5ed8b67f20bb
/convertingService net.pipe://127.0.0.1/WordServer71cf62b9-c34c-46c4-9828-55de2d5f5ac0 /assembly WdsrvWorker.dll /type WACWS /IsBatchedTracing True /LogQuota 100 WorkerType: WorkerType1 Directory: c:\windows\system32\inetsrv, pid : 3700, IsSandBoxed: True,
UniqueSandBoxSid: S-1-5-26473-19571-45394-48 00000001-0001-10e2-80af-d08c970b9892
11/18/2011 09:24:15.93 w3wp.exe (0x1BC4) 0x211C Word Automation Services
Office Viewing Architecture vioz Medium RemoveWorker isRemoved: True session id : uuid:c9cce13b-5285-47d6-a666-29da19e57c67;id=47, Guid: cce33245-48b9-4b0d-afcd-e3218845d81a
00000001-0001-10e2-80af-d08c970b9892
11/18/2011 09:24:15.93 w3wp.exe (0x1BC4) 0x211C Word Automation Services
Office Viewing Architecture b4em Monitorable AppWorker:cce33245-48b9-4b0d-afcd-e3218845d81a recycle worker process because the conversion failed with result WorkerException.
Worker is WordAutomationServices 00000001-0001-10e2-80af-d08c970b9892
11/18/2011 09:24:15.93 w3wp.exe (0x1BC4) 0x211C Word Automation Services
Office Viewing Architecture xpre Medium Removing worker cce33245-48b9-4b0d-afcd-e3218845d81a, thread: 216 00000001-0001-10e2-80af-d08c970b9892
11/18/2011 09:24:15.93 w3wp.exe (0x1BC4) 0x211C Word Automation Services
Office Viewing Architecture vioz Medium RemoveWorker isRemoved: False session id : uuid:c9cce13b-5285-47d6-a666-29da19e57c67;id=47, Guid: cce33245-48b9-4b0d-afcd-e3218845d81a
00000001-0001-10e2-80af-d08c970b9892
11/18/2011 09:24:15.93 w3wp.exe (0x1BC4) 0x211C Word Automation Services
Office Viewing Architecture a2oj Medium PreProcessTime = 0; InConversionQueueTime = 0.0019142; ResponseTime = 0.0066997; TotalConversionTime = 0.0535976; AvgPreProcessTime
= 0; AvgInConversionQueueTime = 0; AvgResponseTime = 0; AvgTotalConversionTime = 0; historyCount = 0; result = WorkerException; format = n/a 00000001-0001-10e2-80af-d08c970b9892
11/18/2011 09:24:15.93 w3wp.exe (0x1BC4) 0x144C Word Automation Services
Office Viewing Architecture 4sig Medium ChildProcess WordServerWorker.exe is launched inside worker 89d80fff-43ec-459e-9d95-5ed8b67f20bb. Pid 3700
11/18/2011 09:24:15.93 w3wp.exe (0x1BC4) 0x144C Word Automation Services
Office Viewing Architecture d9hn Medium NotifyNewChildProcessInWorker has seen WordServerWorker.exe in worker 89d80fff-43ec-459e-9d95-5ed8b67f20bb
11/18/2011 09:24:16.45 w3wp.exe (0x1BC4) 0x18CC Word Automation Services
Office Viewing Architecture viou Medium ... registering worker 89d80fff-43ec-459e-9d95-5ed8b67f20bb
11/18/2011 09:24:16.48 w3wp.exe (0x1BC4) 0x18CC Word Automation Services
Office Viewing Architecture viox Medium Worker 89d80fff-43ec-459e-9d95-5ed8b67f20bb is now initialized.
11/18/2011 09:24:16.55 w3wp.exe (0x1BC4) 0x18CC Word Automation Services
Office Viewing Architecture vipx Monitorable AppWorker:89d80fff-43ec-459e-9d95-5ed8b67f20bb application server host exited unexpectedly (thread: 6)
11/18/2011 09:24:16.55 w3wp.exe (0x1BC4) 0x18CC Word Automation Services
Office Viewing Architecture c78j Unexpected AppWorker:89d80fff-43ec-459e-9d95-5ed8b67f20bb ProcessRequestDone() received error response WorkerCrashed, restarting the worker
11/18/2011 09:24:16.57 w3wp.exe (0x1BC4) 0x18CC Word Automation Services
Office Viewing Architecture xpre Medium Removing worker 89d80fff-43ec-459e-9d95-5ed8b67f20bb, thread: 6
11/18/2011 09:24:16.57 w3wp.exe (0x1BC4) 0x18CC Word Automation Services
Office Viewing Architecture f2yg Medium CreateSandBoxedProcessWorker() is called
11/18/2011 09:24:16.57 w3wp.exe (0x1BC4) 0x18CC Word Automation Services
Office Viewing Architecture b10e Medium Created desktop: Service-0x0-3eb1722$\Microsoft Office Isolated Environment
11/18/2011 09:24:16.57 w3wp.exe (0x1BC4) 0x18CC Word Automation Services
Office Viewing Architecture 2brt Medium AppWorker:59168d75-7086-4318-8d12-633affa7b783 worker process is started Exe: WordServerWorker.exe Args: /id 59168d75-7086-4318-8d12-633affa7b783
/convertingService net.pipe://127.0.0.1/WordServer71cf62b9-c34c-46c4-9828-55de2d5f5ac0 /assembly WdsrvWorker.dll /type WACWS /IsBatchedTracing True /LogQuota 100 WorkerType: WorkerType1 Directory: c:\windows\system32\inetsrv, pid : 6752, IsSandBoxed: True,
UniqueSandBoxSid: S-1-5-26473-19571-45394-49
11/18/2011 09:24:16.57 w3wp.exe (0x1BC4) 0x18CC Word Automation Services
Office Viewing Architecture vioz Medium RemoveWorker isRemoved: True session id : uuid:c9cce13b-5285-47d6-a666-29da19e57c67;id=48, Guid: 89d80fff-43ec-459e-9d95-5ed8b67f20bb
11/18/2011 09:24:16.57 w3wp.exe (0x1BC4) 0x144C Word Automation Services
Office Viewing Architecture 4sig Medium ChildProcess WordServerWorker.exe is launched inside worker 59168d75-7086-4318-8d12-633affa7b783. Pid 6752
11/18/2011 09:24:16.57 w3wp.exe (0x1BC4) 0x144C Word Automation Services
Office Viewing Architecture d9hn Medium NotifyNewChildProcessInWorker has seen WordServerWorker.exe in worker 59168d75-7086-4318-8d12-633affa7b783
11/18/2011 09:24:17.10 w3wp.exe (0x1BC4) 0x1CA0 Word Automation Services
Office Viewing Architecture viou Medium ... registering worker 59168d75-7086-4318-8d12-633affa7b783
11/18/2011 09:24:17.13 w3wp.exe (0x1BC4) 0x1CA0 Word Automation Services
Office Viewing Architecture viox Medium Worker 59168d75-7086-4318-8d12-633affa7b783 is now initialized.
Thank you for your help.Hi Jean,
Were you able to resolve this? I am coming across the exact same error on a SharePoint 2010 development machine. I don't see any other posts on the web about it. Here is the entry from my ULS logs:
Local Controller 'fc8b8704-f0f1-4e85-a69a-dc5686c27e39': Failure: <http://ip-0a6ee272/Shared%20Documents/Word/hello.docx> not uploaded to <http://ip-0a6ee272/Shared%20Documents/PDF/hello.pdf>
(65543)
Do we share any of the following configuration points? I'm trying to narrow down the potential root cause ...
MSDN subscriber EXE install media "SharePoint Server 2010 with Service Pack 1 (x64) - (English)"
SP1 slipstream patch level. No cumulative updates.
http://autospinstaller.codeplex.com/ PowerShell scripted install
SQL 2008 R2 installed on same box as SharePoint
Active Directory domain controller on same box as SharePoint
c:\Windows\System32\drivers\etc\HOSTS file 127.0.0.1 entry for both machine and domain name
Thanks in advance for the research.
I've actually tried re-installing SharePoint several times on brand new virtual machines. That did not resolve the issue. Strangely enough, the RTM version of SharePoint appears to work just fine. With all other configuration points the
same, I loaded RTM ... ran a Word Automation PowerShell script ... and received the expected PDF output. Then when I apply the SP1 patch ... it stops working and I get error 65543.
Best,
@SPJeff -
Converting Word To Pdf using Windows Automation Services
Hi,
I tried to convert word documents to pdf using "Windows automation Services" and followed below links to create event receiver but it is not converting to pdf, then I tried to debug code but I got an error "Unable to automatically
step into the server.Unable to determine a stopping location.Verify symbols are loaded.The breakpoint has a filter conditions have not been satisfied".
http://msdn.microsoft.com/en-us/library/ff181518.aspx
http://www.zquad.in/2011/01/sharepoint-2010-convert-document-to-pdf.html
Can anybody help me to resolve this issue?
Any help would be appreciated.
Thank you,
AA.Hey
i suggest if you are using SharePoint server 2013 and you have Office Web Apps available in your farm, then this feature will be there out-of-the-box without using any code.
Ahmed Said Moussa SharePoint Consultant -
Moving a List Item attachment from one list to another
Hi,
What are the best way of coping / moving the List Item attachment using
jQuery / JavaScript in SharePoint 2013 from one list to another.
Thanks
Saroj
Impossible is nth but good coding :-)For your needs better try to code your own solution. See
SharePoint JavaScript Class Library for details. You can have two possible architectures:
Make all work from JavaScript. And the first your step will be
addItem method of SP.List.
Make processing of selection on client in JavaScript and call your custom server-side component (may be an application page) for items copying (creating copies in new list of already existed items from initial list.). See
this for example.
Also be careful with context.load. It's recommended to write all next code in context.executeQueryAsync. Use Firebug in FF and developer tools in Chrome for debugging your code and to find what is wrong.
Or
https://social.msdn.microsoft.com/Forums/sharepoint/en-US/1d01a48f-c28b-467b-acd1-22e5fb266670/how-to-retrieve-list-items-and-copy-it-to-other-list-using-javascript-object-model?forum=sharepointdevelopmentprevious
<script type="text/javascript">
ExecuteOrDelayUntilScriptLoaded(retrieveListItems, "sp.js");
var siteUrl = 'Site Url';
function retrieveListItems() {
var clientContext = new SP.ClientContext(siteUrl);
var oList = clientContext.get_web().get_lists().getByTitle('List1');
var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml('<View><Query><Where><Geq><FieldRef Name=\'ID\'/>' +
'<Value Type=\'Number\'>1</Value></Geq></Where></Query><RowLimit>10</RowLimit></View>');
this.collListItem = oList.getItems(camlQuery);
clientContext.load(collListItem);
clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
function onQuerySucceeded(sender, args) {
var listItemInfo = '';
var listItemEnumerator = collListItem.getEnumerator();
while (listItemEnumerator.moveNext()) {
var objListItem = listItemEnumerator.get_current();
var clientContext = new SP.ClientContext(siteUrl);
var oList = clientContext.get_web().get_lists().getByTitle('List2');
var itemCreateInfo = new SP.ListItemCreationInformation();
this.oListItem = oList.addItem(itemCreateInfo);
oListItem.set_item('Title', objListItem.get_item('Title'));
oListItem.update();
clientContext.load(oListItem);
clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceededFinal), Function.createDelegate(this, this.onQueryFailed));
function onQueryFailed(sender, args) {
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
function onQuerySucceededFinal(sender, args) {
//Do next set of operation if needed
</script><input name="btnVarIQReject" onclick="retrieveListItems()" type="button" value="Submit"/>
Please use my above POC code to start. This will copy all the title field value from list1 to list2
If this helped you resolve your issue, please mark it Answered -
How to download list item attachment from display.aspx
Im uploading documents
to list item in list by
using file upload control. Now I should download that file. I can able to insert documents into list item in attachment column which is predefined but am how can I download the attachments by clicking on the link in display.aspx.
I have written this for uploadFile controller.
SPSite site = SPContext.Current.Site;
SPWeb web = site.OpenWeb();
SPList list = web.Lists["list2"];
//SPListItem itemId = list.GetItemById(5);
int itemId=3;
SPListItem newItem = list.GetItemById(itemId);
byte[] contents = null;
if (FileUpload1.PostedFile != null && FileUpload1.HasFile)
using (Stream fileStream = FileUpload1.PostedFile.InputStream)
contents = new byte[fileStream.Length];
fileStream.Read(contents, 0, (int)fileStream.Length);
fileStream.Close();
SPAttachmentCollection attachments = newItem.Attachments;
string fileName = Path.GetFileName(FileUpload1.PostedFile.FileName);
attachments.Add(fileName, contents);
newItem["CLMSAttachments"] = fileName;
newItem.Update();
Thanks in advance.Hi ,
It is your browser that decides to download/open the file.
If you have compatible client software for the file (word for docx) your computer will by default automatically try to open it.
But we can force the download. You have to develop a handler/aspx page that will just handle the file download and you have to override the http header "content-disposition" to "attachment;filename=yourfilename"
Here a sample :
var fileName = "myfile.sql";
var r = context.Response;
r.AddHeader("Content-Disposition", "attachment; filename=" + fileName);
r.ContentType = "text/plain";
r.WriteFile(context.Server.MapPath(fileName));
Hope that will help you
Moudhafer -
Problems with hyperlink when converting .docx to .pdf using Word 2010
I have a Word 2010 .docx document that has a link to a web site in it. The link works fine in Word, but does not work after the conversion to PDF. I am using the Acrobat add on in Word to create the PDF.
There is a pound sign ( # ) in the Word doc hyperlink and it is being changed to a percent sign ( % ) during the conversion to PDF. Any suggestions?I will report the bug. I had read about some other problems with .docx files so I saved the .docx to .doc and then converted but I got the same results.
Thanks for the feedback. -
Using script to delete list item attachment
$.ajax({
url: "/_api/lists/getByTitle('Test')/getItemById(1)/AttachmentFiles/getByFileName('test.txt')",
method: 'DELETE',
headers: {
'X-RequestDigest': $('#__REQUESTDIGEST').val()
i want to delete list item attachment using script.
Above code working only in ie
in firefox and chrome it fails
Any sugestion cladsworking fine when i degug the script...
-
Copy List Item Attachment for archiving using SharePoint Designer 2013
hi,
how to Copy List Item Attachment for archiving using SharePoint Designer 20131. You can use access:
http://viziblr.com/news/2011/11/5/batch-exporting-sharepoint-2010-list-item-attachments-using.html
Or you can try below script
You can loop through each list item, and get each attachment.
List<SPAttachment> attachments = new List<SPAttachment>();
SPList list = SPContext.Current.Web.Lists["My List"];
foreach (SPListItem item in list.Items)
attachments.AddRange(item.Attachments.Cast<SPAttachment>());
If this helped you resolve your issue, please mark it Answered -
Attach doc from external content server- using Generic Object Service (GOS)
Dear All,
i have intergrated an external content server to SAP using SAP archive link. All the scanned document are there in Content server and corresponding entries are done in SAP.I can search and view document using tcode : OAAD
Please tell me steps for "how to attach a document from external content server using Generic Object Service "
Scenario is : For example when we change any Master records or create a new PO, or do some financial transaction then i need to attach the supporting document which is there in my content server connected to SAP.how do we manual attach a Document in SAP using GOS.
Do we need to do some special configuration to use GOS .please give the steps from initial.
Thanks
sandeepHello,
Check your configuration of document type assignement to required business document - object type, Archivelink table, content repository in OAC3 transaction.
Goto respective business document > Click on GOS > Create > Store business document - Here you can see defined document type with desctiption. Double click on this the assign your document to this business document. Save it.
This will help in attaching the document to your required business document.
To verify you can check the archivelink table or by transaction OAAD.
Hope this will help you.
-Thanks,
Ajay -
Ive just subscribed online but realised I have the wrong service by mistake... I require Convert PDF into Word doc service but selected Adobe send in error, sorry. Can you please switch the service for me? Thanks Anthony Levy
Hi Tony,
Please refer this KB document : Return, cancel, or exchange an Adobe order
Please let me know if you need any further assistance.
Regards,
Rahul -
I purchased the PDF to Word export service.I got a word download of my PDF-but can't edit it
I bought the pdf to word export service but got no instructions. I was able to down load a word doc x version of my pdf from Adobe, but have no instructions on how to edit it, or how to save the document to my computer. Help please!!!.
Hi Joe,
I have some great documents that will assist you:
'Getting started' guide
FAQ
Let me know if you have further questions!
Regards, Stacy -
How to insert sharepoint list item attachment to sql server db programatically
Hi,
I need to insert sharepoint list item attachments to sql server db programatically. Could some one suggest some approach and if any one work on it please provide the code. Thanks in advancehi,
you can do it using powershell. Use the below script to loop through all the items attachments inside list.
$web = $site.RootWeb<br />
$Lists = $Web.Lists[$ListName]
$Library = $web.Lists[$LibName]
foreach($listItem in $Lists.Items)
if($listItem.Attachments.Count -gt 0)
Write-Host "**************************************************"
Write-Host $listItem.Attachments.Count"Attachment(s) available in the ListItem:" $listItem.Title
Write-Host "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
$i=0
foreach($attachment in $listItem.Attachments)<br />
$i++
Write-Host $i".Attachment Name:" $listItem.Attachments.UrlPrefix$attachment
$file = $web.GetFile($listItem.Attachments.UrlPrefix+$attachment)
Write-Host "Adding Files to Library:"$Library.Title
$bytes = $file.OpenBinary()
Write-Host "Successfully Added"<br /> Write-Host "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
Write-Host "**************************************************"
And use the below script to insert into SQL.
#Connect to DB
$DB = “server=MyInstanceName;integrated security=sspi;database=Bob”
$conn = new-object System.Data.SqlClient.SqlConnection($DB)
#Build the command and parameters
$cmd = New-Object System.Data.SQLClient.SQLCommand
$cmd.CommandType = [System.Data.CommandType]‘StoredProcedure‘
$cmd.Parameters.Add(“@Col1″, [System.Data.SqlDbType]‘VarBinary‘)
$cmd.Parameters[“@Col1″].Size = -1
$cmd.Parameters[“@Col1″].Value = $bytes
$sql = "INSERT INTO <table> (Col1) VALUES " + $cmd.Parameters[“@Col1″]
#Execute the command
$conn.Open()
$cmd.ExecuteNonQuery()
P.S. There may be some syntax error you have to make it work but the concept is right.
Whenever you see a reply and if you think is helpful,Vote As Helpful! And whenever you see a reply being an answer to the question of the thread, click Mark As Answer -
Send Email with Contents of List Item (not from workflow)
End users have requested the capability to email a single list item, with all its data (by which they mean the data they see in their view), to an address to be entered on the fly. In other words, they want an option in the ECB or ribbon where
they would fill in a box with an email address (not necessarily a SharePoint user) and the contents of the selected list item would be sent out by the portals email, which is already configured.
My searching has found similar solutions involving workflows, but nothing in the way of an 'on-demand' type of process. If this is something that needs to be developed, I am not afraid to jump in, but am hoping there might be something I can leverage already
in place.
I would appreciate any ideas on this.
Echo Train Nashville TNHi Echo Train,
I would still look at using a Workflow for this. Easiest option to setup and maintain, and
you can still enter an email (or multiple emails) on demand.
For the List Workflow click on Initiation Parameters and add one with
Field name of Email for example.
Description (something like): "Please enter the email(s) you wish to send the list item information. Separate each email with a semi colon ;"
Information type: Single line of text
Default value: leave it blank
Next add a Send an Email action with the following settings:
To: Select from existing Users and Groups > Workflow Lookup for a User...
> Data source: Workflow Variables and Parameters
> Field from source: Parameter: Email
> Return field as: As String
Then setup your Subject and Body using the Fields from the Current List Item
Save the Workflow then go back into the Workflow settings and ensure that: Allow this workflow to be manually started is the only option selected.
Publish the workflow and your users should now be able to click on the Workflow with the ability to enter one or more emails.
There are other options apart from using a Workflow such as setting up an Action with some ECMA script, but much more difficult to create and maintain, which in this instance I would still opt for the Workflow solution. -
How to Copy list item attachment to document library in SharePoint 2010
Hi,
How to Create a folder ("List Item - Title Name") in Document library and copy list items Attachments to the same folder in SharePoint 2010,thanks in advance.
Regards,
Selvan.J
Selvan JHi,
You should first check whether the folder exists in the library, if the folder not exists, then create it.
I had modified the code, you can use the following code snippet to achieve it.
private void EventCopyFileWhenItemCreatedOrUpdated(SPItemEventProperties properties)
SPSite site = new SPSite(http://YourSiteName);
SPWeb web = site.OpenWeb();
SPList doclibList=properties.Web.Lists["YourLibName"];
bool foundFolder = false;
if (doclibList.Folders.Count>0)
foreach (SPListItem fitem in doclibList.Folders)
if (fitem.Title.Equals("FolderA"))
foundFolder = true;
break;
if (foundFolder == false)
SPListItem folder = doclibList.Folders.Add(doclibList.RootFolder.ServerRelativeUrl, SPFileSystemObjectType.Folder,"FolderA");
folder.Update();
string fUrl = doclibList.RootFolder.ServerRelativeUrl+"/FolderA";
SPFolder myLibrary = web.GetFolder(fUrl);
if (properties.ListTitle == "YourListName")
SPListItem sourceItem = properties.ListItem;
properties.Web.AllowUnsafeUpdates = true;
//get the folder with the attachments for the source item
SPFolder sourceItemAttachmentsFolder =
sourceItem.Web.Folders["Lists"].SubFolders[sourceItem.ParentList.Title].SubFolders["Attachments"].SubFolders[sourceItem.ID.ToString()];
//Loop over the attachments, and add them to the target item
foreach (SPFile file in sourceItemAttachmentsFolder.Files)
if (CheckFileNameExist(file.Name , properties) == false)
byte[] binFile = file.OpenBinary();
myLibrary.Files.Add(System.IO.Path.GetFileName(file.Url) , binFile);
private bool CheckFileNameExist(string fileNameInFileAttach, SPItemEventProperties properties)
bool flag = false;
SPList myDocumentLib = properties.Web.Lists["YourLibName"];
SPQuery spQuery = new SPQuery();
SPListItemCollection items = myDocumentLib.GetItems(spQuery);
foreach (SPListItem item in items)
if (fileNameInFileAttach == item["Name"].ToString())
flag = true;
break;
return flag;
Thanks & Regards,
Jason
Jason Guo
TechNet Community Support -
Why can I not Convert a Microsoft Office Document to a PDF using the Context Menu?
Why can I not Convert a Microsoft Office 2013 Document to a PDF using the options found in the Context Menu? (Ex: Convert to PDF, Combine Supported Files into PDF?)
I updated to Acrobat XI PRO recently, but now i'm unable to combine or convert microsoft word docs to PDF.
In Adobe Acrobat X I had this feature below, and it would combine Microsoft Office Documents all into a single PDF. Now I no longer have this issue in Adobe Acrobat XI Pro. It seems like it was program named Adobe Elements that was running the conversion.Ajlan. That page is showing as not available. Would the fix apply to Adobe Acrobat X and XI?
Zach Moses
Direct Phone and Fax (615) 577-5814 | [email protected]
W Squared, Inc.
5500 Maryland Way | Suite 200 | Brentwood, TN 37027 | www.wsquared.com<http://www.wsquared.com>
This email and any attachments may be confidential and are solely for the use of the individual to whom they were intended. If you are not the intended recipient of this email, you must take no action based upon it, nor must you copy it or show it to anyone. Please immediately reply to the sender if you suspect you were not the intended recipient. All contents of this email are provided "as-is" without warranty of any kind and are subject to change without notice. W Squared assumes no risk from the recipient's use of this email. W Squared is not a certified tax firm or law firm and recipient should not rely on any communication from W Squared or its employees as having such authority.
Maybe you are looking for
-
I have an apple id; but when I try to sign in to iCloud, I get the msg that the apple id is not an iCloud account. However, apple was able to bill me for my non-existent iCloud account. How does that happen?
-
Error 1714 Message when Installing Adobe XI Pro
I am trying to install Adobe XI Pro, but it will not install. The error message is 1714 - the older version of Adobe Acrobat XI Pro can't be removed. I tried uninstalling all other Adobe Programs but it will not uninstall, saying The patch package
-
HT4623 i just update software in my iphone 3gs but at the end its not activating my iphone
i have updated software in my iphone 3gs by plugging wire with my laptop but at the end its not activating so, i just want to know how can i activate software update 6.1.2 on my iphone 3gs
-
How can use a script to separate data into separate sheets?
For example sake, I have three columns: Food Eaten (lbs), Date, and Pet (Fido, Penny, Whiskers). I'd like to tease the data apart such that the data for the first two columns for Penny, Fido, and Whiskers all appear on different sheets. Thanks in adv
-
Hello, Where can I find the best practices after migrating Forms 6i to Forms 10g ??? thanks in advance