使用Aspose.Pdf处理现有的水印
来源:互联网 发布:云朵播放器网络原因 编辑:程序博客网 时间:2024/05/21 17:03
由Adobe Acrobat创建的水印称为artifact。Aspose.Pdf拥有两个类专门处理artifact:Artifact和ArtifactCollection。
为了得到特定页面上的所有artifacts,该页面类上要有Artifacts属性。
本文解释了如何使用Aspose.Pdf处理PDF文件中的Artifacts。
处理Artifacts
Artifact类包含以下属性:
- Artifact.Type——获得artifact类型(支持包括背景、布局、页面、分页和未定义在内的Artifact.ArtifactType枚举值)。
- Artifact.Subtype——得到工件artifact子类型(支持包括背景、页脚、页眉、未定义,水印在内的Artifact.ArtifactSubtype枚举值)。
- Artifact.Contents——得到一组artifact内部运算符。它所支持的类型是System.Collections.ICollection。
- Artifact.Form——得到一个artifact的变换(如果使用XForm)。水印、页眉和页脚artifacts包含了所有的artifacts内容变换。
- Artifact.Image——得到一个artifact的图像(如果只呈现一个图像,其他的为空值)。
- Artifact.Text——得到一个artifact的文本。
- Artifact.Rectangle--得到页面上artifact的位置。
- Artifact.Rotation--得到一个artifact的旋转(degrees, positive的值表示逆时针旋转)。
- Artifact.Opacity——得到一个artifact的不透明度。可能的值范围在0……1,1是代表完全透明的。
下面的代码片段显示了如何获得在第一页的PDF文件上的每个水印。
C#
//Open documentDocument pdfDocument = new Document("input.pdf");// Iterate through and get tub-type, text and location of artifactforeach(Artifact artifact in pdfDocument.Pages[1].Artifacts){ Console.WriteLine(artifact.Subtype + " " + artifact.Text + " " + artifact.Rectangle); }
VB.NET
'Open documentDim pdfDocument As Document = New Document("input.pdf")' Iterate through and get tub-type, text and location of artifactFor Each artifact As Artifact In pdfDocument.Pages(1).Artifacts Console.WriteLine(artifact.Subtype.ToString() & " " & artifact.Text & " " & artifact.Rectangle.ToString())Next
编程实例:计算某一特定类型的Artifacts
计算某一特定类型的artifacts总数(例如,水印的总数),使用下面的代码:
C#
//Open documentDocument pdfDocument = new Document("input.pdf");int count = 0;foreach(Artifact artifact in pdfDocument.Pages[1].Artifacts){ // if artifact type is watermark, increate the counter if (artifact.Subtype == Artifact.ArtifactSubtype.Watermark) count++;}Console.WriteLine("Page contains " + count + " watermarks");
VB.NET
' Open documentDim pdfDocument As Document = New Document("d:/pdftest/DifferentStamps.pdf")Dim count As Integer = 0For Each artifact As Artifact In pdfDocument.Pages(1).Artifacts ' if artifact type is watermark, increate the counter If (artifact.Subtype = artifact.ArtifactSubtype.Watermark) Then count += 1 End IfNextConsole.WriteLine("Page contains " & count & " watermarks")
- 使用Aspose.Pdf处理现有的水印
- 使用Aspose.Pdf在现有的PDF文件中添加注释
- 使用Aspose.Pdf处理XML文档生成PDF文件
- 给现有的word和pdf加水印
- 使用Aspose.PDF更改PDF文件的内容
- Aspose.Pdf使用教程分享
- 使用Aspose.Pdf设置PDF文件信息
- 使用Aspose.Pdf从PDF文件中获取个别的附件
- 使用Aspose.Pdf for .NET实现PDF文档到Excel、EPS、SVG等的转换
- 使用Aspose.Pdf为FreeTextAnnotation设置格式
- 使用Aspose.Pdf获取附件信息
- 使用PitStop去掉pdf的xobject类型的"水印"
- PDF转JPG图片使用ICEPDF,解决水印的问题
- 使用Aspose.Cells为工作表添加艺术字水印
- 使用Aspose.Pdf在PDF文件中调整文本
- 使用Aspose.Pdf从PDF文件中获取注释
- 使用Aspose.Pdf从PDF文件中获取注释
- 使用Aspose.Pdf在PDF文件中添加图片
- 有了这27种小技巧,人人可以成为大师
- HTTP代理原理以及HTTP隧道技术(经典)
- Windows平台下使用Android NDK进行开发
- jQuery获取及设置单选框、多选框、文本框
- Oracle序列使用:建立、删除
- 使用Aspose.Pdf处理现有的水印
- 小机器人5岁了!细数Android甜点史
- 多线程下载和断电续传
- 软件测试的科学
- C#日期处理
- Python Yield versus Return
- Makefile 之 wildcard用法:
- Xcode - Could not launch app - No such file or directory Error
- 查询有重复出现的列并且