4 Replies Latest reply on Oct 7, 2013 3:40 PM by HectorBragado

    Exporting HTML

    HectorBragado Level 1

      Hi all,

       

      I'm trying to generate HTML content out of selected articles on my documents via JavaScript. I though it would be as easy as exporting a pdf but apparently is not. The only solution I can think of is this: tag every Paragraph Style, export the XML, apply XSLT and keep only the paragraph styles from the articles I want and then get the HTML.

       

      I think I can do that (not sure how it will turn out) but it seems to me a lot of going around... Any other ideas for this?

       

      Thanks in advance.

       

      Hector

        • 1. Re: Exporting HTML
          [Eric B]

          The approach you've described is the one we are using in our project and it works pretty well.

          • 2. Re: Exporting HTML
            HectorBragado Level 1

            Eric,

             

            Thanks, I'll try this way then. I'm kind of new to all this, so forgive if this is a stupid question. My main concern is this: how do you add, in the XSLT file, the CSS style for each tag, or paragraph style? (I have the CSS from exporting manually the HTML but not sure where to apply it here).

             

            And how do you get from Indesign, via exporting filtered XML and HTML and not an XML. Below my simple XSL with a line <xsl:output method="html"/> trying to export html but no success, still exports as xml. Again, I´m sure am missing something important.

             

            Also, how do you link an XSL to javascript?

             

            <?xml version="1.0" encoding="ISO-8859-1"?>

            <!-- Edited by XMLSpy® -->

            <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

             

            <xsl:output method="html"/>

            <xsl:template match="/">

             

            <link rel="stylesheet" type="text/css" href="StylePruebacss.css">

             

              <html>

              <body>

                  

                  <xsl:for-each select="Root/Story">              

             

                   <div><xsl:value-of select="BT1"/></div>

                

                  </xsl:for-each>

             

              </body>

              </html>

            </xsl:template>

            </xsl:stylesheet>

             

             

            Thanks again.

             

            Hector

            • 3. Re: Exporting HTML
              AnshulJain19 Adobe Employee

              Hi Hector,

               

              If you are trying to export a document to HTML whose content order is based on Articles panel using JavaScript then may be following script can help

               

              myDoc = app.activeDocument;

              myDoc.htmlExportPreferences.exportOrder = ExportOrder.ARTICLE_PANEL_ORDER;

              myDoc.exportFile(ExportFormat.HTML, <filePath>);

               

              Thanks

              -Anshul

              • 4. Re: Exporting HTML
                HectorBragado Level 1

                Thanks Anshul,

                 

                I wanted to export only one text frame from my document, so I changed your second line with those two and now I can export my selected story. Not sure if it's the best way but...

                 

                var mySelectedFrame = app.selection[0].parentStory;

                mySelectedFrame.exportFile(ExportFormat.HTML, (myFolder.fsName + "XXXXXXXX"));

                 

                mySelectedFrame.exportFile(ExportFormat.HTML, <filePath>);

                 

                 

                Thank you so much.

                1 person found this helpful