PHP Classes

Images folder to epub

Recommend this page to a friend!

      EPub  >  All threads  >  Images folder to epub  >  (Un) Subscribe thread alerts  
Subject:Images folder to epub
Summary:Images to epub
Messages:6
Author:Peter
Date:2013-12-28 13:03:05
Update:2013-12-28 18:51:43
 

  1. Images folder to epub   Reply   Report abuse  
Picture of Peter Peter - 2013-12-28 13:03:05
Because after the class phpdocx Epub does not create the "images" folder inside with the images ..... but only the folder "file ....." on the server. Where do you put your hands? While if I use the example script type EPub.Example1.php everything is ok, otherwise it does not automatically create the folder "image".

  2. Re: Images folder to epub   Reply   Report abuse  
Picture of Asbjorn Grandt Asbjorn Grandt - 2013-12-28 13:42:23 - In reply to message 1 from Peter
As far as I understand, the PHPDocX Community Edition does not extract the images from the Docx file.

  3. Re: Images folder to epub   Reply   Report abuse  
Picture of Peter Peter - 2013-12-28 14:23:41 - In reply to message 2 from Asbjorn Grandt
YES! .. The file library / class / TransformDoc.inc.php on line 255

////////////////////////////////////////////////////////////////////////
foreach ($idImgs as $datsIdImgs) {
$this->_xhtml = str_replace(
"src=\"?image=$datsIdImgs\"",
"src=\"files/files_" .
"$this->strFile/media/word/$pathImgs[$datsIdImgs]\"",
$this->_xhtml
);
}

if (!empty($pathZip)) {
$package->extractTo(
"files/files_$this->strFile/media", $pathZip
);
$package->close();
}
///////////////////////////////////////////////////////////////////////

creates the image on the server and a link to the image file. inner html to epub, but not in the epub folder on the local.



PS.: excuse my english I'm Italian

  4. Re: Images folder to epub   Reply   Report abuse  
Picture of Asbjorn Grandt Asbjorn Grandt - 2013-12-28 15:23:39 - In reply to message 3 from Peter
The images in a docX is referenced via an id found in the word/_rels/document.xml._rels file, which maps the image id to the correct image file.
The document.xml may reference the image name, but that is not guaranteed.

But from what little I've seen, phpDocx does not insert the image tag into the extracted html.

I have no problem helping with my own ePub class, but you are essentially asking me to help bug hunt someone else's classes.

Please make sure that the html you are trying to add to the ePub is in fact valid, and if it contains the image tag needed. From there you can either manually add the images to match the filename in the image tag. Under normal circumstances this is fairly trivial to do once you found the pattern the docx class will be using.

Alternatively, if the image tag is relative to the location of the html, ePub takes a root dir as argument, so if the image tag is referencing "images/anImage.png" that rood dir needs to point to the directory containing the images dir.

  5. Re: Images folder to epub   Reply   Report abuse  
Picture of Peter Peter - 2013-12-28 18:11:40 - In reply to message 4 from Asbjorn Grandt
OEBPS in the file / Body.html link to the image is created on the server remto (files.. etc) but I wanted to create the images folder in the local example. OEBPS / images.

Here is where I'm working, do a test http://www.ellepi.us/epub/documenti/

  6. Re: Images folder to epub   Reply   Report abuse  
Picture of Asbjorn Grandt Asbjorn Grandt - 2013-12-28 18:51:43 - In reply to message 5 from Peter
That would be what the EPub::EXTERNAL_REF_ADD is for.

If the image src is an address with http, it should pick it up if you allow it to load external images.

This line from the EPub.Example1.php shows how:
$book->addChapter("Chapter 1: Lorem ipsum", "Chapter001.html", $chapter1, true, EPub::EXTERNAL_REF_ADD);