Skip to content

Freeze when add string resources #2

Description

@LionZXY

Big thanks for your work.

But i can't create book from string resource.

    val epubBook = EpubBook()
    epubBook.metadata.addTitle(book.title)
    epubBook.metadata.addDate(nl.siegmann.epublib.domain.Date(Date(book.created_at)))
    epubBook.metadata.addDescription(book.annotation)
    book.tags.forEach { epubBook.metadata.addType(it.name) }
    book.genres.forEach { epubBook.metadata.addType(it.name) }
    epubBook.metadata.addCreator(CreatorContributor(book.author_name));
    epubBook.coverImage = Resource(URL(book.cover).openStream(), "cover.jpg")
    book.chapters.forEach {
        try {
            val text = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n" +
                    "\n" +
                    "<html xmlns=\"http://www.w3.org/1999/xhtml\"><head><title> ${it.title} </title></head><body>\n ${getTextChapter(it.id)}</body></html>"
            val res = Resource(text.toByteArray(),  MediatypeService.XHTML)
            res.title = it.title
            epubBook.addSection(it.title, res)
        } catch (e: NoSuchFileException) {
            println("Не найдена часть ${it.title} для книги ${book.title}")
        }
    }
    val epubWritter = Epub3Writer()
    val filename = book.title.replace("[^a-zA-Zа-яА-Я0-9-_\\.]", "_")
    epubWritter.write(epubBook, FileOutputStream("bookOut/$filename.epub"))

When i try creating book the program freezes and print in log:

href: item_5.xhtml
href: item_4.xhtml
href: cover.jpg
href: item_2.xhtml
href: item_6.xhtml
href: item_1.xhtml
href: item_3.xhtml
item_1.xhtml

Freeze In line from Epub3PackageDocumentWriter:

Document d = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(resource.getInputStream());

Using version: 0.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions