繁体   English   中英

如何在ms dynamics crm 2011中输入压缩PDF文件作为附件?

[英]How to enter Compress PDF file as attachments in ms dynamics crm 2011?

我正在为一个客户端工作,该客户端要求在MS Dynamics CRM中上载6MB的文件。 客户端具有要在Dynamics CRM中上载的.pdf,.csv文件。 现在,如果我们可以在上传到Dynamics CRM之前压缩这些文件,则可以正常工作。 我正在尝试通过使用以下代码来修复需求。 这正在工作并正在压缩文件,但是当我们此时下载附件时,我们可以看到弹出的消息

我们无法打开此文件xxx.pdf文件,因为我们发现其内容有问题。

  if (entity.Attributes.Contains("documentbody")) { string bytes = entity.Attributes["documentbody"].ToString(); tracingService.Trace("CompressImagePlugin: {0}", "crossed try block first line " + bytes.Length); byte[] Uncompressedtext = Convert.FromBase64String(bytes); if (entity.Attributes.Contains("filename") && entity.Attributes["filename"] != null && (entity.Attributes["filename"].ToString() .Contains(".pdf") || entity.Attributes["filename"].ToString() .Contains(".docx"))) { tracingService.Trace(entity.Attributes["filename"].ToString()); byte[] compress = CompressZip(Uncompressedtext); string compressedData = Convert.ToBase64String(compress); entity.Attributes["documentbody"] = compressedData; } } 

谢谢

由于您是将文件类型从PDF更改为ZIP,因此您还需要更新附件的文件名和mimetype。 像这样:

entity.Attributes["filename"] = entity.Attributes["filename"].ToString().Replace(".pdf", ".zip");
entity.Attributes["mimetype"] = "application/zip";

现在,当用户单击附件时,将提示他们下载包含PDF文件的ZIP文件。

暂无
暂无

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

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