Title: Re: [iText-questions] Can I embed Movies, Flash, etc using iText?
Send me the pdf you generated.
 
Best regards,
Paulo Soares


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Tom Groves
Sent: Thursday, November 11, 2004 3:24 PM
To: [EMAIL PROTECTED]
Subject: Re: [iText-questions] Can I embed Movies, Flash, etc using iText?

OK, this is very weird!  I’ve copied and pasted your code (and put the below listed imports at the top) and compiled and run it.  It generates a pdf but when you try to click in the box you get nothing.  Changing the final createScreen parameter to true still gives the error from before though.

Now I feel I should note that I’m compiling this on Mac OS 10.3.6 which could be the root cause of all these problems as java for Mac OS is maintained by apple themselves.  I’m downloading JDK onto a windows box now to test.

Imports I added are:
import java.io.FileOutputStream;
import java.io.IOException;
import java.awt.Color;
import com.lowagie.text.*;
import com.lowagie.text.pdf.*;
import com.lowagie.text.pdf.PdfWriter;

Anyway, I’ll keep you posted once I have the JDK down...could be a while, our allegedly 2Mbit connection barely manages more than about 768Kbits.  I hope this works on windows – it’d not be a big problem if it does as the code would be run from tomcat on a windows box.

FYI:
Omnia-Workstation:~/itextpdf tomgroves$ java -version
java version "1.4.2_05"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_05-141.3)
Java HotSpot(TM) Client VM (build 1.4.2-38, mixed mode)

So...until later!

Tom


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

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    


Reply via email to