Copy link to clipboard
Copied
Hi all,
We are using InDesignCC for creating PDF files online.
This hapens with XML output. And on demand our customers can put variabel fields in en can generate a pdf to view the results.
Online it looks something like this:
This is the problem:
A textbox in InDesign have a fixed length. But the customers can give in a large text for this field. Larger than the tekstbox it self.
Now, default, InDesign sets the given text on to 2 lines.
Is there a script to be attached on a textbox that horizontaly scales the text to fit the textbox?
I hope someone can help.
thx
Copy link to clipboard
Copied
Hi,
Does this work:
var document = app.activeDocument
// Give your text item the name "fitText" (in InDesign, double click on the item in the layer panel)
var textFrame = document.textFrames.itemByName("fitText");
var minimumHorizontalScale = 50;
var horizontalScale = textFrame.parentStory.horizontalScale;
while(textFrame.overflows && horizontalScale > minimumHorizontalScale)
{
textFrame.parentStory.horizontalScale = horizontalScale--;
}
Copy link to clipboard
Copied
Hi,
According to our programmer this should work.
Put we have an issue. Is it possible and how: to execute this script automaticly when a file is opend and the file contains text item with the name "fittext". Do you know if this is possible?
Also, i have just manualy test the script you wrote and got this error:
it's in Dutch:
Object is niet geldig = Object is not valid
Regel =Line
Bron=Source
tnx
Copy link to clipboard
Copied
Hi,
Did you use the exact same name "fitText" in the InDesign document (mind the capital "T")?
Copy link to clipboard
Copied
Hi,
Yes i did.
And i have saved the notepad script as .js. is that correct?
Copy link to clipboard
Copied
Hi,
The script currently works without groups. Can you try without the grouping (ungroup the "fitText" item in InDesign).
Copy link to clipboard
Copied
Hi,
Manually It WORKS without grouping!
But i need grouping in order to make other scripts to work.
Can you adapt the script? I woulde be very greatfull!
Also, i have tried automatically to get it to work (without grouping) but it doesn't work.
Where do i have to place the script in order for indesign to auto run the script when the file is opened.
tnx
Copy link to clipboard
Copied
With grouping:
var document = app.activeDocument
var items = document.allPageItems;
var textFrame = null;
for(index = 0; index < items.length; index++)
{
if(items[index].name == "fitText")
{
textFrame= items[index];
}
}
if(textFrame != null)
{
var minimumHorizontalScale = 50;
var horizontalScale = textFrame.parentStory.horizontalScale;
while(textFrame.overflows && horizontalScale > minimumHorizontalScale)
{
textFrame.parentStory.horizontalScale = horizontalScale--;
}
}
For opening automatically, see:
Copy link to clipboard
Copied
Hi,
New script works perfectly with groups, tnx!
Only i now just can get it to run automatically.
I'm not a IT guy so i don't understand a lot on de page you send me.
I have donwloaded APID Toolkit's docLoaded and put it in the "startup scripts" in. Now when i open a file or indesign i get 2 errors. one from the APID script and one from de "fittext" script.
-Shouldn't the "fitText" script contain a line like "OpenAfter"?
- Or do i need to adapt the APID script?
I hope you can help me with this. I'm so close..
tnx
Copy link to clipboard
Copied
Hi,
I can't help you with that (need time to investigate it). We use InDesignServer for this kind of stuff.
Copy link to clipboard
Copied
Is this something that you are willing to do?
Maybe it's better to post a new Discussion?
Because i don't understand nothing about APID tool assistant/toolkit
tnx
Copy link to clipboard
Copied
@StyleM – the developers for APID Toolkit, Rorohiko, say "for InDesign CS – CS6". InDesign CC is not mentioned. Maybe it's not compatible with InDesign CC v9.x.0 ?
Uwe
Copy link to clipboard
Copied
Hi all,
The latest APID ToolAssistant is compatible with CC. We haven't updated the developer toolkit, but nothing has been changed to that part - only the 'runtime' plugin has been updated, and works fine with CC, so the Toolkit can be used with CC as long as you download the correct APID ToolAssistant version from our web site.
I have no clear idea what you're attempting to do but it sounds like you're mixing up things. InDesign has scriptable events, and APID ToolAssistant has scriptable events.
APID ToolAssistant predates the appearance of InDesign scriptable events by a few years (APID ToolAssistant was first released for InDesign CS), and the approach to events is totally different than what later became the InDesign standard model.
There is also a substantial amount of functional overlap - i.e. a lot of things can be done with one as well as with the other. But APID ToolAssistant does have some events or event functionality that InDesign does not provide.
I am not sure whether you even need APID ToolAssistant for this particular exercise. The standard InDesign events should cover the functionality you need. So, I'd take APID ToolAssistant out of the picture, and concentrate on the standard InDesign event model. Would that make sense?
P.S. If anyone has issues with APID ToolAssistant, we do provide support, hence it might be easier to e-mail support@rorohiko.com rather than post a question on this forum. I don't think there are many people on the forums who know much about APID ToolAssistant
(And we also provide Dutch- and French-language support if needed).
Cheers,
Kris
Copy link to clipboard
Copied
Tnx all especially 2i_Geert for the help.
It seem that i have made it work!
Copy link to clipboard
Copied
Hi 2i_Geert,
The last script (with grouping) works great. But i have encountered a problem.
I have attached your script to a free field that visitors of our webiste can use.
Your script works fine but when someone wants to give a lots of text in this field and the script hits de 50% (configurd in the script) mark remaining text is not shown.
Is it possible to adapt the script, so when some typs that much text and hits the 50% mark; that indesign the given text sets on to 2 lines with 100% horizontal scale (Indesign default)?
And when some stil keeps on typing that the script also scales the 2 lines antill they reach the 50% mark for both lines. After that they should contact us.
______________________________________________________________________________
Maybe usefull information:
In order to make your script work a had to adapt the textbox size in indesign:
Textbox before "fitText" script:
Textbox after "fitText" script:
Hope your or someone els can help me.
thanks a lot.