Pages: 1
Print
Author Topic: .mobi output - is it possible?  (Read 8843 times)
JoAnne
Member

Posts: 49



« on: June 13, 2011, 12:01:44 PM »

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.
Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 2621



WWW
« Reply #1 on: June 13, 2011, 12:56:28 PM »

Not too much extra work to run it through this tool I think:
http://www.mobipocket.com/en/DownloadSoft/ProductDetailsCreator.asp

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.
Logged
JoAnne
Member

Posts: 49



« Reply #2 on: June 13, 2011, 01:56:08 PM »

Thanks, Derek. I think that as long as I can give them something for now, I can wait for a more automated method.

Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 2621



WWW
« Reply #3 on: June 13, 2011, 02:20:53 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).

Steps:
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.

« Last Edit: June 13, 2011, 02:57:39 PM by Derek Read » Logged
JoAnne
Member

Posts: 49



« Reply #4 on: June 13, 2011, 03:27:12 PM »

Thanks - that works perfectly! 
Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 2621



WWW
« Reply #5 on: June 13, 2011, 03:43:59 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.
« Last Edit: June 13, 2011, 03:50:08 PM by Derek Read » Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 2621



WWW
« Reply #6 on: June 13, 2011, 04:33:00 PM »

A little bit more info from the Mobipocket Creator help:

Quote from: Mobipocket Creator 4 Help section: "Importing Image files")
Image file import and conversion

  • 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.
Logged
WinstonRV
Member

Posts: 9


« Reply #7 on: September 13, 2012, 12:18:25 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.
Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 2621



WWW
« Reply #8 on: September 13, 2012, 06:04:26 PM »

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 dita4publishers plug-in into the DITA OT (works out of the box). It generates output to Mobi/Kindle via the "KindleGen" tool (which does need to be installed separately). The "deliverable type" in XMetaL is listed as "KINDLE (mobi format experimental)".
« Last Edit: September 13, 2012, 06:23:21 PM by Derek Read » Logged
WinstonRV
Member

Posts: 9


« Reply #9 on: September 20, 2012, 11:15:40 PM »

We are currently using Xmetal 6.0 with TC, is there anyway we can integrate dita4publishers plug-in to Xmetal 6.
Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 2621



WWW
« Reply #10 on: September 23, 2012, 05:16:01 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).
Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 2621



WWW
« Reply #11 on: February 21, 2013, 02:13:39 PM »

update:
dita4publishers is integrated by default starting with XMetaL Author Enterprise 7.0 (available 2012/04)
Logged
Pages: 1
Print
Jump to: