Loading a Poster to a Movie Annotation

Ask a Question related to Adobe Acrobat SDK, Design and Development.

  1. #1

    Default Loading a Poster to a Movie Annotation

    Hi,

    I'm trying to add a poster to my movie annotation because when it initially loads before playing, it is a blank rectangle.

    So, I thought of creating a PDF with an image of the first frame of the movie to be displayed as a poster. However, this doesn't work. Is it posible to load a poster to this type of annotation or is there a better way of doing this?

    Thanks,
    Kristy
    miniCooper@adobeforums.com Guest

  2. Similar Questions and Discussions

    1. Hide a movie poster?
      I am putting a movie into a PDF using Acrobat 9 Pro Extended. There are a couple of things I'd like to do but can't figure out how to accomplish. ...
    2. Creating a Movie Annotation Plug-in
      Hi, I'm trying to create a plug-in that creates a pdf and embeds a movie annotation into the pdf. The only problem i'm having is locating the...
    3. loading movie into another movie problems
      ill try to explain my issue, i have a flash movie say at 500x400 if i load a movie into that movie and say the movie is smaller 300x100 it shows...
    4. help with loading movie
      i need help making a loading movie for a flash web-site does anyone have any good advice
    5. Loading a new movie
      I have a movie.exe from Director which is probably too big for autorun (233 MB), I wanna create a new movie_start.exe (with autorun) which will...
  3. #2

    Default Re: Loading a Poster to a Movie Annotation

    The poster can be as simple as a raster image XObject.

    As always - make one in Acrobat and see.
    Leonard_Rosenthol@adobeforums.com Guest

  4. #3

    Default Re: Loading a Poster to a Movie Annotation

    Hi Leonard,

    The problem is I've created a poster [Ie: PDF] and created a loadPoster function that creates an XObject and adds the poster to the page. I used this procedure to place a poster for my 3D annotation, but for some reason, it doesn't seem to work for the movie annotation.

    Heres my code which loads my Poster:

    // Global definitions
    bool gbUseExternalPosterFile = true;

    // input poster file
    #ifdef PLUGIN // code for Acrobat plugin. full path.

    #if WIN_PLATFORM
    char* posterPath = "C:/tmp/input/ImagePoster.pdf";
    #else
    char* posterPath = "/tmp/input/ImagePoster.pdf";
    #endif

    #else // PDFL SDK
    char* posterPath = "ImagePoster.pdf";
    #endif

    // Load Poster Function
    void loadImagePoster (PDDoc pdDoc, PDAnnot newAnnot)
    {
    DURING
    CosObj formXObject;

    if(gbUseExternalPosterFile == true)
    {
    // Form XObject generated from an external image PDF file
    formXObject = GetFormXObjectFromFileByConversion(posterPath, pdDoc);
    }

    else
    {
    // using the internal PDF Form XObject, we get form XObject through watermark generation.
    formXObject = GetFormXObjectFromFileByWatermark("", pdDoc);
    }

    // Specify the poster as appearance for the movie annotation
    if (!CosObjEqual(formXObject, CosNewNull()))
    {
    CosObj cosAnnot = PDAnnotGetCosObj(newAnnot);
    CosDoc cosDoc = CosObjGetDoc(cosAnnot);
    CosObj apprDict = CosNewDict(cosDoc, false, 1);

    // Set the stream object (now a Forms XObject) as the normal (N) key
    // and add to the Appearance (AP) key.
    CosDictPutKeyString(apprDict, "N", formXObject);
    CosDictPutKeyString(apprDict, "D", formXObject);
    CosDictPutKeyString(cosAnnot, "AP", apprDict);
    }

    HANDLER
    char buf[256];
    AVAlertNote(ASGetErrorString(ERRORCODE, buf, 255));
    END_HANDLER
    }

    Then where I create my movie annotation and set its contents, I call the poster function. [The exact same procedure I used to load my 3D Annotation Poster] Only in this case, it does not work.

    Please, any help would be great.

    Im just wondering if I need to add an entry called "Poster" when setting up my movie annotation and set up my stream [which is my poster] to be loaded...
    Ex:

    // Key = Poster, Value = true [boolean]
    CosDictPutKeyString(dictMovie, "Poster", CosNewBoolean(cosDoc, false, true));
    miniCooper@adobeforums.com Guest

  5. #4

    Default Re: Loading a Poster to a Movie Annotation

    Poster frames for movies are NOT set the same way as other annotations, as documented in the PDF Reference (Ref 1.7, Section 9.3, Table 9.30, entry "Poster").

    Also, they MUST be an Image XObject as stipulated.
    Leonard_Rosenthol@adobeforums.com Guest

  6. #5

    Default Re: Loading a Poster to a Movie Annotation

    Okay, that's what I thought.

    How would I create an XObject and set it to the image I want to load?
    miniCooper@adobeforums.com Guest

  7. #6

    Default Re: Loading a Poster to a Movie Annotation

    Can you please provide an example of how I would create a stream and XObject with my image?

    Thank you!
    miniCooper@adobeforums.com Guest

  8. #7

    Default Re: Loading a Poster to a Movie Annotation

    Same way you do it for XObjects. CosStmNewStream, ASStmRead, etc.

    Except in this case, you are giving it a collection of bytes of raw pixel data.
    Leonard_Rosenthol@adobeforums.com Guest

  9. #8

    Default Re: Loading a Poster to a Movie Annotation

    Is there any example that you can provide me with? I don't quite understand.

    thanks
    miniCooper@adobeforums.com Guest

  10. #9

    Default Re: Loading a Poster to a Movie Annotation

    Do you mean something like this? :

    CosObj movieStm = CosNewStream (cosDoc, true, (ASStm)ASStmRead(...)), 0, false, CosNewNull(), CosNewNull(), -1);

    CosDictPutKeyString(cosAnnot, "Movie", movieStm);

    And then use "Poster"

    CosDictPutKeyString(dictMovie, "Poster", movieStm);
    miniCooper@adobeforums.com Guest

  11. #10

    Default Re: Loading a Poster to a Movie Annotation

    something like that...

    But the hard part is how you are going to take an existing image file (.jpg, .png, etc.) and get that into PDF? JPEG is the easiest, though not trivial...
    Leonard_Rosenthol@adobeforums.com Guest

  12. #11

    Default Re: Loading a Poster to a Movie Annotation

    This is what I have so far...

    char* buffer;

    // buffer, itemSize, bytes, stm to read
    CosObj movieStm = CosNewStream (cosDoc, true, (ASStm)ASStmRead(buffer, 1, sizeof("C:/tmp/Image/Snapshot.jpg"), (ASStm)"C:/tmp/Image/Snapshot.jpg"), 0, false, CosNewNull(), CosNewNull(), -1);

    CosDictPutKeyString(dictMovie, "Poster", movieStm);

    Except this causes my plug-in to crash...
    miniCooper@adobeforums.com Guest

  13. #12

    Default Re: Loading a Poster to a Movie Annotation

    ASStmRead returns a number of bytes read. You can't typecast that to
    an ASStm.

    You cannot typecast a char* string into an ASStm.

    You are missing out all of the necessary steps to create an
    ASPathName, an ASFile, an ASStm, NOT to read the ASStm but to pass it
    direct to CosNewStream.

    You seem to be dipping in and picking out at random. Read all of the
    ASStm, ASFile, ASFileSys and ASPathName methods to get a feeling for
    the territory.

    If you find you are having to use wild typecasts, it's a sure sign you
    are going the wrong way.

    Aandi Inston
    Aandi_Inston@adobeforums.com Guest

  14. #13

    Default Re: Loading a Poster to a Movie Annotation

    Ok ... that CosNewStream call will not work, and I am not at all surprised it causes a crash.

    You need to be very careful with your typecasting, and it would be best to have read the documentation regarding those data types before you cast to them.

    1> ASStmRead
    - You cannot cast the result from this method to an ASStm. Per the documentation, ASStmRead returns the number of bytes read.

    2> sizeof("string")
    - This is a basic C function and not part of the SDK at all, so there is not documentation on its use in the SDK. However, per the documentation on this parameter to CosNewStream, this is the offset into the stream to start reading from. If sizeof("static string") even returns anything (and I'm not sure it will in this case), it would return the number of bytes contained in that string - so why are you wanting to only start reading the stream from 26 bytes in?

    3> (ASStm)"string"
    - Again, you cannot typecast a string to an ASStm. Think of an ASStm like a FILE* variable (they are very different, but from a basic level can act the same). It is simply a pointer to a stream being read from a given location defined by how you opened the stream. Also, as is described in the documentation, this parameter should be a boolean value, not an ASStm.

    What you will have to do ...

    You need to read the ASStm section of the API reference to find how to return an ASStm of an ASFile (ASFileStmRdOpen is a good place to start, since it returns an ASStm). You'll want to research if you need to provide an offset to the stream or if an offset of 0 will work for that file type. Once this is done, then you can tackle the documentation on the CosNewStream method, which is actually quite verbose and has entire paragraphs on what each parameter should be.
    PDL@adobeforums.com Guest

  15. #14

    Default Re: Loading a Poster to a Movie Annotation

    Sorry, I realized I had to create a fileStm when the plug-in crashed.

    I've done that now. I'm just a little confused with how to append this fileStm to the CosNewStream.

    Here's what I have:

    char* snapshot = readPosterImageFromTxtFile();

    // Open the Data File
    char sPathFlag1[BUFFER_SIZE] = "Cstring";

    ASPathName asPathName2 = ASFileSysCreatePathName (ASGetDefaultFileSys(), ASAtomFromString(sPathFlag1), snapshot, 0);

    ASFile asFile2 = NULL;

    ASInt32 err2 = ASFileSysOpenFile(ASGetDefaultFileSys(), asPathName2, ASFILE_READ, &asFile2);

    ASFileSysReleasePath (ASGetDefaultFileSys(), asPathName2);

    if ((err2 != 0) || (asFile2 == NULL)) {
    AVAlertNote("Error opening movie data file. km ");
    E_RETURN (false);
    }

    ASStm fileStm2 = ASFileStmRdOpen(asFile2, BUFFER_SIZE);

    if (fileStm2 == NULL){
    AVAlertNote("Error: This movie data stream is empty.");
    E_RETURN (false);
    }

    AVAlertNote(snapshot);

    // --------------------------------
    // CosObj Setup - Movie Annotation
    // --------------------------------

    // Create Dictionary and set its Key as "Movie" in the annot dictionary
    CosObj dictMovie = CosNewDict( cosDoc, true, DICTIONARY_SIZE );
    CosDictPutKeyString ( cosAnnot, "Movie", dictMovie );

    Now, how would i go about creating the CosNewStream and placing my fileStm2 in?
    I've tried this, however no image appeared on the movie annotation rectangle:

    CosObj movieStm = CosNewStream (cosDoc, true, fileStm2, 0, true, CosNewNull(), CosNewNull(), -1);

    CosDictPutKeyString(dictMovie, "Poster", movieStm);
    miniCooper@adobeforums.com Guest

  16. #15

    Default Re: Loading a Poster to a Movie Annotation

    As Leonard has said, the "Poster" needs to be an Image XObject, so you can't just dump the stream from a JPEG file in there. You will need the JPEG stream to create the Image XObject, but it is more complicated than what you have above.

    Perhaps if you could detail which part of the Image XObject documentation in the PDF Reference you don't understand then we could better help you with your project.
    PDL@adobeforums.com Guest

  17. #16

    Default Re: Loading a Poster to a Movie Annotation

    You need to read about Image XObjects, as they have MANY required fields for their attributes dictionary (NONE of which you are setting).
    Leonard_Rosenthol@adobeforums.com Guest

  18. #17

    Default Re: Loading a Poster to a Movie Annotation

    Ok, well I've already created a PDF that embeds the jpg into the doc.
    This is what I have as my ASStm "file stream" called "posterStm".

    Then I:
    1) Get the stream length
    2) Create a CosObj object that represents the stream length
    3) Create a CosObj that represents a stream dictionary [called "StmDict"] and set it key-value pairs
    4) Read the stream [posterStm]into memory by invoking the ASMemStmRdOpen method
    5) Create a new Cos stream [called "movieStm"] using data from the ASStm object [posterStm]
    6) Finally, I apply the "Poster" entry by passing in "movieStm" like this:
    CosDictPutKeyString(StmDict, "Poster", movieStm);

    But like you mentioned the Poster entry must be a stream of the Image XObject. This is the part I am unsure of... My posterStm is reading my PDF with the image embedded into it. Why do I need an XObject when the Poster entry value calls for a boolean or stream? What I've done is created a stream which reads my PDF.
    miniCooper@adobeforums.com Guest

  19. #18

    Default Re: Loading a Poster to a Movie Annotation

    Another thing, I actually do create an Image XObject when embedding my image into my newly created PDF. Its a separate function being called when my image annotation is created and setup.
    miniCooper@adobeforums.com Guest

  20. #19

    Default Re: Loading a Poster to a Movie Annotation

    So basically my steps are:

    1) Create a PDF [my Image Poster]
    2) Create an image annotation, setup its contents, read the image from a txt file, and add the image to the PDF
    3) Save the PDF with the image embedded
    4) Create the movie annotation, read the movie from a txt file, open/load the file, setup the ASStm, read the PDF posterImage, create a stream dictionary, and invoke the stream in the Poster entry.

    And so far...I still cannot get my PDF poster image to display in the rectangle of my movie annotation...
    miniCooper@adobeforums.com Guest

  21. #20

    Default Re: Loading a Poster to a Movie Annotation

    > Why do I need an XObject when the Poster entry value calls for a boolean or stream?

    Because that's what the specification says. An image XObject _is_ a
    stream object, but it is not _just_ a stream object. Have you read the
    specifications of image XObjects?

    Also, the stream data needs to be a raw or filtered collection of
    pixels. Is it?

    Aandi Inston
    Aandi_Inston@adobeforums.com Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139