Bug 198764

Summary: EPUB: relative URLs are not resolved (causes e.g. cover image to not display)
Product: [Applications] okular Reporter: Alan Jenkins <alan.christopher.jenkins>
Component: EPub backendAssignee: Okular developers <okular-devel>
Status: RESOLVED FIXED    
Severity: normal CC: elylevy, jthorell, Vmickus
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Ubuntu   
OS: Linux   
Latest Commit: Version Fixed In: 4.6
Attachments: All errors from opening the file

Description Alan Jenkins 2009-07-03 12:28:32 UTC
Version:            (using KDE 4.2.90)
OS:                Linux
Installed from:    Ubuntu Packages

For an example, use Okular to open the EPUB document at <http://www.webscription.net/p-379-1632.aspx>.  The cover image will not display.  A "blank page" icon appears in it's place.

Lots of errors shown, e.g.:

libepub (II):   guide item: Cover href: content/calibre_title_page.html type: cover                                  
libepub (II):   resources/_cover_.jpg - No such file

Root cause:

/content/calibre_title_page.html:
<img src="resources/_cover_.jpg" alt="cover" style="height: 100%"/>

"resources" is a subdirectory of content, i.e. the path needs to be resolved to "/content/resources/_cover_.jpg".
Comment 1 Alan Jenkins 2009-07-03 12:37:15 UTC
Note - EPUB can have several HTML files which are then combined together.  At the moment, all the HTML files are inserted into a single QTextDocument.

But the HTML files could be in different directories.  I think we need a separate QTextDocument for each HTML file.  I'm hoping they can then be combined using frames, as in QTextCursor::insertFrame().
Comment 2 Alan Jenkins 2009-07-03 14:41:13 UTC
Created attachment 35019 [details]
All errors from opening the file

(See original description for a link to the problem file).
Comment 3 Alan Jenkins 2009-07-04 10:24:38 UTC
Re #1: oops.  I misread the documentation.  "Frames" in QTextDocuments don't work that way - they don't use a different QTextDocument.

I don't think there is a way to solve this with a single QTextDocument, other than rewriting the HTML.
Comment 4 Albert Astals Cid 2010-02-19 20:35:04 UTC
Ely?
Comment 5 Ely 2010-02-26 12:09:34 UTC
Yes, I've been trying to figure out how it should work for a while.
I had no great idea... I wonder how the mobi backend solved that, after all they should go into the same issue.
Comment 6 Vytax 2010-03-04 15:45:01 UTC
I have same problem: 
libepub (II):   OEBPS/../styles/style001.css - No such file
libepub (II):   OEBPS/../images/img0001.jpg - No such file
libepub (II):   OEBPS/../images/img0001.jpg - No such file
libepub (II):   OEBPS/../styles/style001.css - No such file

I can't see any images.  

When open text editor, and change all links: 
From: 
<link href="../styles/style001.css" rel="stylesheet" type="text/css"/>
<p class="sgc-2"><img border="0" src="../images/img0001.jpg"/></p>
To:
<link href="styles/style001.css" rel="stylesheet" type="text/css"/>
<p class="sgc-2"><img border="0" src="images/img0001.jpg"/></p>

Then Okular works good. Can anyone solve this problem?
Comment 7 Pino Toscano 2010-05-22 23:05:01 UTC
*** Bug 236454 has been marked as a duplicate of this bug. ***
Comment 8 Pino Toscano 2010-10-05 01:17:49 UTC
@Alan:
looks like the two documents work a bit better with ebook-tools 0.2.x, can you confirm?

@Vytax:
hard to say what is the real issue without a document... please check with ebook-tools 0.2.x, and if the problem is still there, attach a document (if public) showing the issue.
Comment 10 Pino Toscano 2010-10-05 10:35:07 UTC
SVN commit 1182629 by pino:

Apply a way to resolve the real location of resources to load.

When iterating through the document HTML files, set in the epub document the URL of the current file being loaded,
so it is possible to resolve the locations of resources based on the base URL of the current file.
This makes it possible to load resources like "foo.css", "somedir/foo.css", "../somedir/foo.css" and so on.

BUG: 198764
FIXED-IN: 4.6


 M  +2 -0      converter.cpp  
 M  +18 -1     epubdocument.cpp  
 M  +3 -0      epubdocument.h  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1182629