Skip to main content
Trevor:
Legend
December 24, 2014
Question

Map Paragraph and Character Styles

  • December 24, 2014
  • 1 reply
  • 1860 views

Hello all,

I am trying to import Word documents based on the Word Import Preset documents.

Here's an example smp document

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<Sangam-Import-Preset reader-type="Word/RTF">

    <!--Style mappings take the form of key-value pairs consisting of:

style-name: Source document's style name, for example RTF style name.

This attribute is mandatory and the value cannot be an empty string.

mapped-to: Target InDesign document's style name.

This attribute is mandatory but can take an empty string as its value.-->

    <Style-Mappings>

        <Paragraph-Style-Mappings>

            <Mapping style-name="Body Text" mapped-to="Body 2" />

            <Mapping style-name="Heading 1" mapped-to="Heading 1" />

            <Mapping style-name="Normal" mapped-to="Normal 2" />

        </Paragraph-Style-Mappings>

        <Character-Style-Mappings>

            <Mapping style-name="Hyperlink" mapped-to="Hyp" />

        </Character-Style-Mappings>

    </Style-Mappings>

    <!--Each Import Preference has two mandatory attributes:

name: Name of the preference (cannot be an empty string).

value:Value of the preference (cannot be an empty string).

For boolean preferences, type 0 for false and 1 for true.-->

    <Import-Preferences>

        <Preference name="import-toc" value="1" />

        <Preference name="import-index" value="1" />

        <Preference name="import-hyperlink" value="1" />

        <Preference name="import-tables" value="1" />

        <Preference name="import-footnotes" value="1" />

        <Preference name="import-endnotes" value="1" />

        <Preference name="import-track-changes" value="1" />

        <Preference name="import-preserve-graphics" value="1" />

        <Preference name="spacing" value="1" />

        <Preference name="break-before-para" value="0" />

        <Preference name="use-typographers-quotes" value="1" />

        <Preference name="convert-tables-to" value="0" />

        <Preference name="remove-formatting" value="0" />

        <Preference name="dont-strip-char-formatting" value="0" />

        <Preference name="bring-unused-styles" value="0" />

        <Preference name="para-style-clash-option" value="0" />

        <Preference name="char-style-clash-option" value="0" />

        <Preference name="use-style-mappings" value="1" />

        <Preference name="convert-BN-to-text" value="0" />

    </Import-Preferences>

</Sangam-Import-Preset>

Everything should be easy to set in the WordRTFImportPreference except for the mappings.

I tried using app.activeDocument. paraStyleMappings.add("Normal","Normal 2",   MapType.STYLE_MAPPING_RULE) after setting app.generalPreferences.mapStylesOnContentPlace = true

Doesn't work . I suspect the mappings are only good for XML placements and not Word ones, in which case I guess the way to do it would be to us changeText() on the styles.  This is not a great solution as the changes would be done after placement unlike when using the UI before the placement.

Has anyone done this or got any ideas?

Regards,

Trevor

1 reply

Community Expert
May 30, 2018

Hi Trevor,

sorry for reviving this old thread, but:

Did you find a solution to load a particular smp document to app.wordRTFImportPreferences ?

Available files are stored in:

~/AppData/Roaming/Adobe/InDesign/Version%2013.0/de_DE/Word-Importvorgaben/

for my German InDesign CC 2018.1 on Windows 10.

I bolded the variable parts of the path. They depend on version and localization.

Regards,
Uwe

Trevor:
Trevor:Author
Legend
May 30, 2018

Hi Uwe

I didn't find a solution.

I'll try have a look tomorrow at a file.

I don't have a Word import folder so I guess I need to save a preset first so it's created.

Regards

Trevor