Skip to main content
Known Participant
March 17, 2023
Question

Convert idml file into HTML

  • March 17, 2023
  • 2 replies
  • 3249 views

Hello everyone,

Im currently working to convert the idml file into html and try to fix this via automation. And tried with some extendscript code

Main();

function Main() {
	// Check to see whether any InDesign documents are open.
	// If no documents are open, display an error message.
	if (app.documents.length > 0) {
		var myDoc = app.activeDocument;
		// Build the filename
		var myDocName = decodeURI(myDoc.fullName);
		var myDocBaseName = myDocName.substring(0, myDocName.lastIndexOf(".")); 
		// Export the page to FXL HTML
		with (myDoc.htmlFXLExportPreferences) {
			// HTMLRangeFormat = PageRangeFormat.EXPORT_ALL_PAGES
			HTMLRangeFormat = PageRangeFormat.EXPORT_PAGE_RANGE
			// HTMLPageRange = "1-2";
		}
		myDoc.exportFile(ExportFormat.HTMLFXL, new File(myDocBaseName + ".html"), true);
	}
	else {
		// No documents are open, so display an error message.
		alert("No InDesign documents are open. Please open a document and try again.")
	}
}

My requirement is to convert the idml file into HTML without formating and it has run in the background means which is helpful, some of the users haven't Indesign Application.
I have checked with different  languages ie., NodeJS, python, C# and not get any solution. Please anyone done this before share your idealogy and apporoach to proceed further.

Thanks


2 replies

Participant
February 20, 2025

There is indeed a script to convert IDML file to HTML / text. You can do it with a python script that I developed. It uses SimpleIDML library and aims at extracting text content in correct order, while also creating a list of images assiciated with your IDML file. Please, refer to github repo: idml2html-python  .

 

The script is intended for batch processing and goes with a bash script that first looks for IDML files and extracts them, and creates list of files that is fed to the py script.

 

There is also an online javascript app which convert IDML into html / text.  It is here: https://textvisualization.app/idml2html/ You can use it to view text content of an IDML file if you do not have inDesign. Surely, you can use it as a converter and extractor of text and image links.  

 

Participant
February 20, 2025

The script to convert IDML to HTML / text is here: https://github.com/roverbird/idml2html-python

Community Expert
March 19, 2023

Hi @Rocky@,

IDML is an open format so you need to read/understand the format specification and then do the translation to HTML as desired. Since IDML is just a bunch of XML files you could use any laguage like JS, Python etc to parse those XML files get the information relevant to you and then write the logic to use that information to create HTML files. It is a tedious process but not that complex.

-Manan

-Manan
Rocky@Author
Known Participant
March 19, 2023

Is it possible to convert with out Indesign application?

Community Expert
March 19, 2023

Yes absolutely, as I said IDML is a bunch of XML files. Read the specification so that you know where to look for which information, then parse the files, get the information you need and create HTML accordingly.

-Manan

-Manan