Title: Re: [iText-questions] Can I embed Movies, Flash, etc using iText?
Here's my code:
 
public class embimage {
 
    public static void main(String[] args) {
 
        Document document = new Document(PageSize.A4, 50, 50, 50, 50);
        try {
            PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("c:\\embimage.pdf"));
            writer.setPdfVersion(PdfWriter.VERSION_1_5);
            document.open();
            PdfContentByte cb = writer.getDirectContent();
            cb.setColorStroke(Color.red);
            cb.rectangle(200, 400, 100, 100);
            cb.stroke();
            document.add(new Paragraph("Images"));
            PdfFileSpecification fs = PdfFileSpecification.fileEmbedded(writer, "saitoz-n.mpeg", "saitoz-n.mpeg", null);
            PdfAnnotation annot = PdfAnnotation.createScreen(writer, new Rectangle(200f, 400f, 300f, 500f), "saitoz-n.mpeg",fs,"video/mpeg",false);
            writer.addAnnotation(annot);
            document.close();
        }
        catch (Exception de) {
            de.printStackTrace();
        }
    }
}
Best Regards,
Paulo Soares


From: Tom Groves [mailto:[EMAIL PROTECTED]
Sent: Thursday, November 11, 2004 1:18 PM
To: Paulo Soares; [EMAIL PROTECTED]
Subject: Re: [iText-questions] Can I embed Movies, Flash, etc using iText?

Paulo,

Yep, that does work – how odd.  Well everything points to a stupid mistake in my code but I’m not having any luck tracking it down!

The following method is what I’m using to add the embedded file into the PDF:

    private static void addEmbeddedFile(PdfWriter writer, String fileName, String mimeType) {
        try {
            PdfFileSpecification fs = PdfFileSpecification.fileEmbedded(writer, fileName, "Embedded File", null);
            writer.addAnnotation(
                PdfAnnotation.createScreen(writer, new Rectangle(300f, 700f, 400f, 800f),
                                            fileName, fs, mimeType, true));
        }
        catch(Exception e) {
            System.err.println(e.toString());
        }        
    }

Am I doing anything totally ridiculously amateur there?! :)

Thanks for the help,

Tom

On 11/11/04 4:45 pm, "Paulo Soares" <[EMAIL PROTECTED]> wrote:

This PDf works for me both in reader and in full. Click in the rectangle to play.

Best Regards,
Paulo Soares


 

From: Tom Groves  [mailto:[EMAIL PROTECTED]
Sent: Thursday, November 11,  2004 11:34 AM
To: Paulo Soares;  [EMAIL PROTECTED]
Subject: Re: [iText-questions]  Can I embed Movies, Flash, etc using iText?

 
Paulo,

Thanks for the reply, I appreciate the  help you’re giving!

Unfortunately I have downloaded the latest version  of the class from your page and I’m still having the same error from Acrobat.   It appears to be working, as it is embedding the movie – it just  doesn’t want to play once it gets into Acrobat.  I’m about to try the  same thing with various movie formats and flash as well and will let you know  if they behave any differently.

Is this anything to do with signing the  PDF, which I’m not currently doing?  I figure not but it’s worth  checking!  I did have a look at the Trust Manager prefs in Acrobat but  they aren’t excluding anything so it doesn’t appear to be that.

Thanks  again,

Tom


On 11/11/04 2:14 pm, "Paulo Soares"  <[EMAIL PROTECTED]> wrote:

 


 

 
 

From:   [EMAIL PROTECTED]  [mailto:[EMAIL PROTECTED]  On Behalf Of Tom  Groves
Sent: Thursday, November  11, 2004 5:47 AM
To: Paulo  Soares
Cc:  [EMAIL PROTECTED];   [EMAIL PROTECTED]
Subject: Re: [iText-questions]  Can I  embed Movies, Flash, etc using iText?

 
 
Paulo,

Thanks  very much for that – only  actually just saw your reply!

I’ve  done little playing about with this  method this morning and there’s  a couple of things that I’d like to ask you  about.  Basically,  there was no problem using your example with the mpeg.   What I  then did was to change it to embed the movie as opposed to just   linking to it, as the files we want to distribute would have to be   self-contained.  This seemed to work, but when I opened it in  vanilla  Acrobat 6 Pro I got the following error:

Cannot  play media clip  because there is no player available that can play  the media while satisfying  the author’s intentions as well as your  security settings.

Given  that it played fine when it was  just annotated and linked I think we can rule  out a player error –  it seems to be a security problem.  Have you any  idea what’s  caused this and how to get around it?


 
That's a bug that is fixed  in   yesterday's release at  http://itextpdf.sourceforge.net <http://itextpdf.sourceforge.net/>  .

 

 
The  second problem I  encountered was when embedding Quicktime.  This caused  an out  of memory error – the file was 20megs.  When I cut the file down   to about 600K it was not a problem at all, except for the above  issue with  regards playback.  Unfortunately I get the feeling  that this is not going  to be easy to fix but if you have any ideas  I’d appreciate it.  What  about using the “
byte[] fileStore” parameter  in  the fileEmbedded method instead of  ‘String  filePath’?


You need  more memory in the JVM.  Currently all the streams are placed in  memory, compressed and output. They  don't linger in memory but  memory is needed for that brief period. I'll try to  find some kind  of solution this weekend, at least for some particular cases  like  this.

 
 
Best Regards,
Paulo   Soares

Thanks in  advance for any assistance you can   provide!

Tom


On   9/11/04 5:30 pm, "Paulo Soares" <[EMAIL PROTECTED]>   wrote:


 
In can be done but it requires Acrobat 6. See the  example  screen_rendition.java at http://itextpdf.sourceforge.net.   As usually if there's a need to improve this functionality it will  be  included in the to-do list.

Best Regards,
Paulo Soares

 
 

 
 
 

From:    [EMAIL PROTECTED]  [mailto:[EMAIL PROTECTED]   On Behalf Of Tom  Groves
Sent: Tuesday,  November 09,  2004 12:56 PM
To:    [EMAIL PROTECTED]
Subject:   [iText-questions] Can  I embed Movies, Flash, etc using   iText?

 
Hi,

I’m looking  into  the viability of using  iText for a project that we’re  doing and,  given that I’ve run into this  barrier with  various other PDF  generation libraries and classes, would like to   confirm whether  iText can handle embedding of ‘New Media’  content.

The  PDFs  that we’ll generate will need to  have the option of having embedded   movies (probably  Quicktime), flash, sounds, etc. (not all, but  possibly any   one).  We were hoping that we could accomplish  this by  having these items  embedded in a PDF that we import

I   have briefly browsed the API  reference documentation but  could find  no reference for movie and flash  embedding...  :(

So  basically, my question is: Is this possible?    It would be NICE  to do this programmatically, but  right now I’m more  worried about  whether we can even do it  at all!

Thanks in   advance,

Tom Groves  <[EMAIL PROTECTED]>
Senior  Digital Media   Developer
Omnia FZ LLC   


--   




--  




--

<<image.gif>>

<<image.gif>>

<<image.gif>>

Reply via email to