*这么优秀的国产工具怎能错过呢!在线下单专享“一口价”,查看优惠价格!想要获取更多福利的朋友可以咨询在线客服哦~
示例代码如下:
import com.spire.doc.*;import com.spire.pdf.security.*;public class wordToPdfEncrypt { public static void main(String[] args) { //加载示例文档 Document document = new Document(); document.loadFromFile("Sample.docx"); //新建ToPdfParameterList实例 ToPdfParameterList toPdf = new ToPdfParameterList(); //为PDF文档设置打开密码和权限密码 toPdf.getPdfSecurity().encrypt("e-iceblue","test", PdfPermissionsFlags.Default, PdfEncryptionKeySize.Key_128_Bit); //保存文档 String result = "output/WordToPdfEncrypt.pdf"; document.saveToFile(result, toPdf); }}
打开PDF结果文档时,需要输入密码:

让人兴奋的是整合所有格式API处理套包Spire.office for Java正在 火热销售中!联系客服立马1分钟了解全部咨询!
标签:
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!