使用ABCPdf删除或隐藏PDF层?

使用ABCPdf删除或隐藏PDF层?,pdf,pdf-generation,abcpdf,ocg,Pdf,Pdf Generation,Abcpdf,Ocg,是否可以使用ABCPdf或其他框架从PDF中删除或隐藏层?以下C#示例显示了如何删除第1页的第2层: Doc theDoc = new Doc(); theDoc.Read("source.pdf"); int thePages = theDoc.GetInfoInt(theDoc.Root, "Pages"); int thePage = theDoc.GetInfoInt(thePages, "Page 1"); int theLayer = theDoc.GetInfoInt(thePag

是否可以使用ABCPdf或其他框架从PDF中删除或隐藏层?

以下C#示例显示了如何删除第1页的第2层:

Doc theDoc = new Doc();
theDoc.Read("source.pdf");
int thePages = theDoc.GetInfoInt(theDoc.Root, "Pages");
int thePage = theDoc.GetInfoInt(thePages, "Page 1");
int theLayer = theDoc.GetInfoInt(thePage, "Content 2");
theDoc.Delete(theLayer);

或者您正在寻找函数?

ABCpdf包含一个名为OCGLayers的示例项目。该项目向您展示了如何识别和编辑图层中的所有项目

例如:

        Properties props = Properties.FromDoc(_doc, false);
        Page page = (Page)_doc.ObjectSoup[_doc.Page];
        Reader reader = Reader.FromPage(props, page);
        List<OptionalContent.Layer> layers = reader.GetLayers();
        foreach (OptionalContent.Layer layer in layers) {
            if (layer.Visible == false) {
                if (reader == null)
                    reader = Reader.FromPage(props, page);
                Reader.Redact(ref reader, layer);
            }
        }
        UpdateLayers();
        UpdatePreview();
Properties-props=Properties.FromDoc(\u-doc,false);
Page Page=(Page)_doc.ObjectSoup[_doc.Page];
Reader=Reader.FromPage(道具,页面);
List layers=reader.GetLayers();
foreach(可选内容。层中的层){
如果(layer.Visible==false){
如果(读卡器==null)
reader=reader.FromPage(道具,页面);
编校(参考读取器,图层);
}
}
UpdateLayers();
UpdatePreview();