Copy link to clipboard
Copied
Hi all,
I need to validate if in Link panel - any linked /embedded file is present or not.
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 !!
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');
}
}
}
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
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.
Copy link to clipboard
Copied
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
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');
}
}
}
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.
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.