顯示或隱藏 PDF 圖層
Spire.PDF for .NET 是一款專(zhuān)門(mén)對(duì) Word 文檔進(jìn)行操作的 .NET 類(lèi)庫(kù)。致力于在于幫助開(kāi)發(fā)人員輕松快捷高效地創(chuàng)建、編輯、轉(zhuǎn)換和打印 Microsoft Word 文檔,而無(wú)需安裝 Microsoft Word。
行號(hào)用于在每行文本旁邊顯示 Word 自動(dòng)計(jì)算的行數(shù)。當(dāng)我們需要參考合同或法律文件等文檔中的特定行時(shí),它非常有用。word中的行號(hào)功能允許我們?cè)O(shè)置起始值、編號(hào)間隔、與文本的距離以及行號(hào)的編號(hào)方式。使用 Spire.Doc,我們可以實(shí)現(xiàn)上述所有功能。本文將介紹如何將 HTML 轉(zhuǎn)換為 PDF。
歡迎加入spire技術(shù)交流群:767755948
創(chuàng)建 PDF 圖層時(shí),Spire.PDF 允許開(kāi)發(fā)人員設(shè)置圖層的初始可見(jiàn)性狀態(tài)。同時(shí),它還支持更改 PDF 文檔中現(xiàn)有圖層的可見(jiàn)性。本文將解釋如何使用 Spire.PDF 顯示或隱藏現(xiàn)有圖層。
PdfLayer.Visibility 屬性用于改變 PDF 圖層的可見(jiàn)性。
要顯示隱藏的圖層,需要將PdfLayer.Visibility屬性設(shè)置為PdfVisibility.On。
要隱藏現(xiàn)有圖層,需要將 PdfLayer.Visibility 屬性設(shè)置為 PdfVisibility.Off。
下面的示例顯示了如何隱藏一個(gè)特定的 PDF 圖層:
using Spire.Pdf; using Spire.Pdf.Graphics.Layer; namespace HideLayer { class Program { static void Main(string[] args) { 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 Spire.Pdf; using Spire.Pdf.Graphics.Layer; namespace ShowLayer { class Program { static void Main(string[] args) { 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 文件樣本截圖:

隱藏所有圖層后的截圖:
