原創|使用教程|編輯:王香|2017-11-01 15:49:17.000|閱讀 1012 次
概述:Spire.PDF 是一個專業的PDF組件,能夠獨立地創建、編寫、編輯、操作和閱讀PDF文件,支持 .NET、WPF和Silverlight三個版本,本文介紹了如何在C#中顯示或隱藏PDF圖層。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
創建PDF圖層時,Spire.PDF允許開發人員為圖層設置初始的可見性狀態。 同時它還支持更改PDF文檔中現有圖層的可見性。 本文介紹如何使用Spire.PDF顯示或隱藏現有圖層。
PdfLayer.Visibility屬性用于更改PDF圖層的可見性,要顯示隱藏層,請將PdfLayer.Visibility屬性設置為PdfVisibility.On。 要隱藏現有圖層,請將PdfLayer.Visibility設置為PdfVisibility.Off.
以下示例顯示如何隱藏特定的PDF圖層:
using (PdfDocument doc = new PdfDocument("AddLayers.pdf")) { //Hide the layer by index doc.Layers[1].Visibility = PdfVisibility.Off; //Hide the layer by Name //doc.Layers["BlueLine"].Visibility = PdfVisibility.Off; //Save the file doc.SaveToFile("HideLayer.pdf"); }
顯示或隱藏所有圖層:
using (PdfDocument doc = new PdfDocument("AddLayers.pdf")) { for (int i = 0; i < doc.Layers.Count; i++) { //Show all of the layers //doc.Layers[i].Visibility = PdfVisibility.On; //Hide all of the layers doc.Layers[i].Visibility = PdfVisibility.Off; } //Save the file doc.SaveToFile("HideAllLayers.pdf"); }
示例PDF文檔的屏幕快照:
隱藏所有圖層后的屏幕截圖:
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn