Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
11

Images is not Visible

Participant ,
Nov 24, 2023 Nov 24, 2023

Hi

 

I used the script to move the images from the top of the page to the bottom of the page. In that, I can't able to view the images placed at the bottom of the page. Please guide me on this...

 

 

var xOffset = 150;
var yOffset = 37.5;
var pageWidth = 480;
var pageHeight = 540;
var frameX = 60;
var frameY = 640;
var frameWidth = 50;
var frameHeight = 50;

var doc = app.activeDocument;
doc.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.POINTS;
doc.viewPreferences.verticalMeasurementUnits = MeasurementUnits.POINTS;

// Iterate through each page
for (var pageIndex = 0; pageIndex < doc.pages.length; pageIndex++) {
    var page = doc.pages[pageIndex];
    var currentPageHeight = page.bounds[2] - page.bounds[1];

    // Check if the page contains text frames
    if (page.textFrames.length > 0) {
        // Iterate through each text frame on the page
        for (var frameIndex = 0; frameIndex < page.textFrames.length; frameIndex++) {
            var textFrame = page.textFrames[frameIndex];

            // Check if the text frame has the specified XML markup tag
            if (textFrame.associatedXMLElement && textFrame.associatedXMLElement.markupTag.name == 'family_name') {
                // Move the text frame to the bottom of the page
                // Move the text frame to the bottom of the page
textFrame.move([textFrame.geometricBounds[1], currentPageHeight - textFrame.geometricBounds[2]]);

                
                // Iterate through associated image frames
              // Iterate through each text frame on the page
for (var frameIndex = 0; frameIndex < page.textFrames.length; frameIndex++) {
    var textFrame = page.textFrames[frameIndex];

    // Check if the text frame has the specified XML markup tag
    if (textFrame.associatedXMLElement && textFrame.associatedXMLElement.markupTag.name == 'family_name') {
        // Move the text frame to the bottom of the page
        textFrame.move([textFrame.geometricBounds[1], currentPageHeight - textFrame.geometricBounds[2]]);
        
        // Iterate through associated image frames
        for (var itemIndex = 0; itemIndex < textFrame.parentPage.allPageItems.length; itemIndex++) {
            if (textFrame.parentPage.allPageItems[itemIndex] instanceof Image) {
                var imageFrame = textFrame.parentPage.allPageItems[itemIndex];
                imageFrame.visible = true;
                textFrame.visible = true;
                var imageFrameHeight = imageFrame.geometricBounds[2] - imageFrame.geometricBounds[0];
                var newY = currentPageHeight - imageFrameHeight - 100; // Adjust this value based on your layout
                var newX = imageFrame.geometricBounds[1];

                // Move the image frame to the specified position on the page
                if (newY >= page.bounds[1] && newY <= page.bounds[2]) {
                    imageFrame.move([newX, newY]);
                }
            }
        }
    }
}

            }
        }
    }
}

 

 

 

MonishaRajendran_0-1700828581895.png

In the attached screenshot the text frame is at the top of the page but the image gets placed at the bottom of the page..

 

 

-Monisha
TOPICS
How to , Scripting
161
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Nov 24, 2023 Nov 24, 2023

Because your script moved image - contents of the frame / container - and not the frame / container. 

 

After this comment 

 

// Iterate through associated image frames 

 

You are iterating through allPageItems - which includes containers and their contents - so when you find image - you need to get its parent - and then move this parent. 

 

Translate
LEGEND ,
Nov 24, 2023 Nov 24, 2023
LATEST

Because your script moved image - contents of the frame / container - and not the frame / container. 

 

After this comment 

 

// Iterate through associated image frames 

 

You are iterating through allPageItems - which includes containers and their contents - so when you find image - you need to get its parent - and then move this parent. 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines