0
votes

My task:
Build a window service (build a C# console app beforehead) to auto print using the default printer any PDF files added to a specific document library in SharePoint.

I found codes for printing PDF from the local directory but have problem in the SharePoint part.

I am new to c# and SharePoint programming and I do not know where to start from. Any help would appreciate!

Problem:

  1. Should I directly get files from SharePoint or download it to local pc (and delete it after print job) before doing the printing part?

  2. If I am to get file directly from SharePoint, I tried to apply the following codes with namespace: using Microsoft.SharePoint.Client; and Microsoft.SharePoint.Client.dll in the lib of the current pj but get error.

    using (SPSite site = new SPSite(url)) { using (SPWeb web = site.OpenWeb()) { SPFile file = web.GetFile(url); } }

Error: The type of namespace name SPSite/SPFile/SPWeb could not be found.

  1. All in all what skills/methods should I use in tackling the task?

    • Auto monitor a SharePoint doucment
    • Retrieve the PDF file
    • Print the PDF
1

1 Answers

0
votes
  1. I think it is better to get files from SP.
  2. Microsoft.SharePoint.Client.dll is used for client side object model, your code is server side (works only on SP server). For server side use Microsoft.SharePoint.dll and Microsoft.SharePoint namespace.
  3. Use event listeners for monitoring: documents added/edited. Retrieve PDF from SP and print it, as you said you ar able to do that.