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

Why is an anchored image in my script of type 'object PDF'?

Community Beginner ,
Aug 12, 2021 Aug 12, 2021

Copy link to clipboard

Copied

Hello everyone,

I'm writing a script where some words should be replaced by anchored images. I can place the images but now I want to apply an object style to those images. I tried to use the method applyObjectStyle but I get the error 'applyObjectStyle is not a function'. I think the prolem lies with the object on which I want to perform the function. If I debug the type of the variable says 'object PDF'. I have no idea why. I'd expect it to be a graphic. This is my code:

app.findTextPreferences = NothingEnum.NOTHING;
app.findTextPreferences.findWhat = textToReplace;
var textObjects = openDoc.findText();

for (var i = 0; i < textObjects.length; i++) {
    var file = new File(imagesFolder + "/" + fileName);
    if (file.exists) {
       var icon = textObjects[i].place(file);
       textObjects[i].contents = "";
       var objectStyle = openDoc.objectStyles.itemByName(objectStyleName);
       icon.applyObjectStyle(objectStyle);
    }
}

 I've also tried the following, this one gives no error but also does not do anything. 

icon.appliedObjectStyle = objectStyle;

The following also returns an object PDF : 

textObjects[i].allGraphics[0].appliedObjectStyle = objectStyle;

 

TOPICS
Scripting

Views

107

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 , Aug 12, 2021 Aug 12, 2021

Hi Nysanna, When you import a .pdf or a .ai file it indesign stores it as a PDF object, so that part is normal. I don't think you can't style a PDF object directly. To apply the object style, try applying it to the PDF's parent, which will be a rectangle in your case.

icon.parent.applyObjectStyle(objectStyle);

 - Mark

Votes

Translate

Translate
Community Expert ,
Aug 12, 2021 Aug 12, 2021

Copy link to clipboard

Copied

Try applying the object style to icon.parent

 

Graphic is a superclass of PDF. I assume the placed icon is a PDF? The object style needs to be applied to the graphic's containing frame (ie icon.parent). 

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 ,
Aug 12, 2021 Aug 12, 2021

Copy link to clipboard

Copied

LATEST

Hi Nysanna, When you import a .pdf or a .ai file it indesign stores it as a PDF object, so that part is normal. I don't think you can't style a PDF object directly. To apply the object style, try applying it to the PDF's parent, which will be a rectangle in your case.

icon.parent.applyObjectStyle(objectStyle);

 - 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