GetURL revisited

This page is outdated. More recent info here:

https://www.rorohiko.com/jsxgeturl

Note: If you are using version 0.0.7 or below, it will have stopped working by now because it was time bombed on December 31 of the year. Please update to version 1.x.x (see link below).

I’ve been dabbling around with ExtendScript DLLs.

These little critters run within ExtendScript and allow me to enhance ExtendScript, for all apps that support it, including InDesign Server, on Mac and Windows.

I can add whatever functionality I decide to wrap into such a DLL.

Now, I’ve just finished wrapping the C++ libcurl into such a wrapper. A full version can be downloaded here.

https://www.rorohiko.com/downloads/rr612412/JSXGetURL.0.0.9.zip

It runs till June 30 of this year.

There is nothing to install, no admin privileges needed. You just need to add a folder with a few .jsx files to your ExtendScript project, and you can simply write ExtendScript like:

#include "JSXGetURL/JSXGetURLLoader.jsx"

var getURL = JSXGetURL();

var s = getURL.get("https://www.rorohiko.com");

alert(s.substr(0,1000));

and this works in InDesign Server, ExtendScript Toolkit, Bridge, InDesign, InCopy, Illustrator or whatever else supports ExtendScript, and it works both on Mac and Windows. And it’s very fast because it’s all compiled C/C++ code.

As it is, this thing now kind of supersedes my old ventures (https://coppieters.nz/?p=133 which uses CEP/node as a ‘servant’ to ExtendScript, and does not work on InDesign Server, and https://rorohiko.blogspot.com/2013/01/geturlsjsx.html which was pure JSX, a subset of http only, no https).

Anyway: if you’re interested in this ExtendScript enhancement and have ideas or questions, contact me at [email protected]

13 thoughts on “GetURL revisited”

  1. Sounds very interesting.
    Would it need to be recompiled for each version of InDesign, and separate versions for Mac/Windows?
    Would it be able to download a graphic file and place it into a document?
    Ariel

    1. No need to recompile, and the same set of files should work across all versions of Adobe apps. And there are no separate versions for Mac/Windows. In fact, there are, but both Mac and Windows (both in 64 and 32 bit) are included in the release, so you get a single, self-contained folder that has everything it needs. The same folder works on Mac, Windows and any reasonably recent version of the CC apps.

    2. And yes, it can download a graphic file. You first download, then use ExtendScript …place() to place it. That also works with ExtendExtendScript and the old GetURL() functions I wrote long time ago.

  2. Sounds great. I’d love to try it out.
    In your snippet above, if I’ve downloaded a jpeg, what sort of object will s be?

    1. It’s just a string. To write it out correctly, you need something like (from memory):


      var f = new File("...");
      f.encoding = "BINARY";
      f.open("w");
      f.write(s);
      f.close();

      and that works for writing out binary content in strings.

  3. Ok, that makes sense. But then I’d need some – is heuristics the word? – to figure out what file type it is, I guess.

    1. Yeah, I intend to fix that in a more capable version later on. I found that the ES-to-DLL API does not support non-null-terminated strings. Binary strings in ES are fine, but the API does not allow them to pass through 🙁

      So, the current alpha version has an optional file path param in the JSXGetURL.get() function to download straight to file.

      Later on, I’ll provide access to the HTTP headers with an enhanced version of JSXGetURL, which will allow you to check for the contentType. At the moment, all you can do is check the file name extension (if there is one), or inspect the downloaded content and do some smart recognition (which is not hard to do for the common image file formats).

  4. Hello, Kris. I tried it, with the sample file zipped and received an error when hit run. ESTK opens the JSXGetURLLoader.jsx and marks line 85 saying “I/O error” in statusbar. Is this something I’m making wrong?

    1. Make sure you have ‘Do Not Break On Guarded Exceptions’ selected in the Debug menu. The loader uses try-catch to figure out what to load (32 bit vs 64 bit). As 64 bit is most common it tries that first. ESTK is 32 bit so it will first throw on the 64 bit load, and then try the 32 bit version.

      Could that be the issue?

  5. Hello Kris,

    you’ve done a nice job, congrats !

    I’m looking for a way to upload files to HTTPS servers from an inDesign server on Windows. No way to use native Socket object so I was thinking I could use app.doScript with some VB (like this : https://github.com/grefel/restix/blob/master/restix.jsx) but when I read your POC, I just figure out your solution seems…hum…better 😉

    With your experience, what do you think about my problem ?
    Is there a chance you decide to open your code and/or accept contributions to implement things like files upload or multipart/form-data requests ?
    Thx.
    Wiser.

    1. I am planning on enhancing the current version and offer multipart, uploading, headers,…

      I am not currently intent on opening the source code. I contribute a fair bit of free and open source, and doing that earns me kudos, but I also have a family to feed. I am only a one-man-band and I need to figure out a way to strike a balance and get paid for at least some of the work I do.

      So, at the moment, the plan/experiment with this one is to make it freely available to anyone who wants it with a limitation that you need to download an update every year, and have no access to the source code. Small operators like me are used to and can normally live with such restrictions and can use the software for free. Large companies (I hope) won’t feel quite comfortable using my software, or might want additional, custom features, which they cannot get unless they have a support contract and/or access to the source code, so I might be able to get some support contracts out of it. It probably won’t work, but one can only try, eh.

  6. Thank your for your quick response !
    I completely understand your choices, I also hope you’ll be recompensed for your work. Here, in France we have a “phrase“ : “tout travail mérite salaire” wich can be translate by “all work merits salary”.
    Be sure I will follow closely your plugin improvements so let me wish you the best for the future !
    BR.

  7. Yes, there is a 2021 version, which runs until December 2021. You need to email me at [email protected] and I will send you a private link to download it. The 2021 version is not and will not be publicly available for the first few months of 2021. It’s only made available to people who personally request it via email.

Comments are closed.