Skip to main content
Inspiring
Oct 25, 2026 6:39 PM UTC
Answered

indesign SDK example—BasicTextAdornment, It seems that it cannot store relevant information in the exported IDML file.

In this example, the intention is for the newly added text attribute, `kBscTAAttrBoss`, to be saved into the IDML file. While the relevant script methods appear to have been implemented, the value corresponding to `kBscTAAttrBoss` is not actually being saved to the IDML file. Is this a bug in the sample code?Thank you. 

    KohakuNekotarou
    KohakuNekotarouCorrect answer
    Inspiring
    Oct 26, 2026 12:16 PM UTC

    The cause is that the sample is a UI plug-in (kUIPlugIn in BscTA.fr), while the Export UI writes IDML asynchronously, on a background thread. Bosses from UI plug-ins cannot be instantiated on a background thread ("the system behaves as if the plug-in were missing and returns a nil pointer"), so the export never sees the text attribute (kBscTAAttrBoss) or its script provider, and the attribute is silently left out of the IDML.

    A script that calls exportFile writes the IDML synchronously on the main thread, so the attribute is written (BasictextadornmentShade="true" on the CharacterStyleRange) and comes back when the IDML is opened. asynchronousExportFile behaves like File > Export and loses it.

    To fix the sample, move everything that ends up in the document (the text attribute, the adornment, the script provider, the error string service and the document responder) into a model plug-in (kModelPlugIn), and keep only the menu actions (the action component and MenuDef/ActionDef) in a separate UI plug-in. I tested a model-only build with the menu actions removed: both exportFile and asynchronousExportFile kept the attribute, and the adornment came back on reopening.

    See the Plug-In Programming Guide, Volume 1: "Multithreading" ("Features that use multithreading" and "Rules for thread safety") and "Model and UI Separation".

    Tested on InDesign 2026 (21.0), Windows.

    10 replies

    Olivier Beltrami
    Legend
    Oct 27, 2026 5:18 AM UTC

    We are also adding persistent frame data to text frames in our plugin using InterfacePtr<IFrmLblData> and this works fine. But if any of these INDD files are saved to IDML then all the persistent frame data is lost. It might be WAD ?

    Translate
    KohakuNekotarou
    KohakuNekotarouCorrect answer
    Inspiring
    Oct 26, 2026 12:16 PM UTC

    The cause is that the sample is a UI plug-in (kUIPlugIn in BscTA.fr), while the Export UI writes IDML asynchronously, on a background thread. Bosses from UI plug-ins cannot be instantiated on a background thread ("the system behaves as if the plug-in were missing and returns a nil pointer"), so the export never sees the text attribute (kBscTAAttrBoss) or its script provider, and the attribute is silently left out of the IDML.

    A script that calls exportFile writes the IDML synchronously on the main thread, so the attribute is written (BasictextadornmentShade="true" on the CharacterStyleRange) and comes back when the IDML is opened. asynchronousExportFile behaves like File > Export and loses it.

    To fix the sample, move everything that ends up in the document (the text attribute, the adornment, the script provider, the error string service and the document responder) into a model plug-in (kModelPlugIn), and keep only the menu actions (the action component and MenuDef/ActionDef) in a separate UI plug-in. I tested a model-only build with the menu actions removed: both exportFile and asynchronousExportFile kept the attribute, and the adornment came back on reopening.

    See the Plug-In Programming Guide, Volume 1: "Multithreading" ("Features that use multithreading" and "Rules for thread safety") and "Model and UI Separation".

    Tested on InDesign 2026 (21.0), Windows.

    Translate
    Community Expert
    Oct 26, 2026 12:19 PM UTC

    Ahh, good catch ​@KohakuNekotarou seems the sample was never updated after this model UI separation was needed. If one had used the debug version of InDesign it would complain about it.

    Translate
    -Manan
    Community Expert
    Oct 26, 2026 4:47 AM UTC

    Which version of SDK are you using. Where are you checking in the IDML. Does the sample say it should save it? Was it working it previous versions of SDK?

    Translate
    -Manan
    lyj2871Author
    Inspiring
    Oct 26, 2026 5:15 AM UTC

    It seems this doesn't work in any version; I’m using the latest version, and it still fails. When I export to an IDML file and then open that file, the effects I created in the example are lost. The reason is that the `kBscTAAttrBoss` value is not being saved into the IDML file.

    Translate
    Community Expert
    Oct 26, 2026 5:34 AM UTC

    Yeah that is what I was thinking this may not be working ever. I never looked into the details of this sample in this respect so I was asking if it ever worked. Old sample rarely get any new updates so it is what it is. You can look at persisting the adornment. I suppose it is an attribute on text or something, been years since I looked into that.

    Translate
    -Manan