Copy link to clipboard
Copied
Is there a GREP etc way to find quickly all pages in a doc in which the text boxes have been manually shortened
Not doable via Grep but script may help. Try the following code.
var doc = app.documents[0];
var tolerance = 0.5; // in points — tweak if needed
for (var i = 0; i < doc.pages.length; i++) {
var page = doc.pages[i];
var mp = page.marginPreferences;
var top = page.bounds[0] + mp.top;
var bottom = page.bounds[2] - mp.bottom;
var left = page.bounds[1] + mp.left;
var right = page.bounds[3] - mp.right;
var marginWidth = right - left;
var marginHeight = bottom - top;
...
Copy link to clipboard
Copied
What would be the definition of shortened? Is it done by applying some object style? If so then you could find it else I don't think so it is possible via search. However, a script can do the job, if you define your needs in a bit more detail
-Manan
Copy link to clipboard
Copied
Hi Manan, so good of you to reply, thank you. It's a long document where all pages by default have the same height of text boxes. However, some of them have been manually shortened, by grabbing the handles on the bottom line and dragging the box up. I need to find all of the pages that have these shortened text boxes.
Copy link to clipboard
Copied
It's a long document where all pages by default have the same height of text boxes
Hi @defaultdeb30zd009k6 , Is there only one text frame per page, and is the text frame supposed to align to the page margins? Something like this:
Copy link to clipboard
Copied
Hi, so grateful for the replies, thank you. Yes, 1 text box per page, and the standard is for them to align with margins. However, for optimal flow / avoiding widows and bad word-breaks etc, some have been pulled up a line or two. Subsequently the text was then changed and everything moved, so I need to check for those short pages and adjust. This happens quite a lot in our typesetting process, so I'd be grateful to see if there's a easy way to check globally.
Copy link to clipboard
Copied
so I need to check for those short pages and adjust
A script could realign all the text frames to the margins—do you want all the text frames realigned to the margins?
Copy link to clipboard
Copied
Hi Rob, thank you for replying. Not really - I'm thinking of something akin to using GREP to search for a particular character or style, or preflight when it flags wrong sized pages etc, so I can whizz through the document without having to look at every single page.
Copy link to clipboard
Copied
Unless all the adjustments need to be the same a script is not going to work.
Copy link to clipboard
Copied
I don't know if I am understanding the problem statement properly. But isn't this about finding pages where the textframe has dimensions lesser or may greater than the area marked between the margins? That should be doable, right?
-Manan
Copy link to clipboard
Copied
Hi Manan, yes, that's exactly what is needed.
Copy link to clipboard
Copied
Not doable via Grep but script may help. Try the following code.
var doc = app.documents[0];
var tolerance = 0.5; // in points — tweak if needed
for (var i = 0; i < doc.pages.length; i++) {
var page = doc.pages[i];
var mp = page.marginPreferences;
var top = page.bounds[0] + mp.top;
var bottom = page.bounds[2] - mp.bottom;
var left = page.bounds[1] + mp.left;
var right = page.bounds[3] - mp.right;
var marginWidth = right - left;
var marginHeight = bottom - top;
if (page.textFrames.length > 0) {
var tf = page.textFrames[0];
var gb = tf.geometricBounds;
var tfHeight = gb[2] - gb[0];
var tfWidth = gb[3] - gb[1];
var widthDiff = Math.abs(tfWidth - marginWidth);
var heightDiff = Math.abs(tfHeight - marginHeight);
if (widthDiff > tolerance || heightDiff > tolerance) {
alert("Page " + page.name + " has a mismatched text frame.");
}
}
}
Do note the following
-Manan
Copy link to clipboard
Copied
Dear Manan, that is brilliant. Does the job perfectly. Thank you very much indeed. Most grateful.
Best wishes,
Sam
Copy link to clipboard
Copied
Thanks for the update Sam. Happy to help
-Manan
Find more inspiration, events, and resources on the new Adobe Community
Explore Now