翻譯|使用教程|編輯:李顯亮|2020-10-19 13:19:17.880|閱讀 185 次
概述:使用Adobe Acrobat創(chuàng)建的水印稱為工件。為了獲得特定頁面上的所有工件,Page類具有Artifacts屬性。本文說明如何使用PDF文件中的工件。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
Aspose.PDF for .NET是一種高PDF處理和解析API,用于在跨平臺(tái)應(yīng)用程序中執(zhí)行文檔管理和操作任務(wù)。API可以輕松用于生成、修改、轉(zhuǎn)換、渲染、保護(hù)和打印PDF文檔,而無需使用Adobe Acrobat。此外,API還提供PDF壓縮選項(xiàng),表格創(chuàng)建和操作,圖形和圖像功能,廣泛的超鏈接功能,印章和水印任務(wù),擴(kuò)展的安全控制和自定義字體處理。
在接下來的系列教程中,將為開發(fā)者帶來Aspose.PDF for .NET的一系列使用教程,例如進(jìn)行文檔間的轉(zhuǎn)換,如何標(biāo)記PDF文件,如何使用表單和圖表等等。本文將介紹說明如何使用PDF文件中的工件。
>>Aspose.PDF for .NET更新至最新版v20.10,歡迎下載體驗(yàn)。
使用Adobe Acrobat創(chuàng)建的水印稱為工件(如PDF規(guī)范的14.8.2.2真實(shí)內(nèi)容和工件中所述)。為了處理工件,Aspose.PDF具有兩個(gè)類:Artifact和ArtifactCollection。
為了獲得特定頁面上的所有工件,Page類具有Artifacts屬性。本主題說明如何使用PDF文件中的工件。
該Artifact類包含以下屬性:
以下代碼段顯示了如何在PDF文件的第一頁上獲取每個(gè)水印。
// The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_StampsWatermarks(); // Open document Document pdfDocument = new Document( dataDir + "watermark.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); }
要計(jì)算特定類型的工件的總數(shù)(例如,水印總數(shù)),請(qǐng)使用以下代碼:
// For complete examples and data files, please go to //github.com/aspose-pdf/Aspose.PDF-for-.NET // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_StampsWatermarks(); // Open document Document pdfDocument = new Document( dataDir + "watermark.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");
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@fc6vip.cn