Hey,
I’m currently working on adding a video to a PDF using the Aspose.pdf library in Java, and I’m encountering a couple of issues:
Default Floating Window Issue: The default floating window (which needs to be selected by right-clicking) is causing problems.
Adding Controllers on Video Frame: I’m unable to add controllers (such as play, pause, and volume controls) to the video frame embedded in the PDF. It only plays the video without any interactive controls.
Thanks
@avinashAdvantal
If possible, can you please share your sample code snippet with the generated output PDF? Also, please share an expected output as well so that we can test the scenario in our environment and address it accordingly.
package org.example;
import com.aspose.pdf.*;
import java.io.FileInputStream;
import java.io.InputStream;
public class EmbedVideoIntoPDF {
public static void main(String[] args) {
try {
// Instantiate Document instance
Document doc = new Document("C:\\images/blank.pdf");
// Add a page to the document
Page page = doc.getPages().get_Item(1);
// Provide the path to the video file
String videoFilePath = "C:\\images\\SampleVideo_1280x720_1mb 1.mp4";
// Change this to the path of your video file
// Create a FileSpecification object
FileSpecification fileSpec = new FileSpecification(videoFilePath, "Sample Video");
// Add the FileSpecification to the document's embedded files collection
doc.getEmbeddedFiles().add(fileSpec);
// Create a ScreenAnnotation object
ScreenAnnotation screenAnnotation = new ScreenAnnotation(page, new Rectangle(100, 500, 300, 600), videoFilePath);
// Set the annotation title and some properties
screenAnnotation.setTitle("Sample Video");
screenAnnotation.setContents("Click to play video");
// Create a LaunchAction to open the video file with an external application
LaunchAction launchAction = new LaunchAction(videoFilePath);
screenAnnotation.setAction(launchAction);
// Add the ScreenAnnotation to the page
page.getAnnotations().add(screenAnnotation);
// Save the document with the embedded video
doc.save("E:\\poc\\TextPdf\\output.pdf");
// Change this to the desired output path
System.out.println("Video embedded successfully.");
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
Thanks For the Reply , I m Not able send the Generated PDF Because size is large .
@avinashAdvantal
Thanks for the code snippet. You can please upload your file to Google Drive or Dropbox and share the link with us. Also, please do share the expected file as well so that we can investigate accordingly.
@asad.ali
This PDF will work with adobe or Nitro. Sorry I Don’t have Excepted solutions Just I working on this to getting the functionally.
@avinashAdvantal
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): PDFJAVA-44059
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
@asad.ali ,
Thanks for your support.
Yes we would like to move forward and purchase the paid support services and also use the services provided by aspose.
But before purchasing, we have some queries that needs to be clarified, if we can get the proper response for that it would be very helpful to move forward.
Our questions are:
- Will the library support to add any controllers in the video (Like play, pause, stop, progress bar etc)
- Will it be able to directly open the video in a floating window?
- Will it support the playing of video past the front page?
would appreciate your quick response.
Thanks.
Avinash
@avinashAdvantal
Thanks for the queries. Please note that the case has been registered in our issue tracking system to perform analysis whether this feature can be implemented or not. Please note that Aspose.PDF mimics the behavior of Adobe Reader and if such feature is supported in Acrobat Reader, there are high chances that we will be able to implement it.
We have recorded your questions under the ticket. As soon as initial investigation is done, we will be able to share some certain feedback with you. Please be patient and spare us some time.