Skip to main content
Known Participant
June 28, 2019
Answered

How to identify the page number of pasted image in Indesign file?

  • June 28, 2019
  • 2 replies
  • 1413 views

Hello,

I'm eager to know about, how to identify the page number of the pasted image in Indesign file through a script?

Any help on this highly appreciated.

This topic has been closed for replies.
Correct answer Manan Joshi

It's working in CS4. Although page 2 has two images. But the script showed only one image on page 2.

Thanks

Pramod


One of them is a group, try the following for CS4

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

{

    if(app.documents[0].allGraphics.itemLink == null)

    {

          var a = app.documents[0].allGraphics

          var parent = app.documents[0].allGraphics.parent

          while(parent.constructor.name != "Spread" && parent.constructor.name != "Page")

              parent = parent.parent

          if(parent.constructor.name == "Page")

              alert("Pasted image on " + parent.name)

          else if(parent.constructor.name == "Spread")

              alert("Pasted image on pasteboard")

    }

}

-Manan

2 replies

Known Participant
July 5, 2019

Hi Laubender,

I have already tested this script. It does not solve my problem. I need a script that shows pasted images page numbers. So that I can inform to client that supplied file has pasted images on those pages.

Thanks,

Pramod

Community Expert
July 5, 2019

Hi Pramod,

Try the following code snippet, it should serve your purpose

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

{

    if(app.documents[0].allGraphics.itemLink == null)

    {

          if(app.documents[0].allGraphics.parentPage)

              alert("Pasted image on " + app.documents[0].allGraphics.parentPage.name)

          else

              alert("Pasted image on pasteboard")

    }

}

-Manan

-Manan
Known Participant
July 5, 2019

Hi Manan,

Thanks for the code. I got an error when I run this code. Attached screen shot for your reference.

Thanks,

Pramod

Community Expert
June 28, 2019

Hi pramod_rawat ,

you have access to pasted images through the allGraphics array of the document.

To get the page see into the value of property parentPage of a graphic.

If the value of parentPage is null the graphic is positioned on a pasteboard outside a page.

How to see if the image is pasted?

The value of itemLink of the graphic is null .

Regards,
Uwe

Known Participant
June 28, 2019

Hi Laubender,

Thanks for your response. It would much appricated if you could send this script to me.

Thanks,

Pramod

Community Expert
June 29, 2019

Hi pramod_rawat ,

if your intention is to transform pasted images to linked image files, see into this script by Peter Kahrel:

Dump/unembed (and link) pasted images | Peter Kahrel

Regards,
Uwe