• Global community
    • Language:
      • Deutsch
      • English
      • EspaƱol
      • FranƧais
      • PortuguĆŖs
  • ę—„ęœ¬čŖžć‚³ćƒŸćƒ„ćƒ‹ćƒ†ć‚£
    Dedicated community for Japanese speakers
  • ķ•œźµ­ ģ»¤ė®¤ė‹ˆķ‹°
    Dedicated community for Korean speakers
Exit Search
0

Validation of Link panel values through jsx.

Adobe Employee ,
Dec 05, 2022 Dec 05, 2022

Copy link to clipboard

Copied

Hi all,

I need to validate if in Link panel - any linked /embedded file is present or not.

Daksri_0-1670240318312.png

Like above , need to validate if particular gif link is present in Link panel or not. Is there any way to validate this ?

 

Thanks in Advance !!

TOPICS
Scripting

Views

412

Translate

Translate

Report

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

Community Expert , Dec 05, 2022 Dec 05, 2022

Hi @Daksri 

If you want to check whether the file exists on the location from where it was placed, you can try the following version. 

var pageItems = app.activeDocument.pageItems;
for (var p = 0; p < pageItems.length; p++) {
    var _item = pageItems[p];
    if (_item.typename == 'RasterItem' || _item.typename == 'PlacedItem') {
        try {
            var _file = File(_item.file);
        } catch (e) {
            alert('Link does not exists');
        }
    }
}

 

Votes

Translate

Translate
Community Expert ,
Dec 05, 2022 Dec 05, 2022

Copy link to clipboard

Copied

Hi @Daksri I think it is possible. But please be explain exactly what you want. For example, do you want to validate only a particular gif, ie. a gif at a particular file path? or just name of gif file? or any gif in document? Also what do you mean validate? Check that it exists and isn't "missing"?

- Mark

Votes

Translate

Translate

Report

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
Adobe Employee ,
Dec 05, 2022 Dec 05, 2022

Copy link to clipboard

Copied

Thanks for replying ! .I need to check if in Link Panel file is listed or not , if any file is placed on the document.

Votes

Translate

Translate

Report

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
Community Expert ,
Dec 05, 2022 Dec 05, 2022

Copy link to clipboard

Copied

LATEST

Hi @Daksri, based on what seem to be asking, @Charu Rajput's script snippet shows that. All PlacedItems and all RasterItems appear in the Link Panel. But only some have a File (their file property). So Charu's script loops over all page items, and shows alert if a PlacedItem or RasterItem has no file.

 

Can you clarify exactly what you want? We are having trouble understanding. For example, do you want script to report that the document contains a PlacedItem with a valid File? Or that document contains any PlacedItem or RasterItem?

 

Please try to be very specific, for example in your specification I need to check if in Link Panel file is listed or not what is file, and do you mean listed meaning visible as a line in the panel, even if the image is embedded with no File?

- Mark

Votes

Translate

Translate

Report

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
Community Expert ,
Dec 05, 2022 Dec 05, 2022

Copy link to clipboard

Copied

Hi @Daksri 

If you want to check whether the file exists on the location from where it was placed, you can try the following version. 

var pageItems = app.activeDocument.pageItems;
for (var p = 0; p < pageItems.length; p++) {
    var _item = pageItems[p];
    if (_item.typename == 'RasterItem' || _item.typename == 'PlacedItem') {
        try {
            var _file = File(_item.file);
        } catch (e) {
            alert('Link does not exists');
        }
    }
}

 

Best regards

Votes

Translate

Translate

Report

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
Adobe Employee ,
Dec 05, 2022 Dec 05, 2022

Copy link to clipboard

Copied

Thanks @Charu Rajput  for replying !! Here you are validating if file is placed or if it is raster or not . But I need to validate it through Link Panel , that If any file is placed on the document , whether it is  listed on link panel or not. 

Votes

Translate

Translate

Report

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
Community Expert ,
Dec 05, 2022 Dec 05, 2022

Copy link to clipboard

Copied

Hi @Daksri 

The above version does not check whether the file is placed or not, or if it is Raster or not.

What you have written still it is not much clear, may be you post some screenshots to expplain. If there is any file in the Link then it must be placed in the document, otherwise, the link will not show in the Link panel.

Best regards

Votes

Translate

Translate

Report

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