原創(chuàng)|其它|編輯:郝浩|2012-11-05 13:11:14.000|閱讀 3164 次
概述:本文解釋了如何使用Aspose.Pdf處理PDF文件中的Artifacts。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門(mén)軟控件火熱銷(xiāo)售中 >>
由Adobe Acrobat創(chuàng)建的水印稱(chēng)為artifact。Aspose.Pdf擁有兩個(gè)類(lèi)專(zhuān)門(mén)處理artifact:Artifact和ArtifactCollection。
為了得到特定頁(yè)面上的所有artifacts,該頁(yè)面類(lèi)上要有Artifacts屬性。
本文解釋了如何使用Aspose.Pdf處理PDF文件中的Artifacts。
處理Artifacts
Artifact類(lèi)包含以下屬性:
下面的代碼片段顯示了如何獲得在第一頁(yè)的PDF文件上的每個(gè)水印。
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
編程實(shí)例:計(jì)算某一特定類(lèi)型的Artifacts
計(jì)算某一特定類(lèi)型的artifacts總數(shù)(例如,水印的總數(shù)),使用下面的代碼:
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")
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@fc6vip.cn
文章轉(zhuǎn)載自:慧都控件網(wǎng)