readium / readium-js-viewer

👁 ReadiumJS viewer: default web app for Readium.js library
BSD 3-Clause "New" or "Revised" License
553 stars 186 forks source link

[Question] Uncompress Epub #637

Closed j0se closed 7 years ago

j0se commented 7 years ago

Hi. I have a question, about viewer. We create an epub with InDesing, then it generate an .epub file, I uncompress IT under my epub_content folder and I can read it but.... my fonts are inoperatives (ofuscates) how its the best way to complete this task.... create an epub, uncompress.... o how?

Thx in advance

danielweck commented 7 years ago

Support for both the IDPF and Adobe font obfuscation algorithms is implemented in ReadiumJS. Could you please share your EPUB package file? (e.g. content.opf) And please also copy-paste the log messages from the web browser's console. Thank you!

j0se commented 7 years ago
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<package version="2.0" xmlns="http://www.idpf.org/2007/opf" unique-identifier="bookid">
    <metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf">
        <meta name="generator" content="Adobe InDesign 12.1" />
        <meta name="cover" content="x1.png" />
        <dc:title>JS_28_07_2017</dc:title>
        <dc:creator></dc:creator>
        <dc:subject></dc:subject>
        <dc:description></dc:description>
        <dc:publisher></dc:publisher>
        <dc:date>2017-07-28T09:42:12Z</dc:date>
        <dc:source></dc:source>
        <dc:relation></dc:relation>
        <dc:coverage></dc:coverage>
        <dc:rights></dc:rights>
        <dc:language>ar-SA</dc:language>
        <dc:language>en-US</dc:language>
        <dc:language>es-ES</dc:language>
        <dc:identifier id="bookid">urn:uuid:29d919dd-24f5-4384-be78-b447c9dc299b</dc:identifier>
    </metadata>
    <manifest>
        <item id="cover" href="cover.xhtml" media-type="application/xhtml+xml" />
        <item id="JS_28_07_2017" href="JS_28_07_2017.xhtml" media-type="application/xhtml+xml" />
        <item id="ncx" href="toc.ncx" media-type="application/x-dtbncx+xml" />
        <item id="idGeneratedStyles.css" href="css/idGeneratedStyles.css" media-type="text/css" />
        <item id="ArialMT.ttf" href="font/ArialMT.ttf" media-type="application/vnd.ms-opentype" />
        <item id="ArialNarrow.TTF" href="font/ArialNarrow.TTF" media-type="application/vnd.ms-opentype" />
        <item id="Cambria-Bold.ttf" href="font/Cambria-Bold.ttf" media-type="application/vnd.ms-opentype" />
        <item id="Univers-Bold.ttf" href="font/Univers-Bold.ttf" media-type="application/x-font-ttf" />
        <item id="Univers-Medium.ttf" href="font/Univers-Medium.ttf" media-type="application/x-font-ttf" />
        <item id="UniversLT-Bold.ttf" href="font/UniversLT-Bold.ttf" media-type="application/x-font-ttf" />
        <item id="UniversLT-LightOblique.ttf" href="font/UniversLT-LightOblique.ttf" media-type="application/x-font-ttf" />
        <item id="UniversLT.ttf" href="font/UniversLT.ttf" media-type="application/x-font-ttf" />
        <item id="x1.png" href="image/1.png" media-type="image/png" />
        <item id="MODIFICADO_ICONO.gif" href="image/MODIFICADO_ICONO.gif" media-type="image/gif" />
        <item id="NUEVO_ICONO.gif" href="image/NUEVO_ICONO.gif" media-type="image/gif" />
        <item id="PAG_01.gif" href="image/PAG_01.gif" media-type="image/gif" />
        <item id="PAG_02.gif" href="image/PAG_02.gif" media-type="image/gif" />
    </manifest>
    <spine toc="ncx">
        <itemref idref="cover" linear="no" />
        <itemref idref="JS_28_07_2017" />
    </spine>
    <guide>
        <reference type="cover" href="cover.xhtml" title="Cover" />
        <reference type="toc" href="JS_28_07_2017.xhtml#_idContainer006" title="Table of Contents" />
    </guide>
</package>

In console.log

readium-js-viewer_all.js:7 Failed to decode downloaded font: http://localhost/libros/10765/OEBPS/font/UniversLT-LightOblique.ttf (this repeats with all fonts )

I unzip the epub and put it in libros folder, but I dont know if this is the correct way.

Thx in advance

danielweck commented 7 years ago

Okay thank you. This is the bit I was interested in:

<dc:identifier id="bookid">urn:uuid:29d919dd-24f5-4384-be78-b447c9dc299b</dc:identifier>

I was wondering whether the culprit could have been the URN / UUID format, which is required by the ReadiumJS implementation. See embeddedFontDeobfuscateAdobe() and urnUuidToByteArray() in https://github.com/readium/readium-js/blob/develop/js/epub-fetch/encryption_handler.js#L60

So, the dc:identifier looks correct.

I doubt there are issues in your META-INF/encryption.xml file (such as an erroneous http://ns.adobe.com/pdf/enc#RC URI), but just to make sure could you please share the source? (or check it yourself)

Have you tested your EPUB with other EPUB reading systems?

j0se commented 7 years ago
<encryption xmlns="urn:oasis:names:tc:opendocument:xmlns:container" xmlns:enc="http://www.w3.org/2001/04/xmlenc#">
    <enc:EncryptedData>
        <enc:EncryptionMethod Algorithm="http://www.idpf.org/2008/embedding" />
        <enc:CipherData>
            <enc:CipherReference URI="OEBPS/font/ArialMT.ttf" />
        </enc:CipherData>
    </enc:EncryptedData>
    <enc:EncryptedData>
        <enc:EncryptionMethod Algorithm="http://www.idpf.org/2008/embedding" />
        <enc:CipherData>
            <enc:CipherReference URI="OEBPS/font/ArialNarrow.TTF" />
        </enc:CipherData>
    </enc:EncryptedData>
    <enc:EncryptedData>
        <enc:EncryptionMethod Algorithm="http://www.idpf.org/2008/embedding" />
        <enc:CipherData>
            <enc:CipherReference URI="OEBPS/font/Cambria-Bold.ttf" />
        </enc:CipherData>
    </enc:EncryptedData>
    <enc:EncryptedData>
        <enc:EncryptionMethod Algorithm="http://www.idpf.org/2008/embedding" />
        <enc:CipherData>
            <enc:CipherReference URI="OEBPS/font/Univers-Bold.ttf" />
        </enc:CipherData>
    </enc:EncryptedData>
    <enc:EncryptedData>
        <enc:EncryptionMethod Algorithm="http://www.idpf.org/2008/embedding" />
        <enc:CipherData>
            <enc:CipherReference URI="OEBPS/font/Univers-Medium.ttf" />
        </enc:CipherData>
    </enc:EncryptedData>
    <enc:EncryptedData>
        <enc:EncryptionMethod Algorithm="http://www.idpf.org/2008/embedding" />
        <enc:CipherData>
            <enc:CipherReference URI="OEBPS/font/UniversLT-Bold.ttf" />
        </enc:CipherData>
    </enc:EncryptedData>
    <enc:EncryptedData>
        <enc:EncryptionMethod Algorithm="http://www.idpf.org/2008/embedding" />
        <enc:CipherData>
            <enc:CipherReference URI="OEBPS/font/UniversLT-LightOblique.ttf" />
        </enc:CipherData>
    </enc:EncryptedData>
    <enc:EncryptedData>
        <enc:EncryptionMethod Algorithm="http://www.idpf.org/2008/embedding" />
        <enc:CipherData>
            <enc:CipherReference URI="OEBPS/font/UniversLT.ttf" />
        </enc:CipherData>
    </enc:EncryptedData>
</encryption>

Only test with readium.

I recevied epub via email.. I decompress it... open the browser and readiumjs and point to the folder with epub.

(Workaround: Open epub with Sigil, delete fonts in folder, save, add fonts to the folder and save, now if I decompress it dont have problems with fonts)

danielweck commented 7 years ago

okay, so based on encryption.xml, the IDPF font obfuscation algorithm is used ( http://www.idpf.org/2008/embedding ), not Adobe.

Can you please explain what you mean by ReadiumJS (Chrome app or cloud reader?). I assume cloud reader, in which case could you ease show me what URL you use in your web browser to open the exploded EPUB?

j0se commented 7 years ago

Daniel thanks for your time Yes its cloud reader, and the url that I use is: http://localhost/readium-js-viewer/dist/cloud-reader-lite/index.html?epub=..%2F..%2Flibros/10765

danielweck commented 7 years ago

The URL looks okay. Can you please try with http://127.0.0.1 instead of localhost? (just in case)

Can you please also use cloud-reader, not cloud-reader-lite.

Thanks!

j0se commented 7 years ago

Failed to decode downloaded font... dont worry I think that the problem is that the fonts when designer make the epub

danielweck commented 7 years ago

Okay, in that case let's close this issue for now. Feel free to re-open it if you discover that the fonts are actually correct, and you think the bug is in Readium.

rkwright commented 7 years ago

I see it is now closed, but just a comment. You cannot use a font embedded in one EPUB in a different EPUB (unless they both EPUBs have the same ID, which is forbidden. I have seen that problem before.

danielweck commented 7 years ago

That's a good remark, Ric. However Jose said: "We create an epub with InDesing, then it generate an .epub file, I uncompress IT under my epub_content folder" which I interpreted as "the obfuscated fonts were generated at the same time as the EPUB". That being said, I am totally unfamiliar with InDesign :)