简体   繁体   English

如何在C#中使用多个PDF文件创建单个PDF而不使用任何第三方库?

[英]How to create a single PDF from multiple PDF files in C# without using any 3rd party library?

I have a client requirement, in which we have multiple pdf attachments present with each of the Opportunity Record in Dynamics CRM. 我有一个客户要求,我们在Dynamics CRM中的每个商机记录中都有多个pdf附件。 Whenever end user needs documents; 每当最终用户需要文件时; he/she has to download multiple files each time. 他/她每次都要下载多个文件。 The requirement is to download all the files as a single pdf file. 要求是将所有文件作为单个pdf文件下载。 Also, the files from second file has to be appended one after the other. 此外,第二个文件中的文件必须一个接一个地附加。

A plugin is the wrong way to do this: 插件是错误的方法:

  • The code to accomplish this is not very plugin compatible. 完成此操作的代码不是非常兼容插件。 Merging documents requires some level of interaction with an operating system (ie reading and writing files). 合并文档需要与操作系统进行某种程度的交互(即读取和写入文件)。 You could probably hack your way through this with ILMerge and a non-sandboxed plugin, but the result would only work with on-premise CRM and would not be supported by Microsoft. 你可能可以通过ILMerge和非沙盒插件破解你的方式,但结果只适用于内部部署CRM,并且不受微软支持。

  • Plugins are server side and must trigger on a database action. 插件是服务器端,必须在数据库操作上触发。 It sounds like you want a user friendly process which produces this combined document which suggests a client facing application. 听起来你想要一个用户友好的过程,产生这个组合文档,建议面向客户的应用程序。 Your client side program could cause some CRUD operation which triggers this plugin, then retrieve the resulting file, but that is unnecessarily complicated. 您的客户端程序可能会导致某些CRUD操作触发此插件,然后检索生成的文件,但这不必要地复杂化。

Write a web page which generates the document and provides it to the user as a file download dialogue. 编写一个生成文档的网页,并将其作为文件下载对话框提供给用户。 Call your application from a button within CRM. 通过CRM中的按钮调用您的应用程序。

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

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