简体   繁体   English

c#从SharePoint 2013中的文档库自动打印PDF

[英]c# Auto print PDF from document library in SharePoint 2013

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. 构建一个窗口服务(先构建一个C#控制台应用程序)以使用默认打印机自动打印添加到SharePoint中特定文档库的任何PDF文件。

I found codes for printing PDF from the local directory but have problem in the SharePoint part. 我找到了用于从本地目录打印PDF的代码,但是在SharePoint部分出现了问题。

I am new to c# and SharePoint programming and I do not know where to start from. 我是C#和SharePoint编程的新手,我不知道从哪里开始。 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? 在打印部分之前,我应该直接从SharePoint获取文件还是将其下载到本地PC(并在打印作业后将其删除)?

  2. If I am to get file directly from SharePoint, I tried to apply the following codes with namespace: using Microsoft.SharePoint.Client; 如果要直接从SharePoint获取文件,则尝试将以下代码与命名空间一起应用: using Microsoft.SharePoint.Client; and Microsoft.SharePoint.Client.dll in the lib of the current pj but get error. 和当前pj的lib中的Microsoft.SharePoint.Client.dll ,但出现错误。

    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 . 错误:找不到名称空间名称SPSite / SPFile / SPWeb的类型

  1. All in all what skills/methods should I use in tackling the task? 总之,我应该使用什么技能/方法来完成任务?

    • Auto monitor a SharePoint doucment 自动监视SharePoint文档
    • Retrieve the PDF file 检索PDF文件
    • Print the PDF 打印PDF
  1. I think it is better to get files from SP. 我认为最好从SP获取文件。
  2. Microsoft.SharePoint.Client.dll is used for client side object model, your code is server side (works only on SP server). Microsoft.SharePoint.Client.dll用于客户端对象模型,您的代码在服务器端(仅在SP服务器上有效)。 For server side use Microsoft.SharePoint.dll and Microsoft.SharePoint namespace. 对于服务器端,请使用Microsoft.SharePoint.dllMicrosoft.SharePoint命名空间。
  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. 如您所说,您可以从SP检索PDF并进行打印。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM