原創|其它|編輯:郝浩|2012-11-05 13:11:14.000|閱讀 3164 次
概述:本文解釋了如何使用Aspose.Pdf處理PDF文件中的Artifacts。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
由Adobe Acrobat創建的水印稱為artifact。Aspose.Pdf擁有兩個類專門處理artifact:Artifact和ArtifactCollection。
為了得到特定頁面上的所有artifacts,該頁面類上要有Artifacts屬性。
本文解釋了如何使用Aspose.Pdf處理PDF文件中的Artifacts。
處理Artifacts
Artifact類包含以下屬性:
下面的代碼片段顯示了如何獲得在第一頁的PDF文件上的每個水印。
C#
//Open document Document pdfDocument = new Document("input.pdf"); // Iterate through and get tub-type, text and location of artifact foreach(Artifact artifact in pdfDocument.Pages[1].Artifacts) { Console.WriteLine(artifact.Subtype + " " + artifact.Text + " " + artifact.Rectangle); }
VB.NET
'Open document Dim pdfDocument As Document = New Document("input.pdf") ' Iterate through and get tub-type, text and location of artifact For Each artifact As Artifact In pdfDocument.Pages(1).Artifacts Console.WriteLine(artifact.Subtype.ToString() & " " & artifact.Text & " " & artifact.Rectangle.ToString()) Next
編程實例:計算某一特定類型的Artifacts
計算某一特定類型的artifacts總數(例如,水印的總數),使用下面的代碼:
C#
//Open document Document 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 document Dim pdfDocument As Document = New Document("d:/pdftest/DifferentStamps.pdf") Dim count As Integer = 0 For 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 If Next Console.WriteLine("Page contains " & count & " watermarks")
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉載自:慧都控件網