Mobile app version of vmapp.org
Login or Join
Nimeshi706

: Rescale EPS According to Text Size 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

@Nimeshi706

Posted in: #AdobeIndesign #Eps #Scale #Text #Vector

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.

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

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Nimeshi706

2 Comments

Sorted by latest first Latest Oldest Best

 

@Nimeshi706

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,
AnchorPoint.CENTER_ANCHOR,
ResizeMethods.MULTIPLYING_CURRENT_DIMENSIONS_BY, [desiredSize/textsize, desiredSize/textsize]);
obj.resize (CoordinateSpaces.INNER_COORDINATES,
AnchorPoint.CENTER_ANCHOR,
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)
{
file.close();
return m[1];
}
}
file.close();
// a reasonable default
return 10;
}


A few disclaimers:


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.
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.)
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.

10% popularity Vote Up Vote Down


 

@Ogunnowo857

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.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme