how export sound annotation

Hi,

  1. we need to get data from sound annotation and make new annotation in other document with same audio data, how we get the stream audio?.
    see sample document for sound extaction, this document is created from other app.
if (annotation.AnnotationType == e_Sound)
               {
                   Sound Oldsound = (Sound)annot;
                   
                   Sound sound = Sound.Create(document.GetSDFDoc(),rect);
                   
                   Sound.SetSoundStream(Oldsound.GetSoundStream());// the obj cant be pass to other document
                  
                   sound.RefreshAppearance();
 
                   targetPage.AnnotPushBack(sound);
                 }
  1. how enable sound rec, playback in the sample proyect for UWP ? we need a create new tool?

Thanks in advance,
Miguel.

FT 102 - Pest Side Story sound.pdf (1.92 MB)

The following is how to extract the sound information from a PDF Sound annotation.

if (annot.GetType() != Annot.Type.e_Sound) return;
Sound sound = new Sound(annot);
Obj soundObj = sound.GetSoundStream();
if (!soundObj.IsStream()) return;

// get required entries
double sampleRate = soundObj.FindObj("R").GetNumber();
// set defaults
int numberOfChannels = 1;
int bitsPerSamplePerChannel = 8;
string encodingFormat = "Raw";
string soundCompression = "None";
// now parse optional entries.
for (DictIterator itr = soundObj.GetDictIterator(); itr.HasNext(); itr.Next())
{
string key = itr.Key().GetName();
if (key == "B") bitsPerSamplePerChannel = (int)itr.Value().GetNumber();
else if (key == "C") numberOfChannels = (int)itr.Value().GetNumber();
else if (key == "E") encodingFormat = itr.Value().GetName();
else if (key == "CO") soundCompression = itr.Value().GetName();
else if (key == "CP")
{
// Both CO and CP have no defined entries in PDF standard. And CP is an undefined type.
// e.g. CP could be an Array, Name, String, Dict, etc.
}
}

// For E (encoding format) the following is from PDF standard.
// Raw Unspecified or unsigned values in the range 0 to 2B - 1
// SignedTwos complement values
// muLawm law–encoded samples
// ALawA law–encoded samples

// Create Source filter chain
pdftron.Filters.Filter source = soundObj.GetDecodedStream();
pdftron.Filters.FilterReader reader = new pdftron.Filters.FilterReader(source);
byte[] buffer = new byte[1024]; // 1KiB buffer
// TODO Create sink
var sink = File.Create("output_file.");
int bytesRead = reader.Read(buffer);
while(bytesRead > 0)
{
// stream bytes_read to sink
bytesRead = reader.Read(buffer);
}
  1. how enable sound rec, playback in the sample proyect for UWP ? we need a create new tool?

You don’t necessarly need to create a new tool, but you would modify the tools code, so that when the user clicked on a Sound annotation, you would handle the playback your self, using the information from the code above, and what is available from the OS on UWP.

thanks Rayan,

how we create the obj for the new annotation with de the data stream?, we work in c#

Obj soundStream = new Obj(" ");
newSound.SetSoundStream();
El viernes, 7 de julio de 2017, 13:22:26 (UTC-4), Ryan escribió:

The following is how to extract the sound information from a PDF Sound annotation.

`
if (annot.GetType() != Annot.Type.e_Sound) return;
Sound sound = new Sound(annot);
Obj soundObj = sound.GetSoundStream();
if (!soundObj.IsStream()) return;

// get required entries
double sampleRate = soundObj.FindObj(“R”).GetNumber();
// set defaults
int numberOfChannels = 1;
int bitsPerSamplePerChannel = 8;
string encodingFormat = “Raw”;
string soundCompression = “None”;
// now parse optional entries.
for (DictIterator itr = soundObj.GetDictIterator(); itr.HasNext(); itr.Next())
{
string key = itr.Key().GetName();
if (key == “B”) bitsPerSamplePerChannel = (int)itr.Value().GetNumber();
else if (key == “C”) numberOfChannels = (int)itr.Value().GetNumber();
else if (key == “E”) encodingFormat = itr.Value().GetName();
else if (key == “CO”) soundCompression = itr.Value().GetName();
else if (key == “CP”)
{
// Both CO and CP have no defined entries in PDF standard. And CP is an undefined type.
// e.g. CP could be an Array, Name, String, Dict, etc.
}
}

// For E (encoding format) the following is from PDF standard.
// Raw Unspecified or unsigned values in the range 0 to 2B - 1
// SignedTwos complement values
// muLawm law–encoded samples
// ALawA law–encoded samples

// Create Source filter chain
pdftron.Filters.Filter source = soundObj.GetDecodedStream();
pdftron.Filters.FilterReader reader = new pdftron.Filters.FilterReader(source);
byte[] buffer = new byte[1024]; // 1KiB buffer
// TODO Create sink
var sink = File.Create(“output_file.”);
int bytesRead = reader.Read(buffer);
while(bytesRead > 0)
{
// stream bytes_read to sink
bytesRead = reader.Read(buffer);
}
`

  1. how enable sound rec, playback in the sample proyect for UWP ? we need a create new tool?

You don’t necessarly need to create a new tool, but you would modify the tools code, so that when the user clicked on a Sound annotation, you would handle the playback your self, using the information from the code above, and what is available from the OS on UWP.

You might find it easier to simply copy the entire annotation over to the new document, as https://groups.google.com/d/msg/pdfnet-sdk/dli_LNY9zGI/awDadzhW9M8J describes.

Thanks Aaron, work fine, but we need create sound annotation too, how do that?
El miércoles, 16 de agosto de 2017, 19:45:30 (UTC-3), Aaron escribió:

You might find it easier to simply copy the entire annotation over to the new document, as https://groups.google.com/d/msg/pdfnet-sdk/dli_LNY9zGI/awDadzhW9M8J describes.

The blog post at https://blog.pdftron.com/2013/09/11/working-with-pdf-richmedia-annotations/ details creating audio annotations. Please let us know if you have any questions.

Preferably we do not use riched media, because we have an application in IOS, which works with sound annotations, can give us an example of how to create sound annotation?
thank you very much.
El jueves, 17 de agosto de 2017, 18:52:56 (UTC-3), Aaron escribió:

The blog post at https://blog.pdftron.com/2013/09/11/working-with-pdf-richmedia-annotations/ details creating audio annotations. Please let us know if you have any questions.