Class OCGRemover

java.lang.Object
com.itextpdf.text.pdf.ocg.OCGRemover

public class OCGRemover extends Object
Class that knows how to remove OCG layers.
  • Constructor Details

    • OCGRemover

      public OCGRemover()
  • Method Details

    • removeLayers

      public void removeLayers(PdfReader reader, String... layers) throws IOException
      Removes layers from a PDF document
      Parameters:
      reader - a PdfReader containing a PDF document
      layers - a sequence of names of OCG layers
      Throws:
      IOException
    • removeOCGsFromArray

      private void removeOCGsFromArray(PdfDictionary dict, PdfName name, Set<String> ocgs)
      Gets an array from a dictionary and checks if it contains references to OCGs that need to be removed
      Parameters:
      dict - the dictionary
      name - the name of an array entry
      ocgs - the removal list
    • removeOCGsFromArray

      private void removeOCGsFromArray(PdfArray array, Set<String> ocgs)
      Searches an array for references to OCGs that need to be removed.
      Parameters:
      array - the array
      ocgs - the removal list
    • removeAnnots

      private void removeAnnots(PdfDictionary page, Set<String> ocgs)
      Removes annotations from a page dictionary
      Parameters:
      page - a page dictionary
      ocgs - a set of names of OCG layers
    • removeProperties

      private void removeProperties(PdfDictionary page, Set<String> ocgs)
      Removes ocgs from a page resources
      Parameters:
      page - a page dictionary
      ocgs - a set of names of OCG layers
    • isToBeRemoved

      private boolean isToBeRemoved(PdfDictionary ocg, Set<String> names)
      Checks if an OCG dictionary is on the list for removal.
      Parameters:
      ocg - a dictionary
      names - the removal list
      Returns:
      true if the dictionary should be removed
    • parse

      private void parse(OCGParser parser, PdfDictionary page) throws IOException
      Uses the OCGParser on a page
      Parameters:
      parser - the OCGParser
      page - the page dictionary of the page that needs to be parsed.
      Throws:
      IOException