RichMediaAnnotation support to embed Video or Audio files in PDF document using Aspose.Pdf for Java 17.5

aspose Pdf for Java RichMediaAnnotation support to embed Video or Audio files in PDF document using Aspose.Pdf for Java 17.5A new release of Aspose.Pdf for Java 17.5 supporting the feature to add RichMediaAnnotation inside PDF document is introduced. The RichMediaAnnotation allows the feature to embed media files within the PDF document and sets video/audio player, implemented as flash application. Furthermore, we also have tested the compatibility of API with Grails, Dockers platform and Oracle Agile Product Lifecycle Management applications and it have proved to work without any issues. It also includes fixes related to previously reported issues, which make this release version stable and robust enough for PDF files creation, manipulation and transformation to other support formats.

Adding RichMediaAnnotation

If we have a requirement to add an external video link in PDF document, we can use MovieAnnotaiton object. However when there is a requirement to embed media inside the PDF document, we need to use RichMediaAnnotation. This annotation allows to embed media file within the PDF document and sets video/audio player, implemented as flash application. Due to license restrictions, we can not include third-party flash scripts in our product, so you need to provide your script for playing videos or audios. You should provide flash application code. For example, you can use videoplayer.swf and audioplayer.swf which are distributed with Adobe Acrobat and may be found in Multimedia Skins/Players sub-folder in Acrobat folder. Another option is using StrobeMediaPLayback.swf player or any other videoplayer implemented in flash. For further details, please visit Working with RichMediaAnnotation

// instantiate Document instance
Document doc = new Document();
 
// add page to pages collection of Document object
Page page = doc.getPages().add();
  
// create RichMediaAnnotation object
RichMediaAnnotation rma = new RichMediaAnnotation(page, new Rectangle(100,500, 300, 600));
  
//here we should specify stream containing code of the video player
InputStream is = new FileInputStream(myDir+"Videoplayer.swf");
rma.setCustomPlayer(is);
  
// Give name to video data. This data will be embedded into document 
// with this name and referenced from flash variables by this name. 
// videoName should not contain path to the file; this is rather "key" 
// to access data inside of the PDF document
String videoName = "VideoTutorial.mp4";
  
//also we use skin for video player
String skinName = "SkinOverAllNoFullNoCaption.swf";
  
//compose flash variables line for player. please note that different players may 
// have different format of the flash variables line. Refer to documentation for your player.
rma.setCustomFlashVariables(String.format("source=%s&skin=%s", "VideoTutorial.mp4", skinName));
  
//add skin code. 
InputStream is2 = new FileInputStream(myDir+"SkinOverAllNoFullNoCaption.swf");
rma.addCustomData(skinName,is2);
  
//set poster for video
InputStream is3 = new FileInputStream(myDir+"barcode.jpg");
rma.setPoster(is3);
  
 
InputStream fs = new FileInputStream(myDir + videoName);
//set video content
rma.setContent(videoName, fs);
  
//set type of the content (video)
rma.setType(RichMediaAnnotation.ContentType.Video);
  
//active player by click
rma.setActivateOn(RichMediaAnnotation.ActivationEvent.Click);
  
//update annotation data. This method should be called after all assignments/setup. 
// This method initializes data structure of the annotation and embeds required data. 
rma.update();
  
//add annotation on the page.
page.getAnnotations().add(rma);
  
doc.save(myDir + "Output"+version+"2.pdf");
 
try
{
    if (is!=null)
        is.close();
    if (is2!=null)
        is2.close();
    if (is3!=null)
        is3.close();
    if (fs!=null)
        fs.close();
} catch (Exception e)
{
    // TODO: handle exception
}

Miscellaneous fixes

Apart from above mentioned improvements, the PDF to HTML conversion is one of the significant improvement feature which helps to create output files with great fidelity. We also have made improvements in PDF to PDF/A conversion feature, Image to PDF conversion, Annotation creation and manipulation, Text extraction, Text replacement. As it is always recommended to use latest release of our API’s, so we suggest you to please download the latest release of Aspose.Pdf for Java 17.5 and check Release Notes section regarding list of issues fixed in Aspose.Pdf for Java 17.5

fake cartier braceletofficial websitecartier jewelry replica

No related posts.


To keep up with our news, you can follow us on Twitter or follow our Facebook page.

One Response to RichMediaAnnotation support to embed Video or Audio files in PDF document using Aspose.Pdf for Java 17.5

  1. Pingback: URL

Leave a Reply