基本信息
源码名称:C#将OFFICE文件转换为PDF文件的源码
源码大小:18.67M
文件格式:.zip
开发语言:C#
更新时间:2021-04-08
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300

本次赞助数额为: 2 元 
   源码介绍

C#将WORD、EXCEL或者PPT文件转换为PDF文件的源码,亲测好用。


 public void WordToPDF(String from,String to)
        {
            try
            {
                Document doc = new Document(from);
                //保存为PDF文件,此处的SaveFormat支持很多种格式,如图片,epub,rtf 等等

                //权限这块的设置成不可复制
                PdfSaveOptions saveOptions = new PdfSaveOptions();
                // Create encryption details and set owner password.
                PdfEncryptionDetails encryptionDetails = new PdfEncryptionDetails(string.Empty, "password", PdfEncryptionAlgorithm.RC4_128);
                // Start by disallowing all permissions.
                encryptionDetails.Permissions = PdfPermissions.DisallowAll;
                // Extend permissions to allow editing or modifying annotations.
                encryptionDetails.Permissions = PdfPermissions.ModifyAnnotations | PdfPermissions.DocumentAssembly;
                saveOptions.EncryptionDetails = encryptionDetails;
                // Render the document to PDF format with the specified permissions.
                doc.Save(to , saveOptions);
            
                //doc.Save(to, SaveFormat.Pdf);
                Console.WriteLine("成功!");
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                Console.WriteLine("强行报错!");
            }