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

Map Paragraph and Character Styles

Guru ,
Dec 24, 2014 Dec 24, 2014

Copy link to clipboard

Copied

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

TOPICS
Scripting

Views

1.4K

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 ,
May 30, 2018 May 30, 2018

Copy link to clipboard

Copied

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

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
Guru ,
May 30, 2018 May 30, 2018

Copy link to clipboard

Copied

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

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
Guru ,
Jun 01, 2018 Jun 01, 2018

Copy link to clipboard

Copied

Sorry Uwe, I won't be able to look into this until Sunday.

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 ,
Jun 01, 2018 Jun 01, 2018

Copy link to clipboard

Copied

No problem, Trevor.

Currently I see no chance, but I will also try some things over the weekend.

Regards,
Uwe

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
Guru ,
Jun 04, 2018 Jun 04, 2018

Copy link to clipboard

Copied

Hi Uwe,

I didn't have any chance to try out anything but the way that one could possibly go is to use duplicate the word document and then using the smp map rename the style names in the duplicate file using vbs / powshell / applescript or some npm package

There might be a npm the you can call strait from ExtendScript, you'll have to check. I have used one for Excel that is very good for reading and writing / changing xlxs files from ExtendScript there might well be one that does the same for docs files but the vbs / applescript is probably very simple even without any experience in it as long as you have access to a site like Google.

Once the Word files been manipulated you can just import it as is and it will "be mapped"

Regards

Trevor

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
Guru ,
Jun 04, 2018 Jun 04, 2018

Copy link to clipboard

Copied

I did a quick search for renaming Word styles renaming Word styles with VBA - Stack Overflow

ActiveDocument.Styles(3).NameLocal = "abbracadabra"

You could build up a script dynamically and then call a doScript.

If multiple Word styles are mapped to the same InDesign style then one could have the script change the applied Word style to to the relevant style.

The problem with this method is that the client needs to have Word installed it could well be that one of the npm packages doesn't require Word and would also work quicker as it would work on the file contents without processing the "live / open" 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 ,
Jun 05, 2018 Jun 05, 2018

Copy link to clipboard

Copied

Hi Trevor,

thank you very much. I will look into the links.

Still I like to find a way with InDesign only.

( Couldn't test anything at the weekend, though. )

Thanks,
Uwe

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
Enthusiast ,
Sep 24, 2021 Sep 24, 2021

Copy link to clipboard

Copied

LATEST

Hello, @Laubender.

Any advance or news about style-mapping or Word Import Presets in InDesign DOM?
I'm working on a batch word import/save as indd and this is painful.

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