Skip to main content
Known Participant
March 21, 2025
Question

Fast way to double check all text frame alignment in book project

  • March 21, 2025
  • 3 replies
  • 681 views

Hi,

I am currently working on a large book layout and want to double-check that all my text frames are aligned correctly. I realized that sometimes during the design process, I accidentally moved the frames and am worried that there are areas I forgot to correct. Is there a fast way to double-check this without needing to go through every page? I thought the preflight tool might work, but it doesn’t seem like it’s possible.

 

Thank you!

3 replies

Peter Spier
Community Expert
Community Expert
March 22, 2025

Here's my contrarian opinion. You SHOULD scroll through the entire document, preferably the PDF you are planning to submit to the printer. There is NO SUBSTITUTE for a human examination.

Robert at ID-Tasker
Legend
March 22, 2025

But in Spreads view and without smooth scrolling - so it will be easier to spot inconsistencies.

 

Community Expert
March 21, 2025

I've several scripts that make text file reports and I've had a look at this and it works IF you only have single text frame per page, I guess I would need to see the file to see what is required to be always aligned. 

 

It's a bit vague the query - but as I typically only  have 1 text frame per page, I have gone with this 

Select a text frame that's in the correct position 

Then run the script 

There's a tolerance built in because I have a tolerance setting for another script I have for something else, thought it might be useful here. 

 

Then it makes a report on your desktop in a text file. 


If it needs to be more specific or needs any other parameters I guess I'd need to know more.

 

Let us know 

if (app.documents.length === 0) {
    alert("No documents are open. Please open a document and try again.");
    exit();
}

var doc = app.activeDocument;

// Ensure a single text frame is selected as the reference.
if (app.selection.length !== 1 || !(app.selection[0] instanceof TextFrame)) {
    alert("Please select a single text frame that you know is correctly positioned.");
    exit();
}

var referenceFrame = app.selection[0];
var refBounds = referenceFrame.geometricBounds; // in points

// Conversion function from points to millimetres.
function ptToMM(pt) {
    return pt * 0.35278;
}

// Function to get local coordinates relative to a page's origin.
// It subtracts the page's top and left from the frame's top and left.
function getLocalCoordinates(frame) {
    var page = frame.parentPage;
    if (!page) {
        // Fallback to absolute if no parent page is available.
        return { top: frame.geometricBounds[0], left: frame.geometricBounds[1] };
    }
    var pageBounds = page.bounds; // [top, left, bottom, right] in points
    var frameBounds = frame.geometricBounds;
    return { 
        top: frameBounds[0] - pageBounds[0], 
        left: frameBounds[1] - pageBounds[1]
    };
}

// Ensure the reference frame has a parent page.
var refPage = referenceFrame.parentPage;
if (!refPage) {
    alert("Reference frame does not have a parent page.");
    exit();
}

// Compute local coordinates for the reference frame.
var refLocal = getLocalCoordinates(referenceFrame);

// Ask the user for an acceptable alignment threshold in millimetres.
var thresholdInput = prompt("Enter the alignment threshold in millimetres", "1");
var thresholdMM = parseFloat(thresholdInput);
if (isNaN(thresholdMM)) {
    alert("Invalid threshold value. Please try again with a numeric value.");
    exit();
}

// Build the report header.
var report = "Misaligned Text Frames Report\n";
report += "-----------------------------------\n";
report += "Reference Frame Local Position (mm): Top = " 
          + ptToMM(refLocal.top).toFixed(2) + ", Left = " 
          + ptToMM(refLocal.left).toFixed(2) + "\n";
report += "Threshold: " + thresholdMM + " mm\n\n";

var misalignedCount = 0;

// Loop through each page and each text frame.
for (var i = 0; i < doc.pages.length; i++) {
    var page = doc.pages[i];
    var textFrames = page.textFrames;
    for (var j = 0; j < textFrames.length; j++) {
        var tf = textFrames[j];
        // Skip the reference frame.
        if (tf === referenceFrame) continue;
        
        // Compute the frame's local position.
        var localPos = getLocalCoordinates(tf);
        var diffTopMM = Math.abs(ptToMM(localPos.top) - ptToMM(refLocal.top));
        var diffLeftMM = Math.abs(ptToMM(localPos.left) - ptToMM(refLocal.left));
        
        // Flag the frame if the difference exceeds the threshold.
        if (diffTopMM > thresholdMM || diffLeftMM > thresholdMM) {
            misalignedCount++;
            var frameName = tf.name !== "" ? tf.name : "Unnamed";
            var pageNum = tf.parentPage ? tf.parentPage.name : "Unknown";
            var info = "Page " + pageNum + " - Frame (" + frameName + "): Local Diff -> Top: " 
                       + diffTopMM.toFixed(2) + " mm, Left: " + diffLeftMM.toFixed(2) + " mm\n";
            report += info;
        }
    }
}

if (misalignedCount === 0) {
    report += "All text frames are aligned within the specified threshold.";
}

// Ask the user where to save the report.
var reportFile = File.saveDialog("Save the alignment report as", "*.txt");
if (reportFile) {
    reportFile.open("w");
    reportFile.write(report);
    reportFile.close();
    alert("Report saved successfully to: " + reportFile.fsName);
} else {
    alert("Report was not saved as no file was selected.");
}

 

 

MateomonoAuthor
Known Participant
March 22, 2025

hi @Eugene Tyson

Thank you for your input! My document has only one frame per page. I don’t really have any experience with scripts. How should I do this

 
Community Expert
March 22, 2025

https://creativepro.com/how-to-install-scripts-in-indesign/

 

For this script, once you have it installed. 

 

Select the frame in the correct position. 

 

Run the script. 

And follow the instructions. 

 

The tolerance is mm, so if you want you adjust by how much you want to allow, it could be 1mm or .2mm or 3mm I didn't know what you're happy with. Set to 0 if you want m

 

It then generates a text file detailing the page and difference. 

 

Then you can go to each page and fix. 

 

Can it possibly correct all? Maybe I'd have to look into a script that can modify the position. 

 

 

Robert at ID-Tasker
Legend
March 21, 2025

If you work on a PC - you could use free version of my ID-Tasker tool.

 

You can load complete structure of your document - then sort / filter by any property.

 

In your case - you would have to hide everything but TextFrames, then sort by POS X. 

 

Then sort by WIDTH - to find TextFrames with a different widths. 

 

You can also limit your search to only specific Layer(s) or applied ObjectStyle, etc. 

 

If you find any discrepancies - double click will instantly get you there.