嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元微信扫码支付:2 元
请留下您的邮箱,我们将在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("强行报错!");
}