Search code examples
htmlidml

html idml viewer


I am trying to implement a idml to html converter. I've managed to produce a single flat html file similar to the one produced by the indesign export.

What I would like to do is to produce html that will be as similar as possible to the indesign view like an html idml viewer. To do this, I need to find the text that can fit into a textframe, I can extract the story text content but I can't really find a way to split this content into frames/pages.

Is there any way I can achieve that?


Solution

  • Just extracting the text from a story isn't enough. The way the text is laid out is controlled by TextFrames in the Spread documents. Each TextFrame has a ParentStory attribute, showing which story it loads text from, and each frame has dimensions which determine the layout. For unthreaded text frames (ie. one story <> one frame), that's all you need.

    For threaded frames, you need to use the PreviousTextFrame and NextTextFrame attributes to create the chain. There is nothing in the IDML to tell you how much text fits in each frame in a threaded chain, you need to do the calculation yourself based on the calculated text dimensions (or using brute force trial and error).

    You can find the spreads in the main designmap.xml:

    <idPkg:Spread src="Spreads/Spread_udd.xml" />
    

    And the spread will contain one or more TextFrame nodes:

    <Spread Self="udd" ...>
        <TextFrame Self="uf7" ParentStory="ue5" PreviousTextFrame="n" NextTextFrame="n" ContentType="TextType">...</>
        ...
    </Spread>
    

    Which will in turn link to a specific story:

    <Story Self="ue5" AppliedTOCStyle="n" TrackChanges="false" StoryTitle="$ID/" AppliedNamedGrid="n">...</>
    

    (In this example the frames are not threaded, hence the 'n' values.

    All this is in the IDML documentation, which you can find with the other InDesign developer docs here: http://www.adobe.com/devnet/indesign/documentation.html