Class PdfOCProperties

    • Field Detail

      • OC_CONFIG_NAME_PATTERN

        static final java.lang.String OC_CONFIG_NAME_PATTERN
        See Also:
        Constant Field Values
      • layers

        private java.util.List<PdfLayer> layers
      • isDuplicateRemoved

        private boolean isDuplicateRemoved
    • Constructor Detail

      • PdfOCProperties

        public PdfOCProperties​(PdfDocument document)
        Creates a new PdfOCProperties instance.
        Parameters:
        document - the document the optional content belongs to
      • PdfOCProperties

        public PdfOCProperties​(PdfDictionary ocPropertiesDict)
        Creates a new PdfOCProperties instance by the dictionary it represents, the dictionary must be an indirect object.
        Parameters:
        ocPropertiesDict - the dictionary of optional content properties, must have an indirect reference.
    • Method Detail

      • addOCGRadioGroup

        public void addOCGRadioGroup​(java.util.List<PdfLayer> group)
        Use this method to set a collection of optional content groups whose states are intended to follow a "radio button" paradigm. That is, the state of at most one optional content group in the array should be ON at a time: if one group is turned ON, all others must be turned OFF.
        Parameters:
        group - the radio group
      • fillDictionary

        public PdfObject fillDictionary()
        Fills the underlying PdfDictionary object with the current layers and their settings. Note that it completely regenerates the dictionary, so your direct changes to the dictionary will not take any affect.
        Returns:
        the resultant dictionary
      • fillDictionary

        public PdfObject fillDictionary​(boolean removeNonDocumentOcgs)
        Fills the underlying PdfDictionary object with the current layers and their settings. Note that it completely regenerates the dictionary, so your direct changes to the dictionary will not take any affect.
        Parameters:
        removeNonDocumentOcgs - the flag indicating whether it is necessary to delete OCGs not from the current document
        Returns:
        the resultant dictionary
      • checkDDictonaryFieldValue

        public static boolean checkDDictonaryFieldValue​(PdfName field,
                                                        PdfObject value)
        Checks if optional content group default configuration dictionary field value matches the required value for this field, if one exists.
        Parameters:
        field - default configuration dictionary field.
        value - value of that field.
        Returns:
        boolean indicating if field meets requirement.
      • getLayers

        public java.util.List<PdfLayer> getLayers()
        Gets the list of all the layers currently registered in the OCProperties. Note that this is just a new list and modifications to it will not affect anything.
        Returns:
        list of all the layers currently registered in the OCProperties
      • isWrappedObjectMustBeIndirect

        protected boolean isWrappedObjectMustBeIndirect()
        Description copied from class: PdfObjectWrapper
        Defines if the object behind this wrapper must be an indirect object in the resultant document.

        If this method returns true it doesn't necessarily mean that object must be in the indirect state at any moment, but rather defines that when the object will be written to the document it will be transformed into indirect object if it's not indirect yet.

        Return value of this method shouldn't depend on any logic, it should return always true or false.
        Specified by:
        isWrappedObjectMustBeIndirect in class PdfObjectWrapper<PdfDictionary>
        Returns:
        true if in the resultant document the object behind the wrapper must be indirect, otherwise false.
      • registerLayer

        protected void registerLayer​(PdfLayer layer)
        This method registers a new layer in the OCProperties.
        Parameters:
        layer - the new layer
        Throws:
        java.lang.IllegalArgumentException - if layer param is null
      • getOCGOrder

        private static void getOCGOrder​(PdfArray order,
                                        PdfLayer layer)
        Gets the order of the layers in which they will be displayed in the layer view panel, including nesting.
      • removeNotRegisteredOcgs

        private void removeNotRegisteredOcgs()
      • addASEvent

        private void addASEvent​(PdfName event,
                                PdfName category)
        Populates the /AS entry in the /D dictionary.
      • readLayersFromDictionary

        private void readLayersFromDictionary()
        Reads the layers from the document to be able to modify them in the future.
      • readOrderFromDictionary

        private void readOrderFromDictionary​(PdfLayer parent,
                                             PdfArray orderArray,
                                             java.util.Map<PdfIndirectReference,​PdfLayer> layerMap)
        Reads the /Order in the /D entry and initialized the parent-child hierarchy.
      • createUniqueName

        private java.lang.String createUniqueName()