/** * Default constructor. */ public PDActionSound() { setSubType(SUB_TYPE); }
COSStream soundStream = new COSStream(); OutputStream os = soundStream.createOutputStream(COSName.FLATE_DECODE); URL url = new URL("http://cd.textfiles.com/hackchronii/WAV/ALBUNDY1.WAV"); InputStream is = url.openStream(); // FileInputStream is = new FileInputStream(".....WAV"); IOUtils.copy(is, os); is.close(); os.close(); // See p. 506 in PDF spec, Table 294 soundStream.setInt(COSName.C, 1); // channels soundStream.setInt(COSName.R, 22050); // sampling rate //soundStream.setString(COSName.E, "Signed"); // The encoding format for the sample data soundStream.setInt(COSName.B, 8); // The number of bits per sample value per channel. Default value: 8 // soundStream.setName(COSName.CO, "MP3"); // doesn't work PDActionSound actionSound = new PDActionSound(); actionSound.getCOSObject().setItem(COSName.getPDFName("Sound"), soundStream); link.setAction(actionSound);
break; case PDActionSound.SUB_TYPE: retval = new PDActionSound(action); break; case PDActionMovie.SUB_TYPE:
PDSimpleFileSpecification fileSpec = new PDSimpleFileSpecification(new COSString("/C/dir1/dir2/blah.mp3")); // see "File Specification Strings" in PDF spec COSStream soundStream = new COSStream(); soundStream.createOutputStream().close(); soundStream.setItem(COSName.F, fileSpec); soundStream.setInt(COSName.R, 44100); // put actual sample rate here PDActionSound actionSound = new PDActionSound(); actionSound.getCOSObject().setItem(COSName.getPDFName("Sound"), soundStream)); link.setAction(actionSound); // reassign the new action to the link annotation
retval = new PDActionSound(action);
break; case PDActionSound.SUB_TYPE: retval = new PDActionSound(action); break; case PDActionMovie.SUB_TYPE:
/** * Default constructor. */ public PDActionSound() { setSubType(SUB_TYPE); }
/** * Default constructor. */ public PDActionSound() { action = new COSDictionary(); setSubType(SUB_TYPE); }