View Full Version : Using WindowScript to product IMP files


=X=
01-16-2009, 12:29 PM
I ported Nicks command-line based script word2imp.pl (a perl script to Windows script --javscript) to facilitate the conversion of doc directly into .IMP format; bypassing the need for the eBook Publisher GUI.

About the script
Word2IMP.js
Converts MS Word document to IMP
Microsoft windows scripts can be written in VB Script or JavaScript, I wrote this in JavaScript.

RUNNING THE SCRIPT
Two methods
1) Command Line: type
cscript Word2IMP.js <Your MS Word file name>

2) Drag and Drop:
Drag and Drop your MS Word document on the Word2IMP.js script.


To use the Window Script you need ePublisher

1. You have previously installed the eBook Publisher software from http://www.ebooktechnologies.com/sup...r_download.htm .

No other software is needed since Window scripts have been part of the MS OS since Windows 2000.

Thanks NICK


=X=

PS If folks find this script useful and would like to see NICK's excellent Perl work ported to Window Script* just let me know

WindowScripts can be written in VBScript or JavaScript.

nrapallo
02-12-2009, 04:56 PM
PS If folks find this script useful and would like to see NICK's excellent Perl work ported to Window Script* just let me know

WindowScripts can be written in VBScript or JavaScript.

OK, =X=, here's asking too much! :grin2: Sure would like to see you add some simple GUI (in javascript) to select the input file and maybe pass some simple options to the script! ;)

Also, I just released a PowerPoint .ppt to .imp Perl script called PPT2imp.pl (http://www.mobileread.com/forums/showthread.php?p=352018#post352018). Could you convert that to javascript too?

Thanks for helping me understand the power of javascript built into my OS (WinXP SP3). :thumbsup:

=X=
02-12-2009, 07:40 PM
I'll take a look over the weekend and see what I can come up with

=X=

=X=
02-19-2009, 05:04 PM
Quick status nick. I've gotten your first request completed. I have the code that will display a "File Open" dialog box. And a simple GUI for the javascript.

The UI is nothing more than a call to IE ActiveX control with hand written HTML.
Since this is test code I've not integrated it with the word2imp script.

OH a FYI. I found some of my old scripts, where I used the Windows Scripting Host (WSH) written in Perl. It provides all the power that VBA and Javascript have but in Perl. The disadvantage is that it requires ActivePerl.

I'll post the finish code here when it's done.
=X=

nrapallo
02-19-2009, 06:21 PM
Quick status nick. I've gotten your first request completed. I have the code that will display a "File Open" dialog box. And a simple GUI for the javascript.

The UI is nothing more than a call to IE ActiveX control with hand written HTML.
Since this is test code I've not integrated it with the word2imp script.

Thanks for helping out here. I do like using a GUI rather than remembering all the command line switches... :grin2:

OH a FYI. I found some of my old scripts, where I used the Windows Scripting Host (WSH) written in Perl. It provides all the power that VBA and Javascript have but in Perl. The disadvantage is that it requires ActivePerl.

I'll post the finish code here when it's done.
=X=

Oh, I like that!!! I have ActivePerl installed; originally to use with tompe's Mobiperl scripts (I use WinXP) and then for SBPubX OLE/COM interface scripts as well as Mobi2IMP and Lit2sb.

Do you think it would be worthwhile to also have the Microsoft Visual Basic example scripts from the SBPubX.doc posted here as well. I know you've converted the above to javascript, but would there be any benefit to using MS Visual Basic, GUI-wise?

=X=
02-20-2009, 12:09 PM
Do you think it would be worthwhile to also have the Microsoft Visual Basic example scripts from the SBPubX.doc posted here as well. I know you've converted the above to javascript, but would there be any benefit to using MS Visual Basic, GUI-wise?

Actually that would be the cleanest way to go. Scripts are great when you want to do something quick and dirty. But once you start creating GUI and more sophisticated good development tools are a must.

I quit using it since VB 6. But if you used the Net platform you could easily write a GUI with Basic/C#/JScript... you get my point :).

The bad news is I have do not programming experience with the NET framework, which is what MS currently supports.

=X=

nrapallo
02-20-2009, 01:49 PM
I quit using it since VB 6. But if you used the Net platform you could easily write a GUI with Basic/C#/JScript... you get my point :).

Neither do/can I program in VB.

Anyone have VB (with GUI) programming skills?

The bad news is I have do not programming experience with the NET framework, which is what MS currently supports.

=X=

Ditto, with .NET (with GUI) programming skills?

Anyone care to help get us started with a simple sample .vbs/.net? :bow2:

I'll surely hack at it if it doesn't quite do what it should; I just need a something to start with... thanks! :thumbsup:

pilotbob
02-20-2009, 02:08 PM
Anyone care to help get us started with a simple sample .vbs/.net? :bow2:


I do .Net dev for my day job. So, if anyone wants help putting together something I would be happy to help. I guess to get started download one of the visual studio express IDEs, they are free. You have to choose VB.Net express or C# Express.

BOb

nrapallo
02-20-2009, 03:59 PM
I do .Net dev for my day job. So, if anyone wants help putting together something I would be happy to help.

Thanks for the offer, BOb! :hatsoff:

I guess to get started download one of the visual studio express IDEs, they are free. You have to choose VB.Net express or C# Express.

BOb

If I download the free VB.Net express, then could you perhaps show us how to GUI-ize =X='s javascript for, say, word2imp.js in post #1 above. In particular, it would be nice to select the MS .doc input file to convert using a File Open Requester here: fileFullPathName = oArgs.item(0);

and perhaps have a GUI screen that includes a browse button for the above and InputBoxes/CheckBoxes to select options, in place of the "Default", for: project.AuthorFirstName = "Default Author";

project.BookTitle = "Default Title";

project.Category = "Default Category";


and
project.BuildTarget = 2;



where BuildTarget has values of 2=EBW1150 .imp; 1=REB1200 .imp; 0=ETI (nonSony) .epub; 3=REB1100 .rb

That's it! :smack: ;) Really would help us get started though... :cool:

ancalex
04-19-2009, 07:33 AM
I have some knowledge in visual basic but my experience with visual basic express 2005 or 2008 was not satisfactory. On my laptop with only 512 MB of RAM visual express is working very, very slow. So I looked for alternatives and I found AutoIT a basic like scripting language. I will post soon a little script that achieve those things asked by nrapallo.

nrapallo
04-20-2009, 09:33 AM
I have some knowledge in visual basic but my experience with visual basic express 2005 or 2008 was not satisfactory. On my laptop with only 512 MB of RAM visual express is working very, very slow. So I looked for alternatives and I found AutoIT a basic like scripting language. I will post soon a little script that achieve those things asked by nrapallo.

That would be terrific! Are you going to use Koda FormDesigner or straight AutoIt code with COM support?

Here is a sample GUI layout I was looking at using before:

http://www.mobileread.com/forums/picture.php?albumid=131&pictureid=1158

And a while back, I was even toying with an Internet Explorer V6 interface, as seen below:

ancalex
04-21-2009, 01:50 PM
Hi
Well, AutoIt support operations with COM objects but like you will see it's a little bit tricky to manage that.
First I tried to do everything in a single script but... surprise... when I want to catch the OnBuildStart event using BuildFromWordDoc the result is... nothing. The event is not firing my function in AutoIt for overriding default project settings.
I can catch this event if I use BuildFromHtmlFile but surprise again... the default projects settings are used despite of what I do in my function. I think AutoIt have some problems with some events with some COMs... especially with SBPublisher COM.
So I decided to write only a GUI wrapper for word2imp.js first.
Here are the results.

First the source file (contains the autoit script and the jscript)

Second, the executable (contains the compiled autoit executable and again the jscript)

nrapallo
04-21-2009, 02:24 PM
First the source file (contains the autoit script and the jscript)

Second, the executable (contains the compiled autoit executable and again the jscript)

EDIT: This GUI wrapper works just fine as can be seen by this post (http://www.mobileread.com/forums/showthread.php?p=435357#post435357) clarifying why this didn't work for me initially! I recommend you try this with short names or just under the root directory to ensure the directory name contains no spaces and/or the comspec environment space doesn't get exhausted (or just increase it).

I tried to run the executable but got a Spybot false positive detection of malicious code (see attached picture). Spybot then deleted the file.

Is this a known problem?

What did you use to create the .exe. I'll try creating another .exe to see if it does the same thing. Weird.

ancalex
04-21-2009, 02:34 PM
Yes, it's a known problem.
Take a look here
http://www.autoitscript.com/forum/index.php?showtopic=34658

nrapallo
04-21-2009, 02:40 PM
Yes, it's a known problem.
Take a look here
http://www.autoitscript.com/forum/index.php?showtopic=34658

Thanks for the information. :thumbsup:

I did compile the script and got the same (false) Spybot warning.

OK now that we know the .exe is ok, why doesn't it open the .doc file and convert it. I get the error in the second picture below (on a Win XP SP3 system with Word 2003 installed). :dunno:

27916 27917

ancalex
04-21-2009, 02:50 PM
In that part of the form the script takes the output from the word2imp.js script so it is an error raised by windows scripting host.
To look what is wrong i suggest to run the jscript from a command screen like this

word2imp.js "doc_file" author title category 2

what happens?

ancalex
04-21-2009, 03:02 PM
You can try also to reinstall the scripting engine from here
http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=47809025-d896-482e-a0d6-524e7e844d81

Hope it helps.

ancalex
04-21-2009, 03:06 PM
or maybe it is enough to locate the file %windir%\inf\wsh.inf (inf is a hidden folder), right click, select "Install".

nrapallo
04-21-2009, 03:15 PM
In that part of the form the script takes the output from the word2imp.js script so it is an error raised by windows scripting host.
To look what is wrong i suggest to run the jscript from a command screen like this

word2imp.js "doc_file" author title category 2

what happens?


I still get an error, as per the below picture:

nrapallo
04-21-2009, 03:18 PM
You can try also to reinstall the scripting engine from here
http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=47809025-d896-482e-a0d6-524e7e844d81

Hope it helps.

or maybe it is enough to locate the file %windir%\inf\wsh.inf (inf is a hidden folder), right click, select "Install".

The original word2imp.js by =X= works, so I don't think WHS is broken...

ancalex
04-21-2009, 03:29 PM
You can see in the source that I'm using the cscript.exe to run the jscript so you can try to place in the front of the command line the cscript executable like i did in my autoit script.
Anyway thank you for your interest, sorry I must go to sleep now, tomorrow a busy day at work.
By

nrapallo
04-21-2009, 04:22 PM
You can see in the source that I'm using the cscript.exe to run the jscript so you can try to place in the front of the command line the cscript executable like i did in my autoit script.
Anyway thank you for your interest, sorry I must go to sleep now, tomorrow a busy day at work.
By

IT WORKS JUST AS IS!!!!!!!!!

:smack: My fault for trying to run this deep inside subdirectories, as I noticed the Windows (default) environment space gets exhausted if the "command.com /c cscript ScriptDir\word2imp.js OpenFileName Title Author Category BuildTarget" is too long.

D:\REB\NEWFOL~1\NE3CF9~1\WORD2I~1>command.com /c cscript "D:\REB\New Folder\New Folder (10)\word2imp-source\word2imp.js" Joke.doc T A C 2
Microsoft (R) Windows Script Host Version 5.7
Copyright (C) Microsoft Corporation. All rights reserved.

Converting... Please wait
Project file saved
Conversion completed

D:\REB\NEWFOL~1\NE3CF9~1\WORD2I~1>command.com /c cscript "D:\REB\New Folder\New Folder (10)\word2imp-source\word2imp.js" Joke.doc MyTitle MyAuthor MyCategory 2
Program too big to fit in memory


I think if you change "command.com /c" to "command.com /c /e:4096" it should help.

However, upon further testing, it appears that the REAL culprit is that @ScriptDir breaks this command when the fullpath directory name (but not $OpenedFileName directory or filename) contains spaces!!!

Can you just substitute $ScrFile where it can be defined as a global at the start of the script? i.e.Global $ScrFile=@ScriptDir & "\word2imp.js"

Have a pleasant well-deserved rest! :)

ancalex
04-23-2009, 04:25 AM
Hi
Here there is the fixed an enhanced version of my gui wrapper for the jscript written by =X=.
It was my fault to omit quoting the directory where the script resides so I corrected this issue and now the gui is working properly.

nrapallo suggested this:

I think if you change "command.com /c" to "command.com /c /e:4096" it should help.

but in autoit the shell invoked by the script is not command.com (the older ms-dos shell) but cmd.exe (the new shell introduced by Microsoft first in windows2000 OS), so I don't think that is necessary to increase the quantity of the extra memory needed by the shell. (cmd.exe does not even has a switch for this cases).
So, I changed a little bit the javascript code and now you can produce imp file from doc, rtf, html, txt, ppt, and pps documents and I have decided to change the name of the program to any2IMP.
I attached the new version bellow:
first the exe compiled with autoit and the modified javascript
second the sources
If you are concerned about the false positives raised by some antivir or antimalware products please take only the source and, you can download AutoIt and you can compile the exe by yourself. The false positives issue it is a known problem, you can read about it on autoit forum (see one of my previous post).

nrapallo
04-23-2009, 08:01 AM
Hi
Here there is the fixed an enhanced version of my gui wrapper for the jscript written by =X=.

...

So, I changed a little bit the javascript code and now you can produce imp file from doc, rtf, html, txt, ppt, and pps documents and I have decided to change the name of the program to any2IMP.

Fantastic enhancements! It works GREAT!

I'm going to be happy to enhance this further, and to start with, in any2IMP.au3, try replacing line 44 with: $OpenedFileName = FileOpenDialog("Choose file...", $LastDir, "MS Word .doc files (*.doc)|MS Word .rtf files (*.rtf)|MS PPT .ppt files (*.ppt;*.pps)|HTML .htm files (*.htm*)|TEXT .txt files (*.txt)|All Files (*.*)")
.
This will help filter out only the input types supported.

Check out my new Any2IMP IE v6 screenshots added here (http://www.mobileread.com/forums/showthread.php?p=433718#post433718) showing more planned input types to be supported.

Next to add my mobi2imp.pl (http://www.mobileread.com/forums/showthread.php?t=22178) and Lit2sp.pl (http://www.mobileread.com/forums/showthread.php?t=28138) Perl scripts, but first they will need to be converted to jscript... :rolleyes:

nrapallo
04-23-2009, 12:57 PM
OK, let the enhancements begin!

I changed line 83 in any2IMP.js to: project.CSS = 2;
This will allow margins to be better supported in the resulting ebooks. I think this is a MUST!

I added another "convert from" if statement before line 40 in any2IMP.js, namely:if (szBaseNameExt == ".opf"){
WScript.StdOut.WriteLine("Converting... Please wait");
oBuilder.BuildFromProject(
sDirName + "\\" + fileName);
WScript.StdOut.WriteLine("Conversion completed");
WScript.Quit();
}


Now only if we can get access to the .tmp (html) file that gets created (and then deleted) by eBook Publisher as well as the images. I tried .epub, but the images are not stored (a bug with eBook Publisher). Previously, I was able to overcome this by first creating the older .oeb and then thereafter creating the .epub (see this solution in my latest mobi2imp.pl v9.4d (http://www.mobileread.com/forums/showthread.php?t=22178))

Oh, by the way, with the above ability to convert directly from .opf to .imp, you will need to tweak in any2IMP.au3 line 44 again to be: $OpenedFileName = FileOpenDialog("Choose file...", $LastDir, "MS Word .doc files (*.doc)|MS Word .rtf files (*.rtf)|MS PPT .ppt files (*.ppt;*.pps)|HTML .htm files (*.htm*)|TEXT .txt files (*.txt)|OPF .opf files (*.opf)|All Files (*.*)")
.


Enjoy!

ancalex
04-23-2009, 01:49 PM
Thank you for this suggestions, they are very useful, it's a shame but I completely forgotten about filters in the open dialog. That's more better now.
About the perl script that you mentione in your post, I must say, sorry but I don't know perl so I can not follow your sugestion. Even with the javascript I had to tell I was in trouble because I'm new also in java scripting.
Anyway for lit converting I find a program called "clit" at http://www.convertlit.com/ and seems to be interesting, it converts lit to OEBPS. I made some testing and it is working fast but the .opf project that is saved seems to be not compatible with Ebook Publisher's own .opf .
Please detail me a little because I don't understood very well what you want to say with:
Now only if we can get access to the .tmp (html) file that gets created (and then deleted) by eBook Publisher as well as the images. I tried .epub, but the images are not stored (a bug with eBook Publisher).
I guess I missing something, (never used .opf only for creating ebooks)

nrapallo
04-23-2009, 02:10 PM
Thank you for this suggestions, they are very useful, it's a shame but I completely forgotten about filters in the open dialog. That's more better now.

Thanks for being so receptive to modifications!

About the perl script that you mentione in your post, I must say, sorry but I don't know perl so I can not follow your sugestion. Even with the javascript I had to tell I was in trouble because I'm new also in java scripting.
Anyway for lit converting I find a program called "clit" at http://www.convertlit.com/ and seems to be interesting, it converts lit to OEBPS. I made some testing and it is working fast but the .opf project that is saved seems to be not compatible with Ebook Publisher's own .opf .

A while back I used the program Lit2sb (http://www.mobileread.com/forums/showthread.php?t=20592) to convert .lit directly into .imp formats and even extracted the Lit2sb.pl (http://www.mobileread.com/forums/showthread.php?t=28138) Perl script used. This program does the necessary changes to the lit .opf so that it can be used with eBook Publisher. The Perl script shows how it is done and has been proven to work extremely well. For quick setup instructions for Lit2sb, Mobi2IMP and PDFRead, see this post (http://www.mobileread.com/forums/showthread.php?p=267753#post267753).

I too lack the necessary Perl to Javascript coding knowledge, but with your help and previously =X='s, I think we can manage to get something working. We can take small steps and see how far it will get us...

Please detail me a little because I don't understood very well what you want to say with:

I guess I missing something, (never used .opf only for creating ebooks)


First, .opf files "hold" or specify everything that the ebook creation software needs to know, be it eBook Publisher or MobiPocket Creator. Each program uses a bit different setup, but the general coding remains the same. Now a .opf is also the cornerstone of .epub files, being a roadmap of its structure and where metadata is stored. They are very useful files to have!!!!

OK, now more on the .tmp files. Examine a .opf file leftover and even load it (by double-clicking it) into eBook Publisher after the ebook has been created. You'll notice that the .tmp holding the .html code is "missing" as are any images referred therein.

Now, if you look inside the ETI .epub (open it up with winzip or my preference being winrar), you will see the .opf above and THAT .tmp (html) file missing above. That file is what I want to have access to and most definitely would post-process it using many desirable text substiutions. However, that file and any images only existing in the temp directory created by eBook Publisher (and then deleted BEFORE I can get to it).

I tried creating a .oeb using any2IMP, but it appears broken in that it doesn't include the underlying base (html) .tmp file and any images. It used to work with v2.2.5 (before .epub support was added).

This is my current "mission", to get access to these .tmp files. Wish me luck! :rolleyes:

ancalex
04-23-2009, 02:57 PM
Hi
I too lack the necessary Perl to Javascript coding knowledge, but with your help and previously =X='s, I think we can manage to get something working. We can take small steps and see how far it will get us...
I will try to help if I could with the coding.
Now, if you look inside the ETI .epub (open it up with winzip or my preference being winrar), you will see the .opf above and THAT .tmp (html) file missing above. That file is what I want to have access to and most definitely would post-process it using many desirable text substiutions.
Now I understand, I have noticed this behavior when i created for test .epub files, and even when I used ExplodeOCF method the temp file was inaccessible in ebook Publisher. I will look again if I can find something useful.

nrapallo
04-24-2009, 09:32 AM
OK, I finally got it to save the images within .epub files. It's a kludge/hack but works for now.

The .oeb that gets created allows the .epub to include the extracted images and hence produces a usable .epub. TO DO: Need to see if I can Extract OEBFF from within OnBuildStart.

I can't say the same for the .oeb that gets created though. eBook Publisher can't even open the .oeb file it creates, so there is no easy way to extract the .oeb to get at the source files! :smack:

Use the ETI .epub Build target if you want/need to tweak the conversion and change the source files (just unzip the .epub)!!!! Note: for text .txt file conversions to .imp, I had to re-edit the .tmp (html) file produced to remove the line-ending <BR>'s as without them it reflows better!!! The eBook Publisher inserted <p> ... </p> during the conversion do work well!

A few modifications:
added version code starting at v0.1
changed saved .opf filename so as to not overwrite input .opf. Naming convention is now "inputfilename_buildtargetnumber.opf"
selected better defaults for some less known OnBuildStart project items (trust me these are required!)
added defaults for title, author and category in case of an empty string passed.
always creates a .oeb files, but only really useful when Build target is ETI .epub!

nrapallo
04-25-2009, 07:35 AM
The .oeb that gets created allows the .epub to include the extracted images and hence produces a usable .epub. TO DO: Need to see if I can Extract OEBFF from within OnBuildStart.

I haven't been able to successfully use ExplodeOEBFF to extract the source files using that IBuilder method from within the .js script. The only option appears to create the .epub and use it as your source files. Must be a bug with eBook Publisher or differing syntax than the documentation in SBPubX.doc. :dunno:

I can't say the same for the .oeb that gets created though. eBook Publisher can't even open the .oeb file it creates, so there is no easy way to extract the .oeb to get at the source files! :smack:

I got eBook Publisher to FINALLY unpack its own created .oeb files (which are just text within) by editing one line therein! By changing the occurance of:Content-Type: application/xhtml+xml to: Content-Type: text/x-oeb1-documenton the header of the .tmp (html) file, eBook Publisher can now open and unpack that .oeb. However, it renames the images and requires manual intervention. Another buggy aspect of this new .epub/.oeb support within eBook Publisher! :rolleyes:

Next, I'm going to see what OnSourceStart and OnSourceDone can yield by way of access to the source files for the intent and purpose of changing it before the .imp gets created.

ancalex
04-27-2009, 03:24 PM
Hi
I made a little research and testing this days and I came up with a solution to access those "vanishing" temporary files created by the time .imp is building.
Now, if you look inside the ETI .epub (open it up with winzip or my preference being winrar), you will see the .opf above and THAT .tmp (html) file missing above. That file is what I want to have access to and most definitely would post-process it using many desirable text substiutions. However, that file and any images only existing in the temp directory created by eBook Publisher (and then deleted BEFORE I can get to it).
My solution (maybe not the best anyway):
- passing 2 more arguments to any2imp jscript from the any2imp autoit script, $UserTmpDir holding the user temporary files path and $DocTmpDir holding the actual path to document that will be converted
- two more lines in jscript
oFSO.CopyFile ( userTmpDir + "\\" + "wrd*.tmp",docTmpDir);
oFSO.CopyFolder (userTmpDir + "\\images",docTmpDir + "\\images" );
placed in OnBuildStartEvent after saving the .opf file

Like you see i made it only for .doc converting but (if it is working good) it can be done for the other file type conversion.
For testing here are the source files

P.S. Copy back the tmp's to their original location, double click on the saved .opf and done. (or edit the opf for the new paths) to do

nrapallo
04-27-2009, 03:30 PM
Hi
I made a little research and testing this days and I came up with a solution to access those "vanishing" temporary files created by the time .imp is building.

My solution (maybe not the best anyway):

Wonderful research!!! Just absolutely wonderful solution!

Thanks again for this! :2thumbsup

Oops: I get Bad Arguments with the GUI. Do the last two parameters need to have quotes for any spaces in the directory names? It works fine from the command line if I quote the last parameter.

p.s. for RTF .rtf its the same prefix as Word .doc files i.e. wrd*.tmp, but
- for PPT files the .tmp file is prefaced by ppt*.tmp and its images are called Slide*.jpg in the temp directory itself and not in an images subdirectory.
- for Text .txt files, the .tmp fiile is prefaced by odf*.tmp
- for .htm, there are no .tmp files, just the files in the source directory used in the .opf or just .html. :)

nrapallo
04-28-2009, 12:19 AM
OK, I took ancalex's progress with copying those temporary files to the source file's directory and tried to eliminate those two extra parameters recently added for userTmpDir and docTmpDir as those are known within the .js script. The results are posted below in any2IMP v0.1.2. The .zip includes the source .au3, compiled .exe and modified .js script.

Basically, I used the variable project.SourceFile(0) to provide me with the filename of the first spine entry (zero-based index) in the .opf; which will usually contain the source (html) .tmp file I need to modify before the .imp conversion takes place. :thumbsup:

This file can then be opened and various replace operations can be applied to remove inconsistencies or add functionality. I prefer small margins, big pictures, and use of the default fonts and will develop some replace regex once I brush up on how jscript implements these. :rolleyes:

ancalex
04-28-2009, 07:02 AM
I was thinking about not building the final .imp file if we need to edit anyway the sources, only build the final result after making all the changes. Also I think it's better to do all the necessary replacements using the AutoIt scripting flexibility (and not jscript)
So I made a little change in any2imp.js, used a function (after function ev_oBuilder_OnBuildStart) for detecting the OnSourceDone event for aborting the build like this:
function ev_oBuilder_OnSourceDone(file_name, file_index, tot_files){
WScript.StdOut.WriteLine("Abort Build");
oBuilder.AbortBuild();
}
What's your opinion?

By the way your modds for temporary file access are not better... but the best:2thumbsup

nrapallo
04-28-2009, 08:08 AM
What's your opinion?

My preferences would be to use an all-in-one solution, producing a .imp after pressing the Convert button and perhaps after choosing some checkboxes/radiobuttons options on the GUI screen. For advanced/complex builds an Option to Abort the build midstream could be useful. The GUI's job should be to just to pass the parameters to the script. The .js script should produce the .imp ebook.

This is the way Lit2sb, Mobi2IMP and PDFRead work to produce usable .imp's from various sourced ebook formats. However, that doesn't mean that the user cannot later re-build the .imp after further editing it, but at least the easy changes will have already been made.

By the way your modds for temporary file access are not better... but the best:2thumbsup

Thanks, hopefully this is the tip of the iceberg, with even better Build/GUI support to come. :)

ancalex
04-28-2009, 01:11 PM
My preferences would be to use an all-in-one solution, producing a .imp after pressing the Convert button and perhaps after choosing some checkboxes/radiobuttons options on the GUI screen.
That will the best choice. My reserve is somehow caused by the fact that I'm working with jscript for the first time and I'm struggling to learn the basics. So excuse me if I will came with solutions a little bit slower.

nrapallo
04-30-2009, 06:10 PM
Fixed a minor bug introduced with the last version where any subsequent conversion was not available. New v0.1.3 attached.

I tried converting Zelda.doc (http://www.mobileread.com/forums/showthread.php?p=443674#post443674) recently uploaded and any2IMP did a fine job (but I would like an option to change the base font family used).

I added a cover afterwards as can be seen by the converted .imp ebooks below!

nrapallo
06-03-2009, 09:38 AM
I could not get the ETI SBPubX COM interface to properly process and/or support .epub manipulations within 'any2IMP', so I cannot, at this time, add any support for converting from .epub.

Once ETI properly documents the new changes to this COM interface, then it may be possible to add this functionality.

As it stands now, the SBPubX cannot be used via Perl or Windowscript to read/write .epub, even though it did work well with .oeb.

I guess these two are really NOT interchangeable, as stated by ETI.

Growing pains.... :blink:

ancalex
06-11-2009, 04:03 AM
Sorry for this long absence from the forum but in may i was moving to a new apartment and I was very busy with the moving and the arrangements.
I was worked this day to port any2imp to vb express because the lack of good com support from autoit and also jscript has some limitations (especially the lack of byref support of com's callings).
In vb everything is working very well, the code is very similar to autoit so the porting was not a big problem.
That was in the middle of may.
From some long weeks now, I'm working to implement in the new any2imp a wysiwyg html editor to make last minute changes to the source file(s) before the imp generation.
Hard task.
There are many free solutions (wrappers, components for .net) based on mshtml for example
- http://itwriting.com/htmleditor/
- http://www.planet-source-code.com/vb/scripts/ (http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=3281&lngWId=10)
- http://groups.google.com/group/csexwb
but i tried also others, for example i tried even some javascript based programs.
I found some interesting things in my searches for example a beautiful html renderer from terrainformatica:
- http://www.terrainformatica.com/htmlayout/
So if you have some ideas/demands for/from this future editor please share your opinion with me.
What I want specifically from this editor:
- access to the header style made by SBPubX for changing the global layout of the ebook
- make changes like bold, italic, ... in text
- make changes for justifying text (left, right, justify, center) for paragraphs
- insert anchors, make (manually) tocs
- insert running headers, footers
- code cleaning
- render the html file with ebookwise like ttf fonts
I hope this is interesting enough.
I'm also thinking about not using the publisher's internal document converter but use this html2rtf converter
http://www.codeproject.com/KB/recipes/RtfConverter.aspx
Waiting for your opinions.

shighfield
06-11-2009, 10:36 AM
Sounds good to me! Having everything in one tool like this might be the way to go and make it easier for new users.

nrapallo
06-11-2009, 12:27 PM
Sorry for this long absence

You're excused, just this one time, ... ;) :rofl:

I was worked this day to port any2imp to vb express because the lack of good com support from autoit and also jscript has some limitations (especially the lack of byref support of com's callings).
In vb everything is working very well, the code is very similar to autoit so the porting was not a big problem.
That was in the middle of may.

Does it still have a nice GUI? Do any vb calls to the new .epub/OCF related functions/methods work for you?

From some long weeks now, I'm working to implement in the new any2imp a wysiwyg html editor to make last minute changes to the source file(s) before the imp generation.

Will it support RegEx? I like using Perl-like RegEX substitutions to fix things "en masse".

So if you have some ideas/demands for/from this future editor please share your opinion with me.
What I want specifically from this editor:
- access to the header style made by SBPubX for changing the global layout of the ebook
- make changes like bold, italic, ... in text
- make changes for justifying text (left, right, justify, center) for paragraphs
- insert anchors, make (manually) tocs
- insert running headers, footers
- code cleaning
- render the html file with ebookwise like ttf fonts
I hope this is interesting enough.

See this eBook Publisher tips/hints (http://www.mobileread.com/forums/showthread.php?t=22238) thread and our EBook Publisher wiki.

I'm also thinking about not using the publisher's internal document converter but use this html2rtf converter
http://www.codeproject.com/KB/recipes/RtfConverter.aspx
Waiting for your opinions.

I agree that the internal ETI rtf converter is not the best, but it's "free" and comes with the COM support. Why not just fix what you don't like about it's output (using RegEx); just my take on this. :dunno: But if you can get the RtfConverter to work then kudos to you! :)

ancalex
06-16-2009, 01:11 PM
Hi
I put here for testing the source code and the executable of any2IMP+:)
Because it was made with vb express 2008 you must have net 3.5 installed.
Hope everything is ok.


edit - it's enough to have net 2.0 installed, sorry my mistake.

nrapallo
06-17-2009, 02:21 PM
Hi
I put here for testing the source code and the executable of any2IMP+:)
Because it was made with vb express 2008 you must have net 3.5 installed.
Hope everything is ok.


edit - it's enough to have net 2.0 installed, sorry my mistake.

I can't get it to work on my WinXP SP3 with .NET 3.5 installed (as well as 2.0) computer. I tried on another WinXP computer and even installed the (free) VB Express 2008 there and still no go.

See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.Configuration.ConfigurationErrorsException: Configuration system failed to initialize ---> System.Configuration.ConfigurationErrorsException: Unrecognized configuration section system.serviceModel. (C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Con fig\machine.config line 146)
at System.Configuration.ConfigurationSchemaErrors.Thr owIfErrors(Boolean ignoreLocal)
at System.Configuration.BaseConfigurationRecord.Throw IfParseErrors(ConfigurationSchemaErrors schemaErrors)
at System.Configuration.BaseConfigurationRecord.Throw IfInitErrors()
at System.Configuration.ClientConfigurationSystem.Ens ureInit(String configKey)
--- End of inner exception stack trace ---
at System.Configuration.ClientConfigurationSystem.Ens ureInit(String configKey)
at System.Configuration.ClientConfigurationSystem.Pre pareClientConfigSystem(String sectionName)
at System.Configuration.ClientConfigurationSystem.Sys tem.Configuration.Internal.IInternalConfigSystem.R efreshConfig(String sectionName)
at System.Configuration.ConfigurationManager.RefreshS ection(String sectionName)
at System.Configuration.ClientSettingsStore.ReadSetti ngs(String sectionName, Boolean isUserScoped)
at System.Configuration.LocalFileSettingsProvider.Get PropertyValues(SettingsContext context, SettingsPropertyCollection properties)
at System.Configuration.SettingsBase.GetPropertiesFro mProvider(SettingsProvider provider)
at System.Configuration.SettingsBase.GetPropertyValue ByName(String propertyName)
at System.Configuration.SettingsBase.get_Item(String propertyName)
at System.Configuration.ApplicationSettingsBase.GetPr opertyValue(String propertyName)
at System.Configuration.ApplicationSettingsBase.get_I tem(String propertyName)
at any2IMP.My.MySettings.get_LastBuildTarget() in C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\any2IMP+\any2IMP\My Project\Settings.Designer.vb:line 74
at any2IMP.MainForm.MainForm_Load(Object sender, EventArgs e) in C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\any2IMP+\any2IMP\MainForm.vb:line 175
at System.EventHandler.Invoke(Object sender, EventArgs e)
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Mes sage& m)
at System.Windows.Forms.ContainerControl.WndProc(Mess age& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.3082 (QFE.050727-3000)
CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
any2IMP
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///E:/ebooks/Coding_Mobi2IMP_PDFRead/Conversion-Perl%20scripts/WindowScripts/any2IMP+_executable/any2IMP.exe
----------------------------------------
Microsoft.VisualBasic
Assembly Version: 8.0.0.0
Win32 Version: 8.0.50727.3053 (netfxsp.050727-3000)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.VisualBasic/8.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll
----------------------------------------
System
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Windows.Forms
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Drawing
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Runtime.Remoting
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Runtime.Remoting/2.0.0.0__b77a5c561934e089/System.Runtime.Remoting.dll
----------------------------------------
Interop.SBPUBXLib
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///E:/ebooks/Coding_Mobi2IMP_PDFRead/Conversion-Perl%20scripts/WindowScripts/any2IMP+_executable/Interop.SBPUBXLib.DLL
----------------------------------------
System.Configuration
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.3082 (QFE.050727-3000)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.




This is the error message I get when it starts up. I see the GUI screen afterwards, but can't use it. :dunno:

Help...

ancalex
06-17-2009, 03:55 PM
I'm sorry, i don't now what is wrong. You sad you even tried with vb express?
Have you tried loading the solution file ?
I saw in the errors about complying about missing settings...
Anyway I think the problem is with not supplying all the files necessary to run the exe. Again my mistake, i wanted to simplify the installation but i caused only troubles. sorry again.
So I "published" in vb the sources, with clickonce you can install it.
unzip and setup.exe

nrapallo
06-17-2009, 04:41 PM
Anyway I think the problem is with not supplying all the files necessary to run the exe.

Yes, that was the issue!

Again my mistake, i wanted to simplify the installation but i caused only troubles. sorry again.
So I "published" in vb the sources, with clickonce you can install it.
unzip and setup.exe

Works great, but the setup.exe calls (just once) 'dfsvc.exe' that wants to access the internet, presumably to verify the 'Publisher' (I denied internet access to 'dfsvc.exe' just to be extra safe).

It installed just fine, except it indicated that the "Publisher cannot be verified". No loss! It works great (did I say that before) and even leaves a copy of the .html used as a .tmp in the target directory. Just edit the .opf to use that file and you're set! :clap:

Suggestion: I would probably place all related files (.tmp and any images, but not the .opf) in a subdirectory named as the source file (without the extension). This makes it feasible to convert multiple documents in the same folder. ;)

To run the program a second time, use the link in the start menu (I just copied it to my desktop for future use)!

Well done!

ancalex
07-04-2009, 02:33 PM
I want to share with you the actual state of my "htmleditor" to have some feedbacks on it.
I tried many editors before start my approach and you will see that actually my tries ended up with a CSS editor like interface. The editor is in a very alpha stage so it's full of unfinished parts (and buga i'm shure). It is standalone (for now), you can load an html file for testing the editing phase and you can save the resulting file, maybe to load in ebook publisher to verify how will look the final imp file.

nrapallo
07-08-2009, 11:11 AM
I want to share with you the actual state of my "htmleditor" to have some feedbacks on it.
I tried many editors before start my approach and you will see that actually my tries ended up with a CSS editor like interface. The editor is in a very alpha stage so it's full of unfinished parts (and buga i'm shure). It is standalone (for now), you can load an html file for testing the editing phase and you can save the resulting file, maybe to load in ebook publisher to verify how will look the final imp file.

I could not try it as setup.exe fails to install on my system as it could not contact the server for authentication???

Can you rebuild the setup to fix this or just provide a standalone .exe?

nrapallo
07-08-2009, 05:13 PM
I could not try it as setup.exe fails to install on my system as it could not contact the server for authentication???

I did get it to install on another Windows machine. It looks like my Windows Firewall was blocking the launching of the application.

I see how it breaks down all the html tags in a vertical fashion for each parent tag. It's a nice visual, but what operations could exploit/use this?

In python, there is a script called beautifulsoup.py that unravels any .html file into it's basic components and allows en masse substitutions. Is this along the lines what you see for this html editor?

ancalex
07-11-2009, 12:10 PM
Hi
I'm aware about the fact that already exists some other programs for html file analizing, what I want to do is a piece of software tailored to edit source files made by ebook publisher.
I used the treeview only to reveal the inside of the html source and the listview in the left I used for css editing. I don't know if you noticed that in the listview if you click on the values column you can edit in place the values, predefined for values used by ebook publisher (after editing click save to see the results.
The bottom part now is used for viewing the selected html node (with syntax highlighting) but will be also used for simple textual html editing.
Also here i want to put (in a tab) the global css properties used in the style tag by ebook publisher with the editing posibility too.
It's interesting why you have this problems with my setup files, i made an offline publishing package with no updates checking, I have to try to made a better approach to make a setup package.