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

Explorer ,
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

639

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Mentor ,
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

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Engaged ,
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

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Explorer ,
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

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Adobe Community Professional ,
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.

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Mentor ,
Jun 28, 2019

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more