Rimuovere o nascondere strato PDF utilizzando ABCpdf?
-
19-09-2019 - |
Domanda
È è possibile rimuovere o nascondere un livello da un file PDF utilizzando ABCpdf o in un altro quadro?
Nessuna soluzione corretta
Altri suggerimenti
Il seguente C # esempio mostra come strato 2 da pagina 1 può essere cancellata:
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);
O forse si stava cercando il Flatten () funzione?
ABCpdf contiene un progetto di esempio chiamato OCGLayers. Questo progetto mostra come identificare e redigere tutti gli elementi in un livello.
Ad esempio:
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();
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow