Skip to main content
M.Hasanin
Inspiring
April 26, 2022
Answered

Trying to Access the Arrays of Images or Pdfs or Epss

  • April 26, 2022
  • 2 replies
  • 973 views

Hi Experts

I was playing with the arrays of Items, so i can access those types of arrays as you see i can get text frames or any items or polygons, also with the same method i can access the others like (ovals - rectangles - graphiclines) :

var allFrames = app.activeDocument.allPageItems;
var allFrames = app.documents[0].pages.everyItem().textFrames.everyItem().getElements(); 
var allFrames = app.documents[0].pages.everyItem().pageItems.everyItem().getElements(); 
var allFrames = app.activeDocument.pages.everyItem().polygons.everyItem().getElements(); 

 but i can't access the Images(content) or pdfs or epss in the containers like( rectangles - ovals - groups..etc), i tried for Images :

var allFrames = app.activeDocument.pages.everyItem().images.everyItem().getElements();

 also can't access pdf or epss :

var allFrames = app.activeDocument.pages.everyItem().epss.everyItem().getElements();

var allFrames = app.activeDocument.pages.everyItem().pdfs.everyItem().getElements();

what im trying to get is control their movements (like) :

var allFrames = app.activeDocument.pages.everyItem().groups.everyItem();
allFrames.move(undefined , [0 ,"100mm"]);

so this is working with all items except the (images - pdfs - epss) ?, maybe i miss something? or miss understand the correct way of access!, i get the error (object doesnt support the property or method (images - pdfs - epss)  message), so please help? and thanks in Advance

This topic has been closed for replies.
Correct answer Laubender

Thanks @Laubender a lot

Can i test if the Image (JPEG) is inside Oval or Rectangle frame? to add this condition? or this is not possible and thanks alot


You could. But you only get good results with objects that are not converted from e.g. type rectangle to type oval.

At least not when you resolve the specifier of the parent of a graphic with:

 

graphics[n].parent.getElements()[0] 

 

and ask for e.g. the constructor and its name:

 

graphics[n].parent.getElements()[0].constructor.name

 

 

Example:

When the user created an oval or a rectangle with the appropriate tool, like the Oval Frame tool or the Rectangle Frame tool and did not use the method to convert the object you can identify as Oval or Rectangle with the method above.

 

Regards,
Uwe Laubender

( ACP )

2 replies

Community Expert
April 26, 2022

Hi M. Hasanain,

you could loop the allGraphics array of the document.

That will also catch graphics or images that have no link in the Links panel.

Like ones where someone pasted a selection of pixels from e.g. PhotoShop to InDesign, just to name one example.

 

With properties like parentPage or imageTypeName you could build a list of e.g. EPS graphics that are on a particular page.

 

Regards,
Uwe Laubender

( ACP )

M.Hasanin
M.HasaninAuthor
Inspiring
April 26, 2022

Thanks a lot @Laubender @Manan Joshi 

now i understand what i miss

 

Mohammad Hasanin
Community Expert
April 26, 2022

Hi @M.Hasanin,

The error you get says it all, there are no such collections in the object model for you to access. What you can do rather is iterate the links collection and check the linkType property to identify the type of placed object. Run the following code and it will alert the type of each placed content.

for(var i = 0; i < app.documents[0].links.length; i++)
	alert(app.documents[0].links[i].linkType)

-Manan

-Manan