|
|
#1 |
|
Evangelist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 469
Karma: 3972002
Join Date: May 2013
Location: Ontario, Canada
Device: Pop_Os!, Kobo Forma
|
New Epub from ODT Not Opened When Created
Here is a funny one. Since building 6.7.2, if I use the ODTImport plugin, I get a failure message. But it doesn't really fail, it creates the epub in the directory where the odt file is, but doesn't open it automatically. I can see nothing wrong with the created file, it is just the handling that is strange. I know I'm not on a standard build, so might this just be a transitory thing?
Here is the message, and a shot of where the file lands: (It chokes a little on the "5.18" in the file name in this example, but that is not the problem, other files work exactly the same.) (Running Pop_OS Linux). |
|
|
|
|
|
#2 |
|
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 9,315
Karma: 6686152
Join Date: Nov 2009
Device: many
|
Very strange, only the status indicates something failed. That happens when there is a non-zero return code from the plugin.py run routine or the subprocess that invokes it.
I would have to look at the plugin's code to know. Have you thought about using our official Sigil AppImage and tryingthe same thing to rule out some issues with your build? Could your java/jre/jdk setup be broken somehow? |
|
|
|
| Advert | |
|
|
|
|
#3 |
|
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 5,787
Karma: 24088595
Join Date: Dec 2010
Device: Kindle PW2
|
I was able to reproduce the problem. It's caused by the period in the file name.
I'll try to upload a fixed version today. Update: The plugin assumes that writer2xhtml will create an output file with the base name without an extension and .epub. However, writer2xhtml uses this code to remove the extension: Code:
public static final String getFileExtension(String sURL) {
String sFileName = getFileName(sURL);
int nDot = sFileName.lastIndexOf('.');
if (nDot>=0) {
return sFileName.substring(nDot);
}
else {
return "";
}
}
public static final String removeExtension(String sURL) {
String sExt = getFileExtension(sURL);
return sURL.substring(0, sURL.length()-sExt.length());
}
Last edited by Doitsu; 02-07-2026 at 08:37 AM. |
|
|
|
|
|
#4 | |
|
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 9,315
Karma: 6686152
Join Date: Nov 2009
Device: many
|
That is very strange. The lastIndexOf('.') routine should return the string position of the last "." in the string.
Quote:
How on earth does the lastIndexOf('.') find and return the first '.'? Great detective work! But something else may be up. It is as-if like they ran it through that routine twice or in a loop and so it first hacked off the ".odt" and then hacked off the ".4" as using this routine just once should do exactly what you would want. Perhaps they invoke that string in a loop? Or maybe that there are multiple threads that somehow invoke it twice? Last edited by KevinH; 02-07-2026 at 09:26 AM. |
|
|
|
|
|
|
#5 |
|
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 9,315
Karma: 6686152
Join Date: Nov 2009
Device: many
|
If I go to the github writer2xhtml site you linked and search for use of removeExtension it appears to be defined in Misc.java (your link) but invoked in both EPUBWriter.java and in Application.java (and there is one use in the UNO routine as well) so it will remove up to two extensions if 2 extensions are provided as the target on the cli interface.
So I do not know if this behaviour is planned or just an accident of using the Application command line interface. Or if this happens in the UNO interface or ... In general, I am not a fan of using multiple "." and spaces in a file name if you want it to be supported cross platform but if that is what the github writer2xhtml seems to be doing. But I have not written java code in over two decades so I only scanned the code. Last edited by KevinH; 02-07-2026 at 10:01 AM. |
|
|
|
| Advert | |
|
|
|
|
#6 |
|
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 29,075
Karma: 211348980
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Does writer2xhtml ever output anything other than the file the Sigil plugin needs to process (or nothing)? Just wondering if the process of opening writer2xhtml's output could be done in a more generic way that's not looking for a specific epub name.
|
|
|
|
|
|
#7 | |
|
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 5,787
Karma: 24088595
Join Date: Dec 2010
Device: Kindle PW2
|
Quote:
The original plugin code was: Code:
epub_path = os.path.splitext(odt_file)[0] + '.epub' The current working version is: Code:
# handle file names with additional periods correctly
base = os.path.basename(odt_file)
# workaround for writer2latex file name bug
stem = base[:-4] # remove ".odt"
name_without_ext = stem
# check for file name with periods
if '.' in stem:
name_without_ext = stem.rsplit('.', 1)[0]
epub_filename = name_without_ext + '.epub'
# assemble epub path
epub_path = os.path.join(os.path.dirname(odt_file), epub_filename)
|
|
|
|
|
|
|
#8 | |
|
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 9,315
Karma: 6686152
Join Date: Nov 2009
Device: many
|
Quote:
The epub converter is the only mimetype converter that hacks off the second extension if one exists that I could find. One way to workaround this issue that might work is according to Application.java, you can pass the full path/name of the target file immediately after the source file in the command line. Code:
System.out.println();
System.out.println("Usage:");
System.out.println(" java -jar <path>/writer2xhtml.jar <options> <source file/directory> [<target file/directory>]");
System.out.println("where the available options are:");
System.out.println(" -xhtml");
System.out.println(" -xhtml11");
System.out.println(" -xhtml+mathml");
System.out.println(" -html5");
System.out.println(" -epub");
System.out.println(" -epub3");
System.out.println(" -template[=]<template file>");
System.out.println(" -stylesheet[=]<style sheet file>");
System.out.println(" -resource[=]<resource file>[::<media type>]");
System.out.println(" -cleanxhtml");
System.out.println(" -config[=]<configuration file>");
System.out.println(" -<configuration option>[=]<value>");
System.out.println("See the documentation for the available configuration options");
Last edited by KevinH; 02-08-2026 at 11:45 AM. |
|
|
|
|
|
|
#9 |
|
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 9,315
Karma: 6686152
Join Date: Nov 2009
Device: many
|
So hopefully the following change is a bit simpler and should make things work too (but I have not tested this). It just adds the desired output epub path/name as the final argument to the jar.
Code:
# process ODT file
if odt_file:
# assemble w2l command line
args = ['java', '-jar', w2l_path, '-' + output_format]
if os.path.isfile(w2l_config_path):
args.append('-config=' + w2l_config_path)
if os.path.isfile(w2l_css_path):
args.append('-stylesheet=' + w2l_css_path)
args.append(odt_file)
epub_path = os.path.splitext(odt_file)[0] + '.epub'
args.append(epub_path)
# run w2l
result = w2lWrapper(*args)
Last edited by KevinH; 02-07-2026 at 01:32 PM. |
|
|
|
|
|
#10 | |
|
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 5,787
Karma: 24088595
Join Date: Dec 2010
Device: Kindle PW2
|
Quote:
I've just tested it and it works fine. Since the current version is looking for custom user files only in the plugin folder, I'll try to update the plugin to also look in the preferences folder for these files. Last edited by Doitsu; 02-07-2026 at 06:16 PM. |
|
|
|
|
|
|
#11 |
|
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 5,787
Karma: 24088595
Join Date: Dec 2010
Device: Kindle PW2
|
@retiredbiker I attached a new plugin version to the first post in the [Plugin] ODTImport thread. You should no longer get any Failed error messages with this version.
I also changed the plugin behavior so that it copies two configuration files (config.xml and epub.css) from the plugin preferences folder to the plugin folder. I.e., you can now uninstall and re-install the plugin without losing your customized configuration files as long as you save them in the plugin preferences folder. If you want to test the new version and have customized config.xml and/or epub.css make sure to copy them from the plugin folder to the plugin preferences folder. Pretty much everyone else can skip this update, because it doesn't offer any new features.
|
|
|
|
|
|
#12 | |
|
Addict
![]() ![]() ![]() ![]() ![]() ![]() Posts: 328
Karma: 516
Join Date: Nov 2015
Location: Europe EEC
Device: Kindle Fire HD6 & HD8
|
Quote:
|
|
|
|
|
|
|
#13 | |
|
Evangelist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 469
Karma: 3972002
Join Date: May 2013
Location: Ontario, Canada
Device: Pop_Os!, Kobo Forma
|
Quote:
So I got the new version and did the config/css copies, and tried it from both my 6.7.2 build and also from the latest 6.7.0 appimage. The result is the same for both versions. I still get an error message, different now, although the epub name is correct as saved in the source folder: Any other info I can provide? |
|
|
|
|
|
|
#14 |
|
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 9,315
Karma: 6686152
Join Date: Nov 2009
Device: many
|
I think it needs the line:
resource_files = None someplace *before* the conditional "if" that creates it so that this variable is in outer scope to be available in later conditional "if" statements. Last edited by KevinH; 02-08-2026 at 05:59 PM. |
|
|
|
|
|
#15 | |
|
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 5,787
Karma: 24088595
Join Date: Dec 2010
Device: Kindle PW2
|
Quote:
The new version should finally work. Last edited by Doitsu; 02-08-2026 at 06:07 PM. |
|
|
|
|
![]() |
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Converting odt to ePub | Jane Eyre | Workshop | 17 | 10-30-2019 12:22 PM |
| rtf/doc/odt to epub: Couldn't opened in Kobo | WolfBack | Kobo Reader | 11 | 10-07-2015 03:11 PM |
| The Videos in the EPUB get automatically played when the EPUB is opened in the iBook | rangaman | ePub | 9 | 12-20-2012 07:57 PM |
| From ODT to EPUB with love | roger64 | Calibre | 23 | 03-23-2010 06:32 AM |
| .odt 2 .epub | renareto | Calibre | 4 | 02-11-2010 04:26 PM |