←选择平台

密码属性

总结
获取或设置与此关联的密码PDFFile
语法
c#
VB
c++
Java
公共字符串密码{得到;}
公共财产密码作为字符串
公共字符串getPassword ();公共无效向setPassword (以字符串);
公共财产字符串^密码{字符串^ get ();无效set (String^));

属性值

一个系统。字符串that contains the password to use when loading thisPDFFile对象(如果文件是加密的)。

讲话

创建对象时,也可以直接设置密码PDFFile对象通过调用PDFFile(字符串文件名,字符串密码)构造函数。

有些PDF文件是加密的,在使用之前需要输入密码。加密文件必须具有密码属性在使用对象的其他属性和方法之前设置为正确的值。使用IsEncrypted以确定PDF文件是否加密并需要密码。

设置文件名(和可选密码)后,调用负载方法来填充PDFFile对象的DocumentProperties而且页面属性的正确值。或者使用该类支持的任何其他文件特性函数。

PDF文件密码不能超过64个ASCII字符。如果需要,LEADTOOLS将自动截断密码字符串并将其转换为ASCII。设置密码的最大长度PDFDocument。MaximumPasswordLength常数。

例子
c#
VB
使用Leadtools;使用Leadtools.Codecs;使用Leadtools.Controls;使用Leadtools.Drawing;使用Leadtools.ImageProcessing;使用Leadtools.Pdf;使用Leadtools.Svg;使用Leadtools.WinForms;公共无效PDFFileEncryptedExample ()字符串pdfFileName1 = Path.Combine(LEAD_VARS.ImagesDir,@“Leadtools.pdf”);字符串pdfFileName2 = Path.Combine(LEAD_VARS.ImagesDir,@“Encrypted.pdf”);//创建一个加密版本的Leadtools.pdfPDFFile文件=PDFFile (pdfFileName1);文件。SecurityOptions =PDFSecurityOptions ();file.SecurityOptions.UserPassword =“领导”文件。Convert(1, -1, pdfFileName2);//现在尝试以文档的形式打开它字符串密码=如果(PDFFile.IsEncrypted (pdfFileName2))控制台。WriteLine (“{0}\ nIs加密。输入密码:", pdfFileName2);password = Console.ReadLine();//如果用户输入了正确的密码(LEAD),您现在可以打开文件试一试文件=PDFFile (pdfFileName2、密码);file.Load ();PDFDocumentProperties props = file.DocumentProperties;控制台。WriteLine (“标题:{0}”, props.Title);控制台。WriteLine (“作者:{0}”, props.Author);控制台。WriteLine (主题:{0}, props.Subject);控制台。WriteLine (“关键词:{0}”, props.Keywords);控制台。WriteLine (“创造者:{0}”, props.Creator);控制台。WriteLine (“制片人:{0}”, props.Producer);控制台。WriteLine (" Created: {0}", props.Created);控制台。WriteLine ("已修改:{0}", props.Modified);控制台。WriteLine ("----------:");(异常交货)//否则,您将得到PDF文件已损坏的错误Console.WriteLine (ex.Message);静态LEAD_VARS公共常量字符串ImagesDir =@“C: \ LEADTOOLS21 \ Resources \图片”
进口Leadtools进口Leadtools。编解码器进口Leadtools.Pdf进口Leadtools。WinForms进口Leadtools.Svg进口Leadtools。ImageProcessing公共PDFFileEncryptedExample ()昏暗的pdfFileName1作为字符串= Path.Combine (LEAD_VARS.ImagesDir“Leadtools.pdf”昏暗的pdfFileName2作为字符串= Path.Combine (LEAD_VARS.ImagesDir“Encrypted.pdf”创建一个加密版本的Leadtools.pdf昏暗的文件作为PDFFile =PDFFile (pdfFileName1)文件。SecurityOptions =PDFSecurityOptions ()file.SecurityOptions.UserPassword =“领导”文件。Convert(1, -1, pdfFileName2)“现在试着把它作为文件打开昏暗的密码作为字符串没有什么如果PDFFile.IsEncrypted (pdfFileName2)然后控制台。WriteLine (“{0}”&常数。vbLf &“是加密的。输入密码:"pdfFileName2)password = Console.ReadLine()结束如果如果用户输入了正确的密码(LEAD),现在就可以打开文件了试一试文件=PDFFile (pdfFileName2、密码)file.Load ()昏暗的道具作为PDFDocumentProperties =文件。DocumentProperties控制台。WriteLine (“标题:{0}”props.Title)控制台。WriteLine (“作者:{0}”props.Author)控制台。WriteLine (主题:{0}props.Subject)控制台。WriteLine (“关键词:{0}”props.Keywords)控制台。WriteLine (“创造者:{0}”props.Creator)控制台。WriteLine (“制片人:{0}”props.Producer)控制台。WriteLine (" Created: {0}"props.Created)控制台。WriteLine ("已修改:{0}"props.Modified)控制台。WriteLine ("----------:"前女友作为异常否则,你会得到一个PDF文件已损坏的错误Console.WriteLine (ex.Message)结束试一试结束公共NotInheritableLEAD_VARS公共常量ImagesDir作为字符串“C: \ LEADTOOLS21 \ Resources \图片”结束
需求

目标平台

另请参阅

参考

PDFFile类

PDFFile成员

Leadtools.Pdf组装
188金宝搏的网址客服|支持|联系我们|知识产权公告
©1991 - 2021领德科技有限公司版权所有。