Extracting HTML and Images from MHT and CHM? 14
smoon asks: "I've
got a boatload of .CHM files, and have recently run across some .MHT files.
The .MHT format appears to be how MS Internet Explorer saves a web site
for offline viewing, and appears to be a basic MIME-format with all images
inlined as base64 encoded data. I've poked around a bit looking for a utility
that will extract the HTML files and associated graphics so that I can view
these in Linux, but no luck so far. The .CHM format is billed as a 'compiled'
HTML, and boils down to the equivalent of a tarball, in some Microsoft
proprietary format, that shows a series of web pages. MS has a .CHM
developers kit that allows you to extract all of the data, but the links stop
working and it ends up not being very useful. Anyone know of a
code that can extract the HTML and associated images from .CHM or
.MHT files?"
Online Documentation (Score:3, Informative)
A .CHM is a compilation of HTML files with support for a tree style view of the documents in it, as well as binary files (examples), images, browse order (associating a "forward" button with the page that represents the page after the current page), searching, etc...
It's a pretty handy way of distributing online documentation, kinda like PDF but for HTML.
Being HTML you can still dynamically resize the window and have the text reflow - In my opinion that's it's big advantage over PDF. A PDF is basically a rendering of a page - not really what you want for an online help system.
It probably ends up just being a bunch of standard filenames inside a .CAB file (the .CAB format is what Microsoft puts a lot of their install packages and other archives into).
As for the format it's in, here's what I found on Google [google.com].
- Steve
Re:Online Documentation (Score:1)
I was thinking of IDC / HTX from the IIS 3 days
sure glad I didn't get suckered into those!
the helpfiles format is good, I agree.
The Windows Help version of the PHP manual is much easier to use than it's docbook html cousin.
Oh crap! that almost makes me an MS apologist
ahhhhhh, I'm going crazy like the like the androids in the "I love you. slap!" sequence in Star Trek
Not exactly a CAB file (Score:2)
Perl! (Score:3, Interesting)
CHM extractor. (Score:4, Informative)
However, for CHM extraction, you can use this portable CHM extractor [uklinux.net]. I don't think Matthew has officially released it, but it should be OK to use. Get in touch with him if you want.
Using IE as an extractor, Plus an offtopic rant (Score:5, Interesting)
This opens up options for using IE to extract text and graphics. If you just need the odd item, go to the page in Help, copy the URL to IE, and use IE's Save features. Mass dumps are harder. You could probably do it programmatically, since IE is a COM Automation server. But there are differences in the way links work, and you'd have to figure those out.
It's my understanding the CHM is built using something called the IStorage Interface [microsoft.com], but I'm vague on the specifics. There's some interesting Delphi software here [helpware.net] (look for the "CHM Explorer Demo"). This Usenet thread [google.com] is also intriguing.
I have to take the excuse to bemoan the poor state of online Help engines. More and more documentation is moving online, yet nobody seems to be really working on it. JavaHelp looks promising [sun.com], but it doesn't seem to attract much interest outside the Java community. (Are the issues technical or political?) The KDE web site boasts of an "XML help system", but that just means they do their authoring in XML -- which is good, but the content is actually distributed as a large collection of HTML files, managed by a standard web indexer and a poorly integrated TOC manager. GNOME does something similar.
Which means that HTML Help, despite its flaws and limitations, is actually the best widely-used Help Engine! A sad state of affairs.
This isn't rocket science. All you need is a way to combine a lot of files into a resource archive (no sane product integrator wants to include thousands of separate text files in a product), an indexer, an outliner, and some basic UI engineering. But I don't see any real open-source effort at all. Come on, do you want people to use Linux on the desktop or not?
HTML Help Workshop (Score:2, Informative)
MHT (Score:1)
---
#!/usr/bin/perl
use MIME::Parser;
my $parser = new MIME::Parser;
$parser->output_under("/tmp");
$entity = $parser->parse(\*STDIN);
---
(call it unmht.pl for this example).
Make that script executable, and then just "cat yourmhtfile.mht | unmht.pl". The files contained within the mht should all end up in a directory under