Remove or hide PDF layer using ABCPdf?

2019-05-22 14:09发布

Is is possible to remove or hide a layer from a PDF using ABCPdf or another framework?

3条回答
Anthone
2楼-- · 2019-05-22 14:34

ABCpdf contains an Example project called OCGLayers. This project shows you how to identify and redact all the items in a layer.

For example:

        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();
查看更多
做自己的国王
3楼-- · 2019-05-22 14:37

The following C# example shows how layer 2 of page 1 can be deleted:

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);
查看更多
爷、活的狠高调
4楼-- · 2019-05-22 14:46

Or perhaps you were looking for the Flatten() function?

查看更多
登录 后发表回答