Giter Site home page Giter Site logo

phpepub's People

Contributors

grandt avatar j0k3r avatar jamie-poitra avatar raqy avatar riconeitzel avatar tcitworld avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

phpepub's Issues

Encoding special caracters for filename

Let's say I want to create an ebook with the title containing a |, like « some text | some text », and a chapter with the same name.
The table of contents is linking to my chapter as some text | some text.html, but the html file created (corresponding to the chapter) is named some text _ some text.html. So I can't access my first chapter.

I'm currently putting PHPePub into wallabag, and without this issue, it works great.

Public access to opf->addMeta

Hello,

I would like to be able to add custom metafields in the opf.
More in particular I would like to be able to add :

This could be solved to add a function like epub->addCustomMeta which directly runs opf->addMeta.

Thanks in advance.

basedir vs. baseDir

in your class in line #533 and #428 you're using $basedir which is not declared and should be $baseDir :-)

How can I set reference/landmark type for specific pages/chapters?

I'm having difficulty creating a valid EPUB3 file due to missing landmarks in the generated epub3toc.xhtml file.

The Cover and TOC are added, but I don't know how to define my colophon, preface, forward, etc. This is a big problem for generating iBooks-valid ePub files.

Replace each() by foreach()

The PHP each() function is deprecated in PHP 7.2
There is an easy migration path with foreach.
I am using PHP 7.2 und I'd like to use your library without any deprecation warnings. Please update your source code.
Thanks.

Add file in META-INF ?

Hello, I can't find a way with the library to add a file in the META-INF folder (I'm trying to add com.apple.ibooks.display-options.xml to be able to force embed font in apple pub reading software).

Is there a way to do it ?

For the moment, I'm using the ZipArchive php class and add it after my pub generation.

composer.json / packagist.org listing

Hi. Thanks for the fantastic package. Lovin' it!

Would you consider adding a composer.json and registering on packagist.org? It will help more people use your library, and help us stay up to date more easily. Thanks!

composer.json

{
    "name": "grandt/phpepub",
    "require": {
        "php": ">=5.3.0"
    },
    "autoload": {
        "classmap": [ "" ]
    }
}

Error converting markup with svgs

Generally, creating an epub from my html markup works just fine and this library is a HUGE time saver. Thank you so much for creating and maintaining it!

There is only problem I'm facing right now though: Whenever my original HTML markup contains an <img> tag linking to a SVG file, adding it to a chapter fails (with EPub::EXTERNAL_REF_ADD enabled, to embed all image files into the epub file). Adding any other image format like PNGs and JPEGs works as expected and if I disable EPub::EXTERNAL_REF_ADD it works, too. I also tried adding other SVG files which still results in the error.

Here's the exact error message I'm facing:

PHP Warning:  imagecreatefromstring(): Data is not in a recognized format in /Users/path/to/project/vendor/grandt/phpepub/src/PHPePub/Core/EPub.php on line 615

This is the markup related to the SVG I'm trying to convert:

<figure>
    <img src="http://example.com/image.svg" alt="My svg image">
</figure>

Using the latest release with composer.

TOC showing up at end of created eBook

This maybe something I'm doing wrong, but I can't seem to figure it out. I'm using the following code to create a new epub file. I need to add the Table of Contents after the cover page but before the rest of the book. Instead I'm getting the whole book THEN the TOC.

Can you help? Thanks.

function epub_generate_rss($blogurl, $authorname = false) {
    $book = new EPub();
    $book->setTitle("test");
    if (!$authorname)
        $authorname = "Ima Author";

    $book->setAuthor($authorname, $authorname);
    $book->setIdentifier($blogurl . "&stamp=" . time(), EPub::IDENTIFIER_URI); 
    $book->setLanguage("en");

    $book->addCSSFile("styles.css", "css1", $epub_css);
    $cover = $epub_content_start . "<h1>" . $feed->get_title() . "</h1>\n";
    if ($authorname)
        $cover .= "<h2>By: $authorname</h2>\n";
    $cover .= "<h2>From: <a href=\"$blogurl\">$blogurl</a></h2>";
    $cover .= $epub_content_end;
    $book->addChapter("Notices", "Cover.html", $cover);
    $book->buildTOC();

        $book->addChapter(
           "Test", 
            "Chapter1.html", 
            $epub_content_start . "<h1Test Title</h1>\nPlenty of test content" . $epub_content_end
        );
    }

    return $book;
}

Two first chapters having the same id

Hi,

wallabag uses PHPePub to produce epubs from articles.

We first add a custom cover as a chapter, then we're looping around our entries to produce a chapter for each entry.
However, it seems the produced epub has it's first two chapters with the same id (1) in the book.opf file. Therefore, our first entry isn't shown since it has the same id as our cover.

A workaround is to set $this->chapterCount to 1, but I can't get to understand why this happens.

Use alt value of img tags when possible while Epub:EXTERNAL_REF_IGNORE is used

Hello!

I think, it could be good to display the alt value of images instead of simply removing entire tag.

It can be done with this regexp for example:

$html_content = preg_replace('/<\s*?img.*alt="(.*?)".*?>/', '${1}', $html_content);

I'll use this regular expression in my epub plugin for the Leed RSS reader and I think, it can be usefull for you too.

Thanks for your great work on PHPePub !

Warnings in PHP log during an export epub

PHPePub is used by wallabag

During export articles in epub format i have :

Warnings in PHP log :

[Mon Nov 21 15:00:14.654739 2016] [:error] [pid 25654] [client IP:PORT] PHP Warning:  file_exists(): open_basedir restriction in effect. File(/) is not within the allowed path(s): (/DIR_ALLOWED) in /DIR_INSTALL_WALLABAG/vendor/grandt/phpepub/src/PHPePub/Core/EPub.php on line 941
[Mon Nov 21 15:00:14.655128 2016] [:error] [pid 25654] [client IP:PORT] PHP Warning:  is_file(): open_basedir restriction in effect. File(/var/www/heraut_eu/lou/www//) is not within the allowed path(s): (/DIR_ALLOWED) in /DIR_INSTALL_WALLABAG/vendor/phpzip/phpzip/src/Zip/Core/AbstractZipArchive.php on line 368
[Mon Nov 21 15:00:14.655281 2016] [:error] [pid 25654] [client IP:PORT] PHP Warning:  file_exists(): open_basedir restriction in effect. File(/) is not within the allowed path(s): (/DIR_ALLOWED) in /DIR_INSTALL_WALLABAG/vendor/grandt/phpepub/src/PHPePub/Core/EPub.php on line 941
[Mon Nov 21 15:00:14.655396 2016] [:error] [pid 25654] [client IP:PORT] PHP Warning:  file_exists(): open_basedir restriction in effect. File(/) is not within the allowed path(s): (/DIR_ALLOWED) in /DIR_INSTALL_WALLABAG/vendor/grandt/phpepub/src/PHPePub/Core/EPub.php on line 941
[Mon Nov 21 15:15:21.146524 2016] [:error] [pid 25655] [client IP:PORT] PHP Warning:  file_exists(): open_basedir restriction in effect. File(/) is not within the allowed path(s): (/DIR_ALLOWED) in /DIR_INSTALL_WALLABAG/vendor/grandt/phpepub/src/PHPePub/Core/EPub.php on line 941
[Mon Nov 21 15:15:21.146917 2016] [:error] [pid 25655] [client IP:PORT] PHP Warning:  is_file(): open_basedir restriction in effect. File(/) is not within the allowed path(s): (/DIR_ALLOWED) in /DIR_INSTALL_WALLABAG/vendor/phpzip/phpzip/src/Zip/Core/AbstractZipArchive.php on line 368
[Mon Nov 21 15:15:21.147072 2016] [:error] [pid 25655] [client IP:PORT] PHP Warning:  file_exists(): open_basedir restriction in effect. File(/) is not within the allowed path(s): (/DIR_ALLOWED) in /DIR_INSTALL_WALLABAG/vendor/grandt/phpepub/src/PHPePub/Core/EPub.php on line 941
[Mon Nov 21 15:15:21.147171 2016] [:error] [pid 25655] [client IP:PORT] PHP Warning:  file_exists(): open_basedir restriction in effect. File(/) is not within the allowed path(s): (/DIR_ALLOWED) in /DIR_INSTALL_WALLABAG/vendor/grandt/phpepub/src/PHPePub/Core/EPub.php on line 941
[Mon Nov 21 15:30:08.834828 2016] [:error] [pid 28756] [client IP:PORT] PHP Warning:  file_exists(): open_basedir restriction in effect. File(/) is not within the allowed path(s): (/DIR_ALLOWED) in /DIR_INSTALL_WALLABAG/vendor/grandt/phpepub/src/PHPePub/Core/EPub.php on line 941
[Mon Nov 21 15:30:08.835217 2016] [:error] [pid 28756] [client IP:PORT] PHP Warning:  is_file(): open_basedir restriction in effect. File(/) is not within the allowed path(s): (/DIR_ALLOWED) in /DIR_INSTALL_WALLABAG/vendor/phpzip/phpzip/src/Zip/Core/AbstractZipArchive.php on line 368
[Mon Nov 21 15:30:08.835384 2016] [:error] [pid 28756] [client IP:PORT] PHP Warning:  file_exists(): open_basedir restriction in effect. File(/) is not within the allowed path(s): (/DIR_ALLOWED) in /DIR_INSTALL_WALLABAG/vendor/grandt/phpepub/src/PHPePub/Core/EPub.php on line 941
[Mon Nov 21 15:30:08.835508 2016] [:error] [pid 28756] [client IP:PORT] PHP Warning:  file_exists(): open_basedir restriction in effect. File(/) is not within the allowed path(s): (/DIR_ALLOWED) in /DIR_INSTALL_WALLABAG/vendor/grandt/phpepub/src/PHPePub/Core/EPub.php on line 941

/DIR_INSTALL_WALLABAG : the install directory of my wallabag instance
/DIR_ALLOWED : two directoy allowed in allowed_paths configuration ( php.ini )

I have open a ticket in wallabag : wallabag/wallabag#2631
but wallabad is not directly concerned.

thanks

Pathinfo extension undefined

I exported two articles containing a lot of different pictures and some of them seem to not return any information through pathinfo, leading to failure.
Therefore, pathinfo($internalSrc); returns undefined here. It should be tested before next conditional.

DOMDocument::loadXML() error

Hi i am having this error when i am trying to put this line of code for every page in the chapter

the code is <span epub:type='pagebreak' id='page1' title='1' />

This gives me an error

Warning: DOMDocument::loadXML() [domdocument.loadxml]: Namespace prefix epub for type on span is not defined in Entity, line: 165 in C:\wamp\www\Dropbox\Audra\Basic Editor\Beta 1.0\basiceditor\lib_epub\EPub.php on line 699

Wrong variable name in buildTOC() V3.30

Dear Asbjørn,
first of all, thanks for your excellent work.
I think I found a the reason, why it was not possible to assign a css-stylesheet to a toc.xhtml file.
In Line 1718 you use
$this->tocCSSFileName = $this->normalizeFileName($cssFileName);
instead of
$this->tocCssFileName = $this->normalizeFileName($cssFileName);

I don't know if this is the right way to inform you about bugs.
Anyway I hope you continue working on this class.

Kind regards,

Schorsch Roch

corrupted file

Hi

i'm actually using your PHPePub for a project

but the generate epub is a corupted file

do you have an idea of the reason of this corrupted file ?
any file i made is corrupted

thanks

Corrupted epub when opening it with Adobe Digital Editions

Hello,

I can create an epub and it's opening without any problem in Calibre and also in a Sony Reader. However, if I try to open it with Adobe Digital Editions it says that the file is corrupted.

Is there anything I should take into account to solve the issue?

Thank you!

Convert all private variables in EPub.php to protected variables

I needed to inherit EPub class to my custom classes, where I wanted to override addChapter with my own version. But since most of the variables are private, I think it would be a good idea to convert them to protected?

Right now, I cannot for instance in my inherited class access $this->isFinalized because that only belongs to EPub class.

Image problem

It only show the last image when there is more than one Image in a Chapter.
Waiting for your response.
Thank you!

Generated epub file does not display on iBook.

Hi,
I generated an epub version of a drupal node through the print module. The epub does not open in iBook and does not validate correctly.

“This page contains the following errors:
error on line 21 at column 27: AttValue: " or ' expected
Below is a rendering of the page up to the first error.”

A similar issue has been filed with the drupal issue queue https://www.drupal.org/node/2147659 but was closed and the author was redirected here.

GIF Images becomes an image with a black background and becomes a jpeg file

Hi, I came across with the problem of gif images being a jpeg file.
I've set isGifImagesEnabled to true. Still Gif images are becoming jpeg files so i've check the code and noticed that the $mime only has png and jpeg conditions so i added the gif condition. Please see code below, the problem is the animation is gone.

`if ($mime == "image/png") {
imagealphablending($image_p, false);
imagesavealpha($image_p, true);
imagealphablending($image_o, true);

                imagecopyresampled($image_p, $image_o, 0, 0, 0, 0, ($width*$ratio), ($height*$ratio), $width, $height);
                ob_start();
                imagepng($image_p, NULL, 9);
                $image = ob_get_contents();
                ob_end_clean();

                $ext = "png";
            }else if ($mime == "image/gif") {
                imagealphablending($image_p, false);
                imagesavealpha($image_p, true);  
                imagealphablending($image_o, true);

                imagecopyresampled($image_p, $image_o, 0, 0, 0, 0, ($width*$ratio), ($height*$ratio), $width, $height);
                ob_start();
                imagepng($image_p, NULL, 9);
                $image = ob_get_contents();
                ob_end_clean();

                $ext = "gif";
            } else {
                imagecopyresampled($image_p, $image_o, 0, 0, 0, 0, ($width*$ratio), ($height*$ratio), $width, $height);
                ob_start();
                imagejpeg($image_p, NULL, 80);
                $image = ob_get_contents();
                ob_end_clean();

                $mime = "image/jpeg";
                $ext = "jpg";
            }`

Adding media files

Hi, I tried copying the function processChapterImages and renamed it to processChapterAudio with the exact code. I'm not that good in PHP so I didn't manage to change the variables because i fear I might do something wrong. Here is the code.
`protected function processChapterAudio(&$xmlDoc, $externalReferences = EPub::EXTERNAL_REF_ADD, $baseDir = "", $htmlDir = "", $backPath = "") {
if ($this->isFinalized || $externalReferences === EPub::EXTERNAL_REF_IGNORE) {
return FALSE;
}
// process img tags.
$postProcDomElememts = array();
$images = $xmlDoc->getElementsByTagName("source");
$itemCount = $images->length;
for ($idx = 0; $idx < $itemCount; $idx++) {
$img = $images->item($idx);
if ($externalReferences === EPub::EXTERNAL_REF_REMOVE_IMAGES) {
$postProcDomElememts[] = $img;
} else if ($externalReferences === EPub::EXTERNAL_REF_REPLACE_IMAGES) {
$altNode = $img->attributes->getNamedItem("alt");
$alt = "image";
if ($altNode !== NULL && strlen($altNode->nodeValue) > 0) {
$alt = $altNode->nodeValue;
}
$postProcDomElememts[] = array($img, $this->createDomFragment($xmlDoc, "[" . $alt . "]"));
} else {
$source = $img->attributes->getNamedItem("src")->nodeValue;

            $parsedSource = parse_url($source);
            $internalSrc = $this->sanitizeFileName(urldecode(pathinfo($parsedSource['path'], PATHINFO_BASENAME)));
            $internalPath = "";
            $isSourceExternal = FALSE;

            if ($this->resolveMedia($source, $internalPath, $internalSrc, $isSourceExternal, $baseDir, $htmlDir, $backPath)) {
                $img->setAttribute("src", $backPath . $internalPath);
            } else if ($isSourceExternal) {
                $postProcDomElememts[] = $img; // External image is missing
            } // else do nothing, if the image is local, and missing, assume it's been generated.
        }
    }`

Its actually the same with the processChapterImages function the only difference is I am looking for the source tag and not the img tag and I used the resolveMedia to replace the src of all the media files.

It replaces the src but it did not download the file. I did not change anything in the resolveMedia function. File source is in here : http://www.noiseaddicts.com/samples/280.mp3

Downloading Images from an https protocol

Hi Grandt,

I think downloading images from an https protocol is not allowed? i've tried downloading the same image from an https site and an http site. The image is downloaded from the http site, but the image fails to download from the https site.

Cover image thumbnail broken in 3.30

in EPub::finalize()
$this->opf->addMeta("cover", "coverImage");
should be
$this->opf->addMeta("cover", "CoverImage");
to match the call
$this->addFile($imgPath, "CoverImage", $imageData, $mimetype);
in setCoverImage()
?

Namespacing

I think more specific class names would really help with compatibility.

I've been trying to get around a name conflict (in the Omeka CMS, which also uses Item) using PHP's namespace to no avail.

For some reason, it's putting together the various book parts but the spine and manifest are empty, producing a corrupt file.

I'm not sure the best way to approach this (nor am I sure I'm using namespaces correctly) but figured I'd put it out there as an issue.

remove composer.phar from legacy folder

Hi

It should be Ok to remove composer.phar from your /legacy/ folder as most people have it separately installed these days. It causes problems in editors like phpStorm because composer.phar has declarations for some widely used Symfony components, so phpStorm reports duplicate class declarations unless you manually go and exclude each composer.phar from your project after each update.

Also, is it possible for you to tag a new release of grandt/relativepath so that composer will pick up that you have deleted composer.phar from there when including it as a dependency of grandt/phpepub?

thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.