5 Replies Latest reply on Nov 26, 2012 4:46 PM by provoloner

    Using the fireworks XML RPC server


      Hi, I am trying to use the XML RPC server in fireworks to export pages of a PNG.


      The relevant help url: http://help.adobe.com/en_US/fireworks/cs/extend/WS5b3ccc516d4fbf351e63e3d1183c949219-7ffe. html

      And the pdf version: http://help.adobe.com/en_US/fireworks/cs/extend/fireworks_cs5_extending.pdf (chapter 7)


      All I want to do is open a file, call exportPages(), and close it. So far this has been a very painful experience. I have CS5 Design Premium on a mac (os 10.5) if it matters. But I have the same problem 1 with my copy of CS3.


      Problem 1


      Fireworks never ever returns a document id. It also does not return an error number. The value attribute of the returned obj element and any error attributes are empty. Here are some example calls and responses:


      request: <func name="createDocument" obj="fw"></func>

      response: <return><obj value="" class="DocumentClass"></obj></return>'


      request: <func name="closeDocument" obj="fw"><string order="0" value="0" /><bool order="1" value="false" /></func>

      response: <return error=""></return>


      Note the value of the response is empty. This is always the case, unless I get something back that is not an integer. For instance. I am able to get the path url of the open doc:


      request: <func name="getDocumentPath" obj="fw"></func>

      response: <return><string value="file:///Macintosh%20HD/Users/me/work/somefile.png"></string></return>


      Is anyone else using this with any success? Will a FW dev some here and set me straight? I am opening a socket with python like this:


      import socket

      self._sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

      self._sock.connect(('localhost', 12124))


      It seems like anything that is an int on FW end doesn't come through the response?


      Problem 2


      When I open a file that was created in CS3 with the API, a blocking dialog pops up asking about converting the fonts. FW will not return my request until this dialog is dismissed. Is there any way around this? This pretty much nullifies any automation with fireworks on files create by an older version.


      Any help or insight into either of these would be extraordinarily helpful. Or if you have a way to export pages from a FW PNG without running fireworks, I would love love love to hear it. Judging by the RPC documentation, the availability of info online (virtually none!) and my experience with it, it seems adobe doesn't care about it all that much.

        • 1. Re: Using the fireworks XML RPC server
          mrbogle Level 1

          I dont know if this is progress, but With CS3 I do get doc ids back, and error numbers. I suppose it means my socket code is working properly. But CS3 doesn't have the exportPages function(). Ugh.


          Are there any workarounds to get the current doc ids for the open documents in the application in CS5?


          Also, In CS3:


          fw.closeDocument('123456', False) doesn't work


          doc.close('123456') seems to work


          The docs are very inconsistent. Many of the properties for document are under the functions section. A few of the properties are actually billed as functions (doc.pageName is one), etc.

          • 2. Re: Using the fireworks XML RPC server
            Sarthak Singhal Adobe Employee

            I am sure you would have read the Fireworks EULA.

            Just to clarify, if you are using Fireworks on a server and interacting with the app via this channel, it is against the EULA.



            • 3. Re: Using the fireworks XML RPC server
              Priyanka C Herur

              The Fireworks APIs - dom.close() and fw.closeDocument() seems to be working fine, both on Fw CS3 and CS5.

              You could try using the following code:


              var dom=fw.getDocumentDOM();           //Gets the document object of the current document.

              var mydoc=fw.documents[0];    // Get the document object of the first document that is open.

              fw.closeDocument(mydoc,false);            //closes the document.


              You can use "fw.closeDocument(dom,false);" to close the current document.

              “dom.close(true);” or “mydoc.close(true);” can also be used to close the document.


              fw.documents is an array of Fireworks documents that are currently open in Fireworks.

              You can use fw.documents[i] to perform operations on the ith document.



              • 4. Re: Using the fireworks XML RPC server
                mrbogle Level 1

                Hi Priyanka. It seems you are using the JS api? Flash? I am trying to use this via the XML RPC server in fireworks. Those are precisely the calls I am making to the RPC server with no avail: they do not return document ids. If you get a chance, can you (or anyone) run the following python code? Just open fireworks CS5, open a file and run this python code. It should return (print) the document id of the current document in a value="" attribute.


                import socket
                s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
                s.connect(("localhost", 12124))
                dom = '<func name="getDocumentDOM" obj="fw"><string order="0" value="document" /></func>\0'
                res = []
                r = s.recv(1)
                while ord(r):
                    r = s.recv(1)
                print ''.join(res)


                Like I said earlier, this code works for me with CS3, but does not work with CS5; value="" is empty.


                I am not running this on a server. I am just trying to do some batch processing.



                • 5. Re: Using the fireworks XML RPC server

                  I noticed that this object ID problem occurs when I run this code on a Mac but it works fine on Windows 7.  I'm running the exact same code but for Fireworks CS6.  On Mac I get:

                  <return><obj value="" class="DocumentClass"></obj></return>

                  but on Windows the value is the proper ID number.


                  So far on the mac NONE of the return objects have a proper value unless the object is of type string.  FwArray, DocumentClass, et cetera all have "" for value.

                  On Windows there is no problem and the code hasn't changed.



                  Is it possible to notify Adobe about this potential bug?  Or has anyone discovered a work-around to get the DocumentClass object ID??