Class SoundAnnotation

  • All Implemented Interfaces:

    
    public class SoundAnnotation
    extends Annotation
                        

    Represents an audio file added to a page. Sound annotations can be created from recording audio using the device's microphone or by importing an existing audio file. Sound annotations are stored inside the PDF file itself. On a page, SoundAnnotations are represented by an icon, similar to NoteAnnotations. PSPDFKit will always render sound annotations at a fixed size, centered in the provided boundingBox.

    • Constructor Detail

      • SoundAnnotation

        SoundAnnotation(int pageIndex, RectF boundingBox, EmbeddedAudioSource audioSource)
        Creates a new sound annotation.
        Parameters:
        pageIndex - Page to which this annotation will be attached to.
        boundingBox - Annotation's bounding box on the page in PDF coordinates.
        audioSource - Source of audio data that should be attached to the annotation.
      • SoundAnnotation

        SoundAnnotation(int pageIndex, RectF boundingBox)
        Creates a new sound annotation.
        Parameters:
        pageIndex - Page to which this annotation will be attached to.
        boundingBox - Annotation's bounding box on the page in PDF coordinates.
      • SoundAnnotation

        SoundAnnotation(AnnotationPropertyMap properties, boolean markDirty, String resourceId)
        Intended for internal usage only
      • SoundAnnotation

        SoundAnnotation(AnnotationPropertyMap propertyMap, boolean markDirty, EmbeddedAudioSource soundData)
        Intended for internal usage only
    • Method Detail

      • setAudioSource

         void setAudioSource(@Nullable() EmbeddedAudioSource soundSource)

        Replaces the audio data in this annotation.

        If the getDescription is not-null, it will be set as new annotation contents (via setContents). If the description is null, the original contents will be kept.

        Parameters:
        soundSource - Source for the embedded sound data.
      • getSampleSize

         int getSampleSize()

        The number of bits per sample value per channel. 8 or 16 bits per channel are supported.

      • getSampleRate

         int getSampleRate()

        The number of audio samples for each channel per second.

      • getChannels

         int getChannels()

        The number of audio channels.

      • hasAudioData

         boolean hasAudioData()

        Checks if the annotation contains valid audio data in supported encoding.

      • getAudioData

        @Nullable() Array<byte> getAudioData()

        Returns audio data from the annotation. This could take a while and should be executed on background thread.

      • updateTransformationProperties

         void updateTransformationProperties(@NonNull() RectF newBoundingBox, @NonNull() RectF oldBoundingBox)

        Annotations may override this method to transform their properties (i.e. points, rects, sizes) whenever the bounding box of the annotation changed.

        Parameters:
        newBoundingBox - New bounding box of the annotation (in PDF points).
        oldBoundingBox - Old bounding box of the annotation (in PDF points).
      • isResizable

         boolean isResizable()

        Check if the annotation is resizable, or if this is a non-resizable annotation.

      • isLocked

         boolean isLocked()

        Check if the annotation is locked - i.e. annotation can't be deleted or modified (except contents).