Recommend this page to a friend! |
EPub | > | All threads | > | validator epub | > | (Un) Subscribe thread alerts |
|
1 - 10 | 11 - 20 | 21 - 21 |
Peter - 2013-12-23 14:26:52 - In reply to message 10 from Peter
This is my EpubModel.php
<?php /** * @defgroup Epub */ /** * @file application/models/EpubModel.php * Distributed under the GNU GPL v2. For * @class EpubModel * @ingroup Epub * @brief Class defining low-level operations for Epub conversion from Microsoft Word Files */ class EpubModel { /** * Constructor * Instantiate bootstrap, get instance of conversion tools */ public function __construct(array $tools) { $this->dfcTools = $tools; } /** * createEpub * Get instance of TransformModel, get HTML from manuscript, pass to conversion tools and send Epub to browser * @param $options array output options and manuscript src */ public function createEpub(TransformModel $transform, array $options) { $epub = $this->dfcTools['epubConverter']; if (!$options['customOptions']['html']) { //if no html has been passed, transform the Word Document $html = strip_tags($transform->getDocumentHTML($options['src']), '<p><script><style><span>'); } else { $html = $options['customOptions']['html']; } $epub->setTitle($options['options']['Title']); //setting specific options to the EPub library $epub->setIdentifier($options['options']['Identifier'], EPub::IDENTIFIER_URI); $epub->addChapter("Body", "Body.html", $html); $epub->finalize(); $zipData = $epub->sendBook("Example"); }
Asbjorn Grandt - 2013-12-23 14:43:58 - In reply to message 9 from Peter
But to get names with a leading / something must have been changed in the EPub.php file. It defaults to "OEBPS/" not "/"
Peter - 2013-12-23 14:58:21 - In reply to message 12 from Asbjorn Grandt
ok ... but it did not change anything
Peter - 2013-12-23 14:59:52 - In reply to message 13 from Peter
Type File Line Position Message
ERROR OEBPS/Body.html 5 40 elements from namespace "" are not allowed ERROR OEBPS/Body.html 7 6 The markup in the document following the root element must be well-formed. ERROR OEBPS/Body.html - - The markup in the document following the root element must be well-formed.
Asbjorn Grandt - 2013-12-23 15:18:36 - In reply to message 14 from Peter
Bafore your $epub->setTitel...
add this: $content_start = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" . "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\"\n" . " \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n" . "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n" . "<head>" . "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n" . "<link rel=\"stylesheet\" type=\"text/css\" href=\"styles.css\" />\n" . "<title>Test Book</title>\n" . "</head>\n" . "<body>\n"; $content_end = "</body>\n</html>\n"; $html = $content_start . $html . $content_end;
Peter - 2013-12-23 15:43:13 - In reply to message 15 from Asbjorn Grandt
Type File Line Position Message
ERROR /Body.html 14 40 element "style" not allowed here; expected element "address", "blockquote", "del", "div", "dl", "h1", "h2", "h3", "h4", "h5", "h6", "hr", "ins", "noscript", "ns:svg", "ol", "p", "pre", "script", "table" or "ul" (with xmlns:ns="http://www.w3.org/2000/svg") ERROR /Body.html 14 40 attribute "id" not allowed here; expected attribute "dir", "lang", "media", "title", "type", "xml:lang" or "xml:space" ERROR /Body.html 16 58 attribute "language" not allowed here; expected attribute "charset", "defer", "src" or "xml:space" ERROR /Body.html 18 10 The character sequence "]]>" must not appear in content unless used to mark the end of a CDATA section. ERROR /Body.html - - The character sequence "]]>" must not appear in content unless used to mark the end of a CDATA section. ERROR /Body.html 6 60 '/styles.css': referenced resource missing in the package.
Asbjorn Grandt - 2013-12-23 16:08:39 - In reply to message 16 from Peter
Considering that your css file is called style.css, you need to change the reference in the code I gave you in the previous post.
The rest is because the html coming from phpDocx is full of weird HTML. EPub does not clean up the HTML passed to it. Also, I tried to download the test epub on the link you gave me earlier, the css file contains html header, it must not. The index files (opf and ncx) reference a toc file, which is missing. Last. looking at the structure inside the ePub file, the Book.html, book.ncx, book.opf and style.css still contain a leading "/", and the META-INF/container.xml references this. That can only happen if $bookRoot in EPub.php have been changed to "/". Download the epub and rename it to .zip, and then unpack it. You'll see what is wrong far easier.
Peter - 2013-12-23 16:21:18 - In reply to message 17 from Asbjorn Grandt
ok thanks .... rcontrollo everything from the beginning and let you know
Kirstyn Amanda Fox - 2013-12-24 14:46:05 - In reply to message 18 from Peter
Have you tried running the HTML through TIDY (http://www.php.net/tidy) or HTML Purifier (http://htmlpurifier.org/)? When generating ePub using user generated input, I always run the HTML through BOTH like so:
function pureStory($raw_story) { $endtags = array("/<\/b>/i", "/<\/u>/i", "/<\/i>/i", "/<\/s>/i", "/<\/em>/i", "/<\/strong>/i"); $less_raw_story = $raw_story; $less_raw_story = preg_replace("/<b>/i","<span style=\"font-weight: bold;\">",$less_raw_story); $less_raw_story = preg_replace("/<u>/i","<span style=\"text-decoration:underline;\">",$less_raw_story); $less_raw_story = preg_replace("/<i>/i","<span style=\"font-style:italic;\">",$less_raw_story); $less_raw_story = preg_replace("/<s>/i","<span style=\"text-decoration:line-through;\">",$less_raw_story); $less_raw_story = preg_replace("/<em>/i","<span style=\"font-style:italic;\">",$less_raw_story); $less_raw_story = preg_replace("/<strong>/i","<span style=\"font-weight: bold;\">",$less_raw_story); $less_raw_story = preg_replace($endtags,"</span>",$less_raw_story); $pure_config = HTMLPurifier_Config::createDefault(); $pure_config->set('HTML.Doctype', 'XHTML 1.1'); $pure_config->set('HTML.TidyLevel', 'heavy'); $pure_config->set('AutoFormat.AutoParagraph', 'true'); $pure_config->set('Core.ConvertDocumentToFragment', 'false'); $purifier = new HTMLPurifier($pure_config); $pure_story = $purifier->purify($less_raw_story); return $pure_story; } function tidyStory($icky_story) { $endtags = array("/<\/b>/i", "/<\/u>/i", "/<\/i>/i", "/<\/s>/i", "/<\/em>/i", "/<\/strong>/i"); $less_icky_story = $icky_story; $less_icky_story = preg_replace("/<b>/i","<span style=\"font-weight: bold;\">",$less_icky_story); $less_icky_story = preg_replace("/<u>/i","<span style=\"text-decoration:underline;\">",$less_icky_story); $less_icky_story = preg_replace("/<i>/i","<span style=\"font-style:italic;\">",$less_icky_story); $less_icky_story = preg_replace("/<s>/i","<span style=\"text-decoration:line-through;\">",$less_icky_story); $less_icky_story = preg_replace("/<em>/i","<span style=\"font-style:italic;\">",$less_icky_story); $less_icky_story = preg_replace("/<strong>/i","<span style=\"font-weight: bold;\">",$less_icky_story); $less_icky_story = preg_replace($endtags,"</span>",$less_icky_story); $tidy_config = array( 'clean' => true, 'join-classes' => true, 'join-styles' => true, 'enclose-block-text' => true, 'drop-empty-paras' => true, 'enclose-text' => true, 'logical-emphasis' => true, 'lower-literals' => true, 'quote-nbsp' => true, 'word-2000' => true, 'break-before-br' => true, 'alt-text' => 'Image', 'quote-nbsp' => false, 'indent' => true, 'output-xhtml' => true, 'wrap' => 100); $tidy_story = new tidy; $tidy_story->parseString($less_icky_story, $tidy_config, 'utf8'); $tidy_story->cleanRepair(); return $tidy_story; }
Peter - 2013-12-24 15:56:45 - In reply to message 19 from Kirstyn Amanda Fox
thanks ... but how to use it?
|
1 - 10 | 11 - 20 | 21 - 21 |
info at phpclasses dot org
.