Class PDFFilterList


  • public class PDFFilterList
    extends java.lang.Object
    This class represents a list of PDF filters to be applied when serializing the output of a PDF object.
    • Constructor Summary

      Constructors 
      Constructor Description
      PDFFilterList()
      Default constructor.
      PDFFilterList​(boolean ignoreASCIIFilters)
      Use this descriptor if you want to have ASCII filters (such as ASCIIHex and ASCII85) ignored, for example, when encryption is active.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addDefaultFilters​(java.util.Map filters, java.lang.String type)
      Adds the default filters to this stream.
      void addFilter​(java.lang.String filterType)
      Add a filter for compression of the stream by name.
      void addFilter​(PDFFilter filter)
      Add a filter for compression of the stream.
      java.io.OutputStream applyFilters​(java.io.OutputStream stream)
      Applies all registered filters as necessary.
      private java.lang.String buildDecodeParms​(java.util.List parms)  
      protected java.lang.String buildFilterDictEntries()
      Apply the filters to the data in the order given and return the /Filter and /DecodeParms entries for the stream dictionary.
      private java.lang.String buildFilterEntries​(java.util.List names)  
      void ensureFilterInPlace​(PDFFilter pdfFilter)
      Checks the filter list for the filter and adds it in the correct place if necessary.
      (package private) java.util.List<PDFFilter> getFilters()  
      boolean isDisableAllFilters()
      Returns true if all filters are disabled.
      boolean isInitialized()
      Indicates whether the filter list is already initialized.
      private int populateNamesAndParms​(java.util.List names, java.util.List parms)  
      private void putDecodeParams​(PDFDictionary dict, java.util.List parms)  
      protected void putFilterDictEntries​(PDFDictionary dict)
      Apply the filters to the data in the order given and add the /Filter and /DecodeParms entries to the stream dictionary.
      private void putFilterEntries​(PDFDictionary dict, java.util.List names)  
      void setDisableAllFilters​(boolean value)
      Used to disable all filters.
      • Methods inherited from class java.lang.Object

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

      • DEFAULT_FILTER

        public static final java.lang.String DEFAULT_FILTER
        Key for the default filter
        See Also:
        Constant Field Values
      • CONTENT_FILTER

        public static final java.lang.String CONTENT_FILTER
        Key for the filter used for normal content
        See Also:
        Constant Field Values
      • PRECOMPRESSED_FILTER

        public static final java.lang.String PRECOMPRESSED_FILTER
        Key for the filter used for precompressed content
        See Also:
        Constant Field Values
      • IMAGE_FILTER

        public static final java.lang.String IMAGE_FILTER
        Key for the filter used for images
        See Also:
        Constant Field Values
      • JPEG_FILTER

        public static final java.lang.String JPEG_FILTER
        Key for the filter used for JPEG images
        See Also:
        Constant Field Values
      • TIFF_FILTER

        public static final java.lang.String TIFF_FILTER
        Key for the filter used for TIFF images
        See Also:
        Constant Field Values
      • FONT_FILTER

        public static final java.lang.String FONT_FILTER
        Key for the filter used for fonts
        See Also:
        Constant Field Values
      • METADATA_FILTER

        public static final java.lang.String METADATA_FILTER
        Key for the filter used for metadata
        See Also:
        Constant Field Values
      • filters

        private java.util.List<PDFFilter> filters
      • ignoreASCIIFilters

        private boolean ignoreASCIIFilters
      • disableAllFilters

        private boolean disableAllFilters
    • Constructor Detail

      • PDFFilterList

        public PDFFilterList()
        Default constructor.

        The flag for ignoring ASCII filters defaults to false.

      • PDFFilterList

        public PDFFilterList​(boolean ignoreASCIIFilters)
        Use this descriptor if you want to have ASCII filters (such as ASCIIHex and ASCII85) ignored, for example, when encryption is active.
        Parameters:
        ignoreASCIIFilters - true if ASCII filters should be ignored
    • Method Detail

      • setDisableAllFilters

        public void setDisableAllFilters​(boolean value)
        Used to disable all filters.
        Parameters:
        value - true if all filters shall be disabled
      • isDisableAllFilters

        public boolean isDisableAllFilters()
        Returns true if all filters are disabled.
        Returns:
        true if all filters are disabled
      • isInitialized

        public boolean isInitialized()
        Indicates whether the filter list is already initialized.
        Returns:
        true if more there are filters present
      • addFilter

        public void addFilter​(PDFFilter filter)
        Add a filter for compression of the stream. Filters are applied in the order they are added. This should always be a new instance of the particular filter of choice. The applied flag in the filter is marked true after it has been applied to the data.
        Parameters:
        filter - filter to add
      • addFilter

        public void addFilter​(java.lang.String filterType)
        Add a filter for compression of the stream by name.
        Parameters:
        filterType - name of the filter to add
      • ensureFilterInPlace

        public void ensureFilterInPlace​(PDFFilter pdfFilter)
        Checks the filter list for the filter and adds it in the correct place if necessary.
        Parameters:
        pdfFilter - the filter to check / add
      • addDefaultFilters

        public void addDefaultFilters​(java.util.Map filters,
                                      java.lang.String type)
        Adds the default filters to this stream.
        Parameters:
        filters - Map of filters
        type - which filter list to modify
      • getFilters

        java.util.List<PDFFilter> getFilters()
      • buildFilterDictEntries

        protected java.lang.String buildFilterDictEntries()
        Apply the filters to the data in the order given and return the /Filter and /DecodeParms entries for the stream dictionary. If the filters have already been applied to the data (either externally, or internally) then the dictionary entries are built and returned.
        Returns:
        a String representing the filter list
      • putFilterDictEntries

        protected void putFilterDictEntries​(PDFDictionary dict)
        Apply the filters to the data in the order given and add the /Filter and /DecodeParms entries to the stream dictionary. If the filters have already been applied to the data (either externally, or internally) then the dictionary entries added.
        Parameters:
        dict - the PDFDictionary to set the entries on
      • populateNamesAndParms

        private int populateNamesAndParms​(java.util.List names,
                                          java.util.List parms)
      • buildFilterEntries

        private java.lang.String buildFilterEntries​(java.util.List names)
      • putFilterEntries

        private void putFilterEntries​(PDFDictionary dict,
                                      java.util.List names)
      • buildDecodeParms

        private java.lang.String buildDecodeParms​(java.util.List parms)
      • putDecodeParams

        private void putDecodeParams​(PDFDictionary dict,
                                     java.util.List parms)
      • applyFilters

        public java.io.OutputStream applyFilters​(java.io.OutputStream stream)
                                          throws java.io.IOException
        Applies all registered filters as necessary. The method returns an OutputStream which will receive the filtered contents.
        Parameters:
        stream - raw data output stream
        Returns:
        OutputStream filtered output stream
        Throws:
        java.io.IOException - In case of an I/O problem