Skip navigation
Currently Being Moderated

Loading jpg image as resource

Sep 13, 2012 5:59 AM

Hi

 

I have found this http://livedocs.adobe.com/acrobat_sdk/9/Acrobat9_HTMLHelp/wwhelp/wwhim   pl/js/html/wwhelp.htm?href=JS_Dev_Overview.71.1.html#1515775&accessib l e=true

in the Acrobat 9 documentation. However this does not work. I tried this in an annotation-script:

 


var a = new Resource("pdf://test.jpg");

var myImage = new Image( a );

console.println("myImage="+myImage);

As you can see, it is almost to the letter what is given in the example. There is no error-message. The consoleout this produces is the following:

 

myImage=Image: "pdf://test.jpg" (0x0 pixels, 0 colors)

 
Replies
  • Currently Being Moderated
    Sep 13, 2012 6:18 AM   in reply to ForrestGimp

    It will work provided the file you're using as a resource is embedded into the RMA and is readable. It sounds in this case that the format of your JPEG isn't correct.

     

    Here's a quick utility function to drop into your RMA so you can test via the console:

     

    function loadDiffTex(_materialName, _resourceName) {

       var _mat = scene.materials.getByName(_materialName);

       var _res = new Resource("pdf://" + _resourceName);

       host.console.println("Resource created, type= " + _res.type);

       var _tex = new Image( _res );

       host.console.println("Image object created: " + _tex.toString());

       _mat.diffuseTexture.image = _tex

    }

     

     

    If your 3D scene has a material in it called 'mat1' and you've attached a JPEG called 'test.jpg' then run the console commands

     

    getAnnots3D(pageNum)[0].context3D.loadDiffTex('mat1','test.jpg');

     

    and see what it says. Note that the filename reported by the Image object may be corrupted, that's a bug in the 3D API but it doesn't stop things working.

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 13, 2012 9:29 AM   in reply to ForrestGimp

    The JPEGs aren't CMYK by any chance?

     

    If you can share one of the images I'll try it out.

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 14, 2012 1:44 AM   in reply to ForrestGimp

    See your private messages

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points