16 Replies Latest reply on Jun 27, 2010 10:00 AM by Marco Lugli

    Indisign scripting and cross-media export -> Xhtml / Dreamweaver

    Serge2k

      Hi.

      I've searched for the solution but haven't found it yet. Hope you'll help me.

      I need to write a script which will transform all indd files in the selected folder to xhtml. But I cannot find methods for exporting files to xhtml in JS (like menu -> File -> Cross-media export -> Xhtml / Dreamweaver). Is it possible? how?

       

      P.S. Using CS3

       

      Thanks

        • 1. Re: Indisign scripting and cross-media export -> Xhtml / Dreamweaver
          Dave Saunders Level 4

          This is how I did something similar in CS4 just the other day. It should be easy to adapt:

           

                  var mainMenu = app.menus[0];
                  var fileMenu = mainMenu.submenus.item("File");
                  var xMediaItem = fileMenu.menuElements.item("Cross-media Export");
                  var xPortItem = xMediaItem.menuItems.item("XHTML / Digital Editions...");
                  var action = xPortItem.associatedMenuAction;
                  action.invoke();

           

          Dave

          1 person found this helpful
          • 2. Re: Indisign scripting and cross-media export -> Xhtml / Dreamweaver
            Serge2k Level 1

            Thanks Dave. But it is still not very clear how to pass the export paramerters.

            • 3. Re: Indisign scripting and cross-media export -> Xhtml / Dreamweaver
              Serge2k Level 1

              Is there any possibility to interract with dialog boxes witch appear after executing action of the menu item?

              • 4. Re: Indisign scripting and cross-media export -> Xhtml / Dreamweaver
                sudar1983_14 Level 2

                Hi Serge,

                 

                The following script used to transform indesign to xhtml, Javascript / CS3 / Windows

                 

                app.scriptPreferences.version = 5.0;

                var outputFile = File("D:\\test.xhtml");

                var document = app.activeDocument;

                 

                var scriptPath = Folder.startup + '/Scripts/Export as XHTML/';

                var scriptFile = File(scriptPath + 'XHTMLExport.jsxbin');

                if (scriptFile.exists) {

                scriptFile.open();

                var script = scriptFile.read();

                scriptFile.close();

                eval(script);

                 

                var opts = new XHTMLExportOptions();

                 

                opts.styleHandling = XHTMLExportOptions.extStyleSheet;

                opts.styleSheet = 'template.css';

                 

                opts.formatted = true;

                 

                app.exportForWebPreferences.gifOptionsInterlaced = true;

                 

                var exporter = new XHTMLExporter(scriptFile);

                 

                var success = exporter.doExport(document, undefined, opts, outputFile); // check the results:

                if(success)

                {

                /*if(exporter.outOfDateLinks.length > 0)

                {

                alert('Exporting ' + document.name + ' succeeded\nHowever ' + exporter.outOfDateLinks.length + ' links were out of date.');

                } */

                }

                else

                {

                alert('Exporting ' + document.name + ' failed with this error message:\n' + exporter.error.message);

                }

                }

                 

                 

                Regards,

                sudar

                • 5. Re: Indisign scripting and cross-media export -> Xhtml / Dreamweaver
                  Serge2k Level 1

                  Thanks a lot. This is what i was looking for...

                  • 6. Re: Indisign scripting and cross-media export -> Xhtml / Dreamweaver
                    steveo de stevelux

                    Where did you find documentation for XHTMLExportOptions?

                    • 7. Re: Indisign scripting and cross-media export -> Xhtml / Dreamweaver
                      steveo de stevelux Level 1

                      http://www.adobe.com/devnet/indesign/pdfs/feature-development-with-scripting.pdf

                       

                      I really had to dig to find this, frustrating. Reading up on this. Exporting XHTML should

                      be a better documented feature. I couldn't get anything to come up in the ExtendScript 2

                      (I'm using CS3) InDesign Object Reference with various searches.

                       

                      If it's in there, it's buried. I also dug through each and every PDF I could find on Adobe's site.

                      I just happened to do a search that finally yielded something new.

                       

                      Hope this helps.

                      • 8. Re: Indisign scripting and cross-media export -> Xhtml / Dreamweaver
                        Olav Martin Kvern Level 3

                        Hi steveo,

                         

                        re: "Exporting XHTML should be a better documented feature. I couldn't get anything to come up in the ExtendScript 2 (I'm using CS3) InDesign Object Reference with various searches. If it's in there, it's buried. I also dug through each and every PDF I could find on Adobe's site. I just happened to do a search that finally yielded something new."

                         

                        It's not in the object model reference because it's not really part of the InDesign object model. The XHTML export feature is provided by a script, not by a plug-in. The objects/properties/methods that get added to the scripting object model are the same as any other functions defined by a script, and are not part of the base model that is constructed by InDesign's (compiled C++) plug-ins.

                         

                        I realize that this might seem like a needless distinction, but the reference is generated by automated means from the plug-ins. While we could use ExtendScript's reflection features to generate some of the reference information for JavaScript-added objects, it's not capable of doing everything we need it to do.

                         

                        I expect this to become more of an issue as more of InDesign's features are implemented using scripting. I'm not yet sure how we'll solve it.

                         

                        Thanks,

                         

                        Ole

                        • 9. Re: Indisign scripting and cross-media export -> Xhtml / Dreamweaver
                          steveo de stevelux Level 1

                          Ah, crud - I was really hoping to scrap a piece of JAVA that transforms our XML to XHTML.

                           

                          Any chance we could get a non-binary version of the XHTML exporting scripts?

                           

                          Since you mentioned the Script driven items are not auto-generated I guess that answers my

                          question to "is it documented anywhere".

                           

                          Thank you for the clarification. Along with the aforementioned PDF it makes a lot

                          more sense to me now.

                          • 10. Re: Indisign scripting and cross-media export -> Xhtml / Dreamweaver
                            Olav Martin Kvern Level 3

                            Hi steveo,

                             

                            I would think that XSLT would be a better choice for an XML transformation than either ExtendScript or Java. What am I missing?

                             

                            Also, I *think* the source for the XHTML export script is available somewhere. Let me check.

                             

                            Thanks,

                             

                            Ole

                            • 11. Re: Indisign scripting and cross-media export -> Xhtml / Dreamweaver
                              steveo de stevelux Level 1

                              Thanks Olav, that would be very helpful if you could.

                               

                              You're right, and XSLT is what Java uses for the CS2 version of

                              this project. We never used ExtendScript to do anything other than

                              mapping styles to XML.

                               

                              I was hoping to avoid too many details, but this might benefit the discussion:

                               

                              Original need:

                              We use an open source project called Sakai (Learning Management System)

                              that comes with documentation which we rebranded every time a new release

                              was rolled out. Our implementation of the Sakai LMS is called TRACS here at

                              Texas State University|San Marcos and we have a pretty strong demand for

                              consistentcy and adhering to project and university level branding guidelines.

                               

                              Our support staff was using word documents and spent a laborious 2 months

                              minimum with their workflow getting everything migrated. Our branding needs

                              were steep. I was the graphic designer at the time the brand was created

                              and saw branding issues with the word docs being authored. We constantly

                              fought issues with inconsistent formatting (logo placement, logo version,

                              leading, fonts, etc.).

                               

                              Automation with ExtendScript was the answer (and Java, AppleScript).

                              What took a variety of people with differing MS word skill sets 2 months

                              now took a mere 5 minutes or less.

                               

                              Rough outline of our app:

                              Our Java process looks at a watched folder and coordinates the automation

                              with receipts that are written out after each phase is done.

                               

                              Our Word documents are formatted with identically named character

                              and paragraph styles that are found in our InDesign template.

                               

                              Java grabs a list of all the word docs to be processed, writes out an include

                              to be used later for our ExtendScript.

                               

                              ExtendScript systematically takes each one in the array:

                              - takes care of flowing in the word doc

                              - page numbering

                              - mapping styles to tags

                              - PDF export

                              - XML export

                              - XML cleanup (some trash comes over from the export)

                              - XHTML generation

                              - writes receipts at each phase to tell JAVA it's ready for

                              the next phase as flow control

                               

                              Java picks up the receipt, transforms XML (using XSLT) to XHTML snippets that

                              the end user copy/pastes into our Content Management System. Ultimately, we'll

                              shoot for direct DB inserts, but we have to get the dust off the CS2 version

                              before we can discuss that again.

                               

                              In regards to not using XSLT:

                              A recent test we did showed that InDesign CS4 had the ability to export very clean XHTML

                              based on style sheets applied to items in the document. Effectively, that negates our

                              need for XML mapping of stylesheets and the use of XSLT.

                               

                              That is, if cross-media exports can be automated.

                              • 12. Re: Indisign scripting and cross-media export -> Xhtml / Dreamweaver
                                Dirk Becker  Level 4

                                Go to http://www.adobe.com/devnet/indesign/sdk/

                                Download the SDK

                                See /source/public/components/xhtmlexport for details.

                                 

                                Dirk

                                • 13. Re: Indisign scripting and cross-media export -> Xhtml / Dreamweaver
                                  steveo de stevelux Level 1

                                  Awesome, going through XHTMLExport.jsx now.

                                   

                                  Thanks Dirk!

                                  • 14. Re: Indisign scripting and cross-media export -> Xhtml / Dreamweaver
                                    v. maz

                                    Hello,

                                    I need  to export the indd documents to XHTML/ Digital Editions.

                                     

                                    I've modified the script that export to Xhtml / Dreamweaver, replacing the XHTML* methods by OEB* methods and files:

                                     

                                     

                                     

                                    app.scriptPreferences.version = 5.0;

                                     

                                    var outputFile = File("C:\\test.epub");

                                    var document = app.activeDocument;

                                     

                                    var scriptPath = Folder.startup + '/Scripts/XHTML For Digital Editions/';

                                    var scriptFile = File(scriptPath + 'OEBExport.jsxbin');

                                    if (scriptFile.exists) {

                                    scriptFile.open();

                                    var script = scriptFile.read();

                                    scriptFile.close();

                                    eval(script);

                                     

                                    var opts = new OEBExportOptions();

                                     

                                    opts.styleHandling = OEBExportOptions.extStyleSheet;

                                    opts.styleSheet = 'template.css';

                                     

                                    opts.formatted = true;

                                     

                                    app.exportForWebPreferences.gifOptionsInterlaced = true;

                                     

                                    var exporter = new OEBExporter(scriptFile);

                                     

                                     

                                    var success = exporter.doExport(document, opts, outputFile); // check the results:

                                    if(success)

                                    {

                                    /*if(exporter.outOfDateLinks.length > 0)

                                    {

                                    alert('Exporting ' + document.name + ' succeeded\nHowever ' + exporter.outOfDateLinks.length + ' links were out of date.');

                                    } */

                                    }

                                    else

                                    {

                                    alert('Exporting ' + document.name + ' failed with this error message:\n' + exporter.error.message);

                                    }

                                    }

                                     

                                     

                                     

                                    It doesn't work. The script fails at that point: "exporter.doExport".

                                     

                                    Debugging the script I've noticed that the doExport method has 5 arguments in the XHTML* option, but only 3 in OEB*.

                                    As the files for Digital Editions exportation are only in .jsxbin format, I can´t get more information about which are those arguments or their types.

                                     

                                    Does anybody knows where to find this information?

                                    The methods to invoke in order to export to .epub, the arguments or something helpful...

                                     

                                    Thanks in advance,

                                    Vidal.

                                    • 15. Re: Indisign scripting and cross-media export -> Xhtml / Dreamweaver
                                      EurekaCP

                                      I came upon this post and I am in the position to require image object height/width properties from InDesign as an XML export from InDesign to straight HTM L – not XHTML. It's not the best process - I know, but a situation where I have no leverage. I have no support to accomplish this requirement.

                                      I can get all the text and table content out appropriately tagged, but the images  - though tagged - lack the height/width properties. I can see them as data in the property menus, but could you point me in the right direction to proceed to get this data available to insert in my basic HTML code? I am finishing up a basic JavaScript course and am going to follow the entire sequence. If scripting this is the best option, at least it will help me to not look at XMP or other processes which might not serve my purpose.

                                      Thank you in advance for ANY assistance you might be able to provide.

                                      • 16. Re: Indisign scripting and cross-media export -> Xhtml / Dreamweaver
                                        Marco Lugli Level 1

                                        Hello sudar1983_14, I tried your script and it worked great except for the fact that when I try to use the option app.exportForWebPreferences.copyOriginalImages = true, the script seems to ignore it and continue to export all images as optimized .jpg files (instead of .png files which is the original format).

                                        Have you got any suggestions about?

                                        Many Thanks