Class PDFSound

  • All Implemented Interfaces:
    Cloneable

    public final class PDFSound
    extends Object
    A PDFSound represents an audio sample in a PDF document. Since 2.11.9 any audio stream that can be parsed by the Java sound subsystem can be used, however for ease of parsing we recommend PCM WAV.
    Since:
    1.1
    • Constructor Detail

      • PDFSound

        public PDFSound​(InputStream in)
                 throws IOException

        Create a new PDFSound from the specified InputStream. The stream can be any type of Audio file that is supported by the AudioSystem, or if that system is not enabled for any reason, PCM WAV formats can be parsed directly.

        Throws:
        IOException - if the file format is invalid
    • Method Detail

      • getRate

        public int getRate()
        Return the number of samples/second this sound is played at. Common values are 8000, 11025 or 22050
        Since:
        1.1.12
      • setMetaData

        public void setMetaData​(String xmldata)
        Set the XML metadata associated with this object. Since 2.26 this method calls getXMP().read(new StringReader(xmldata == null ? "" : xmldata)). We strongly recommend using the getXMP() method and modifying the XMP directly rather than using this method.
        Parameters:
        xmldata - the XML data to embed into the document, or null to clear any existing metadata. No validation is performed on this input.
        Since:
        1.1.12
        See Also:
        getXMP()
      • getMetaData

        public Reader getMetaData()
                           throws IOException

        Return any XML metadata associated with this object.

        Since 2.26 this simply returns getXMP().isEmpty() ? null : new StringReader(getXMP().toString()). It is strongly recommended that any code migrates to using the getXMP() method.

        Since 2.24.3, the returned type is guaranteed to hava a toString() method that will return the Metadata as a String.

        Returns:
        a Reader containing the source of the XML or null if no metadata is available.
        Throws:
        IOException - if the metadata can't be extracted
        Since:
        1.1.12
        See Also:
        getXMP()
      • getXMP

        public XMP getXMP()
        Return an XMP Metadata object representing any XML metadata associated with this object
        Returns:
        the XMP, which may be empty or invalid but wil never be null
        Since:
        2.26
      • toString

        public String toString()
      • close

        public void close()
        Close the sound object. This will prevent any further changes from being made to the object, but will potentially free up some resources as well.
        Since:
        2.2
      • isDamaged

        public boolean isDamaged()