翻譯|使用教程|編輯:胡濤|2022-05-06 14:01:54.920|閱讀 312 次
概述:本文將向您展示如何使用生成的 PDF 文件的加密密碼將 Word 轉(zhuǎn)換為 PDF,歡迎查閱!
# 界面/圖表報(bào)表/文檔/IDE等千款熱門(mén)軟控件火熱銷(xiāo)售中 >>
相關(guān)鏈接:
在 Spire.Doc 的幫助下,開(kāi)發(fā)人員可以使用密碼對(duì) word 進(jìn)行加密,也可以將 word 文檔轉(zhuǎn)換為 PDF。本文將向您展示如何使用生成的 PDF 文件的加密密碼將 Word 轉(zhuǎn)換為 PDF。
確保 .NET版本 5.8.92(或更高版本)的 Spire.Doc 已正確安裝,然后通過(guò)以下路徑在下載的 Bin 文件夾中添加 Spire.Doc.dll 作為參考:“..\Spire.Doc\Bin\ NET4.0\Spire.Doc.dll”。
下面是如何直接從 word 到 PDF 轉(zhuǎn)換創(chuàng)建密碼加密 PDF 的代碼片段。
第 1 步:創(chuàng)建一個(gè)新的 Word 文檔并從文件中加載該文檔。
Document document = new Document(); document.LoadFromFile("Sample.docx");
第 2 步:創(chuàng)建 ToPdfParameterList 的實(shí)例。
ToPdfParameterList toPdf = new ToPdfParameterList();
第 3 步:設(shè)置PDF文檔的打開(kāi)密碼、權(quán)限密碼和用戶(hù)權(quán)限
toPdf.PdfSecurity.Encrypt("open password","permission password", PdfPermissionsFlags.None, PdfEncryptionKeySize.Key128Bit);
第 4 步:將文檔保存到文件中。
document.SaveToFile("EncryptedPDF.pdf",toPdf);
有效截圖:
完整代碼:
using Spire.Doc; namespace EncryptPDF { class Program { static void Main(string[] args) { Document document = new Document(); document.LoadFromFile("Sample.docx"); ToPdfParameterList toPdf = new ToPdfParameterList(); toPdf.PdfSecurity.Encrypt("open password","permission password", PdfPermissionsFlags.None, PdfEncryptionKeySize.Key128Bit); document.SaveToFile("EncryptedPDF.pdf", toPdf); } } }
歡迎下載|體驗(yàn)更多E-iceblue產(chǎn)品
如需獲取更多產(chǎn)品相關(guān)信息請(qǐng)咨詢(xún)
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@fc6vip.cn