Class OCGRemover


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

      Constructors 
      Constructor Description
      OCGRemover()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private boolean isToBeRemoved​(PdfDictionary ocg, java.util.Set<java.lang.String> names)
      Checks if an OCG dictionary is on the list for removal.
      private void parse​(OCGParser parser, PdfDictionary page)
      Uses the OCGParser on a page
      private void removeAnnots​(PdfDictionary page, java.util.Set<java.lang.String> ocgs)
      Removes annotations from a page dictionary
      void removeLayers​(PdfReader reader, java.lang.String... layers)
      Removes layers from a PDF document
      private void removeOCGsFromArray​(PdfArray array, java.util.Set<java.lang.String> ocgs)
      Searches an array for references to OCGs that need to be removed.
      private void removeOCGsFromArray​(PdfDictionary dict, PdfName name, java.util.Set<java.lang.String> ocgs)
      Gets an array from a dictionary and checks if it contains references to OCGs that need to be removed
      private void removeProperties​(PdfDictionary page, java.util.Set<java.lang.String> ocgs)
      Removes ocgs from a page resources
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • OCGRemover

        public OCGRemover()
    • Method Detail

      • removeLayers

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

        private void removeOCGsFromArray​(PdfDictionary dict,
                                         PdfName name,
                                         java.util.Set<java.lang.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,
                                         java.util.Set<java.lang.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,
                                  java.util.Set<java.lang.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,
                                      java.util.Set<java.lang.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,
                                      java.util.Set<java.lang.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 java.io.IOException
        Uses the OCGParser on a page
        Parameters:
        parser - the OCGParser
        page - the page dictionary of the page that needs to be parsed.
        Throws:
        java.io.IOException