View Full Version : Convert .lit directly into .IMP formats


nrapallo
02-14-2008, 03:01 PM
A while ago, I used this procedure to convert many .lit files into .IMP formats (EBW 1150 and REB 1200).

This information was originally posted to the REB 1200 Yahoo group, and for those who do not have access to that group, I re-post same here, namely:

1. s32lit2sb.exe - Lit2sb converter compatible with eBook Publisher 2.x (EBW/GEB 1150, REB1200,GEB2250/2200/2150 )

2. s32lit2sb-INSTRUCTIONS-by-NR.txt - Instructions on how to effectively use this program to convert .lit files into .imp (Reb 1200/GEB 1150 formats)

After setting this up, one "double-click" and your .lit file gets converted. Note, you can also use batch files to convert en-masse!

Enjoy!

-Nick

EDIT 14 Feb 2008: added batch files to convert all .lit files in a directory to .IMP. Must read the instructions first, create the empty file 'GEB1150' and ensure you 'associate' .lit as described therein, and properly place all required programs in your 'path'. After that, double-click 'NRconvert lit to 1150 imp.bat' and wait for your results. By the way, when you double-click just the .lit file in windows explorer, you must manually rename the 'o_sb.imp' file; when using these batch files (even for one .lit), it's all done for you.

EDIT 23 Aug 2008: I have re-compiled a windows executable (Lit2sb.exe) based on a modified copy of that perl script to allow proper conversions. Just replace the original lit2sb.exe executable with the one in the lit2sb.zip attachment in the thread Original Lit2sb perl script RESURRECTED! (http://www.mobileread.com/forums/showthread.php?t=28138)
Among the things fixed were:
- uses source .lit filename as final .imp output filename and places resulting .imp in the same directory as the .lit source.
- for resulting .imp and .opf, no longer uses 8.3 filenames.
- uses "2%" left and right margins now, instead of "18pt"
- properly scales GEB1150/EBW1150 cover image so as to avoid bottom margin bleeding.
- fixed system calls to external programs to properly prefix path.


p.s. thanks to zelda_pinwheel for inspiring me to write this

JSWolf
02-14-2008, 03:44 PM
I've just made this thread a sticky to make it easier to find/see.

zelda_pinwheel
02-14-2008, 07:04 PM
Nick, you are my hero ! i just tried this automatic conversion and it worked a treat ! in under 30 seconds i had a nice, readable, .imp version of my .lit file.

of course, then i spent 2 hours "fixing" the code so it would be even nicer, but
i *could* have left it alone, it would have been fine.

i also tried it on that stupid drm book i bought the other day (i think it will be the last one, as well as the first one i buy), since i was having such terrible results before. the formatting is still strange, but not the same way it was before, and infinitely better than my previous efforts. at least it's readable, and at this point i think that's really as much as i can hope for !

thanks for this !!

crazyTash
03-10-2008, 10:12 AM
Thank you so much for this post! It is very useful!

sassanik
05-23-2008, 06:28 PM
I just converted a .lit file to .imp, I can open the file just fine, however the book seems to have been aligned to the right side margin instead of the left.

Suggestions? Ideas on how to fix this?

nrapallo
05-23-2008, 06:45 PM
I just converted a .lit file to .imp, I can open the file just fine, however the book seems to have been aligned to the right side margin instead of the left.

Suggestions? Ideas on how to fix this?

The .html and .opf files are leftover when the .lit conversion is finished. You can check the .html for the <p> formatting to see if there is a <p align=right> for each line or a <style> rule making the default <p> behaviour 'p {text-align: right}'. If so, remove it of substitute 'right' with either 'left' or 'justify'.

To re-create the .imp ebook, after editing the .html as per above, you should use the (free) eBook Publisher software from ETI. Even though eBookwise Librarian can create ebooks, the eBook Publisher software allows better control but however needs much more working knowledge of HTML.

sassanik
05-23-2008, 07:04 PM
Okie I opened the html file in ebook publisher. Now I am just not sure what I need to change:

<html>
<head>
<style type="text/css">
<!--
body {margin-left:18pt; margin-right:18pt; x-sbp-widow-push:1; x-sbp-orphan-pull:1}
td {vertical-align:top}
table.hdr {width:100%; border:none; margin-left:0pt; margin-right:0pt}
td.hdrl {text-align:left}
td.hdrc {text-align:center}
td.hdrr {text-align:right}
.plain {text-decoration:none; font-style:none; font-weight:none; font-size:x-small; font-family:serif; color:#000000}
header {display:none; display:oeb-page-head; oeb-column-number:1; margin-bottom:10pt}
footer {display:none; display:oeb-page-foot; oeb-column-number:1; margin-top:10pt}
pbrk {page-break-before:always}
.KWN {page-break-inside:avoid}
fn {font-size:-1}
sp {font-size:-3}
adv2lm {sbp-advance:left}
p {margin-top:0pt; margin-bottom:0pt; text-align:left; text-decoration:none; font-style:none; font-weight:none; font-size:x-small; font-family:serif; color:#000000}
a {color: #0000ff}
p.FullPagePicture, li.FullPagePicture, div.FullPagePicture
{margin-left:0cm;
text-align:center;
font-size:12.0pt;
}
-->
</style>


Should I set style to left align? It looks like the text is set up to left align, I think....

Amy

Edit-

The first few pages are aligned to the left, then after the acknowledgements it goes to right. So I am guessing somewhere in there a right align command got thrown in.

nrapallo
05-23-2008, 09:23 PM
Okie I opened the html file in ebook publisher. Now I am just not sure what I need to change:

...

Should I set style to left align? It looks like the text is set up to left align, I think....

Amy

Edit-

The first few pages are aligned to the left, then after the acknowledgements it goes to right. So I am guessing somewhere in there a right align command got thrown in.

The top of the .html file looks OK, but it appears you've found your answer in bold above! Just open the .html in eBook Publisher or any text editor (like notepad) and search for: right

or

right" and look for text around the acknowledgement that includes a 'text-align' or <table align=right> there. Chances are the end of the acknowledgment doesn't 'close' the alignment.

This is probably a clitch/error in the original code that was somehow 'overlooked' by the MS LIT reader.

If you can't find it, post here the area around the acknowledgment and include enough to show the text body, before and after. When you post the text here, just place it between [ CODE ] place text here [ /CODE ] (click the '#' in the edit bar above the Message area when entering your message.)

drudo
08-07-2008, 10:34 AM
Can someone help with this? First, it seems the html2sb program is missing when I install lit2sb. I tried downloading that and adding it, but to no avail. When I set it all up like it says in the instructions and run the bat file, the .lit file gets expanded into a subfolder and it looks like the opf file gets renamed, but no imp file is generated. If I try running html2sb on it's own, it crashes. Am I missing something? I basically end up with a .lit file and a directory full of html, images, and opf files. Any idea why this wouldn't work?

Thanks.

nrapallo
08-07-2008, 11:11 AM
Can someone help with this? First, it seems the html2sb program is missing when I install lit2sb. I tried downloading that and adding it, but to no avail. When I set it all up like it says in the instructions and run the bat file, the .lit file gets expanded into a subfolder and it looks like the opf file gets renamed, but no imp file is generated. If I try running html2sb on it's own, it crashes. Am I missing something? I basically end up with a .lit file and a directory full of html, images, and opf files. Any idea why this wouldn't work?

Thanks.

First, html2sb is "broken" under current versions of Windows and especially so if eBook Publisher is installed. I can't get it to run now, even though I used it 4 or 5 years ago and perhaps under Win98se. It is not required as part of the 'lit2sb' package and usage. Just avoid it.

The resulting .imp should be located in the directory where your .lit resides. Did you "double-click" the .lit file to launch the conversion?

Now if you did the above, the .imp conversion may have been halted due to errors in to .opf or .html. Just load the .opf in eBook Publisher and try to build your .imp edition. Was it successful?

If not, then review the Messages log and see if anything needs fixing.

If not, to see if your installation of lit2sb is working, try to convert another .lit file to see if that one works.

If not, private message me with some details of your failed conversion attempt.

drudo
08-07-2008, 11:17 AM
Thanks, I'll try your suggestions when I get home from work today. I'm getting my reader this weekend for my birthday and I'm trying to make sure I have some books ready to test on it.

thanks again.
Dave

sophie27
10-24-2008, 01:04 PM
This program works great! Is there a similar program for pdf direct to imp?

nrapallo
10-24-2008, 01:14 PM
This program works great! Is there a similar program for pdf direct to imp?

Try PDFRead 1.8.2 released! (http://www.mobileread.com/forums/showthread.php?t=21906) for direct .pdf to .imp (and .djvu/.cbr/.cbz/images to .imp!)

And if you need .prc/.mobi to .imp, look at Mobi2IMP 9.4 with new Windows GUI & UTF-8 (http://www.mobileread.com/forums/showthread.php?t=22178)!

AND when you get those installed, you can get direct .lit/.pdf/.prc to .imp conversion while surfing the internet as well (though it's less efficient), using Impserve (http://ebookutils.berlios.de/wiki/Main/Impserve) as discussed in this thread (http://www.mobileread.com/forums/showthread.php?t=28363)!
(your plugins would all be setup then, just download the latest release here (http://ebookutils.berlios.de/wiki/Main/ImpservePlugins)!)

Enjoy the world of converting to .imp... ;)

=X=
11-02-2009, 01:29 PM
I'm having trouble converted Calibre generated LIT files to IMP.

There are three problems.

1) The LIT2SB tool is having problems with the CSS file. Calibre is using an tag called
@namespace h "http://www.w3.org/1999/xhtml";

Since it doesn't understand this it is showing up in the generated IMP file.

2) The order of the content page is incorrect. The tool assumes the <manifest> data will be in sequential order and process the IMP OPF that way. Calibre's OPF file does is not in sequential order but properly laysout the the ID in the <spine> tag so that the order is correct. This results in chapters, TOC, and cover pages to be shuffled around in the IMP book.

3)The cover.htm file assumes an image Cover_SB.jpg but this file is not created. However there is a cover.jpg and it is in calibre's OPF file.

=X=

nrapallo
11-02-2009, 03:42 PM
I'm having trouble converted Calibre generated LIT files to IMP.

=X=

This tool was developed about 5 years ago when there were only MS-commissioned .lit ebooks and so the program, Lit2sb.exe, does not know how to handle any of the inconsistencies introduced by the calibre .lit encoding method.

However, I was able to RESURRECT the original Lit2sb Perl script (http://www.mobileread.com/forums/showthread.php?t=28138) and so it can be manipulated (re-coded) to suit! At the time I had "extracted" that Perl script, I also "tweaked" it to better produce .imp ebooks so I can and have produced new windows executables of lit2sb.exe.

I mainly wrote the INSTRUCTIONS on how to effectively use this tool so my knowledge of this program comes only from reading the Perl code. I could recompile it quite easily if you know the exact patches you need implemented (otherwise there may be some heavy debugging to do ;) ).

Either send me a problematic .lit file or attach it here and let's see what's needs to be done to make this work for calibre generated .lit ebooks. :)

=X=
11-02-2009, 04:07 PM
Sure I think I still have your PM I'll send you the LIT file. I'll also take a look at the Perl file.

On an aside, is there a know tool that knows how to make IMP files without requiring eBookTechnologies?

I know you worked with the EBook-Tools but I don't know how complete of a solution it has because I could never get that tool to work.

=X=

nrapallo
11-02-2009, 04:32 PM
Sure I think I still have your PM I'll send you the LIT file. I'll also take a look at the Perl file.

If not, send it to "nrapallo at yahoo dot ca" :)

On an aside, is there a know tool that knows how to make IMP files without requiring eBookTechnologies?

No, only after installing eBook Publisher by ETI can you make .imp ebooks using their software or COM interface to the PubX.dll/PubUtil22.dll libraries. It can be made to work (http://www.mobileread.com/forums/showthread.php?p=277427#post277427) using wine for Linux and using the Mac OS X software equivalent (http://www.mobileread.com/forums/showthread.php?p=392951#post392951) on the ETI support download page (http://www.ebooktechnologies.com/support_publisher_download.htm) for eBook Publisher.

I know you worked with the EBook-Tools but I don't know how complete of a solution it has because I could never get that tool to work.

=X=

The CPAN Ebook-Tools took a different approach where it worked directly with the .imp/.res format to MANIPULATE it but not GENERATE it. It's more of an extraction/tweaking tool than a "to .imp" creation tool.

I don't recall doing anything special to download and install the Ebook-Tools, but do remember the syntax was a bit obscure but powerful. If you want to try it again, just PM and I'll walk you through it as best I can.

=X=
11-02-2009, 05:10 PM
Okay I took a look at the Lit2sb tool. This tool does exactly what your Word2Imp and any2imp tool does. That is to use ETI to build an IMP file.

The code however is poorly written and hardcodes everything. In addition it creates an OPF file when it does not need to. I'm thinking this was due to legacy issues but this is no longer a problem and now has become a liability for the tool.

It would be better to just upgraded your any2imp tool to support converting LIT files and not put any effort upgrading this tool.

=X=

nrapallo
11-02-2009, 05:41 PM
It would be better to just upgraded your any2imp tool to support converting LIT files and not put any effort upgrading this tool.

=X=

On that point, the any in any2imp refers to the COM interface's MS supported formats like .doc/.rtf/.ppt/ .htm/.txt as well as .opf so any exploded (.lit) directory should be able to be converted to .imp "AS IS" if the .opf is properly written.

Try converting you .lit to .oeb using calibre and feed that .oeb directory's .opf to Any2imp+ (http://www.mobileread.com/forums/showthread.php?p=493869#post493869)!

:chinscratch: See if that meets your needs... :cool:

=X=
11-02-2009, 06:35 PM
Yeah, before I my last post #18, I tried exploding a LIT file using clit and running any2IMP. That did resolve 2 of the 3 issues. However the CSS issue is still there and that is going to require the IMP creator tool to scrub the CSS file to make it IMP friendly.

=X=

nrapallo
11-02-2009, 06:46 PM
Yeah, before I my last post #18, I tried exploding a LIT file using clit and running any2IMP. That did resolve 2 of the 3 issues. However the CSS issue is still there and that is going to require the IMP creator tool to scrub the CSS file to make it IMP friendly.

=X=

The main things I change in CSS are:
(1) the <body> style to have small left/right margins via style="margin-left: 2%;margin-right: 2%" and
(2) the "control" for the spacing between paragraphs via style="margin-top: 0;margin-bottom: 1em" for <p>'s or <div>'s used for body text.

This can be done manually for one or two conversions, but the real challenge is reading the html code and trying to "clean up" the right CSS styles to make it more .imp-friendly...