网站首页 > 开源技术 正文
Aspose.Words无需Microsoft Word也可在任何平台上满足Word文档的一切操作需求。本文将与大家分享如何检测文件格式和检查格式兼容性。
克隆文档
如果你需要从单个文档生成数百或数千个文档,只需将文档加载到内存中一次,克隆此文档,然后使用你的数据填充克隆文档。 这加速了文档的生成,因为不需要每次都从文件加载和解析文档。克隆是使用Document.Clone方法完成的,该方法执行Document的深层副本并返回克隆文档。下面的代码示例显示了如何深度克隆文档。
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-.NET // The path to the documents directory. string dataDir = RunExamples.GetDataDir_WorkingWithDocument(); // Load the document from disk. Document doc = new Document(dataDir + "TestFile.doc"); Document clone = doc.Clone(); dataDir = dataDir + "TestFile_clone_out.doc"; // Save the document to disk. clone.Save(dataDir);
在窗口的标题栏中显示文档的标题
如果你需要在PDF的窗口标题栏中显示文档的标题,PdfSaveOptions.DisplayDocTitle就可以实现此目的。将此属性的值设置为true,窗口的标题栏中就会显示文档的标题。如果此属性的值为false,则标题栏应显示包含该文档的PDF文件的名称。
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-.NET // The path to the documents directory. string dataDir = RunExamples.GetDataDir_QuickStart(); // Load the document from disk. Document doc = new Document(dataDir + "Template.doc"); PdfSaveOptions saveOptions = new PdfSaveOptions(); saveOptions.DisplayDocTitle = true; dataDir = dataDir + "Template_out.pdf"; // Save the document in PDF format. doc.Save(dataDir, saveOptions);
保护文件
当文档受到保护时,用户只能进行有限的更改,例如添加注释,修订或填写表单。即使文档受密码保护,Aspose.Words也不需要密码来打开,修改或取消保护此文档。使用Aspose.Words保护文档时,你可以选择保留现有密码或指定新密码。
如果你需要确保文档确实受到保护,请考虑对文档进行数字签名。Aspose.Words支持检测DOC,OOXML和ODT文档的数字签名。Aspose.Words还保留应用于文档中包含的VBA项目(宏)的数字签名。
注意:在Microsoft Word中保护的文档可以很轻易地被一个没有密码的用户变成不受保护的文档。当文档受到保护时,可以在Microsoft Word中打开,保存为RTF或WordprocessingML文档,然后使用记事本或任何纯文本编辑器删除保护密码。之后,用户可以在Microsoft Word中再次打开文档并另存为不受保护的DOC。
保护文档
使用Document.Protect方法保护文档免受更改。此方法通过传递一个Document.Protect来接受ProtectionType参数和可选的密码。下面的代码示例显示了如何保护文档。
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-.NET Document doc = new Document(inputFileName); doc.Protect(ProtectionType.AllowOnlyFormFields, "password");
取消保护文档
调用Document.Unprotect即使具有保护密码也会取消保护。下面的代码示例显示了如何取消保护文档。请注意,密码不是必需的。
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-.NET Document doc = new Document(inputFileName); doc.Unprotect();
获得保护类型
你可以通过获取Document.ProtectionType属性的值来检索文档保护的类型。下面的代码示例显示了如何获取当前在文档中设置的保护类型。
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-.NET Document doc = new Document(inputFileName); ProtectionType protectionType = doc.ProtectionType;
点击“了解更多”,立即体验iSpring Suite
↓↓↓
猜你喜欢
- 2024-10-12 使用Aspose.Word将报表导出为Word文档
- 2024-10-12 SpringBoot 将外部引入的Jar包打进Jar包中
- 2024-10-12 在 Python 中将 HTML 转换为 PNG、JPEG、BMP、GIF 或 TIFF 图像
- 2024-10-12 为什么Aspose文档控件备受开发者喜欢?
- 2024-10-12 Word处理控件Aspose.Words如何在 Java 中将 DOC 或 DOCX 转换为 JPG
- 2024-10-12 文档开发工具Aspose.Wordsv20.9四大新功能演示
- 2024-10-12 Word处理控件Aspose.Words for Java 8月新版发布!支持Java 12
- 2024-10-12 java如何生成动态Word文件(java动态生成word文档)
- 2024-10-12 Word文档管理首选工具Aspose.Words for .NET完整功能一览
- 2024-10-12 如何使用Aspose.Words以编程方式处理文档部分(1)
你 发表评论:
欢迎- 03-19基于layui+springcloud的企业级微服务框架
- 03-19开箱即用的前端开发模板,扩展Layui原生UI样式,集成第三方组件
- 03-19SpringMVC +Spring +Mybatis + Layui通用后台管理系统OneManageV2.1
- 03-19SpringBoot+LayUI后台管理系统开发脚手架
- 03-19layui下拉菜单form.render局部刷新方法亲测有效
- 03-19Layui 遇到的坑(记录贴)(layui chm)
- 03-19基于ASP.NET MVC + Layui的通用后台开发框架
- 03-19LayUi自定义模块的定义与使用(layui自定义表格)
- 最近发表
-
- 基于layui+springcloud的企业级微服务框架
- 开箱即用的前端开发模板,扩展Layui原生UI样式,集成第三方组件
- SpringMVC +Spring +Mybatis + Layui通用后台管理系统OneManageV2.1
- SpringBoot+LayUI后台管理系统开发脚手架
- layui下拉菜单form.render局部刷新方法亲测有效
- Layui 遇到的坑(记录贴)(layui chm)
- 基于ASP.NET MVC + Layui的通用后台开发框架
- LayUi自定义模块的定义与使用(layui自定义表格)
- Layui 2.9.11正式发布(layui2.6)
- Layui 2.9.13正式发布(layui2.6)
- 标签列表
-
- jdk (81)
- putty (66)
- rufus (78)
- 内网穿透 (89)
- okhttp (70)
- powertoys (74)
- windowsterminal (81)
- netcat (65)
- ghostscript (65)
- veracrypt (65)
- asp.netcore (70)
- wrk (67)
- aspose.words (80)
- itk (80)
- ajaxfileupload.js (66)
- sqlhelper (67)
- express.js (67)
- phpmailer (67)
- xjar (70)
- redisclient (78)
- wakeonlan (66)
- tinygo (85)
- startbbs (72)
- webftp (82)
- vsvim (79)
本文暂时没有评论,来添加一个吧(●'◡'●)