DITA and XMetaL Discussion
JoAnne June 13, 2011 at 6:01 pm
.mobi output – is it possible?June 13, 2011 at 6:01 pmParticipants 10Replies 11Last Activity 11 years, 5 months ago
XMetal 6 / Dita 1.1 / Windows
In the never-ending search to make everything available to everybody all the time… is there a plugin or anything that would let me output my DITA to .mobi?
thanks, as always.Derek Read June 13, 2011 at 6:56 pm
Reply to: .mobi output – is it possible?June 13, 2011 at 6:56 pm
Not too much extra work to run it through this tool I think:
It says that the inputs it accepts are HTML + images. So if you were to generate output to XHTML using the XMetaL Author Enterprise deliverable “Multiple HTML” I assume this tool could read that in and package it appropriately (perhaps with some additional tweaking if the tool needs that).
One additional manual step is probably not a big overhead, but I guess you are hoping someone might have created a proper DITA Open Toolkit plug-in.
I suspect the best you could hope for might be similar to creating CHM output from the DITA OT. That generates output to XHTML and a few other CHM-specific input files which you can then run through Microsoft's “HTML Help Workshop” to generate the CHM (the latter happens automatically if you are using XMetaL Author Enterprise). If “Mobipocket Creator” supports other input files besides HTML (maybe it needs them for TOC and other settings?) then something could be done along the same lines as CHM.
My searches turn up nothing so far for a DITA-specific solution though so I think a manual post-HTML-output step might be your best bet for now.JoAnne June 13, 2011 at 7:56 pm
Reply to: .mobi output – is it possible?June 13, 2011 at 7:56 pm
Thanks, Derek. I think that as long as I can give them something for now, I can wait for a more automated method.Derek Read June 13, 2011 at 8:20 pm
Reply to: .mobi output – is it possible?June 13, 2011 at 8:20 pm
Just had quick try of the Mobipocket Creator and got it working quite easily. See attached.
Here are some notes:
1) If you output using “Multiple HTML” from XMetaL Author Enterprise you will end up with multiple HTML files (one for each DITA input topic). The Mobipocket Creator GUI doesn't support selecting multiple files when you click “Add” but you can drag and drop files.
2) It doesn't automatically find images that are linked to. You must also manually “Add” those to your project.
3. The GUI doesn't support folders but the “Build” step seems to. So, if you store your DITA files in multiple folders (which most people do) the folder structure replicated the DITA OT. This makes it difficult to get working with Mobipocket Creator but not impossible. Hand editing the file it saves for your “project” with *.opf file extension can be done and the “Build” step seems to support folder paths. It is the *.opt file that is used as input to generate the ebook, which has *.prc file extension. You can open the *.opf file in a text editor and fix links by adding folder paths and the code that generates the *.prc file seems to understand that, but this would be some amount of work to do if you have lots of files stored in different folders.
So, instead of doing that I generated output using “Single HTML”. That gives you a single HTML file containing all topics including a simple table of contents at the top. When Mobipocket Creator reads this file in there isn't anything else that needs to be done for output (unless you have links to images). The TOC seems to work just fine in my testing using “”.
Note that Mobipocket suggests that a read is included. That wasn't true in my case. I needed to download and install a separate program called “” in order to view the ebook output (the *.prc file).
If you do have images and they are stored relative to your original DITA documents but in different folders then the DITA OT replicates those folder paths. You have three options here (from best to worst in my opinion):
A) Get XMetaL Author Enterprise to Output a Single HTML File and the Images it References in the Same Folder
We have a setting not intended for this but it should work in this case. What it does is add an additional step prior to passing all files to the DITA OT. This step copies all files referenced in your map into a temporary folder, including images and renames them using 8.3 format filenames (randomly generated using ASCII alphanumeric characters only) and all links to all files are rewritten (in these temp files) so that they all reference the proper filenames in this folder. The original purpose for this was to force file naming compatibility for the DITA Open Toolkit in the case where characters are used in filenames that are not supported by the DITA OT (XMetaL Author Enterprise – Japanese edition ships with this enabled by default for example).
1. In XMetaL Author Enterprise select Tools > Configure Output.
2. Select the “Single HTML file” deliverable then press the Duplicate button. This will allow us to set up a custom deliverable we will use just for Mobipocket Creator so we can continue to use the standard deliverable “Single HTML file” (in case we want that).
3. Select the deliverable called “Copy of Single HTML file” then click the Edit button.
4. Rename the deliverable so it makes sense. In my case “Single HTML file for Input to Mobipocket Creator”.
5. On the Advanced tab in the section called “Other output parameters” add the following setting (it should probably be the only one you have there):
cmd_fs_sandboxing = yes
Now when you generate output using the deliverable named “Single HTML file for Input to Mobipocket Creator” you should get a single HTML file in your output folder along with all of your images (if any).
To create your ebook using Mobipocket Creator you would just create a new project in that product's GUI, then drag and drop the single HTML file generated by XMetaL plus any images it references. You can easily find these files by selecting “Open Folder” when XMetaL finishes generating output. Then do whatever else needs to be done and select “Build”.
B) Store DITA Files and Images in the Same Folder
Copy all of your DITA topics and files so that they are in the same folder. I would not recommend this but it is an option for people that might happen to already be working this way. For example, you might have a small set of DITA files for a particularly simple piece of documentation and happen to have already done this for simplicity. Not that if you happen to be working this way option (A) will also still work.
C) Hand Edit
Use the “Save” feature in Mobipocket Creator to save the *.opf file, then open it in a text editor and fix the paths to any images that need fixing (in my case by adding “image” before all image paths in href attributes. Then reopen the new *.opf file in Mobipocket Creator before clicking the Build button. I would not recommend working this way either. It was basically how I figured out what Mobipocket does and what it supports as input.JoAnne June 13, 2011 at 9:27 pm
Reply to: .mobi output – is it possible?June 13, 2011 at 9:27 pm
Thanks – that works perfectly!Derek Read June 13, 2011 at 9:43 pm
Reply to: .mobi output – is it possible?June 13, 2011 at 9:43 pm
One more oddity with Mobipocket Creator (warning).
If you drag and drop files onto the “Publication Files” window it accepts JPG files but doesn't accept PNG files (and possibly others). In order to get PNG files to show in my ebook (and stop errors from showing up in the build log) I had to manually copy them into the project folder created by this tool. No additional settings seemed to be necessary, the build process just seems to bundle them into the *.prc file as long as they are there.
I have not tested all file types, just HTML, JPG and PNG, so this could possibly affect other image formats. Presumably GIF are OK?
My version of Mobipocket Creator is 4.2 build 41 (and was described as “beta” during download).
In my testing this process seems to be the cleanest:
1. Don't use the Mobipocket Creator “Import from Existing file” feature, instead use “Create New Publication” > “Blank Publication”. It is faster and cleaner.
1a. Give the project a name. Probably the same name as the title of your map (copy and paste from there).
1b. Optionally, change the folder path.
1c. Optionally, set the language (no time to become an expert on this but I'm sure this information is available somewhere).
1d. Change the encoding to UTF-8 (as the DITA OT generates UTF-8 encoded HTML this seems to be desirable to me).
1e. Click “Create >” button.
2. Drag and drop the HTML file created using the deliverable “Single HTML file as Input for Mobipocket Creator” discussed in my ealier post. The file will be copied into the publication folder (see 1b above + publication name) by Mobipocket.
3. Don't drag and drop any images onto the Mobipocket GUI. It might not pick up some file types (PNG at least) causing some files to be copied to the publication folder but not others (becomes messy). Instead, just open the folder from step 2 using Windows Explorer and copy and paste all your image files from those created by “Single HTML file as Input for Mobipocket Creator” into the publication folder.
4. Set any other settings you need to set for Mobipocket. This includes getting it to create its version of the TOC maybe (although it doesn't seem to do a better job than what our Single HTML output already does, so I'd skip that). Also, just looking at the “Metadata” section you might need to do some serious reading to get this perfect if you plan to publish the ebook on a commercial site. *
5. Tell Mobipocket to “Build”.
* This is one reason I find it unlikely that anyone would try to create a plug-in for the DITA OT that does all this. There are so many options here and this tool already lets you set them with a nice GUI (so why recreate it). This is similar to CHM in a way. In some cases what the DITA OT generates is OK, but in many cases people will still want to open the CHM project files, tweak them using HTML Help Workshop and rebuild from those tweaked files.Derek Read June 13, 2011 at 10:33 pm
Reply to: .mobi output – is it possible?June 13, 2011 at 10:33 pm
A little bit more info from the Mobipocket Creator help:
[quote=Mobipocket Creator 4 Help section: “Importing Image files”)]
[u]Image file import and conversion[/u]
- All image files are copied from their original location into the publication folder.
- At the same time as it is copied, an image file is converted from its original format into a GIF file and resized to the optimal size for a display in the Mobipocket Reader, i.e. to a size less than 64Kbytes.
In all cases and for all formats, an image may be resized during the final build of the publication, for an optimal display in the Mobipocket Reader, ie to a size less than 64Kbytes for a GIF-equivalent file size.
That's a little bit worrying to me because as far as I can tell all of these image formats are displayed directly by my version of Mobipocket Reader (for PC). Perhaps other versions for other platforms only support GIF? You might wish to research that because the auto-conversion to GIF seems to be broken as described here (JPG are left as they are as JPG files and appear fine and nothing seems to happen for PNG). The only thing I can think of is that maybe this conversion occurs during the “Build” step and not while “Importing Image Files”. So, if this is an imporant format for you perhaps testing on a “real” Mobi device of some kind would make sense.WinstonRV September 13, 2012 at 6:18 am
Reply to: .mobi output – is it possible?September 13, 2012 at 6:18 am
This thread was very useful. everything is working fine except for tables, the table layout gets converted into paragraph layout. Other than converting the table to a image, could you give some hints how can we keep the table layout.Derek Read September 14, 2012 at 12:04 am
Reply to: .mobi output – is it possible?September 14, 2012 at 12:04 am
You might try XMetaL Author Enterprise 7.0 to see what it outputs. Not sure if it will give better output or what it will look like in your Mobi reader / Kindle. XMetaL Author Enterprise 7.0 integrates the [url=http://dita4publishers.sourceforge.net/]dita4publishers[/url] plug-in into the DITA OT (works out of the box). It generates output to Mobi/Kindle via the “[url=http://www.amazon.com/gp/feature.html?ie=UTF8&docId=1000765211]KindleGen[/url]” tool (which does need to be installed separately). The “deliverable type” in XMetaL is listed as “KINDLE (mobi format experimental)”.WinstonRV September 21, 2012 at 5:15 am
Reply to: .mobi output – is it possible?September 21, 2012 at 5:15 am
We are currently using Xmetal 6.0 with TC, is there anyway we can integrate dita4publishers plug-in to Xmetal 6.Derek Read September 23, 2012 at 11:16 am
Reply to: .mobi output – is it possible?September 23, 2012 at 11:16 am
I believe dita4publishers requires the DITA OT to be 1.5.something (XMetaL Author Enterprise 7.0 integrates version 1.5.4 of the DITA OT).
- You must be logged in to reply to this topic.