I searched a long time already for an elegant way but couldn't find an option. I am using InDesign CS5 and wanted to know how to scale an EPS (or any other vector-) graphic that I inserted to my poster according to its text size.
The EPS file that I have contains chemical reaction schemes with element symbols and bonds and so on (made by ChemDraw). The text that is included in this file is still a text text (I didn't convert it into curves or anything). Now I am searching for the power to enlarge these reaction schemes by telling the program to make the font for example 20 pt big and every other element of this vector graphic should be enlarged proportionally.
The reason why I am asking this, is that I have multiple of those images but they are not imported with the same size but I would like to display them uniformly all over the poster or document.
The dirty way would be to write text with the desired size next to it and rescale the scheme until the font sizes match. However, as soon as it is necessary for one scheme to be a little smaller, I would have to repeat the whole process for every single graphic.

download of dummy EPS file (the file is called "wilkinson.eps" in reference to the catalyst)

  • Well, you could fish this metric from the eps itself Is it possible for you to share a representative dummy version?
    – joojaa
    Jul 16, 2015 at 13:28
  • Hi Crystal, welcome to GDSE and thanks for your question. If you want to know more about the site, please see the help center or ping one of us in the Graphic Design Chat once your reputation is sufficient (20). Keep contributing and enjoy the site!
    – Vincent
    Jul 16, 2015 at 13:50
  • Thank you for your warm welcome! I prepared a download link for an EPS file example. Does that suffice or would something else help? Jul 16, 2015 at 14:30

2 Answers 2


Observing that the EPS file uses PDF-style syntax, I noted that the text scaling is done with Tf:

8 0 0 8 5.327283 18.119995 Tm

The 6 numbers are a transformation matrix, where the first number (8) is the x scale and the fourth number (also, as it happens, 8) is the y scale of the text. You have to pick one (well, usually) – I picked the first number.

Next, getting hold of the image file from any selection. You can test if a selection (either 'direct' or its parent rectangle) is any graphic, and if so, what its textual description is: imageTypeName. For my version of InDesign, this is "EPS".

A linked file gives access to its original full path name, and as the EPS is a simple plain text format, you can then read it one line at a time and test with a regular expression for the first Tf command to come along. This, the function scanFile, returns the actual text size. Multiplying this by the object's scale gives the effective text size, at the scale currently in your document. Then all that's left is issuing 2 resize commands: one for the container rectangle, and one for the containing image.

The following Javascript does all this on a selected EPS. Save as scaleEPS.jsx in your User/Scripts Panel folder. Change the desiredSize at the top to your wanted size, or replace it with the line

desiredSize = Number(prompt("Size", "10"));

to enter it for each separate run if you need different sizes for each run.

//DESCRIPTION:Scale EPS Image for Text
// A Jongware Script 17-Jul-2015
var desiredSize = 12;

if (app.selection.length == 1)
    obj = app.selection[0];
    if (obj.hasOwnProperty('graphics') && obj.graphics.length == 1)
    obj = obj.graphics[0];
    if (obj instanceof EPS ||
        (obj instanceof Graphic && obj.imageTypeName == "EPS"))
        textsize = scanFile (obj.itemLink.filePath);
        textsize *= obj.horizontalScale/100;
        obj.parent.resize (CoordinateSpaces.INNER_COORDINATES,
            ResizeMethods.MULTIPLYING_CURRENT_DIMENSIONS_BY, [desiredSize/textsize, desiredSize/textsize]);
        obj.resize (CoordinateSpaces.INNER_COORDINATES,
            ResizeMethods.MULTIPLYING_CURRENT_DIMENSIONS_BY, [desiredSize/textsize, desiredSize/textsize]);

function scanFile (fullpath)
    var file = File(fullpath)
    if (file.open('r') == false)
        return 0;
    var m;
    while (!file.eof)
        m = file.readln().match(/^(\d+(\.\d*)?)( (\d+(\.\d*)?)){5} Tm/);
        if (m)
            return m[1];
    // a reasonable default
    return 10;

A few disclaimers:

  1. This script assumes you are placing EPS files, created through ChemDraw and saved exactly like your sample file. It Will Not Work (most likely) with any random EPS.
  2. It returns the size of the first text item in the EPS. If there are multiple different sizes, you wouldn't know which one to use anyway. The texts in your file are all the same – well, kind of. The subscript numbers are a bit smaller. If you are really unlucky, you may come across a file where the first text is actually in super- or subscript; and then that size will be reported. (Computers famously do what you tell 'em to do, not what you meant it to.)
  3. It is assumed both image and containing rectangle can safely scale from the center. You will see this fail if you crop off a bit on one side only.

This is a very simple procedure. what do you what to know exactly is how much enlarging (in percentage) a text from 18pt to 20pt.

Just measure the text before enlarging it (in pixel or mm) and measure it after enlarging it. then do some calculation, and this will be the ratio that you must enlarge the whole drawing with.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.