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

How can I split a .fm document based on the h1/h2 headings using extended script?

Explorer ,
Jun 25, 2019 Jun 25, 2019

Copy link to clipboard

Copied

I have a .fm document that I need to split into multiple files based on h1 or h2 paragraph tags. The headings and its content should be copied or saved/split into separate files.

TOPICS
Scripting

Views

827

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
Mentor ,
Jun 26, 2019 Jun 26, 2019

Copy link to clipboard

Copied

Hi, your question is broad. I know how I would do it and I think several others would too, but no one is likely to write a script for you. I would do something like:

1) Set up a template to receive the h1/h2 sections, that I will paste in the content and Save As to the separate files.

2) Starting with the first paragraph in the flow (probably something like doc.MainFlowInDoc.FirstTextFrameInFlow.FirstPgf), iterate through all paragraphs (pgf.NextPgfInFlow).

3) At each h1 or h2 paragraph (pgf.name=="h1" etc.) remember the paragraph object. Then go to the next h1/h2 pgf and remember the previous paragraph.

4) Create a text range between the two paragraphs, select the text, and copy the text to the clipboard. You could also cut.

5) Paste it over the contents of the template and do a save as

6) Keep iterating.

All of these steps require substantial expertise. I don't know what your current skill level is. Likely, you won't get too much more help unless you come here with more specific questions.

Russ

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
Engaged ,
Jun 26, 2019 Jun 26, 2019

Copy link to clipboard

Copied

my approach to solve such problems is a Little unconventionial, but it worked well in several Scenarios my projects

1. Create a EDD with a flat structure (only p, tables and some Special object like graphics, xrefs) and assign Paragraph styles by attributes

2. Import this EDD in your template (nothings changes)

3. create a simple Conversion table which generates that flat structure (Standard Generation gives a good starting Point)

4. convert document to a structured one via conversion table

5. Setup a simple XML application

6. Add an XSLT as postprocess which splits documents, when document is saved to XML

7. Select "File Save As XML"

8. open splitted XML files angain and save it as FM binaries. Remove structure

9. create a simple scripts which automates save and open actions

All is done with FM board functionality with only a Little bit scripting

Hope this helps

Markus

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
Explorer ,
Jun 26, 2019 Jun 26, 2019

Copy link to clipboard

Copied

Thanks Russ. I'll explain what I want exactly.

I have a following .fm file:

h1_1

text

    h2_1

    text

h1_2

text

    h2_2

    text

h3_3

text

    h2_3

    text

I want al the h1 headings (including the content under it) to be copied and saved in separate .fm files as following:

h1_1

text

    h2_1

    text

h1_2

text

    h2_2

    text

h3_3

text

    h2_3

    text

Hope this makes it more clear.

Thanks,

S

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 27, 2019 Jun 27, 2019

Copy link to clipboard

Copied

What you want makes perfect sense. Do you have any budget for this? If you can provide a sample document or two, I will give you a quote for a script. This is involved enough where I would not do it for free on the forum.

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
Mentor ,
Jun 28, 2019 Jun 28, 2019

Copy link to clipboard

Copied

LATEST

Yeah, I get it too. I don't think there was too much question about what you wanted to do. The problem is that you are asking for too much here. This is a good place for focused questions about specific issues, but not a place to get free scripts. We like to help, but nobody is likely to have hours to spend on free development for strangers.

Russ

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