├── .gitattributes ├── .github └── workflows │ └── gradle.yml ├── .gitignore ├── .sdkmanrc ├── .travis.yml ├── .upstream ├── CREDITS ├── LICENSE ├── Makefile ├── Makefile.txt ├── README.md ├── build.gradle ├── doc ├── Alice’s-Adventures-in-Wonderland_2011-01-30_18-17-30.png ├── schema.min.svg └── schema.svg ├── epub4j-core ├── build.gradle └── src │ ├── main │ ├── java │ │ ├── io │ │ │ └── documentnode │ │ │ │ └── epub4j │ │ │ │ ├── Constants.java │ │ │ │ ├── browsersupport │ │ │ │ ├── NavigationEvent.java │ │ │ │ ├── NavigationEventListener.java │ │ │ │ ├── NavigationHistory.java │ │ │ │ ├── Navigator.java │ │ │ │ └── package-info.java │ │ │ │ ├── domain │ │ │ │ ├── Author.java │ │ │ │ ├── Book.java │ │ │ │ ├── Date.java │ │ │ │ ├── EpubResourceProvider.java │ │ │ │ ├── Guide.java │ │ │ │ ├── GuideReference.java │ │ │ │ ├── Identifier.java │ │ │ │ ├── LazyResource.java │ │ │ │ ├── LazyResourceProvider.java │ │ │ │ ├── ManifestItemProperties.java │ │ │ │ ├── ManifestItemRefProperties.java │ │ │ │ ├── ManifestProperties.java │ │ │ │ ├── MediaType.java │ │ │ │ ├── MediaTypes.java │ │ │ │ ├── Metadata.java │ │ │ │ ├── Relator.java │ │ │ │ ├── Resource.java │ │ │ │ ├── ResourceInputStream.java │ │ │ │ ├── ResourceReference.java │ │ │ │ ├── Resources.java │ │ │ │ ├── Spine.java │ │ │ │ ├── SpineReference.java │ │ │ │ ├── TOCReference.java │ │ │ │ ├── TableOfContents.java │ │ │ │ └── TitledResourceReference.java │ │ │ │ ├── epub │ │ │ │ ├── BookProcessor.java │ │ │ │ ├── BookProcessorPipeline.java │ │ │ │ ├── DOMUtil.java │ │ │ │ ├── EpubProcessorSupport.java │ │ │ │ ├── EpubReader.java │ │ │ │ ├── EpubWriter.java │ │ │ │ ├── HtmlProcessor.java │ │ │ │ ├── Main.java │ │ │ │ ├── NCXDocument.java │ │ │ │ ├── PackageDocumentBase.java │ │ │ │ ├── PackageDocumentMetadataReader.java │ │ │ │ ├── PackageDocumentMetadataWriter.java │ │ │ │ ├── PackageDocumentReader.java │ │ │ │ ├── PackageDocumentWriter.java │ │ │ │ └── ResourcesLoader.java │ │ │ │ └── util │ │ │ │ ├── CollectionUtil.java │ │ │ │ ├── IOUtil.java │ │ │ │ ├── NoCloseOutputStream.java │ │ │ │ ├── NoCloseWriter.java │ │ │ │ ├── ResourceUtil.java │ │ │ │ ├── StreamWriterDelegate.java │ │ │ │ ├── StringUtil.java │ │ │ │ └── commons │ │ │ │ └── io │ │ │ │ ├── BOMInputStream.java │ │ │ │ ├── ByteOrderMark.java │ │ │ │ ├── ProxyInputStream.java │ │ │ │ ├── XmlStreamReader.java │ │ │ │ └── XmlStreamReaderException.java │ │ └── net │ │ │ └── sf │ │ │ └── jazzlib │ │ │ ├── Adler32.java │ │ │ ├── CRC32.java │ │ │ ├── CheckedInputStream.java │ │ │ ├── CheckedOutputStream.java │ │ │ ├── Checksum.java │ │ │ ├── DataFormatException.java │ │ │ ├── Deflater.java │ │ │ ├── DeflaterConstants.java │ │ │ ├── DeflaterEngine.java │ │ │ ├── DeflaterHuffman.java │ │ │ ├── DeflaterOutputStream.java │ │ │ ├── DeflaterPending.java │ │ │ ├── GZIPInputStream.java │ │ │ ├── GZIPOutputStream.java │ │ │ ├── Inflater.java │ │ │ ├── InflaterDynHeader.java │ │ │ ├── InflaterHuffmanTree.java │ │ │ ├── InflaterInputStream.java │ │ │ ├── OutputWindow.java │ │ │ ├── PendingBuffer.java │ │ │ ├── StreamManipulator.java │ │ │ ├── ZipConstants.java │ │ │ ├── ZipEntry.java │ │ │ ├── ZipException.java │ │ │ ├── ZipFile.java │ │ │ ├── ZipInputStream.java │ │ │ └── ZipOutputStream.java │ └── resources │ │ └── dtd │ │ ├── openebook.org │ │ └── dtds │ │ │ └── oeb-1.2 │ │ │ ├── oeb12.ent │ │ │ └── oebpkg12.dtd │ │ ├── www.daisy.org │ │ └── z3986 │ │ │ └── 2005 │ │ │ └── ncx-2005-1.dtd │ │ └── www.w3.org │ │ └── TR │ │ ├── ruby │ │ └── xhtml-ruby-1.mod │ │ ├── xhtml-modularization │ │ └── DTD │ │ │ ├── xhtml-arch-1.mod │ │ │ ├── xhtml-attribs-1.mod │ │ │ ├── xhtml-base-1.mod │ │ │ ├── xhtml-bdo-1.mod │ │ │ ├── xhtml-blkphras-1.mod │ │ │ ├── xhtml-blkpres-1.mod │ │ │ ├── xhtml-blkstruct-1.mod │ │ │ ├── xhtml-charent-1.mod │ │ │ ├── xhtml-csismap-1.mod │ │ │ ├── xhtml-datatypes-1.mod │ │ │ ├── xhtml-datatypes-1.mod.1 │ │ │ ├── xhtml-edit-1.mod │ │ │ ├── xhtml-events-1.mod │ │ │ ├── xhtml-form-1.mod │ │ │ ├── xhtml-framework-1.mod │ │ │ ├── xhtml-hypertext-1.mod │ │ │ ├── xhtml-image-1.mod │ │ │ ├── xhtml-inlphras-1.mod │ │ │ ├── xhtml-inlpres-1.mod │ │ │ ├── xhtml-inlstruct-1.mod │ │ │ ├── xhtml-inlstyle-1.mod │ │ │ ├── xhtml-lat1.ent │ │ │ ├── xhtml-link-1.mod │ │ │ ├── xhtml-list-1.mod │ │ │ ├── xhtml-meta-1.mod │ │ │ ├── xhtml-notations-1.mod │ │ │ ├── xhtml-object-1.mod │ │ │ ├── xhtml-param-1.mod │ │ │ ├── xhtml-pres-1.mod │ │ │ ├── xhtml-qname-1.mod │ │ │ ├── xhtml-script-1.mod │ │ │ ├── xhtml-special.ent │ │ │ ├── xhtml-ssismap-1.mod │ │ │ ├── xhtml-struct-1.mod │ │ │ ├── xhtml-style-1.mod │ │ │ ├── xhtml-symbol.ent │ │ │ ├── xhtml-symbol.ent.1 │ │ │ ├── xhtml-table-1.mod │ │ │ ├── xhtml-text-1.mod │ │ │ └── xhtml11-model-1.mod │ │ ├── xhtml1 │ │ └── DTD │ │ │ ├── xhtml-lat1.ent │ │ │ ├── xhtml-special.ent │ │ │ ├── xhtml-symbol.ent │ │ │ ├── xhtml1-strict.dtd │ │ │ └── xhtml1-transitional.dtd │ │ └── xhtml11 │ │ └── DTD │ │ └── xhtml11.dtd │ └── test │ ├── java │ └── io │ │ └── documentnode │ │ └── epub4j │ │ ├── browsersupport │ │ └── NavigationHistoryTest.java │ │ ├── domain │ │ ├── BookTest.java │ │ ├── ResourcesTest.java │ │ └── TableOfContentsTest.java │ │ ├── epub │ │ ├── DOMUtilTest.java │ │ ├── EpubReaderTest.java │ │ ├── EpubWriterTest.java │ │ ├── NCXDocumentTest.java │ │ ├── PackageDocumentMetadataReaderTest.java │ │ ├── PackageDocumentReaderTest.java │ │ ├── ResourcesLoaderTest.java │ │ ├── Sample.java │ │ └── SampleLazy.java │ │ └── util │ │ ├── CollectionUtilTest.java │ │ ├── IOUtilTest.java │ │ ├── NoCloseOutputStreamTest.java │ │ ├── NoCloseWriterTest.java │ │ └── StringUtilTest.java │ └── resources │ ├── book1 │ ├── book1.css │ ├── chapter1.html │ ├── chapter2.html │ ├── chapter2_1.html │ ├── chapter3.html │ ├── cover.html │ ├── cover.png │ └── flowers.jpg │ ├── chm1 │ ├── #IDXHDR │ ├── #IVB │ ├── #STRINGS │ ├── #SYSTEM │ ├── #TOPICS │ ├── #URLSTR │ ├── #URLTBL │ ├── #WINDOWS │ ├── $FIftiMain │ ├── $OBJINST │ ├── $WWAssociativeLinks │ │ ├── BTree │ │ ├── Data │ │ ├── Map │ │ └── Property │ ├── $WWKeywordLinks │ │ ├── BTree │ │ ├── Data │ │ ├── Map │ │ └── Property │ ├── CHM-example.hhc │ ├── CHM-example.hhk │ ├── Context-sensitive_example │ │ ├── contextID-10000.htm │ │ ├── contextID-10010.htm │ │ ├── contextID-20000.htm │ │ └── contextID-20010.htm │ ├── Garden │ │ ├── flowers.htm │ │ ├── garden.htm │ │ └── tree.htm │ ├── HTMLHelp_Examples │ │ ├── CloseWindowAutomatically.htm │ │ ├── Jump_to_anchor.htm │ │ ├── LinkPDFfromCHM.htm │ │ ├── Simple_link_example.htm │ │ ├── example-external-pdf.htm │ │ ├── pop-up_example.htm │ │ ├── shortcut_link.htm │ │ ├── topic-02.htm │ │ ├── topic-03.htm │ │ ├── topic-04.htm │ │ ├── topic_split_example.htm │ │ ├── using_window_open.htm │ │ └── xp-style_radio-button_check-boxes.htm │ ├── design.css │ ├── embedded_files │ │ └── example-embedded.pdf │ ├── external_files │ │ └── external_topic.htm │ ├── filelist.txt │ ├── images │ │ ├── blume.jpg │ │ ├── ditzum.jpg │ │ ├── eiche.jpg │ │ ├── extlink.gif │ │ ├── insekt.jpg │ │ ├── list_arrow.gif │ │ ├── lupine.jpg │ │ ├── riffel_40px.jpg │ │ ├── riffel_helpinformation.jpg │ │ ├── riffel_home.jpg │ │ ├── rotor_enercon.jpg │ │ ├── screenshot_big.png │ │ ├── screenshot_small.png │ │ ├── up_rectangle.png │ │ ├── verlauf-blau.jpg │ │ ├── verlauf-gelb.jpg │ │ ├── verlauf-rot.jpg │ │ ├── welcome_small_big-en.gif │ │ └── wintertree.jpg │ ├── index.htm │ └── topic.txt │ ├── holmes_scandal_bohemia.html │ ├── not_a_zip.epub │ ├── opf │ ├── test1.opf │ ├── test2.opf │ ├── test_default_language.opf │ └── test_language.opf │ ├── testbook1.epub │ ├── toc.xml │ └── zero_length_file.epub ├── epub4j-tools ├── README.md ├── build.gradle └── src │ ├── main │ ├── groovy │ │ └── io │ │ │ └── documentnode │ │ │ └── epub4j │ │ │ └── docbook2epub.groovy │ ├── java │ │ ├── io │ │ │ └── documentnode │ │ │ │ └── epub4j │ │ │ │ ├── Fileset2Epub.java │ │ │ │ ├── bookprocessor │ │ │ │ ├── CoverPageBookProcessor.java │ │ │ │ ├── DefaultBookProcessorPipeline.java │ │ │ │ ├── FixIdentifierBookProcessor.java │ │ │ │ ├── FixMissingResourceBookProcessor.java │ │ │ │ ├── HtmlBookProcessor.java │ │ │ │ ├── HtmlCleanerBookProcessor.java │ │ │ │ ├── HtmlSplitterBookProcessor.java │ │ │ │ ├── SectionHrefSanityCheckBookProcessor.java │ │ │ │ ├── SectionTitleBookProcessor.java │ │ │ │ ├── TextReplaceBookProcessor.java │ │ │ │ ├── XslBookProcessor.java │ │ │ │ └── package-info.java │ │ │ │ ├── chm │ │ │ │ ├── ChmParser.java │ │ │ │ ├── HHCParser.java │ │ │ │ └── package-info.java │ │ │ │ ├── fileset │ │ │ │ └── FilesetBookCreator.java │ │ │ │ ├── html │ │ │ │ └── htmlcleaner │ │ │ │ │ ├── XmlEventSerializer.java │ │ │ │ │ └── XmlSerializer.java │ │ │ │ ├── search │ │ │ │ ├── ResourceSearchIndex.java │ │ │ │ ├── SearchIndex.java │ │ │ │ ├── SearchResult.java │ │ │ │ └── SearchResults.java │ │ │ │ ├── util │ │ │ │ ├── DesktopUtil.java │ │ │ │ ├── ToolsResourceUtil.java │ │ │ │ └── VFSUtil.java │ │ │ │ ├── utilities │ │ │ │ ├── HtmlSplitter.java │ │ │ │ └── NumberSayer.java │ │ │ │ └── viewer │ │ │ │ ├── AboutDialog.java │ │ │ │ ├── BrowseBar.java │ │ │ │ ├── ButtonBar.java │ │ │ │ ├── ContentPane.java │ │ │ │ ├── GuidePane.java │ │ │ │ ├── HTMLDocumentFactory.java │ │ │ │ ├── ImageLoaderCache.java │ │ │ │ ├── MetadataPane.java │ │ │ │ ├── MyHtmlEditorKit.java │ │ │ │ ├── MyParserCallback.java │ │ │ │ ├── NavigationBar.java │ │ │ │ ├── SpineSlider.java │ │ │ │ ├── TableOfContentsPane.java │ │ │ │ ├── ValueHolder.java │ │ │ │ ├── Viewer.java │ │ │ │ └── ViewerUtil.java │ │ └── org │ │ │ └── htmlcleaner │ │ │ └── EPUB4JXmlSerializer.java │ └── resources │ │ ├── viewer │ │ ├── book │ │ │ ├── 00_cover.html │ │ │ └── index.txt │ │ ├── epub4jviewer-help.epub │ │ └── icons │ │ │ ├── chapter-first.png │ │ │ ├── chapter-last.png │ │ │ ├── chapter-next.png │ │ │ ├── chapter-previous.png │ │ │ ├── history-next.png │ │ │ ├── history-previous.png │ │ │ ├── layout-content.png │ │ │ ├── layout-toc-content-meta.png │ │ │ ├── layout-toc-content.png │ │ │ ├── page-next.png │ │ │ ├── page-previous.png │ │ │ ├── search-icon.png │ │ │ ├── search-next.png │ │ │ └── search-previous.png │ │ └── xsl │ │ ├── chm_remove_prev_next.xsl │ │ ├── chm_remove_prev_next_2.xsl │ │ ├── chm_remove_prev_next_3.xsl │ │ └── remove_comment_container.xsl │ └── test │ ├── java │ └── io │ │ └── documentnode │ │ └── epub4j │ │ ├── FilesetBookCreatorTest.java │ │ ├── bookprocessor │ │ └── CoverpageBookProcessorTest.java │ │ ├── fileset │ │ └── FilesetBookCreatorTest.java │ │ ├── hhc │ │ └── ChmParserTest.java │ │ ├── html │ │ └── htmlcleaner │ │ │ ├── FixIdentifierBookProcessorTest.java │ │ │ └── HtmlCleanerBookProcessorTest.java │ │ ├── search │ │ └── SearchIndexTest.java │ │ └── utilities │ │ ├── HtmlSplitterTest.java │ │ ├── NumberSayerTest.java │ │ └── ResourceUtilTest.java │ └── resources │ ├── book1 │ ├── book1.css │ ├── chapter1.html │ ├── chapter2.html │ ├── chapter2_1.html │ ├── chapter3.html │ ├── cover.html │ ├── cover.png │ └── flowers_320x240.jpg │ ├── chm1 │ ├── #IDXHDR │ ├── #IVB │ ├── #STRINGS │ ├── #SYSTEM │ ├── #TOPICS │ ├── #URLSTR │ ├── #URLTBL │ ├── #WINDOWS │ ├── $FIftiMain │ ├── $OBJINST │ ├── $WWAssociativeLinks │ │ ├── BTree │ │ ├── Data │ │ ├── Map │ │ └── Property │ ├── $WWKeywordLinks │ │ ├── BTree │ │ ├── Data │ │ ├── Map │ │ └── Property │ ├── CHM-example.hhc │ ├── CHM-example.hhk │ ├── Context-sensitive_example │ │ ├── contextID-10000.htm │ │ ├── contextID-10010.htm │ │ ├── contextID-20000.htm │ │ └── contextID-20010.htm │ ├── Garden │ │ ├── flowers.htm │ │ ├── garden.htm │ │ └── tree.htm │ ├── HTMLHelp_Examples │ │ ├── CloseWindowAutomatically.htm │ │ ├── Jump_to_anchor.htm │ │ ├── LinkPDFfromCHM.htm │ │ ├── Simple_link_example.htm │ │ ├── example-external-pdf.htm │ │ ├── pop-up_example.htm │ │ ├── shortcut_link.htm │ │ ├── topic-02.htm │ │ ├── topic-03.htm │ │ ├── topic-04.htm │ │ ├── topic_split_example.htm │ │ ├── using_window_open.htm │ │ └── xp-style_radio-button_check-boxes.htm │ ├── design.css │ ├── embedded_files │ │ └── example-embedded.pdf │ ├── external_files │ │ └── external_topic.htm │ ├── filelist.txt │ ├── images │ │ ├── blume.jpg │ │ ├── ditzum.jpg │ │ ├── eiche.jpg │ │ ├── extlink.gif │ │ ├── insekt.jpg │ │ ├── list_arrow.gif │ │ ├── lupine.jpg │ │ ├── riffel_40px.jpg │ │ ├── riffel_helpinformation.jpg │ │ ├── riffel_home.jpg │ │ ├── rotor_enercon.jpg │ │ ├── screenshot_big.png │ │ ├── screenshot_small.png │ │ ├── up_rectangle.png │ │ ├── verlauf-blau.jpg │ │ ├── verlauf-gelb.jpg │ │ ├── verlauf-rot.jpg │ │ ├── welcome_small_big-en.gif │ │ └── wintertree.jpg │ ├── index.htm │ └── topic.txt │ ├── holmes_scandal_bohemia.html │ ├── opf │ ├── test1.opf │ └── test2.opf │ └── toc.xml ├── gradle.properties ├── gradle ├── libs.versions.toml └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitattributes: -------------------------------------------------------------------------------- 1 | # 2 | # https://help.github.com/articles/dealing-with-line-endings/ 3 | # 4 | # These are explicitly windows files and should use crlf 5 | *.bat text eol=crlf 6 | 7 | -------------------------------------------------------------------------------- /.github/workflows/gradle.yml: -------------------------------------------------------------------------------- 1 | # This workflow will build a Java project with Gradle 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle 3 | 4 | name: Java CI with Gradle 5 | 6 | on: 7 | push: 8 | branches: [ main ] 9 | pull_request: 10 | branches: [ main ] 11 | 12 | jobs: 13 | build: 14 | 15 | runs-on: ubuntu-latest 16 | 17 | steps: 18 | - uses: actions/checkout@v4 19 | - name: Set up JDK 17 20 | uses: actions/setup-java@v2 21 | with: 22 | distribution: 'zulu' 23 | java-version: 17 24 | 25 | - name: Grant execute permission for gradlew 26 | run: chmod +x gradlew 27 | - name: Build with Gradle 28 | run: ./gradlew clean build --warning-mode all 29 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled class file 2 | *.class 3 | 4 | # Log file 5 | *.log 6 | 7 | # BlueJ files 8 | *.ctxt 9 | 10 | # Mobile Tools for Java (J2ME) 11 | .mtj.tmp/ 12 | 13 | # Package Files # 14 | *.jar 15 | *.war 16 | *.nar 17 | *.ear 18 | *.zip 19 | *.tar.gz 20 | *.rar 21 | 22 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 23 | hs_err_pid* 24 | 25 | # Ignore Gradle project-specific cache directory 26 | .gradle 27 | 28 | # Ignore Gradle build output directory 29 | build 30 | /.idea/ 31 | /test1_book1.epub 32 | **/build/ 33 | **/.gradle 34 | !**/gradle-wapper.jar 35 | /testbook1.epub 36 | /epub4j-core/src/main/java/io/documentnode/epub4j/util/GVersion.java 37 | /testbook1_lazy.epub 38 | /epub4j-core/testbook1.epub 39 | -------------------------------------------------------------------------------- /.sdkmanrc: -------------------------------------------------------------------------------- 1 | # Enable auto-env through the sdkman_auto_env config 2 | # Add key=value pairs of SDKs to use below 3 | java=17.0.3-oracle 4 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | install: true 3 | script: make clean build 4 | -------------------------------------------------------------------------------- /.upstream: -------------------------------------------------------------------------------- 1 | commit 5df37656ef9370be6b784b12a8640e37facdbc0f 2 | Merge: c5aafb2 69ac6b0 3 | Author: Paul Siegmann 4 | Date: Mon Dec 16 18:44:38 2019 +0100 5 | 6 | Merge pull request #126 from nelkinda/master 7 | 8 | Fix a few Javadoc issues. -------------------------------------------------------------------------------- /CREDITS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/CREDITS -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | LATEST_TAG?=`git tag|sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n | tail -1` 2 | 3 | help: 4 | cat Makefile.txt 5 | 6 | clean: 7 | ./gradlew clean 8 | 9 | pull: 10 | git pull 11 | git submodule update --init --recursive 12 | git submodule foreach git checkout main 13 | git submodule foreach git pull 14 | 15 | .PHONY: build 16 | build: 17 | ./gradlew build --warning-mode all 18 | 19 | build-fast: 20 | ./gradlew build -Pcheck=false -x test --warning-mode all 21 | 22 | release: 23 | ./gradlew release --warning-mode all 24 | 25 | publish: build 26 | rm -rf $$HOME/.m2/repository/io/documentnode/epub4j-core 27 | ./gradlew publishToMavenLocal --warning-mode all 28 | 29 | publish-remote: publish 30 | ./gradlew publishMavenJavaPublicationToMavenRepository --warning-mode all 31 | 32 | -------------------------------------------------------------------------------- /Makefile.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: make options... 3 | 4 | Option Description 5 | ------ ----------- 6 | clean Clean build directories of projects 7 | pull Pull latest source code including submodules 8 | build Build projects with tests 9 | build-fast Build projects without tests 10 | release Release a new version for projects 11 | publish Publish libraries to Maven local 12 | publish-remote Publish libraries to Maven Central 13 | 14 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2024 Document Node Pty Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | plugins { 18 | alias(libs.plugins.axion.release) 19 | } 20 | 21 | allprojects { 22 | group = 'io.documentnode' 23 | project.version = rootProject.version 24 | } 25 | 26 | subprojects { 27 | // Apply the java-library plugin for API and implementation separation. 28 | apply plugin: "java-library" 29 | apply plugin: "java" 30 | 31 | repositories { 32 | // Use Maven Central for resolving dependencies. 33 | mavenCentral() 34 | } 35 | 36 | def javaVersion = JavaVersion.VERSION_17 37 | java { 38 | toolchain { 39 | languageVersion = JavaLanguageVersion.of(javaVersion.toString()) 40 | } 41 | } 42 | task enforceVersion { 43 | doLast { 44 | def foundVersion = JavaVersion.current() 45 | if (foundVersion != javaVersion) 46 | throw new IllegalStateException("Wrong Java version; required is " 47 | + javaVersion + ", but found " + foundVersion) 48 | } 49 | } 50 | compileJava.dependsOn(enforceVersion) 51 | 52 | dependencies { 53 | implementation libs.dn.minilog 54 | 55 | // Don't use the traditional logging framework to make it easier 56 | // for creating a native shared library (smaller) 57 | // implementation("org.slf4j:slf4j-api:1.8.0-beta4") 58 | // implementation("org.slf4j:slf4j-simple:1.8.0-beta4") 59 | 60 | // Use JUnit for testing 61 | testImplementation libs.junit4 62 | testImplementation libs.mockito.core 63 | } 64 | 65 | tasks.named('test') { 66 | // Use JUnit for unit tests. 67 | useJUnit() 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /doc/Alice’s-Adventures-in-Wonderland_2011-01-30_18-17-30.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/doc/Alice’s-Adventures-in-Wonderland_2011-01-30_18-17-30.png -------------------------------------------------------------------------------- /epub4j-core/src/main/java/io/documentnode/epub4j/Constants.java: -------------------------------------------------------------------------------- 1 | package io.documentnode.epub4j; 2 | 3 | import io.documentnode.epub4j.util.GVersion; 4 | 5 | public interface Constants { 6 | 7 | String CHARACTER_ENCODING = "UTF-8"; 8 | String DOCTYPE_XHTML = ""; 9 | String NAMESPACE_XHTML = "http://www.w3.org/1999/xhtml"; 10 | String EPUB4J_GENERATOR_NAME = "EPUB4J v" 11 | + GVersion.VERSION.replace("-SNAPSHOT", "") + "." 12 | + GVersion.GIT_REVISION; 13 | char FRAGMENT_SEPARATOR_CHAR = '#'; 14 | String DEFAULT_TOC_ID = "toc"; 15 | } 16 | -------------------------------------------------------------------------------- /epub4j-core/src/main/java/io/documentnode/epub4j/browsersupport/NavigationEventListener.java: -------------------------------------------------------------------------------- 1 | package io.documentnode.epub4j.browsersupport; 2 | 3 | /** 4 | * Implemented by classes that want to be notified if the user moves to 5 | * another location in the book. 6 | * 7 | * @author paul 8 | * 9 | */ 10 | public interface NavigationEventListener { 11 | 12 | /** 13 | * Called whenever the user navigates to another position in the book. 14 | * 15 | * @param navigationEvent 16 | */ 17 | void navigationPerformed(NavigationEvent navigationEvent); 18 | } -------------------------------------------------------------------------------- /epub4j-core/src/main/java/io/documentnode/epub4j/browsersupport/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Provides classes that help make an epub reader application. 3 | * 4 | * These classes have no dependencies on graphic toolkits, they're purely 5 | * to help with the browsing/navigation logic. 6 | */ 7 | package io.documentnode.epub4j.browsersupport; 8 | -------------------------------------------------------------------------------- /epub4j-core/src/main/java/io/documentnode/epub4j/domain/Author.java: -------------------------------------------------------------------------------- 1 | package io.documentnode.epub4j.domain; 2 | 3 | import io.documentnode.epub4j.util.StringUtil; 4 | import java.io.Serializable; 5 | 6 | /** 7 | * Represents one of the authors of the book 8 | * 9 | * @author paul 10 | * 11 | */ 12 | public class Author implements Serializable { 13 | 14 | private static final long serialVersionUID = 6663408501416574200L; 15 | 16 | private String firstname; 17 | private String lastname; 18 | private Relator relator = Relator.AUTHOR; 19 | 20 | public Author(String singleName) { 21 | this("", singleName); 22 | } 23 | 24 | public Author(String firstname, String lastname) { 25 | this.firstname = firstname; 26 | this.lastname = lastname; 27 | } 28 | 29 | public String getFirstname() { 30 | return firstname; 31 | } 32 | 33 | public void setFirstname(String firstname) { 34 | this.firstname = firstname; 35 | } 36 | 37 | public String getLastname() { 38 | return lastname; 39 | } 40 | 41 | public void setLastname(String lastname) { 42 | this.lastname = lastname; 43 | } 44 | 45 | public String toString() { 46 | return lastname + ", " + firstname; 47 | } 48 | 49 | public int hashCode() { 50 | return StringUtil.hashCode(firstname, lastname); 51 | } 52 | 53 | public boolean equals(Object authorObject) { 54 | if (!(authorObject instanceof Author)) { 55 | return false; 56 | } 57 | Author other = (Author) authorObject; 58 | return StringUtil.equals(firstname, other.firstname) 59 | && StringUtil.equals(lastname, other.lastname); 60 | } 61 | 62 | public Relator setRole(String code) { 63 | Relator result = Relator.byCode(code); 64 | if (result == null) { 65 | result = Relator.AUTHOR; 66 | } 67 | this.relator = result; 68 | return result; 69 | } 70 | 71 | public Relator getRelator() { 72 | return relator; 73 | } 74 | 75 | 76 | public void setRelator(Relator relator) { 77 | this.relator = relator; 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /epub4j-core/src/main/java/io/documentnode/epub4j/domain/EpubResourceProvider.java: -------------------------------------------------------------------------------- 1 | package io.documentnode.epub4j.domain; 2 | 3 | import java.io.IOException; 4 | import java.io.InputStream; 5 | import java.util.zip.ZipEntry; 6 | import java.util.zip.ZipFile; 7 | 8 | /** 9 | * @author jake 10 | */ 11 | public class EpubResourceProvider implements LazyResourceProvider { 12 | 13 | private final String epubFilename; 14 | 15 | /** 16 | * @param epubFilename the file name for the epub we're created from. 17 | */ 18 | public EpubResourceProvider(String epubFilename) { 19 | this.epubFilename = epubFilename; 20 | } 21 | 22 | @Override 23 | public InputStream getResourceStream(String href) throws IOException { 24 | ZipFile zipFile = new ZipFile(epubFilename); 25 | ZipEntry zipEntry = zipFile.getEntry(href); 26 | if (zipEntry == null) { 27 | zipFile.close(); 28 | throw new IllegalStateException( 29 | "Cannot find entry " + href + " in epub file " + epubFilename); 30 | } 31 | return new ResourceInputStream(zipFile.getInputStream(zipEntry), zipFile); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /epub4j-core/src/main/java/io/documentnode/epub4j/domain/LazyResourceProvider.java: -------------------------------------------------------------------------------- 1 | package io.documentnode.epub4j.domain; 2 | 3 | import java.io.IOException; 4 | import java.io.InputStream; 5 | 6 | /** 7 | * @author jake 8 | */ 9 | public interface LazyResourceProvider { 10 | 11 | InputStream getResourceStream(String href) throws IOException; 12 | } 13 | -------------------------------------------------------------------------------- /epub4j-core/src/main/java/io/documentnode/epub4j/domain/ManifestItemProperties.java: -------------------------------------------------------------------------------- 1 | package io.documentnode.epub4j.domain; 2 | 3 | public enum ManifestItemProperties implements ManifestProperties { 4 | COVER_IMAGE("cover-image"), 5 | MATHML("mathml"), 6 | NAV("nav"), 7 | REMOTE_RESOURCES("remote-resources"), 8 | SCRIPTED("scripted"), 9 | SVG("svg"), 10 | SWITCH("switch"); 11 | 12 | private String name; 13 | 14 | ManifestItemProperties(String name) { 15 | this.name = name; 16 | } 17 | 18 | public String getName() { 19 | return name; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /epub4j-core/src/main/java/io/documentnode/epub4j/domain/ManifestItemRefProperties.java: -------------------------------------------------------------------------------- 1 | package io.documentnode.epub4j.domain; 2 | 3 | public enum ManifestItemRefProperties implements ManifestProperties { 4 | PAGE_SPREAD_LEFT("page-spread-left"), 5 | PAGE_SPREAD_RIGHT("page-spread-right"); 6 | 7 | private String name; 8 | 9 | ManifestItemRefProperties(String name) { 10 | this.name = name; 11 | } 12 | 13 | public String getName() { 14 | return name; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /epub4j-core/src/main/java/io/documentnode/epub4j/domain/ManifestProperties.java: -------------------------------------------------------------------------------- 1 | package io.documentnode.epub4j.domain; 2 | 3 | public interface ManifestProperties { 4 | 5 | String getName(); 6 | } 7 | -------------------------------------------------------------------------------- /epub4j-core/src/main/java/io/documentnode/epub4j/domain/MediaType.java: -------------------------------------------------------------------------------- 1 | package io.documentnode.epub4j.domain; 2 | 3 | import java.io.Serializable; 4 | import java.util.Arrays; 5 | import java.util.Collection; 6 | 7 | /** 8 | * MediaType is used to tell the type of content a resource is. 9 | * 10 | * Examples of mediatypes are image/gif, text/css and application/xhtml+xml 11 | * 12 | * All allowed mediaTypes are maintained bye the MediaTypeService. 13 | * 14 | * @see MediaTypes 15 | * 16 | * @author paul 17 | */ 18 | public class MediaType implements Serializable { 19 | 20 | private static final long serialVersionUID = -7256091153727506788L; 21 | private String name; 22 | private String defaultExtension; 23 | private Collection extensions; 24 | 25 | public MediaType(String name, String defaultExtension) { 26 | this(name, defaultExtension, new String[]{defaultExtension}); 27 | } 28 | 29 | public MediaType(String name, String defaultExtension, 30 | String[] extensions) { 31 | this(name, defaultExtension, Arrays.asList(extensions)); 32 | } 33 | 34 | public int hashCode() { 35 | if (name == null) { 36 | return 0; 37 | } 38 | return name.hashCode(); 39 | } 40 | 41 | public MediaType(String name, String defaultExtension, 42 | Collection extensions) { 43 | super(); 44 | this.name = name; 45 | this.defaultExtension = defaultExtension; 46 | this.extensions = extensions; 47 | } 48 | 49 | public String getName() { 50 | return name; 51 | } 52 | 53 | 54 | public String getDefaultExtension() { 55 | return defaultExtension; 56 | } 57 | 58 | 59 | public Collection getExtensions() { 60 | return extensions; 61 | } 62 | 63 | public boolean equals(Object otherMediaType) { 64 | if (!(otherMediaType instanceof MediaType)) { 65 | return false; 66 | } 67 | return name.equals(((MediaType) otherMediaType).getName()); 68 | } 69 | 70 | public String toString() { 71 | return name; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /epub4j-core/src/main/java/io/documentnode/epub4j/domain/ResourceInputStream.java: -------------------------------------------------------------------------------- 1 | package io.documentnode.epub4j.domain; 2 | 3 | import java.io.FilterInputStream; 4 | import java.io.IOException; 5 | import java.io.InputStream; 6 | import java.util.zip.ZipFile; 7 | 8 | /** 9 | * A wrapper class for closing a ZipFile object when the InputStream derived 10 | * from it is closed. 11 | * 12 | * @author ttopalov 13 | */ 14 | public class ResourceInputStream extends FilterInputStream { 15 | 16 | private final ZipFile zipFile; 17 | 18 | /** 19 | * Constructor. 20 | * 21 | * @param in 22 | * The InputStream object. 23 | * @param zipFile 24 | * The ZipFile object. 25 | */ 26 | public ResourceInputStream(InputStream in, ZipFile zipFile) { 27 | super(in); 28 | this.zipFile = zipFile; 29 | } 30 | 31 | @Override 32 | public void close() throws IOException { 33 | super.close(); 34 | zipFile.close(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /epub4j-core/src/main/java/io/documentnode/epub4j/domain/ResourceReference.java: -------------------------------------------------------------------------------- 1 | package io.documentnode.epub4j.domain; 2 | 3 | import java.io.Serializable; 4 | 5 | public class ResourceReference implements Serializable { 6 | 7 | private static final long serialVersionUID = 2596967243557743048L; 8 | 9 | protected Resource resource; 10 | 11 | public ResourceReference(Resource resource) { 12 | this.resource = resource; 13 | } 14 | 15 | 16 | public Resource getResource() { 17 | return resource; 18 | } 19 | 20 | /** 21 | * Besides setting the resource it also sets the fragmentId to null. 22 | * 23 | * @param resource 24 | */ 25 | public void setResource(Resource resource) { 26 | this.resource = resource; 27 | } 28 | 29 | 30 | /** 31 | * The id of the reference referred to. 32 | * 33 | * null of the reference is null or has a null id itself. 34 | * 35 | * @return The id of the reference referred to. 36 | */ 37 | public String getResourceId() { 38 | if (resource != null) { 39 | return resource.getId(); 40 | } 41 | return null; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /epub4j-core/src/main/java/io/documentnode/epub4j/domain/SpineReference.java: -------------------------------------------------------------------------------- 1 | package io.documentnode.epub4j.domain; 2 | 3 | import java.io.Serializable; 4 | 5 | 6 | /** 7 | * A Section of a book. 8 | * Represents both an item in the package document and a item in the index. 9 | * 10 | * @author paul 11 | */ 12 | public class SpineReference extends ResourceReference implements Serializable { 13 | 14 | private static final long serialVersionUID = -7921609197351510248L; 15 | private boolean linear = true; 16 | 17 | public SpineReference(Resource resource) { 18 | this(resource, true); 19 | } 20 | 21 | 22 | public SpineReference(Resource resource, boolean linear) { 23 | super(resource); 24 | this.linear = linear; 25 | } 26 | 27 | /** 28 | * Linear denotes whether the section is Primary or Auxiliary. 29 | * Usually the cover page has linear set to false and all the other sections 30 | * have it set to true. 31 | * 32 | * It's an optional property that readers may also ignore. 33 | * 34 | *
primary or auxiliary is useful for Reading Systems which 35 | * opt to present auxiliary content differently than primary content. 36 | * For example, a Reading System might opt to render auxiliary content in 37 | * a popup window apart from the main window which presents the primary 38 | * content. (For an example of the types of content that may be considered 39 | * auxiliary, refer to the example below and the subsequent discussion.)
40 | * @see OPF Spine specification 41 | * 42 | * @return whether the section is Primary or Auxiliary. 43 | */ 44 | public boolean isLinear() { 45 | return linear; 46 | } 47 | 48 | public void setLinear(boolean linear) { 49 | this.linear = linear; 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /epub4j-core/src/main/java/io/documentnode/epub4j/domain/TOCReference.java: -------------------------------------------------------------------------------- 1 | package io.documentnode.epub4j.domain; 2 | 3 | import java.io.Serializable; 4 | import java.util.ArrayList; 5 | import java.util.Comparator; 6 | import java.util.List; 7 | 8 | /** 9 | * An item in the Table of Contents. 10 | * 11 | * @see TableOfContents 12 | * 13 | * @author paul 14 | */ 15 | public class TOCReference extends TitledResourceReference 16 | implements Serializable { 17 | 18 | private static final long serialVersionUID = 5787958246077042456L; 19 | private List children; 20 | private static final Comparator COMPARATOR_BY_TITLE_IGNORE_CASE = 21 | (tocReference1, tocReference2) -> 22 | String.CASE_INSENSITIVE_ORDER 23 | .compare(tocReference1.getTitle(), tocReference2.getTitle()); 24 | 25 | public TOCReference() { 26 | this(null, null, null); 27 | } 28 | 29 | public TOCReference(String name, Resource resource) { 30 | this(name, resource, null); 31 | } 32 | 33 | public TOCReference(String name, Resource resource, String fragmentId) { 34 | this(name, resource, fragmentId, new ArrayList<>()); 35 | } 36 | 37 | public TOCReference(String title, Resource resource, String fragmentId, 38 | List children) { 39 | super(resource, title, fragmentId); 40 | this.children = children; 41 | } 42 | 43 | public static Comparator getComparatorByTitleIgnoreCase() { 44 | return COMPARATOR_BY_TITLE_IGNORE_CASE; 45 | } 46 | 47 | public List getChildren() { 48 | return children; 49 | } 50 | 51 | public TOCReference addChildSection(TOCReference childSection) { 52 | this.children.add(childSection); 53 | return childSection; 54 | } 55 | 56 | public void setChildren(List children) { 57 | this.children = children; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /epub4j-core/src/main/java/io/documentnode/epub4j/domain/TitledResourceReference.java: -------------------------------------------------------------------------------- 1 | package io.documentnode.epub4j.domain; 2 | 3 | import io.documentnode.epub4j.Constants; 4 | import io.documentnode.epub4j.util.StringUtil; 5 | import java.io.Serializable; 6 | 7 | public class TitledResourceReference extends ResourceReference 8 | implements Serializable { 9 | 10 | private static final long serialVersionUID = 3918155020095190080L; 11 | private String fragmentId; 12 | private String title; 13 | 14 | public TitledResourceReference(Resource resource) { 15 | this(resource, null); 16 | } 17 | 18 | public TitledResourceReference(Resource resource, String title) { 19 | this(resource, title, null); 20 | } 21 | 22 | public TitledResourceReference(Resource resource, String title, 23 | String fragmentId) { 24 | super(resource); 25 | this.title = title; 26 | this.fragmentId = fragmentId; 27 | } 28 | 29 | public String getFragmentId() { 30 | return fragmentId; 31 | } 32 | 33 | public void setFragmentId(String fragmentId) { 34 | this.fragmentId = fragmentId; 35 | } 36 | 37 | public String getTitle() { 38 | return title; 39 | } 40 | 41 | public void setTitle(String title) { 42 | this.title = title; 43 | } 44 | 45 | 46 | /** 47 | * If the fragmentId is blank it returns the resource href, otherwise 48 | * it returns the resource href + '#' + the fragmentId. 49 | * 50 | * @return If the fragmentId is blank it returns the resource href, 51 | * otherwise it returns the resource href + '#' + the fragmentId. 52 | */ 53 | public String getCompleteHref() { 54 | if (StringUtil.isBlank(fragmentId)) { 55 | return resource.getHref(); 56 | } else { 57 | return resource.getHref() + Constants.FRAGMENT_SEPARATOR_CHAR 58 | + fragmentId; 59 | } 60 | } 61 | 62 | public void setResource(Resource resource, String fragmentId) { 63 | super.setResource(resource); 64 | this.fragmentId = fragmentId; 65 | } 66 | 67 | /** 68 | * Sets the resource to the given resource and sets the fragmentId to null. 69 | */ 70 | public void setResource(Resource resource) { 71 | setResource(resource, null); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /epub4j-core/src/main/java/io/documentnode/epub4j/epub/BookProcessor.java: -------------------------------------------------------------------------------- 1 | package io.documentnode.epub4j.epub; 2 | 3 | import io.documentnode.epub4j.domain.Book; 4 | 5 | /** 6 | * Post-processes a book. 7 | * 8 | * Can be used to clean up a book after reading or before writing. 9 | * 10 | * @author paul 11 | */ 12 | public interface BookProcessor { 13 | 14 | /** 15 | * A BookProcessor that returns the input book unchanged. 16 | */ 17 | BookProcessor IDENTITY_BOOKPROCESSOR = book -> book; 18 | 19 | Book processBook(Book book); 20 | } 21 | -------------------------------------------------------------------------------- /epub4j-core/src/main/java/io/documentnode/epub4j/epub/BookProcessorPipeline.java: -------------------------------------------------------------------------------- 1 | package io.documentnode.epub4j.epub; 2 | 3 | import io.documentnode.epub4j.domain.Book; 4 | import io.documentnode.minilog.Logger; 5 | import java.util.ArrayList; 6 | import java.util.Collection; 7 | import java.util.List; 8 | 9 | /** 10 | * A book processor that combines several other bookprocessors 11 | * 12 | * Fixes coverpage/coverimage. 13 | * Cleans up the XHTML. 14 | * 15 | * @author paul.siegmann 16 | */ 17 | public class BookProcessorPipeline implements BookProcessor { 18 | 19 | private Logger log = Logger.create(BookProcessorPipeline.class); 20 | private List bookProcessors; 21 | 22 | public BookProcessorPipeline() { 23 | this(null); 24 | } 25 | 26 | public BookProcessorPipeline(List bookProcessingPipeline) { 27 | this.bookProcessors = bookProcessingPipeline; 28 | } 29 | 30 | @Override 31 | public Book processBook(Book book) { 32 | if (bookProcessors == null) { 33 | return book; 34 | } 35 | for (BookProcessor bookProcessor : bookProcessors) { 36 | try { 37 | book = bookProcessor.processBook(book); 38 | } catch (Exception e) { 39 | log.error(e.getMessage(), e); 40 | } 41 | } 42 | return book; 43 | } 44 | 45 | public void addBookProcessor(BookProcessor bookProcessor) { 46 | if (this.bookProcessors == null) { 47 | bookProcessors = new ArrayList(); 48 | } 49 | this.bookProcessors.add(bookProcessor); 50 | } 51 | 52 | public void addBookProcessors(Collection bookProcessors) { 53 | if (this.bookProcessors == null) { 54 | this.bookProcessors = new ArrayList(); 55 | } 56 | this.bookProcessors.addAll(bookProcessors); 57 | } 58 | 59 | 60 | public List getBookProcessors() { 61 | return bookProcessors; 62 | } 63 | 64 | 65 | public void setBookProcessingPipeline( 66 | List bookProcessingPipeline) { 67 | this.bookProcessors = bookProcessingPipeline; 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /epub4j-core/src/main/java/io/documentnode/epub4j/epub/HtmlProcessor.java: -------------------------------------------------------------------------------- 1 | package io.documentnode.epub4j.epub; 2 | 3 | import io.documentnode.epub4j.domain.Resource; 4 | import java.io.OutputStream; 5 | 6 | public interface HtmlProcessor { 7 | 8 | void processHtmlResource(Resource resource, OutputStream out); 9 | } 10 | -------------------------------------------------------------------------------- /epub4j-core/src/main/java/io/documentnode/epub4j/epub/Main.java: -------------------------------------------------------------------------------- 1 | package io.documentnode.epub4j.epub; 2 | 3 | public class Main { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /epub4j-core/src/main/java/io/documentnode/epub4j/util/CollectionUtil.java: -------------------------------------------------------------------------------- 1 | package io.documentnode.epub4j.util; 2 | 3 | import java.util.Collection; 4 | import java.util.Enumeration; 5 | import java.util.Iterator; 6 | import java.util.List; 7 | 8 | public class CollectionUtil { 9 | 10 | /** 11 | * Wraps an Enumeration around an Iterator 12 | * @author paul.siegmann 13 | * 14 | * @param 15 | */ 16 | private static class IteratorEnumerationAdapter implements Enumeration { 17 | 18 | private Iterator iterator; 19 | 20 | public IteratorEnumerationAdapter(Iterator iter) { 21 | this.iterator = iter; 22 | } 23 | 24 | @Override 25 | public boolean hasMoreElements() { 26 | return iterator.hasNext(); 27 | } 28 | 29 | @Override 30 | public T nextElement() { 31 | return iterator.next(); 32 | } 33 | } 34 | 35 | /** 36 | * Creates an Enumeration out of the given Iterator. 37 | * @param 38 | * @param it 39 | * @return an Enumeration created out of the given Iterator. 40 | */ 41 | public static Enumeration createEnumerationFromIterator( 42 | Iterator it) { 43 | return new IteratorEnumerationAdapter(it); 44 | } 45 | 46 | 47 | /** 48 | * Returns the first element of the list, null if the list is null or empty. 49 | * 50 | * @param 51 | * @param list 52 | * @return the first element of the list, null if the list is null or empty. 53 | */ 54 | public static T first(List list) { 55 | if (list == null || list.isEmpty()) { 56 | return null; 57 | } 58 | return list.get(0); 59 | } 60 | 61 | /** 62 | * Whether the given collection is null or has no elements. 63 | * 64 | * @param collection 65 | * @return Whether the given collection is null or has no elements. 66 | */ 67 | public static boolean isEmpty(Collection collection) { 68 | return collection == null || collection.isEmpty(); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /epub4j-core/src/main/java/io/documentnode/epub4j/util/NoCloseOutputStream.java: -------------------------------------------------------------------------------- 1 | package io.documentnode.epub4j.util; 2 | 3 | import java.io.IOException; 4 | import java.io.OutputStream; 5 | 6 | /** 7 | * OutputStream with the close() disabled. 8 | * We write multiple documents to a ZipOutputStream. 9 | * Some of the formatters call a close() after writing their data. 10 | * We don't want them to do that, so we wrap regular OutputStreams in this NoCloseOutputStream. 11 | * 12 | * @author paul 13 | */ 14 | public class NoCloseOutputStream extends OutputStream { 15 | 16 | private OutputStream outputStream; 17 | 18 | public NoCloseOutputStream(OutputStream outputStream) { 19 | this.outputStream = outputStream; 20 | } 21 | 22 | @Override 23 | public void write(int b) throws IOException { 24 | outputStream.write(b); 25 | } 26 | 27 | /** 28 | * A close() that does not call it's parent's close() 29 | */ 30 | public void close() { 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /epub4j-core/src/main/java/io/documentnode/epub4j/util/NoCloseWriter.java: -------------------------------------------------------------------------------- 1 | package io.documentnode.epub4j.util; 2 | 3 | import java.io.IOException; 4 | import java.io.Writer; 5 | 6 | /** 7 | * Writer with the close() disabled. 8 | * We write multiple documents to a ZipOutputStream. 9 | * Some of the formatters call a close() after writing their data. 10 | * We don't want them to do that, so we wrap regular Writers in this NoCloseWriter. 11 | * 12 | * @author paul 13 | */ 14 | public class NoCloseWriter extends Writer { 15 | 16 | private Writer writer; 17 | 18 | public NoCloseWriter(Writer writer) { 19 | this.writer = writer; 20 | } 21 | 22 | @Override 23 | public void close() throws IOException { 24 | } 25 | 26 | @Override 27 | public void flush() throws IOException { 28 | writer.flush(); 29 | } 30 | 31 | @Override 32 | public void write(char[] cbuf, int off, int len) throws IOException { 33 | writer.write(cbuf, off, len); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /epub4j-core/src/main/java/net/sf/jazzlib/DeflaterPending.java: -------------------------------------------------------------------------------- 1 | /* net.sf.jazzlib.DeflaterPending 2 | Copyright (C) 2001 Free Software Foundation, Inc. 3 | 4 | This file is part of GNU Classpath. 5 | 6 | GNU Classpath is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 2, or (at your option) 9 | any later version. 10 | 11 | GNU Classpath is distributed in the hope that it will be useful, but 12 | WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with GNU Classpath; see the file COPYING. If not, write to the 18 | Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 19 | 02111-1307 USA. 20 | 21 | Linking this library statically or dynamically with other modules is 22 | making a combined work based on this library. Thus, the terms and 23 | conditions of the GNU General Public License cover the whole 24 | combination. 25 | 26 | As a special exception, the copyright holders of this library give you 27 | permission to link this library with independent modules to produce an 28 | executable, regardless of the license terms of these independent 29 | modules, and to copy and distribute the resulting executable under 30 | terms of your choice, provided that you also meet, for each linked 31 | independent module, the terms and conditions of the license of that 32 | module. An independent module is a module which is not derived from 33 | or based on this library. If you modify this library, you may extend 34 | this exception to your version of the library, but you are not 35 | obligated to do so. If you do not wish to do so, delete this 36 | exception statement from your version. */ 37 | 38 | package net.sf.jazzlib; 39 | 40 | /** 41 | * This class stores the pending output of the Deflater. 42 | * 43 | * @author Jochen Hoenicke 44 | * @date Jan 5, 2000 45 | */ 46 | 47 | class DeflaterPending extends PendingBuffer { 48 | public DeflaterPending() { 49 | super(DeflaterConstants.PENDING_BUF_SIZE); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /epub4j-core/src/main/resources/dtd/www.w3.org/TR/xhtml-modularization/DTD/xhtml-arch-1.mod: -------------------------------------------------------------------------------- 1 | 2 | 3 | 17 | 18 | 25 | 26 | 27 | 28 | 29 | 30 | 32 | 35 | 36 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /epub4j-core/src/main/resources/dtd/www.w3.org/TR/xhtml-modularization/DTD/xhtml-base-1.mod: -------------------------------------------------------------------------------- 1 | 2 | 3 | 17 | 18 | 29 | 30 | 31 | 32 | 33 | 35 | 36 | 37 | ]]> 38 | 39 | 40 | 45 | ]]> 46 | 47 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /epub4j-core/src/main/resources/dtd/www.w3.org/TR/xhtml-modularization/DTD/xhtml-bdo-1.mod: -------------------------------------------------------------------------------- 1 | 2 | 3 | 17 | 18 | 28 | 29 | 30 | 34 | 35 | 36 | ]]> 37 | 38 | 39 | 45 | ]]> 46 | 47 | 48 | -------------------------------------------------------------------------------- /epub4j-core/src/main/resources/dtd/www.w3.org/TR/xhtml-modularization/DTD/xhtml-blkpres-1.mod: -------------------------------------------------------------------------------- 1 | 2 | 3 | 17 | 18 | 25 | 26 | 27 | 29 | 30 | 31 | ]]> 32 | 33 | 34 | 38 | ]]> 39 | 40 | 41 | -------------------------------------------------------------------------------- /epub4j-core/src/main/resources/dtd/www.w3.org/TR/xhtml-modularization/DTD/xhtml-blkstruct-1.mod: -------------------------------------------------------------------------------- 1 | 2 | 3 | 17 | 18 | 25 | 26 | 27 | 31 | 32 | 33 | ]]> 34 | 35 | 36 | 40 | ]]> 41 | 42 | 43 | 46 | 47 | 48 | ]]> 49 | 50 | 51 | 55 | ]]> 56 | 57 | 58 | -------------------------------------------------------------------------------- /epub4j-core/src/main/resources/dtd/www.w3.org/TR/xhtml-modularization/DTD/xhtml-charent-1.mod: -------------------------------------------------------------------------------- 1 | 2 | 3 | 17 | 18 | 23 | 24 | 27 | %xhtml-lat1; 28 | 29 | 32 | %xhtml-symbol; 33 | 34 | 37 | %xhtml-special; 38 | 39 | 40 | -------------------------------------------------------------------------------- /epub4j-core/src/main/resources/dtd/www.w3.org/TR/xhtml-modularization/DTD/xhtml-edit-1.mod: -------------------------------------------------------------------------------- 1 | 2 | 3 | 17 | 18 | 25 | 26 | 27 | 28 | 29 | 33 | 34 | 35 | ]]> 36 | 37 | 38 | 44 | ]]> 45 | 46 | 47 | 48 | 49 | 53 | 54 | 55 | ]]> 56 | 57 | 58 | 64 | ]]> 65 | 66 | 67 | -------------------------------------------------------------------------------- /epub4j-core/src/main/resources/dtd/www.w3.org/TR/xhtml-modularization/DTD/xhtml-hypertext-1.mod: -------------------------------------------------------------------------------- 1 | 2 | 3 | 17 | 18 | 27 | 28 | 29 | 30 | 31 | 35 | 36 | 37 | ]]> 38 | 39 | 40 | 52 | ]]> 53 | 54 | 55 | -------------------------------------------------------------------------------- /epub4j-core/src/main/resources/dtd/www.w3.org/TR/xhtml-modularization/DTD/xhtml-image-1.mod: -------------------------------------------------------------------------------- 1 | 2 | 3 | 17 | 18 | 24 | 25 | 30 | 31 | 32 | 34 | 35 | 36 | ]]> 37 | 38 | 39 | 49 | ]]> 50 | 51 | 52 | -------------------------------------------------------------------------------- /epub4j-core/src/main/resources/dtd/www.w3.org/TR/xhtml-modularization/DTD/xhtml-inlstruct-1.mod: -------------------------------------------------------------------------------- 1 | 2 | 3 | 17 | 18 | 25 | 26 | 27 | 28 | 29 | 32 | 33 | 34 | 35 | ]]> 36 | 37 | 38 | 42 | ]]> 43 | 44 | 45 | 46 | 47 | 51 | 52 | 53 | ]]> 54 | 55 | 56 | 60 | ]]> 61 | 62 | 63 | -------------------------------------------------------------------------------- /epub4j-core/src/main/resources/dtd/www.w3.org/TR/xhtml-modularization/DTD/xhtml-inlstyle-1.mod: -------------------------------------------------------------------------------- 1 | 2 | 3 | 17 | 18 | 24 | 25 | 28 | 29 | 30 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /epub4j-core/src/main/resources/dtd/www.w3.org/TR/xhtml-modularization/DTD/xhtml-link-1.mod: -------------------------------------------------------------------------------- 1 | 2 | 3 | 17 | 18 | 35 | 36 | 37 | 38 | 39 | 41 | 42 | 43 | ]]> 44 | 45 | 46 | 57 | ]]> 58 | 59 | 60 | -------------------------------------------------------------------------------- /epub4j-core/src/main/resources/dtd/www.w3.org/TR/xhtml-modularization/DTD/xhtml-meta-1.mod: -------------------------------------------------------------------------------- 1 | 2 | 3 | 17 | 18 | 25 | 26 | 27 | 28 | 29 | 31 | 32 | 33 | ]]> 34 | 35 | 36 | 45 | ]]> 46 | 47 | 48 | -------------------------------------------------------------------------------- /epub4j-core/src/main/resources/dtd/www.w3.org/TR/xhtml-modularization/DTD/xhtml-param-1.mod: -------------------------------------------------------------------------------- 1 | 2 | 3 | 17 | 18 | 26 | 27 | 28 | 29 | 30 | 32 | 33 | 34 | ]]> 35 | 36 | 37 | 46 | ]]> 47 | 48 | 49 | -------------------------------------------------------------------------------- /epub4j-core/src/main/resources/dtd/www.w3.org/TR/xhtml-modularization/DTD/xhtml-pres-1.mod: -------------------------------------------------------------------------------- 1 | 2 | 3 | 17 | 18 | 23 | 24 | 25 | 29 | %xhtml-inlpres.mod;]]> 30 | 31 | 32 | 36 | %xhtml-blkpres.mod;]]> 37 | 38 | 39 | -------------------------------------------------------------------------------- /epub4j-core/src/main/resources/dtd/www.w3.org/TR/xhtml-modularization/DTD/xhtml-script-1.mod: -------------------------------------------------------------------------------- 1 | 2 | 3 | 17 | 18 | 26 | 27 | 28 | 29 | 30 | 32 | 33 | 34 | ]]> 35 | 36 | 37 | 47 | ]]> 48 | 49 | 50 | 51 | 52 | 56 | 57 | 58 | ]]> 59 | 60 | 61 | 65 | ]]> 66 | 67 | 68 | -------------------------------------------------------------------------------- /epub4j-core/src/main/resources/dtd/www.w3.org/TR/xhtml-modularization/DTD/xhtml-ssismap-1.mod: -------------------------------------------------------------------------------- 1 | 2 | 3 | 17 | 18 | 23 | 24 | 27 | 28 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /epub4j-core/src/main/resources/dtd/www.w3.org/TR/xhtml-modularization/DTD/xhtml-style-1.mod: -------------------------------------------------------------------------------- 1 | 2 | 3 | 17 | 18 | 25 | 26 | 27 | 28 | 29 | 31 | 32 | 33 | ]]> 34 | 35 | 36 | 46 | ]]> 47 | 48 | 49 | -------------------------------------------------------------------------------- /epub4j-core/src/main/resources/dtd/www.w3.org/TR/xhtml-modularization/DTD/xhtml-text-1.mod: -------------------------------------------------------------------------------- 1 | 2 | 3 | 17 | 18 | 23 | 24 | 25 | 29 | %xhtml-inlstruct.mod;]]> 30 | 31 | 32 | 36 | %xhtml-inlphras.mod;]]> 37 | 38 | 39 | 43 | %xhtml-blkstruct.mod;]]> 44 | 45 | 46 | 50 | %xhtml-blkphras.mod;]]> 51 | 52 | 53 | -------------------------------------------------------------------------------- /epub4j-core/src/test/java/io/documentnode/epub4j/domain/BookTest.java: -------------------------------------------------------------------------------- 1 | package io.documentnode.epub4j.domain; 2 | 3 | import org.junit.Assert; 4 | import org.junit.Test; 5 | 6 | public class BookTest { 7 | 8 | @Test 9 | public void testGetContents1() { 10 | Book book = new Book(); 11 | Resource resource1 = new Resource("id1", "Hello, world !".getBytes(), "chapter1.html", MediaTypes.XHTML); 12 | book.getSpine().addResource(resource1); 13 | book.getTableOfContents().addSection(resource1, "My first chapter"); 14 | Assert.assertEquals(1, book.getContents().size()); 15 | } 16 | 17 | @Test 18 | public void testGetContents2() { 19 | Book book = new Book(); 20 | Resource resource1 = new Resource("id1", "Hello, world !".getBytes(), "chapter1.html", MediaTypes.XHTML); 21 | book.getSpine().addResource(resource1); 22 | Resource resource2 = new Resource("id1", "Hello, world !".getBytes(), "chapter2.html", MediaTypes.XHTML); 23 | book.getTableOfContents().addSection(resource2, "My first chapter"); 24 | Assert.assertEquals(2, book.getContents().size()); 25 | } 26 | 27 | @Test 28 | public void testGetContents3() { 29 | Book book = new Book(); 30 | Resource resource1 = new Resource("id1", "Hello, world !".getBytes(), "chapter1.html", MediaTypes.XHTML); 31 | book.getSpine().addResource(resource1); 32 | Resource resource2 = new Resource("id1", "Hello, world !".getBytes(), "chapter2.html", MediaTypes.XHTML); 33 | book.getTableOfContents().addSection(resource2, "My first chapter"); 34 | book.getGuide().addReference(new GuideReference(resource2, GuideReference.FOREWORD, "The Foreword")); 35 | Assert.assertEquals(2, book.getContents().size()); 36 | } 37 | 38 | @Test 39 | public void testGetContents4() { 40 | Book book = new Book(); 41 | 42 | Resource resource1 = new Resource("id1", "Hello, world !".getBytes(), "chapter1.html", MediaTypes.XHTML); 43 | book.getSpine().addResource(resource1); 44 | 45 | Resource resource2 = new Resource("id1", "Hello, world !".getBytes(), "chapter2.html", MediaTypes.XHTML); 46 | book.getTableOfContents().addSection(resource2, "My first chapter"); 47 | 48 | Resource resource3 = new Resource("id1", "Hello, world !".getBytes(), "foreword.html", MediaTypes.XHTML); 49 | book.getGuide().addReference(new GuideReference(resource3, GuideReference.FOREWORD, "The Foreword")); 50 | 51 | Assert.assertEquals(3, book.getContents().size()); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /epub4j-core/src/test/java/io/documentnode/epub4j/domain/ResourcesTest.java: -------------------------------------------------------------------------------- 1 | package io.documentnode.epub4j.domain; 2 | 3 | import org.junit.Assert; 4 | import org.junit.Test; 5 | 6 | public class ResourcesTest { 7 | 8 | @Test 9 | public void testGetResourcesByMediaType1() { 10 | Resources resources = new Resources(); 11 | resources.add(new Resource("foo".getBytes(), MediaTypes.XHTML)); 12 | resources.add(new Resource("bar".getBytes(), MediaTypes.XHTML)); 13 | Assert.assertEquals(0, resources.getResourcesByMediaType(MediaTypes.PNG).size()); 14 | Assert.assertEquals(2, resources.getResourcesByMediaType(MediaTypes.XHTML).size()); 15 | Assert.assertEquals(2, resources.getResourcesByMediaTypes(new MediaType[] { 16 | MediaTypes.XHTML}).size()); 17 | } 18 | 19 | @Test 20 | public void testGetResourcesByMediaType2() { 21 | Resources resources = new Resources(); 22 | resources.add(new Resource("foo".getBytes(), MediaTypes.XHTML)); 23 | resources.add(new Resource("bar".getBytes(), MediaTypes.PNG)); 24 | resources.add(new Resource("baz".getBytes(), MediaTypes.PNG)); 25 | Assert.assertEquals(2, resources.getResourcesByMediaType(MediaTypes.PNG).size()); 26 | Assert.assertEquals(1, resources.getResourcesByMediaType(MediaTypes.XHTML).size()); 27 | Assert.assertEquals(1, resources.getResourcesByMediaTypes(new MediaType[] { 28 | MediaTypes.XHTML}).size()); 29 | Assert.assertEquals(3, resources.getResourcesByMediaTypes(new MediaType[] { 30 | MediaTypes.XHTML, MediaTypes.PNG}).size()); 31 | Assert.assertEquals(3, resources.getResourcesByMediaTypes(new MediaType[] { 32 | MediaTypes.CSS, MediaTypes.XHTML, MediaTypes.PNG}).size()); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /epub4j-core/src/test/java/io/documentnode/epub4j/epub/DOMUtilTest.java: -------------------------------------------------------------------------------- 1 | package io.documentnode.epub4j.epub; 2 | 3 | import java.io.StringReader; 4 | 5 | import org.junit.Test; 6 | import static org.junit.Assert.*; 7 | import org.junit.experimental.runners.Enclosed; 8 | import org.junit.runner.RunWith; 9 | import org.w3c.dom.Document; 10 | import org.xml.sax.InputSource; 11 | 12 | 13 | @RunWith(Enclosed.class) 14 | public class DOMUtilTest { 15 | 16 | public static class GetAttribute { 17 | 18 | @Test 19 | public void test_simple_foo() { 20 | // given 21 | String input = ""; 22 | 23 | try { 24 | Document document = EpubProcessorSupport.createDocumentBuilder().parse(new InputSource(new StringReader(input))); 25 | 26 | // when 27 | String actualResult = DOMUtil.getAttribute(document.getDocumentElement(), "foo", "myattr"); 28 | 29 | // then 30 | assertEquals("red", actualResult); 31 | } catch (Exception e) { 32 | fail(e.getMessage()); 33 | } 34 | } 35 | 36 | @Test 37 | public void test_simple_bar() { 38 | // given 39 | String input = ""; 40 | 41 | try { 42 | Document document = EpubProcessorSupport.createDocumentBuilder().parse(new InputSource(new StringReader(input))); 43 | 44 | // when 45 | String actualResult = DOMUtil.getAttribute(document.getDocumentElement(), "bar", "myattr"); 46 | 47 | // then 48 | assertEquals("green", actualResult); 49 | } catch (Exception e) { 50 | fail(e.getMessage()); 51 | } 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /epub4j-core/src/test/java/io/documentnode/epub4j/epub/NCXDocumentTest.java: -------------------------------------------------------------------------------- 1 | package io.documentnode.epub4j.epub; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import io.documentnode.epub4j.domain.MediaTypes; 6 | import java.io.File; 7 | import java.io.FileInputStream; 8 | import java.io.IOException; 9 | 10 | import io.documentnode.epub4j.domain.Book; 11 | import io.documentnode.epub4j.domain.Resource; 12 | import io.documentnode.epub4j.util.IOUtil; 13 | 14 | import org.junit.After; 15 | import org.junit.AfterClass; 16 | import org.junit.Before; 17 | import org.junit.BeforeClass; 18 | import org.junit.Test; 19 | 20 | public class NCXDocumentTest { 21 | 22 | byte[] ncxData; 23 | 24 | public NCXDocumentTest() { 25 | } 26 | 27 | @BeforeClass 28 | public static void setUpClass() { 29 | } 30 | 31 | @AfterClass 32 | public static void tearDownClass() { 33 | } 34 | 35 | @Before 36 | public void setUp() throws IOException { 37 | ncxData = IOUtil.toByteArray(new FileInputStream(new File("src/test/resources/toc.xml"))); 38 | } 39 | 40 | @After 41 | public void tearDown() { 42 | } 43 | 44 | private void addResource(Book book, String filename) { 45 | Resource chapterResource = new Resource("id1", "Hello, world !".getBytes(), filename, MediaTypes.XHTML); 46 | book.addResource(chapterResource); 47 | book.getSpine().addResource(chapterResource); 48 | } 49 | 50 | /** 51 | * Test of read method, of class NCXDocument. 52 | */ 53 | @Test 54 | public void testReadWithNonRootLevelTOC() { 55 | 56 | // If the tox.ncx file is not in the root, the hrefs it refers to need to preserve its path. 57 | Book book = new Book(); 58 | Resource ncxResource = new Resource(ncxData, "xhtml/toc.ncx"); 59 | addResource(book, "xhtml/chapter1.html"); 60 | addResource(book, "xhtml/chapter2.html"); 61 | addResource(book, "xhtml/chapter2_1.html"); 62 | addResource(book, "xhtml/chapter3.html"); 63 | 64 | book.setNcxResource(ncxResource); 65 | book.getSpine().setTocResource(ncxResource); 66 | 67 | NCXDocument.read(book, new EpubReader()); 68 | assertEquals("xhtml/chapter1.html", book.getTableOfContents().getTocReferences().get(0).getCompleteHref()); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /epub4j-core/src/test/java/io/documentnode/epub4j/util/CollectionUtilTest.java: -------------------------------------------------------------------------------- 1 | package io.documentnode.epub4j.util; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Arrays; 5 | 6 | import org.junit.Assert; 7 | import org.junit.Test; 8 | 9 | public class CollectionUtilTest { 10 | 11 | @Test 12 | public void testIsEmpty_null() { 13 | Assert.assertTrue(CollectionUtil.isEmpty(null)); 14 | } 15 | 16 | @Test 17 | public void testIsEmpty_empty() { 18 | Assert.assertTrue(CollectionUtil.isEmpty(new ArrayList())); 19 | } 20 | 21 | @Test 22 | public void testIsEmpty_elements() { 23 | Assert.assertFalse(CollectionUtil.isEmpty(Arrays.asList("foo"))); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /epub4j-core/src/test/java/io/documentnode/epub4j/util/NoCloseOutputStreamTest.java: -------------------------------------------------------------------------------- 1 | package io.documentnode.epub4j.util; 2 | 3 | import org.junit.Before; 4 | import org.junit.Test; 5 | import org.mockito.Mock; 6 | import org.mockito.Mockito; 7 | import org.mockito.MockitoAnnotations; 8 | 9 | import java.io.IOException; 10 | import java.io.OutputStream; 11 | 12 | public class NoCloseOutputStreamTest { 13 | 14 | @Mock 15 | private OutputStream outputStream; 16 | 17 | private NoCloseOutputStream noCloseOutputStream; 18 | 19 | @Before 20 | public void setUp() { 21 | MockitoAnnotations.initMocks(this); 22 | this.noCloseOutputStream = new NoCloseOutputStream(outputStream); 23 | } 24 | 25 | @Test 26 | public void testWrite() throws IOException { 27 | // given 28 | 29 | // when 30 | noCloseOutputStream.write(17); 31 | 32 | // then 33 | Mockito.verify(outputStream).write(17); 34 | Mockito.verifyNoMoreInteractions(outputStream); 35 | } 36 | 37 | @Test 38 | public void testClose() throws IOException { 39 | // given 40 | 41 | // when 42 | noCloseOutputStream.close(); 43 | 44 | // then 45 | Mockito.verifyNoMoreInteractions(outputStream); 46 | } 47 | 48 | @Test 49 | public void testWriteClose() throws IOException { 50 | // given 51 | 52 | // when 53 | noCloseOutputStream.write(17); 54 | noCloseOutputStream.close(); 55 | 56 | // then 57 | Mockito.verify(outputStream).write(17); 58 | Mockito.verifyNoMoreInteractions(outputStream); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /epub4j-core/src/test/java/io/documentnode/epub4j/util/NoCloseWriterTest.java: -------------------------------------------------------------------------------- 1 | package io.documentnode.epub4j.util; 2 | 3 | import org.junit.Before; 4 | import org.junit.Test; 5 | import org.mockito.Mock; 6 | import org.mockito.Mockito; 7 | import org.mockito.MockitoAnnotations; 8 | 9 | import java.io.IOException; 10 | import java.io.Writer; 11 | 12 | public class NoCloseWriterTest { 13 | 14 | @Mock 15 | private Writer delegateWriter; 16 | 17 | private NoCloseWriter noCloseWriter; 18 | 19 | @Before 20 | public void setUp() { 21 | MockitoAnnotations.initMocks(this); 22 | this.noCloseWriter = new NoCloseWriter(delegateWriter); 23 | } 24 | 25 | @Test 26 | public void testWrite() throws IOException { 27 | // given 28 | 29 | // when 30 | noCloseWriter.write(new char[]{'e','f','g'},2,1); 31 | 32 | // then 33 | Mockito.verify(delegateWriter).write(new char[]{'e','f','g'},2,1); 34 | Mockito.verifyNoMoreInteractions(delegateWriter); 35 | } 36 | 37 | @Test 38 | public void testFlush() throws IOException { 39 | // given 40 | 41 | // when 42 | noCloseWriter.flush(); 43 | 44 | // then 45 | Mockito.verify(delegateWriter).flush(); 46 | Mockito.verifyNoMoreInteractions(delegateWriter); 47 | } 48 | 49 | @Test 50 | public void testClose() throws IOException { 51 | // given 52 | 53 | // when 54 | noCloseWriter.close(); 55 | 56 | // then 57 | Mockito.verifyNoMoreInteractions(delegateWriter); 58 | } 59 | 60 | @Test 61 | public void testWriteClose() throws IOException { 62 | // given 63 | 64 | // when 65 | noCloseWriter.write(new char[]{'e','f','g'},2,1); 66 | noCloseWriter.close(); 67 | 68 | // then 69 | Mockito.verify(delegateWriter).write(new char[]{'e','f','g'},2,1); 70 | Mockito.verifyNoMoreInteractions(delegateWriter); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /epub4j-core/src/test/resources/book1/book1.css: -------------------------------------------------------------------------------- 1 | @CHARSET "UTF-8"; 2 | 3 | body { 4 | font-family: "New Century Schoolbook", serif; 5 | } -------------------------------------------------------------------------------- /epub4j-core/src/test/resources/book1/chapter2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Chapter 2 4 | 5 | 6 | 7 |

Second chapter

8 |

9 | Welcome to Chapter 2 of the epub4j book1 test book.
10 | Pretty flowers:
11 | flowers
12 | We hope you are still enjoying the test. 13 |

14 | 15 | -------------------------------------------------------------------------------- /epub4j-core/src/test/resources/book1/chapter3.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Chapter 3 4 | 5 | 6 | 7 |

Final chapter

8 |

9 | Welcome to Chapter 3 of the epub4j book1 test book.
10 | We hope you enjoyed the test. 11 |

12 | 13 | -------------------------------------------------------------------------------- /epub4j-core/src/test/resources/book1/cover.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Cover 4 | 5 | 6 |
Cover
7 | 8 | -------------------------------------------------------------------------------- /epub4j-core/src/test/resources/book1/cover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-core/src/test/resources/book1/cover.png -------------------------------------------------------------------------------- /epub4j-core/src/test/resources/book1/flowers.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-core/src/test/resources/book1/flowers.jpg -------------------------------------------------------------------------------- /epub4j-core/src/test/resources/chm1/#IDXHDR: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-core/src/test/resources/chm1/#IDXHDR -------------------------------------------------------------------------------- /epub4j-core/src/test/resources/chm1/#IVB: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-core/src/test/resources/chm1/#IVB -------------------------------------------------------------------------------- /epub4j-core/src/test/resources/chm1/#STRINGS: -------------------------------------------------------------------------------- 1 | mainOnline HelpCHM-example.hhcCHM-example.hhkindex.htmwndTopicNew Topic WindowContext-sensitive_example\contextID-10000.htmContext-sensitive_example\contextID-10010.htmContext-sensitive_example\contextID-20000.htmContext-sensitive_example\contextID-20010.htmWelcomeContext-sensitive exampleGardenHTMLHelp ExamplesContext sensitive help topic 10000Context sensitive help topic 10010Context sensitive help topic 20000Context sensitive help topic 20010FlowersHow one grows treesAttention (!) - Close Window automaticallyTopic split exampleUsing CHM shortcut linksHow to jump to a anchorHow to jump to a second anchorHow to create PopUpLinking from CHM with standard HTMLLinking to PDF from CHMExample load PDF from TOCHow to link to PDF (server)How to jump directly from here (e.g. VW)How to jump to a anchorTopic 2Topic 3Topic 4XP Style for RadioButton and Check BoxesExternal TopicUsing window.open -------------------------------------------------------------------------------- /epub4j-core/src/test/resources/chm1/#SYSTEM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-core/src/test/resources/chm1/#SYSTEM -------------------------------------------------------------------------------- /epub4j-core/src/test/resources/chm1/#TOPICS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-core/src/test/resources/chm1/#TOPICS -------------------------------------------------------------------------------- /epub4j-core/src/test/resources/chm1/#URLSTR: -------------------------------------------------------------------------------- 1 | index.htmContext-sensitive_example/contextID-10000.htmContext-sensitive_example/contextID-10010.htmContext-sensitive_example/contextID-20000.htmContext-sensitive_example/contextID-20010.htmGarden/flowers.htmGarden/garden.htmGarden/tree.htmHTMLHelp_Examples/CloseWindowAutomatically.htmHTMLHelp_Examples/example-external-pdf.htmHTMLHelp_Examples/Jump_to_anchor.htmHTMLHelp_Examples/LinkPDFfromCHM.htmHTMLHelp_Examples/pop-up_example.htmHTMLHelp_Examples/shortcut_link.htmHTMLHelp_Examples/Simple_link_example.htmHTMLHelp_Examples/topic_split_example.htmHTMLHelp_Examples/topic-02.htmHTMLHelp_Examples/topic-03.htmHTMLHelp_Examples/topic-04.htmCHM-example.hhcCHM-example.hhkHTMLHelp_Examples/xp-style_radio-button_check-boxes.htmexternal_files/external_topic.htmHTMLHelp_Examples/using_window_open.htmHTMLHelp_Examples/Jump_to_anchor.htm#AnchorSampleHTMLHelp_Examples/Jump_to_anchor.htm#SecondAnchorhttp://www.help-info.de/download/pdf/example.pdfhttp://www.volkswagen.co.uk/home -------------------------------------------------------------------------------- /epub4j-core/src/test/resources/chm1/#URLTBL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-core/src/test/resources/chm1/#URLTBL -------------------------------------------------------------------------------- /epub4j-core/src/test/resources/chm1/#WINDOWS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-core/src/test/resources/chm1/#WINDOWS -------------------------------------------------------------------------------- /epub4j-core/src/test/resources/chm1/$FIftiMain: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-core/src/test/resources/chm1/$FIftiMain -------------------------------------------------------------------------------- /epub4j-core/src/test/resources/chm1/$OBJINST: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-core/src/test/resources/chm1/$OBJINST -------------------------------------------------------------------------------- /epub4j-core/src/test/resources/chm1/$WWAssociativeLinks/BTree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-core/src/test/resources/chm1/$WWAssociativeLinks/BTree -------------------------------------------------------------------------------- /epub4j-core/src/test/resources/chm1/$WWAssociativeLinks/Data: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-core/src/test/resources/chm1/$WWAssociativeLinks/Data -------------------------------------------------------------------------------- /epub4j-core/src/test/resources/chm1/$WWAssociativeLinks/Map: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /epub4j-core/src/test/resources/chm1/$WWAssociativeLinks/Property: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /epub4j-core/src/test/resources/chm1/$WWKeywordLinks/BTree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-core/src/test/resources/chm1/$WWKeywordLinks/BTree -------------------------------------------------------------------------------- /epub4j-core/src/test/resources/chm1/$WWKeywordLinks/Data: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-core/src/test/resources/chm1/$WWKeywordLinks/Data -------------------------------------------------------------------------------- /epub4j-core/src/test/resources/chm1/$WWKeywordLinks/Map: -------------------------------------------------------------------------------- 1 | * -------------------------------------------------------------------------------- /epub4j-core/src/test/resources/chm1/$WWKeywordLinks/Property: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /epub4j-core/src/test/resources/chm1/Garden/flowers.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Flowers 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 |

Flowers

23 |

You can cultivate flowers in your garden. It is beautiful if one can give his 24 | wife a bunch of self-cultivated flowers.

25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 |
39 |

 

40 | 41 |

 

42 | 43 | 44 | 45 | 46 | 47 |
back to top ...
48 |
49 |

 

50 | 51 | -------------------------------------------------------------------------------- /epub4j-core/src/test/resources/chm1/Garden/garden.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Garden 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 |

Own Garden

27 |

It is nice to have a garden near your home.

28 |

You can plant trees of one's own, lay out a pond with fish and cultivate flowers. 29 | For the children a game lawn can be laid out. You can learn much about botany.

30 |

 

31 | 32 | 33 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 |
A garden is good for your health and you can relax 34 | at the gardening.
46 |

 

47 |

 

48 |

 

49 |

 

50 | 51 | 52 | 53 | 54 | 55 |
back to top ...
56 |
57 |

 

58 | 59 | -------------------------------------------------------------------------------- /epub4j-core/src/test/resources/chm1/Garden/tree.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | How one grows trees 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 |

How one grows trees

25 |

You must dig a big hole first.

26 |

Wonder well which kind of tree you want to plant.

27 |

(oak, beech, alder)

28 |

The tree planted newly has always to be watered with sufficient water.

29 |

30 |

 

31 | 32 |

 

33 | 34 | 35 | 36 | 37 | 38 | 39 |
back to top ...
40 |
41 |

 

42 | 43 | -------------------------------------------------------------------------------- /epub4j-core/src/test/resources/chm1/HTMLHelp_Examples/LinkPDFfromCHM.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Linking to PDF from CHM 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 |

Linking to PDF from CHM

19 |

This topic is only used to show linking from a compiled CHM to other files 20 | and places. Open/Save dialog is used.

21 |

PDF

22 |

Link relative to PDF

23 |
24 | <p><a href="../embedded_files/example-embedded.pdf">Link relative to PDF</a></p>
25 | 
26 |

 

27 |

 

28 |

 

29 |

 

30 | 31 | 32 | 33 | 34 | 35 |
back to top ...
36 |
37 |

 

38 | 39 | 40 | -------------------------------------------------------------------------------- /epub4j-core/src/test/resources/chm1/HTMLHelp_Examples/example-external-pdf.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | Example load PDF from TOC 4 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /epub4j-core/src/test/resources/chm1/HTMLHelp_Examples/topic-02.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Topic 2 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 |

To do so insert following code to the HTML file at this place:

18 |
  <object type="application/x-oleobject"
19 |      classid="clsid:1e2a7bd0-dab9-1­1d0-b93a-00c04fc99f9
20 |      <param name="New HTML file" value="topic-02.htm">
21 |      <param name="New HTML title" value="Topic 2">
22 |   </object>
23 |

Split example - Topic 2

24 |

This example is used to show how the SPLIT function is working for generating 25 | sub-topics from one HTML file to the table of contents. This is the topic 26 | 2 of one HTML file.

27 |

28 |

Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam
29 |
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy 30 | eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. 31 | At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, 32 | no sea takimata sanctus est Lorem ipsum dolor sit amet.

33 | 34 | 35 | 36 | 37 |
back to top ...
38 |
39 | 40 | 41 | -------------------------------------------------------------------------------- /epub4j-core/src/test/resources/chm1/HTMLHelp_Examples/topic-03.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Topic 3 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 |

To do so insert following code to the HTML file at this place:

18 |
  <object type="application/x-oleobject"
19 |      classid="clsid:1e2a7bd0-dab9-1­1d0-b93a-00c04fc99f9
20 |      <param name="New HTML file" value="topic-03.htm">
21 |      <param name="New HTML title" value="Topic 3">
22 |   </object>
23 |

Split example - Topic 3

24 |

This example is used to show how the SPLIT function is working for generating 25 | sub-topics from one HTML file to the table of contents. This is the topic 26 | 3 of one HTML file.

27 |

28 |

Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam
29 |
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy 30 | eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. 31 | At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, 32 | no sea takimata sanctus est Lorem ipsum dolor sit amet.

33 |

 

34 | 35 | 36 | 37 | 38 |
back to top ...
39 |
40 | 41 | -------------------------------------------------------------------------------- /epub4j-core/src/test/resources/chm1/HTMLHelp_Examples/topic-04.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Topic 4 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 |

Split example - Topic 4

17 |

This is a short example text for Topic 4 for a small pop-up window.

18 |

See link at Topic 1.

19 |

 

20 |

 

21 |

 

22 | 23 | -------------------------------------------------------------------------------- /epub4j-core/src/test/resources/chm1/design.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-core/src/test/resources/chm1/design.css -------------------------------------------------------------------------------- /epub4j-core/src/test/resources/chm1/embedded_files/example-embedded.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-core/src/test/resources/chm1/embedded_files/example-embedded.pdf -------------------------------------------------------------------------------- /epub4j-core/src/test/resources/chm1/external_files/external_topic.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | External Topic 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

External Topic

21 |

 

22 |

This is a external topic that resides relativ to the CHM files and isn't compiled 23 | into the CHM file. Here it's used to show how to link to external files in a 24 | CHM topic window.

25 |

Delete links in all HTML files of your project - otherwise the external file 26 | is compiled to the CHM file.

27 |

Make a copy of the external file and delete the file in your project structure 28 | before the last compile runs. So the file isn't compiled into the CHM file. 29 | But you have to install the external file on the customers PC.

30 |

To try this example you must download the complete 31 | project example to a local folder, delete all files excepting "CHM-example.chm" 32 | and folder "external_files".

33 |

Edit following date in the external HTML file "external_topic.htm" 34 | to check that you can update the HTML file without recompiling the CHM file:

35 |

 

36 |

2005-05-17

37 |

 

38 |
39 | 40 | 41 | 42 | 43 |
back to top ...
44 |
45 |

 

46 | 47 | -------------------------------------------------------------------------------- /epub4j-core/src/test/resources/chm1/filelist.txt: -------------------------------------------------------------------------------- 1 | #IDXHDR 2 | #IVB 3 | #STRINGS 4 | #SYSTEM 5 | #TOPICS 6 | #URLSTR 7 | #URLTBL 8 | #WINDOWS 9 | $FIftiMain 10 | $OBJINST 11 | $WWAssociativeLinks/BTree 12 | $WWAssociativeLinks/Data 13 | $WWAssociativeLinks/Map 14 | $WWAssociativeLinks/Property 15 | $WWKeywordLinks/BTree 16 | $WWKeywordLinks/Data 17 | $WWKeywordLinks/Map 18 | $WWKeywordLinks/Property 19 | CHM-example.hhc 20 | CHM-example.hhk 21 | Context-sensitive_example/contextID-10000.htm 22 | Context-sensitive_example/contextID-10010.htm 23 | Context-sensitive_example/contextID-20000.htm 24 | Context-sensitive_example/contextID-20010.htm 25 | design.css 26 | embedded_files/example-embedded.pdf 27 | external_files/external_topic.htm 28 | Garden/flowers.htm 29 | Garden/garden.htm 30 | Garden/tree.htm 31 | HTMLHelp_Examples/CloseWindowAutomatically.htm 32 | HTMLHelp_Examples/example-external-pdf.htm 33 | HTMLHelp_Examples/Jump_to_anchor.htm 34 | HTMLHelp_Examples/LinkPDFfromCHM.htm 35 | HTMLHelp_Examples/pop-up_example.htm 36 | HTMLHelp_Examples/shortcut_link.htm 37 | HTMLHelp_Examples/Simple_link_example.htm 38 | HTMLHelp_Examples/topic-02.htm 39 | HTMLHelp_Examples/topic-03.htm 40 | HTMLHelp_Examples/topic-04.htm 41 | HTMLHelp_Examples/topic_split_example.htm 42 | HTMLHelp_Examples/using_window_open.htm 43 | HTMLHelp_Examples/xp-style_radio-button_check-boxes.htm 44 | images/blume.jpg 45 | images/ditzum.jpg 46 | images/eiche.jpg 47 | images/extlink.gif 48 | images/insekt.jpg 49 | images/list_arrow.gif 50 | images/lupine.jpg 51 | images/riffel_40px.jpg 52 | images/riffel_helpinformation.jpg 53 | images/riffel_home.jpg 54 | images/rotor_enercon.jpg 55 | images/screenshot_big.png 56 | images/screenshot_small.png 57 | images/up_rectangle.png 58 | images/verlauf-blau.jpg 59 | images/verlauf-gelb.jpg 60 | images/verlauf-rot.jpg 61 | images/welcome_small_big-en.gif 62 | images/wintertree.jpg 63 | index.htm 64 | topic.txt -------------------------------------------------------------------------------- /epub4j-core/src/test/resources/chm1/images/blume.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-core/src/test/resources/chm1/images/blume.jpg -------------------------------------------------------------------------------- /epub4j-core/src/test/resources/chm1/images/ditzum.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-core/src/test/resources/chm1/images/ditzum.jpg -------------------------------------------------------------------------------- /epub4j-core/src/test/resources/chm1/images/eiche.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-core/src/test/resources/chm1/images/eiche.jpg -------------------------------------------------------------------------------- /epub4j-core/src/test/resources/chm1/images/extlink.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-core/src/test/resources/chm1/images/extlink.gif -------------------------------------------------------------------------------- /epub4j-core/src/test/resources/chm1/images/insekt.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-core/src/test/resources/chm1/images/insekt.jpg -------------------------------------------------------------------------------- /epub4j-core/src/test/resources/chm1/images/list_arrow.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-core/src/test/resources/chm1/images/list_arrow.gif -------------------------------------------------------------------------------- /epub4j-core/src/test/resources/chm1/images/lupine.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-core/src/test/resources/chm1/images/lupine.jpg -------------------------------------------------------------------------------- /epub4j-core/src/test/resources/chm1/images/riffel_40px.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-core/src/test/resources/chm1/images/riffel_40px.jpg -------------------------------------------------------------------------------- /epub4j-core/src/test/resources/chm1/images/riffel_helpinformation.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-core/src/test/resources/chm1/images/riffel_helpinformation.jpg -------------------------------------------------------------------------------- /epub4j-core/src/test/resources/chm1/images/riffel_home.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-core/src/test/resources/chm1/images/riffel_home.jpg -------------------------------------------------------------------------------- /epub4j-core/src/test/resources/chm1/images/rotor_enercon.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-core/src/test/resources/chm1/images/rotor_enercon.jpg -------------------------------------------------------------------------------- /epub4j-core/src/test/resources/chm1/images/screenshot_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-core/src/test/resources/chm1/images/screenshot_big.png -------------------------------------------------------------------------------- /epub4j-core/src/test/resources/chm1/images/screenshot_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-core/src/test/resources/chm1/images/screenshot_small.png -------------------------------------------------------------------------------- /epub4j-core/src/test/resources/chm1/images/up_rectangle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-core/src/test/resources/chm1/images/up_rectangle.png -------------------------------------------------------------------------------- /epub4j-core/src/test/resources/chm1/images/verlauf-blau.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-core/src/test/resources/chm1/images/verlauf-blau.jpg -------------------------------------------------------------------------------- /epub4j-core/src/test/resources/chm1/images/verlauf-gelb.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-core/src/test/resources/chm1/images/verlauf-gelb.jpg -------------------------------------------------------------------------------- /epub4j-core/src/test/resources/chm1/images/verlauf-rot.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-core/src/test/resources/chm1/images/verlauf-rot.jpg -------------------------------------------------------------------------------- /epub4j-core/src/test/resources/chm1/images/welcome_small_big-en.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-core/src/test/resources/chm1/images/welcome_small_big-en.gif -------------------------------------------------------------------------------- /epub4j-core/src/test/resources/chm1/images/wintertree.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-core/src/test/resources/chm1/images/wintertree.jpg -------------------------------------------------------------------------------- /epub4j-core/src/test/resources/chm1/index.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Welcome 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Welcome

21 |

22 |

.. to CHM examples!

23 |

HTMLHelp is the current help system for Microsoft Windows. This file includes 24 | some examples how to use Microsoft HTMLHelp and is used to show how to work 25 | with HTMLHelp 1.x CHM files in Visual Basic Applications.

26 |

This "Welcome" page is the default page of the compiled help module 27 | (CHM).

28 |

 

29 |

 

30 |

Version Information:

31 |

Release: 2005-07-17

32 |

(c) help-info.de

33 |

 

34 |
35 | 36 | 37 | 38 | 39 |
back to top ...
40 |
41 |

 

42 | 43 | -------------------------------------------------------------------------------- /epub4j-core/src/test/resources/chm1/topic.txt: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------- 2 | ; topic.h file example for HTMLHelp (CHM) 3 | ; www.help-info.de 4 | ; 5 | ; 6 | ; This is a file including the ID and PopUp text 7 | ;------------------------------------------------- 8 | .topic 900;nohelp 9 | Sorry, no help available! 10 | 11 | .topic 100;PopUp_AddressData_btnOK 12 | This is context sensitive help text for a button (ID: IDH_100). 13 | 14 | .topic 110;PopUp_AddressData_txtFirstName 15 | This is context sensitive help text for a text box (ID: IDH_110). 16 | 17 | .topic 120;PopUp_AddressData_txtLastName 18 | This is context sensitive help text for a text box (ID: IDH_120). 19 | -------------------------------------------------------------------------------- /epub4j-core/src/test/resources/not_a_zip.epub: -------------------------------------------------------------------------------- 1 | This is not a valid zip file. 2 | Used for testing LoadResources. -------------------------------------------------------------------------------- /epub4j-core/src/test/resources/opf/test1.opf: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | EPUB4J test book 1 5 | Joe Tester 6 | 2010-05-27 7 | en 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /epub4j-core/src/test/resources/opf/test2.opf: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | This Dynamic Earth 5 | this_dynamic_earth-AAH813 6 | en 7 | W. Jacquelyne Kious, Robert I. Tilling 8 | 9 | Infogrid Pacific 10 | 11 | 12 | 13 | 22-01-2009 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /epub4j-core/src/test/resources/opf/test_default_language.opf: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | This Dynamic Earth 5 | this_dynamic_earth-AAH813 6 | W. Jacquelyne Kious, Robert I. Tilling 7 | 8 | Infogrid Pacific 9 | 10 | 11 | 12 | 22-01-2009 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /epub4j-core/src/test/resources/opf/test_language.opf: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | This Dynamic Earth 5 | this_dynamic_earth-AAH813 6 | fi 7 | W. Jacquelyne Kious, Robert I. Tilling 8 | 9 | Infogrid Pacific 10 | 11 | 12 | 13 | 22-01-2009 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /epub4j-core/src/test/resources/testbook1.epub: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-core/src/test/resources/testbook1.epub -------------------------------------------------------------------------------- /epub4j-core/src/test/resources/toc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | EPUB4J test book 1 11 | 12 | 13 | Tester, Joe 14 | 15 | 16 | 17 | 18 | Introduction 19 | 20 | 21 | 22 | 23 | 24 | Second Chapter 25 | 26 | 27 | 28 | 29 | Chapter 2, section 1 30 | 31 | 32 | 33 | 34 | 35 | 36 | Conclusion 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /epub4j-core/src/test/resources/zero_length_file.epub: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-core/src/test/resources/zero_length_file.epub -------------------------------------------------------------------------------- /epub4j-tools/README.md: -------------------------------------------------------------------------------- 1 | ## Epub Viewer 2 | 3 | A simple epub viewer built with java Swing. 4 | 5 | ### Startup 6 | 7 | java io.documentnode.epub4j.viewer.Viewer 8 | 9 | ## Fileset2epub 10 | 11 | A tool to generate an epub from a windows help / chm file or from a set of html files. 12 | 13 | java io.documentnode.epub4j.Fileset2Epub 14 | 15 | Arguments: 16 | 17 | --author [lastname,firstname] 18 | --cover-image [image to use as cover] 19 | --input-ecoding [text encoding] # The encoding of the input html files. If funny characters show 20 | # up in the result try 'iso-8859-1', 'windows-1252' or 'utf-8' 21 | # If that doesn't work try to find an appropriate one from 22 | # this list: http://en.wikipedia.org/wiki/Character_encoding 23 | --in [input directory] 24 | --isbn [isbn number] 25 | --out [output epub file] 26 | --title [book title] 27 | --type [input type, can be 'epub', 'chm' or empty] 28 | --xsl [html post processing file] 29 | -------------------------------------------------------------------------------- /epub4j-tools/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'application' 3 | 4 | alias(libs.plugins.shadow) 5 | } 6 | 7 | dependencies { 8 | implementation project(':epub4j-core') 9 | 10 | implementation(libs.htmlcleaner) { 11 | exclude group: 'org.jdom', module: 'jdom' 12 | exclude group: 'org.apache.ant', module: 'ant' 13 | } 14 | implementation(libs.commons.vfs) 15 | implementation(libs.commons.lang) 16 | implementation(libs.commons.io) 17 | } 18 | 19 | application { 20 | mainClass = 'io.documentnode.epub4j.Fileset2Epub' 21 | } 22 | 23 | // Required by the 'shadowJar' task 24 | project.ext.mainClassName = "io.documentnode.epub4j.Fileset2Epub" 25 | 26 | tasks.withType(com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { 27 | manifest { 28 | attributes( 29 | "Implementation-Title": "Fileset2Epub Command Line Tool", 30 | // Uncomment and replace `version` with the actual version if needed 31 | // "Implementation-Version": version, 32 | "Main-Class": "io.documentnode.epub4j.Fileset2Epub" 33 | ) 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /epub4j-tools/src/main/java/io/documentnode/epub4j/bookprocessor/DefaultBookProcessorPipeline.java: -------------------------------------------------------------------------------- 1 | package io.documentnode.epub4j.bookprocessor; 2 | 3 | import io.documentnode.epub4j.epub.BookProcessor; 4 | import io.documentnode.epub4j.epub.BookProcessorPipeline; 5 | import io.documentnode.minilog.Logger; 6 | import java.util.ArrayList; 7 | import java.util.Arrays; 8 | import java.util.List; 9 | 10 | /** 11 | * A book processor that combines several other bookprocessors 12 | * 13 | * Fixes coverpage/coverimage. 14 | * Cleans up the XHTML. 15 | * 16 | * @author paul.siegmann 17 | * 18 | */ 19 | public class DefaultBookProcessorPipeline extends BookProcessorPipeline { 20 | 21 | private Logger log = Logger.create(DefaultBookProcessorPipeline.class); 22 | 23 | public DefaultBookProcessorPipeline() { 24 | super(createDefaultBookProcessors()); 25 | } 26 | 27 | private static List createDefaultBookProcessors() { 28 | List result = new ArrayList(); 29 | result.addAll(Arrays.asList(new BookProcessor[]{ 30 | new SectionHrefSanityCheckBookProcessor(), 31 | new HtmlCleanerBookProcessor(), 32 | new CoverPageBookProcessor(), 33 | new FixIdentifierBookProcessor() 34 | })); 35 | return result; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /epub4j-tools/src/main/java/io/documentnode/epub4j/bookprocessor/FixIdentifierBookProcessor.java: -------------------------------------------------------------------------------- 1 | package io.documentnode.epub4j.bookprocessor; 2 | 3 | import io.documentnode.epub4j.domain.Book; 4 | import io.documentnode.epub4j.domain.Identifier; 5 | import io.documentnode.epub4j.epub.BookProcessor; 6 | 7 | /** 8 | * If the book has no identifier it adds a generated UUID as identifier. 9 | * 10 | * @author paul 11 | * 12 | */ 13 | public class FixIdentifierBookProcessor implements BookProcessor { 14 | 15 | @Override 16 | public Book processBook(Book book) { 17 | if(book.getMetadata().getIdentifiers().isEmpty()) { 18 | book.getMetadata().addIdentifier(new Identifier()); 19 | } 20 | return book; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /epub4j-tools/src/main/java/io/documentnode/epub4j/bookprocessor/FixMissingResourceBookProcessor.java: -------------------------------------------------------------------------------- 1 | package io.documentnode.epub4j.bookprocessor; 2 | 3 | import java.util.Collection; 4 | 5 | import io.documentnode.epub4j.domain.Book; 6 | import io.documentnode.epub4j.domain.TOCReference; 7 | import io.documentnode.epub4j.epub.BookProcessor; 8 | 9 | public class FixMissingResourceBookProcessor implements BookProcessor { 10 | 11 | @Override 12 | public Book processBook(Book book) { 13 | return book; 14 | } 15 | 16 | private void fixMissingResources(Collection tocReferences, Book book) { 17 | for (TOCReference tocReference: tocReferences) { 18 | if (tocReference.getResource() == null) { 19 | 20 | } 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /epub4j-tools/src/main/java/io/documentnode/epub4j/bookprocessor/HtmlBookProcessor.java: -------------------------------------------------------------------------------- 1 | package io.documentnode.epub4j.bookprocessor; 2 | 3 | 4 | import io.documentnode.epub4j.Constants; 5 | import io.documentnode.epub4j.domain.Book; 6 | import io.documentnode.epub4j.domain.Resource; 7 | import io.documentnode.epub4j.epub.BookProcessor; 8 | import io.documentnode.epub4j.domain.MediaTypes; 9 | import io.documentnode.minilog.Logger; 10 | import java.io.IOException; 11 | 12 | /** 13 | * Helper class for BookProcessors that only manipulate html type resources. 14 | * 15 | * @author paul 16 | */ 17 | public abstract class HtmlBookProcessor implements BookProcessor { 18 | 19 | private final static Logger log = Logger.create(HtmlBookProcessor.class); 20 | public static final String OUTPUT_ENCODING = "UTF-8"; 21 | 22 | public HtmlBookProcessor() { 23 | } 24 | 25 | @Override 26 | public Book processBook(Book book) { 27 | for (Resource resource : book.getResources().getAll()) { 28 | try { 29 | cleanupResource(resource, book); 30 | } catch (IOException e) { 31 | log.error(e.getMessage(), e); 32 | } 33 | } 34 | return book; 35 | } 36 | 37 | private void cleanupResource(Resource resource, Book book) 38 | throws IOException { 39 | if (resource.getMediaType() == MediaTypes.XHTML) { 40 | byte[] cleanedHtml = processHtml(resource, book, 41 | Constants.CHARACTER_ENCODING); 42 | resource.setData(cleanedHtml); 43 | resource.setInputEncoding(Constants.CHARACTER_ENCODING); 44 | } 45 | } 46 | 47 | protected abstract byte[] processHtml(Resource resource, Book book, 48 | String encoding) throws IOException; 49 | } 50 | -------------------------------------------------------------------------------- /epub4j-tools/src/main/java/io/documentnode/epub4j/bookprocessor/HtmlSplitterBookProcessor.java: -------------------------------------------------------------------------------- 1 | package io.documentnode.epub4j.bookprocessor; 2 | 3 | import io.documentnode.epub4j.domain.Book; 4 | import io.documentnode.epub4j.epub.BookProcessor; 5 | 6 | /** 7 | * In the future this will split up too large html documents into smaller ones. 8 | * 9 | * @author paul 10 | * 11 | */ 12 | public class HtmlSplitterBookProcessor implements BookProcessor { 13 | 14 | @Override 15 | public Book processBook(Book book) { 16 | return book; 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /epub4j-tools/src/main/java/io/documentnode/epub4j/bookprocessor/SectionHrefSanityCheckBookProcessor.java: -------------------------------------------------------------------------------- 1 | package io.documentnode.epub4j.bookprocessor; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import io.documentnode.epub4j.domain.Book; 7 | import io.documentnode.epub4j.domain.Resource; 8 | import io.documentnode.epub4j.domain.Spine; 9 | import io.documentnode.epub4j.domain.SpineReference; 10 | import io.documentnode.epub4j.epub.BookProcessor; 11 | 12 | import org.apache.commons.lang.StringUtils; 13 | 14 | /** 15 | * Removes Sections from the page flow that differ only from the previous section's href by the '#' in the url. 16 | * 17 | * @author paul 18 | * 19 | */ 20 | public class SectionHrefSanityCheckBookProcessor implements BookProcessor { 21 | 22 | @Override 23 | public Book processBook(Book book) { 24 | book.getSpine().setSpineReferences(checkSpineReferences(book.getSpine())); 25 | return book; 26 | } 27 | 28 | private static List checkSpineReferences(Spine spine) { 29 | List result = new ArrayList(spine.size()); 30 | Resource previousResource = null; 31 | for(SpineReference spineReference: spine.getSpineReferences()) { 32 | if(spineReference.getResource() == null 33 | || StringUtils.isBlank(spineReference.getResource().getHref())) { 34 | continue; 35 | } 36 | if(previousResource == null 37 | || spineReference.getResource() == null 38 | || ( ! (spineReference.getResource().getHref().equals(previousResource.getHref())))) { 39 | result.add(spineReference); 40 | } 41 | previousResource = spineReference.getResource(); 42 | } 43 | return result; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /epub4j-tools/src/main/java/io/documentnode/epub4j/bookprocessor/SectionTitleBookProcessor.java: -------------------------------------------------------------------------------- 1 | package io.documentnode.epub4j.bookprocessor; 2 | 3 | import java.io.IOException; 4 | import java.util.List; 5 | 6 | import javax.xml.xpath.XPath; 7 | import javax.xml.xpath.XPathExpressionException; 8 | import javax.xml.xpath.XPathFactory; 9 | 10 | import io.documentnode.epub4j.domain.Book; 11 | import io.documentnode.epub4j.domain.Resource; 12 | import io.documentnode.epub4j.domain.TOCReference; 13 | import io.documentnode.epub4j.epub.BookProcessor; 14 | 15 | import org.apache.commons.lang.StringUtils; 16 | import org.xml.sax.InputSource; 17 | 18 | public class SectionTitleBookProcessor implements BookProcessor { 19 | 20 | @Override 21 | public Book processBook(Book book) { 22 | XPath xpath = createXPathExpression(); 23 | processSections(book.getTableOfContents().getTocReferences(), book, xpath); 24 | return book; 25 | } 26 | 27 | private void processSections(List tocReferences, Book book, XPath xpath) { 28 | for(TOCReference tocReference: tocReferences) { 29 | if(! StringUtils.isBlank(tocReference.getTitle())) { 30 | continue; 31 | } 32 | try { 33 | String title = getTitle(tocReference, book, xpath); 34 | tocReference.setTitle(title); 35 | } catch (XPathExpressionException e) { 36 | // TODO Auto-generated catch block 37 | e.printStackTrace(); 38 | } catch (IOException e) { 39 | // TODO Auto-generated catch block 40 | e.printStackTrace(); 41 | } 42 | } 43 | } 44 | 45 | 46 | private String getTitle(TOCReference tocReference, Book book, XPath xpath) throws IOException, XPathExpressionException { 47 | Resource resource = tocReference.getResource(); 48 | if(resource == null) { 49 | return null; 50 | } 51 | InputSource inputSource = new InputSource(resource.getInputStream()); 52 | String title = xpath.evaluate("/html/head/title", inputSource); 53 | return title; 54 | } 55 | 56 | 57 | private XPath createXPathExpression() { 58 | return XPathFactory.newInstance().newXPath(); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /epub4j-tools/src/main/java/io/documentnode/epub4j/bookprocessor/TextReplaceBookProcessor.java: -------------------------------------------------------------------------------- 1 | package io.documentnode.epub4j.bookprocessor; 2 | 3 | import io.documentnode.epub4j.Constants; 4 | import io.documentnode.epub4j.domain.Book; 5 | import io.documentnode.epub4j.domain.Resource; 6 | import io.documentnode.epub4j.epub.BookProcessor; 7 | import java.io.ByteArrayOutputStream; 8 | import java.io.IOException; 9 | import java.io.OutputStreamWriter; 10 | import java.io.Reader; 11 | import java.io.Writer; 12 | import org.apache.commons.io.IOUtils; 13 | 14 | /** 15 | * Cleans up regular html into xhtml. 16 | * Uses HtmlCleaner to do this. 17 | * 18 | * @author paul 19 | * 20 | */ 21 | public class TextReplaceBookProcessor extends HtmlBookProcessor implements 22 | BookProcessor { 23 | 24 | public TextReplaceBookProcessor() { 25 | } 26 | 27 | public byte[] processHtml(Resource resource, Book book, String outputEncoding) 28 | throws IOException { 29 | Reader reader = resource.getReader(); 30 | ByteArrayOutputStream out = new ByteArrayOutputStream(); 31 | Writer writer = new OutputStreamWriter(out, Constants.CHARACTER_ENCODING); 32 | for (String line : IOUtils.readLines(reader)) { 33 | writer.write(processLine(line)); 34 | writer.flush(); 35 | } 36 | return out.toByteArray(); 37 | } 38 | 39 | private String processLine(String line) { 40 | return line.replace("'", "'"); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /epub4j-tools/src/main/java/io/documentnode/epub4j/bookprocessor/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * The classes in this package are used for post-processing Books. 3 | * Things like cleaning up the html, adding a cover page, etc. 4 | */ 5 | package io.documentnode.epub4j.bookprocessor; -------------------------------------------------------------------------------- /epub4j-tools/src/main/java/io/documentnode/epub4j/chm/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Classes related to making a Book out of a set of .chm (windows help) files. 3 | */ 4 | package io.documentnode.epub4j.chm; -------------------------------------------------------------------------------- /epub4j-tools/src/main/java/io/documentnode/epub4j/search/ResourceSearchIndex.java: -------------------------------------------------------------------------------- 1 | package io.documentnode.epub4j.search; 2 | 3 | import io.documentnode.epub4j.domain.Resource; 4 | 5 | /** 6 | * The search index for a single resource. 7 | * 8 | * @author paul.siegmann 9 | * 10 | */ 11 | // package 12 | class ResourceSearchIndex { 13 | private String content; 14 | private Resource resource; 15 | 16 | public ResourceSearchIndex(Resource resource, String searchContent) { 17 | this.resource = resource; 18 | this.content = searchContent; 19 | } 20 | 21 | public String getContent() { 22 | return content; 23 | } 24 | 25 | public Resource getResource() { 26 | return resource; 27 | } 28 | 29 | } -------------------------------------------------------------------------------- /epub4j-tools/src/main/java/io/documentnode/epub4j/search/SearchResult.java: -------------------------------------------------------------------------------- 1 | package io.documentnode.epub4j.search; 2 | 3 | import io.documentnode.epub4j.domain.Resource; 4 | 5 | public class SearchResult { 6 | private int pagePos = -1; 7 | private String searchTerm; 8 | private Resource resource; 9 | public SearchResult(int pagePos, String searchTerm, Resource resource) { 10 | super(); 11 | this.pagePos = pagePos; 12 | this.searchTerm = searchTerm; 13 | this.resource = resource; 14 | } 15 | public int getPagePos() { 16 | return pagePos; 17 | } 18 | public String getSearchTerm() { 19 | return searchTerm; 20 | } 21 | public Resource getResource() { 22 | return resource; 23 | } 24 | } -------------------------------------------------------------------------------- /epub4j-tools/src/main/java/io/documentnode/epub4j/search/SearchResults.java: -------------------------------------------------------------------------------- 1 | package io.documentnode.epub4j.search; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import io.documentnode.epub4j.domain.Book; 7 | 8 | public class SearchResults { 9 | private String searchTerm; 10 | public String getSearchTerm() { 11 | return searchTerm; 12 | } 13 | public void setSearchTerm(String searchTerm) { 14 | this.searchTerm = searchTerm; 15 | } 16 | public Book getBook() { 17 | return book; 18 | } 19 | public void setBook(Book book) { 20 | this.book = book; 21 | } 22 | public List getHits() { 23 | return hits; 24 | } 25 | public void setHits(List hits) { 26 | this.hits = hits; 27 | } 28 | private Book book; 29 | private List hits = new ArrayList(); 30 | public boolean isEmpty() { 31 | return hits.isEmpty(); 32 | } 33 | public int size() { 34 | return hits.size(); 35 | } 36 | public void addAll(List searchResults) { 37 | hits.addAll(searchResults); 38 | } 39 | } -------------------------------------------------------------------------------- /epub4j-tools/src/main/java/io/documentnode/epub4j/util/DesktopUtil.java: -------------------------------------------------------------------------------- 1 | 2 | package io.documentnode.epub4j.util; 3 | 4 | import java.awt.Desktop; 5 | import java.net.URL; 6 | 7 | public class DesktopUtil { 8 | 9 | /** 10 | * Open a URL in the default web browser. 11 | * 12 | * @param url a URL to open in a web browser. 13 | * @return true if a browser has been launched. 14 | */ 15 | public static boolean launchBrowser(URL url) throws BrowserLaunchException { 16 | if (Desktop.isDesktopSupported()) { 17 | try { 18 | Desktop.getDesktop().browse(url.toURI()); 19 | return true; 20 | } catch (Exception ex) { 21 | throw new BrowserLaunchException("Browser could not be launched for "+url, ex); 22 | } 23 | } 24 | return false; 25 | } 26 | 27 | public static class BrowserLaunchException extends Exception { 28 | 29 | private BrowserLaunchException(String message, Throwable cause) { 30 | super(message, cause); 31 | } 32 | 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /epub4j-tools/src/main/java/io/documentnode/epub4j/util/ToolsResourceUtil.java: -------------------------------------------------------------------------------- 1 | package io.documentnode.epub4j.util; 2 | 3 | import io.documentnode.epub4j.domain.Resource; 4 | import io.documentnode.epub4j.domain.MediaTypes; 5 | import io.documentnode.minilog.Logger; 6 | import java.io.IOException; 7 | import java.io.Reader; 8 | import java.util.Scanner; 9 | import java.util.regex.Pattern; 10 | import org.apache.commons.lang.StringEscapeUtils; 11 | 12 | /** 13 | * Various resource utility methods 14 | * 15 | * @author paul 16 | * 17 | */ 18 | public class ToolsResourceUtil { 19 | 20 | private static Logger log = Logger.create(ToolsResourceUtil.class); 21 | 22 | 23 | public static String getTitle(Resource resource) { 24 | if (resource == null) { 25 | return ""; 26 | } 27 | if (resource.getMediaType() != MediaTypes.XHTML) { 28 | return resource.getHref(); 29 | } 30 | String title = findTitleFromXhtml(resource); 31 | if (title == null) { 32 | title = ""; 33 | } 34 | return title; 35 | } 36 | 37 | 38 | /** 39 | * Retrieves whatever it finds between <title>...</title> or <h1-7>...</h1-7>. 40 | * The first match is returned, even if it is a blank string. 41 | * If it finds nothing null is returned. 42 | * @param resource 43 | * @return whatever it finds in the resource between <title>...</title> or <h1-7>...</h1-7>. 44 | */ 45 | public static String findTitleFromXhtml(Resource resource) { 46 | if (resource == null) { 47 | return ""; 48 | } 49 | if (resource.getTitle() != null) { 50 | return resource.getTitle(); 51 | } 52 | Pattern h_tag = Pattern.compile("^h\\d\\s*", Pattern.CASE_INSENSITIVE); 53 | String title = null; 54 | try { 55 | Reader content = resource.getReader(); 56 | Scanner scanner = new Scanner(content); 57 | scanner.useDelimiter("<"); 58 | while (scanner.hasNext()) { 59 | String text = scanner.next(); 60 | int closePos = text.indexOf('>'); 61 | String tag = text.substring(0, closePos); 62 | if (tag.equalsIgnoreCase("title") 63 | || h_tag.matcher(tag).find()) { 64 | 65 | title = text.substring(closePos + 1).trim(); 66 | title = StringEscapeUtils.unescapeHtml(title); 67 | break; 68 | } 69 | } 70 | } catch (IOException e) { 71 | log.error(e.getMessage()); 72 | } 73 | resource.setTitle(title); 74 | return title; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /epub4j-tools/src/main/java/io/documentnode/epub4j/utilities/NumberSayer.java: -------------------------------------------------------------------------------- 1 | package io.documentnode.epub4j.utilities; 2 | 3 | public class NumberSayer { 4 | 5 | private static final String[] NUMBER_BELOW_20 = new String[] {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "nineteen"}; 6 | private static final String[] DECIMALS = new String[] {"zero", "ten", "twenty", "thirty", "fourty", "fifty", "sixty", "seventy", "eighty", "ninety"}; 7 | private static final String[] ORDER_NUMBERS = new String[] {"hundred", "thousand", "million", "billion", "trillion"}; 8 | 9 | 10 | public static String getNumberName(int number) { 11 | if(number < 0) { 12 | throw new IllegalArgumentException("Cannot handle numbers < 0 or > " + Integer.MAX_VALUE); 13 | } 14 | if(number < 20) { 15 | return NUMBER_BELOW_20[number]; 16 | } 17 | if(number < 100) { 18 | return DECIMALS[number / 10] + NUMBER_BELOW_20[number % 10]; 19 | } 20 | if(number >= 100 && number < 200) { 21 | return ORDER_NUMBERS[0] + getNumberName(number - 100); 22 | } 23 | if(number < 1000) { 24 | return NUMBER_BELOW_20[number / 100] + ORDER_NUMBERS[0] + getNumberName(number % 100); 25 | } 26 | throw new IllegalArgumentException("Cannot handle numbers < 0 or > " + Integer.MAX_VALUE); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /epub4j-tools/src/main/java/io/documentnode/epub4j/viewer/AboutDialog.java: -------------------------------------------------------------------------------- 1 | package io.documentnode.epub4j.viewer; 2 | 3 | import java.awt.GridLayout; 4 | import java.awt.event.ActionEvent; 5 | import java.awt.event.ActionListener; 6 | import java.awt.event.WindowAdapter; 7 | import java.awt.event.WindowEvent; 8 | 9 | import javax.swing.JButton; 10 | import javax.swing.JDialog; 11 | import javax.swing.JFrame; 12 | import javax.swing.JLabel; 13 | 14 | /** 15 | * First stab at an about dialog. 16 | * 17 | * @author paul.siegmann 18 | * 19 | */ 20 | public class AboutDialog extends JDialog { 21 | 22 | private static final long serialVersionUID = -1766802200843275782L; 23 | 24 | public AboutDialog(JFrame parent) { 25 | super(parent, true); 26 | 27 | super.setResizable(false); 28 | super.getContentPane().setLayout(new GridLayout(3, 1)); 29 | super.setSize(400, 150); 30 | super.setTitle("About epub4j"); 31 | super.setLocationRelativeTo(parent); 32 | 33 | JButton close = new JButton("Close"); 34 | close.addActionListener(new ActionListener() { 35 | public void actionPerformed(ActionEvent e) { 36 | AboutDialog.this.dispose(); 37 | } 38 | }); 39 | super.getRootPane().setDefaultButton(close); 40 | add(new JLabel("epub4j viewer")); 41 | add(new JLabel("https://github.com/documentnode/epub4j")); 42 | add(close); 43 | super.addWindowListener(new WindowAdapter() { 44 | public void windowClosing(WindowEvent e) { 45 | AboutDialog.this.dispose(); 46 | } 47 | }); 48 | pack(); 49 | setVisible(true); 50 | 51 | } 52 | } -------------------------------------------------------------------------------- /epub4j-tools/src/main/java/io/documentnode/epub4j/viewer/BrowseBar.java: -------------------------------------------------------------------------------- 1 | package io.documentnode.epub4j.viewer; 2 | 3 | import java.awt.BorderLayout; 4 | 5 | import javax.swing.JPanel; 6 | 7 | import io.documentnode.epub4j.browsersupport.Navigator; 8 | 9 | public class BrowseBar extends JPanel { 10 | 11 | private static final long serialVersionUID = -5745389338067538254L; 12 | 13 | public BrowseBar(Navigator navigator, ContentPane chapterPane) { 14 | super(new BorderLayout()); 15 | add(new ButtonBar(navigator, chapterPane), BorderLayout.CENTER); 16 | add(new SpineSlider(navigator), BorderLayout.NORTH); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /epub4j-tools/src/main/java/io/documentnode/epub4j/viewer/SpineSlider.java: -------------------------------------------------------------------------------- 1 | package io.documentnode.epub4j.viewer; 2 | 3 | import javax.swing.JSlider; 4 | import javax.swing.event.ChangeEvent; 5 | import javax.swing.event.ChangeListener; 6 | 7 | import io.documentnode.epub4j.browsersupport.NavigationEvent; 8 | import io.documentnode.epub4j.browsersupport.NavigationEventListener; 9 | import io.documentnode.epub4j.browsersupport.Navigator; 10 | import io.documentnode.epub4j.domain.Book; 11 | 12 | // package 13 | class SpineSlider extends JSlider implements NavigationEventListener { 14 | 15 | /** 16 | * 17 | */ 18 | private static final long serialVersionUID = 8436441824668551056L; 19 | private final Navigator navigator; 20 | 21 | public SpineSlider(Navigator navigator) { 22 | super(JSlider.HORIZONTAL); 23 | this.navigator = navigator; 24 | navigator.addNavigationEventListener(this); 25 | setPaintLabels(false); 26 | addChangeListener(new ChangeListener() { 27 | public void stateChanged(ChangeEvent evt) { 28 | JSlider slider = (JSlider) evt.getSource(); 29 | int value = slider.getValue(); 30 | SpineSlider.this.navigator.gotoSpineSection(value, SpineSlider.this); 31 | } 32 | }); 33 | initBook(navigator.getBook()); 34 | } 35 | 36 | private void initBook(Book book) { 37 | if (book == null) { 38 | return; 39 | } 40 | super.setMinimum(0); 41 | super.setMaximum(book.getSpine().size() - 1); 42 | super.setValue(0); 43 | // setPaintTicks(true); 44 | updateToolTip(); 45 | } 46 | 47 | private void updateToolTip() { 48 | String tooltip = ""; 49 | if (navigator.getCurrentSpinePos() >= 0 && navigator.getBook() != null) { 50 | tooltip = String.valueOf(navigator.getCurrentSpinePos() + 1) + " / " + navigator.getBook().getSpine().size(); 51 | } 52 | setToolTipText(tooltip); 53 | } 54 | 55 | @Override 56 | public void navigationPerformed(NavigationEvent navigationEvent) { 57 | updateToolTip(); 58 | if (this == navigationEvent.getSource()) { 59 | return; 60 | } 61 | 62 | if (navigationEvent.isBookChanged()) { 63 | initBook(navigationEvent.getCurrentBook()); 64 | } else if (navigationEvent.isResourceChanged()) { 65 | setValue(navigationEvent.getCurrentSpinePos()); 66 | } 67 | } 68 | 69 | } -------------------------------------------------------------------------------- /epub4j-tools/src/main/java/io/documentnode/epub4j/viewer/ValueHolder.java: -------------------------------------------------------------------------------- 1 | package io.documentnode.epub4j.viewer; 2 | 3 | public class ValueHolder { 4 | 5 | private T value; 6 | 7 | public ValueHolder() { 8 | } 9 | 10 | public ValueHolder(T value) { 11 | this.value = value; 12 | } 13 | 14 | 15 | public T getValue() { 16 | return value; 17 | } 18 | 19 | public void setValue(T value) { 20 | this.value = value; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /epub4j-tools/src/main/java/io/documentnode/epub4j/viewer/ViewerUtil.java: -------------------------------------------------------------------------------- 1 | package io.documentnode.epub4j.viewer; 2 | 3 | import io.documentnode.minilog.Logger; 4 | import java.awt.Image; 5 | import javax.imageio.ImageIO; 6 | import javax.swing.ImageIcon; 7 | import javax.swing.JButton; 8 | 9 | public class ViewerUtil { 10 | 11 | private static Logger log = Logger.create(ViewerUtil.class); 12 | 13 | /** 14 | * Creates a button with the given icon. The icon will be loaded from the classpath. 15 | * If loading the icon is unsuccessful it will use the defaultLabel. 16 | * 17 | * @param iconName 18 | * @param backupLabel 19 | * @return a button with the given icon. 20 | */ 21 | // package 22 | static JButton createButton(String iconName, String backupLabel) { 23 | JButton result = null; 24 | ImageIcon icon = createImageIcon(iconName); 25 | if (icon == null) { 26 | result = new JButton(backupLabel); 27 | } else { 28 | result = new JButton(icon); 29 | } 30 | return result; 31 | } 32 | 33 | 34 | static ImageIcon createImageIcon(String iconName) { 35 | ImageIcon result = null; 36 | String fullIconPath = "/viewer/icons/" + iconName + ".png"; 37 | try { 38 | Image image = ImageIO 39 | .read(ViewerUtil.class.getResourceAsStream(fullIconPath)); 40 | result = new ImageIcon(image); 41 | } catch (Exception e) { 42 | log.error("Icon \'" + fullIconPath + "\' not found"); 43 | } 44 | return result; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /epub4j-tools/src/main/resources/viewer/book/index.txt: -------------------------------------------------------------------------------- 1 | title: EPUB4J - a java epub library 2 | author: P. Siegmann 3 | 4 | 00_cover.html -------------------------------------------------------------------------------- /epub4j-tools/src/main/resources/viewer/epub4jviewer-help.epub: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-tools/src/main/resources/viewer/epub4jviewer-help.epub -------------------------------------------------------------------------------- /epub4j-tools/src/main/resources/viewer/icons/chapter-first.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-tools/src/main/resources/viewer/icons/chapter-first.png -------------------------------------------------------------------------------- /epub4j-tools/src/main/resources/viewer/icons/chapter-last.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-tools/src/main/resources/viewer/icons/chapter-last.png -------------------------------------------------------------------------------- /epub4j-tools/src/main/resources/viewer/icons/chapter-next.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-tools/src/main/resources/viewer/icons/chapter-next.png -------------------------------------------------------------------------------- /epub4j-tools/src/main/resources/viewer/icons/chapter-previous.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-tools/src/main/resources/viewer/icons/chapter-previous.png -------------------------------------------------------------------------------- /epub4j-tools/src/main/resources/viewer/icons/history-next.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-tools/src/main/resources/viewer/icons/history-next.png -------------------------------------------------------------------------------- /epub4j-tools/src/main/resources/viewer/icons/history-previous.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-tools/src/main/resources/viewer/icons/history-previous.png -------------------------------------------------------------------------------- /epub4j-tools/src/main/resources/viewer/icons/layout-content.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-tools/src/main/resources/viewer/icons/layout-content.png -------------------------------------------------------------------------------- /epub4j-tools/src/main/resources/viewer/icons/layout-toc-content-meta.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-tools/src/main/resources/viewer/icons/layout-toc-content-meta.png -------------------------------------------------------------------------------- /epub4j-tools/src/main/resources/viewer/icons/layout-toc-content.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-tools/src/main/resources/viewer/icons/layout-toc-content.png -------------------------------------------------------------------------------- /epub4j-tools/src/main/resources/viewer/icons/page-next.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-tools/src/main/resources/viewer/icons/page-next.png -------------------------------------------------------------------------------- /epub4j-tools/src/main/resources/viewer/icons/page-previous.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-tools/src/main/resources/viewer/icons/page-previous.png -------------------------------------------------------------------------------- /epub4j-tools/src/main/resources/viewer/icons/search-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-tools/src/main/resources/viewer/icons/search-icon.png -------------------------------------------------------------------------------- /epub4j-tools/src/main/resources/viewer/icons/search-next.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-tools/src/main/resources/viewer/icons/search-next.png -------------------------------------------------------------------------------- /epub4j-tools/src/main/resources/viewer/icons/search-previous.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-tools/src/main/resources/viewer/icons/search-previous.png -------------------------------------------------------------------------------- /epub4j-tools/src/main/resources/xsl/chm_remove_prev_next.xsl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /epub4j-tools/src/main/resources/xsl/chm_remove_prev_next_2.xsl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /epub4j-tools/src/main/resources/xsl/chm_remove_prev_next_3.xsl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /epub4j-tools/src/main/resources/xsl/remove_comment_container.xsl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /epub4j-tools/src/test/java/io/documentnode/epub4j/FilesetBookCreatorTest.java: -------------------------------------------------------------------------------- 1 | package io.documentnode.epub4j; 2 | 3 | import junit.framework.TestCase; 4 | import io.documentnode.epub4j.domain.Book; 5 | import io.documentnode.epub4j.fileset.FilesetBookCreator; 6 | 7 | import org.apache.commons.io.IOUtils; 8 | import org.apache.commons.vfs.FileObject; 9 | import org.apache.commons.vfs.FileSystemManager; 10 | import org.apache.commons.vfs.NameScope; 11 | import org.apache.commons.vfs.VFS; 12 | 13 | public class FilesetBookCreatorTest extends TestCase { 14 | 15 | public void test1() { 16 | try { 17 | FileSystemManager fsManager = VFS.getManager(); 18 | FileObject dir = fsManager.resolveFile("ram://test-dir"); 19 | dir.createFolder(); 20 | FileObject chapter1 = dir.resolveFile("chapter1.html", NameScope.CHILD); 21 | chapter1.createFile(); 22 | IOUtils.copy(this.getClass().getResourceAsStream("/book1/chapter1.html"), chapter1.getContent().getOutputStream()); 23 | Book bookFromDirectory = FilesetBookCreator.createBookFromDirectory(dir, Constants.CHARACTER_ENCODING); 24 | assertEquals(1, bookFromDirectory.getResources().size()); 25 | assertEquals(1, bookFromDirectory.getSpine().size()); 26 | assertEquals(1, bookFromDirectory.getTableOfContents().size()); 27 | } catch(Exception e) { 28 | assertTrue(false); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /epub4j-tools/src/test/java/io/documentnode/epub4j/bookprocessor/CoverpageBookProcessorTest.java: -------------------------------------------------------------------------------- 1 | package io.documentnode.epub4j.bookprocessor; 2 | 3 | import junit.framework.TestCase; 4 | 5 | public class CoverpageBookProcessorTest extends TestCase { 6 | 7 | public void testCalculateAbsoluteImageHref1() { 8 | String[] testData = new String[] { 9 | "/foo/index.html", "bar.html", "/foo/bar.html", 10 | "/foo/index.html", "../bar.html", "/bar.html", 11 | "/foo/index.html", "../sub/bar.html", "/sub/bar.html" 12 | }; 13 | for (int i = 0; i < testData.length; i+= 3) { 14 | String actualResult = CoverPageBookProcessor 15 | .calculateAbsoluteImageHref(testData[i + 1], testData[i]); 16 | assertEquals(testData[i + 2], actualResult); 17 | } 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /epub4j-tools/src/test/java/io/documentnode/epub4j/hhc/ChmParserTest.java: -------------------------------------------------------------------------------- 1 | package io.documentnode.epub4j.hhc; 2 | 3 | import io.documentnode.epub4j.Constants; 4 | import java.util.Iterator; 5 | 6 | import junit.framework.TestCase; 7 | import io.documentnode.epub4j.chm.ChmParser; 8 | import io.documentnode.epub4j.domain.Book; 9 | 10 | import org.apache.commons.io.IOUtils; 11 | import org.apache.commons.vfs.FileObject; 12 | import org.apache.commons.vfs.FileSystemManager; 13 | import org.apache.commons.vfs.NameScope; 14 | import org.apache.commons.vfs.VFS; 15 | 16 | public class ChmParserTest extends TestCase { 17 | 18 | public void test1() { 19 | try { 20 | FileSystemManager fsManager = VFS.getManager(); 21 | FileObject dir = fsManager.resolveFile("ram://chm_test_dir"); 22 | dir.createFolder(); 23 | String chm1Dir = "/chm1"; 24 | Iterator lineIter = IOUtils.lineIterator(ChmParserTest.class.getResourceAsStream(chm1Dir + "/filelist.txt"), Constants.CHARACTER_ENCODING); 25 | while(lineIter.hasNext()) { 26 | String line = lineIter.next(); 27 | FileObject file = dir.resolveFile(line, NameScope.DESCENDENT); 28 | file.createFile(); 29 | IOUtils.copy(this.getClass().getResourceAsStream(chm1Dir + "/" + line), file.getContent().getOutputStream()); 30 | file.getContent().close(); 31 | } 32 | 33 | Book chmBook = ChmParser.parseChm(dir, Constants.CHARACTER_ENCODING); 34 | assertEquals(45, chmBook.getResources().size()); 35 | assertEquals(18, chmBook.getSpine().size()); 36 | assertEquals(19, chmBook.getTableOfContents().size()); 37 | assertEquals("chm-example", chmBook.getMetadata().getTitles().get(0)); 38 | } catch(Exception e) { 39 | e.printStackTrace(); 40 | assertTrue(false); 41 | } 42 | } 43 | 44 | 45 | } -------------------------------------------------------------------------------- /epub4j-tools/src/test/java/io/documentnode/epub4j/html/htmlcleaner/FixIdentifierBookProcessorTest.java: -------------------------------------------------------------------------------- 1 | package io.documentnode.epub4j.html.htmlcleaner; 2 | 3 | import junit.framework.TestCase; 4 | import io.documentnode.epub4j.bookprocessor.FixIdentifierBookProcessor; 5 | import io.documentnode.epub4j.domain.Book; 6 | import io.documentnode.epub4j.domain.Identifier; 7 | import io.documentnode.epub4j.util.CollectionUtil; 8 | 9 | public class FixIdentifierBookProcessorTest extends TestCase { 10 | 11 | public void test_empty_book() { 12 | Book book = new Book(); 13 | FixIdentifierBookProcessor fixIdentifierBookProcessor = new FixIdentifierBookProcessor(); 14 | Book resultBook = fixIdentifierBookProcessor.processBook(book); 15 | assertEquals(1, resultBook.getMetadata().getIdentifiers().size()); 16 | Identifier identifier = CollectionUtil.first(resultBook.getMetadata().getIdentifiers()); 17 | assertEquals(Identifier.Scheme.UUID, identifier.getScheme()); 18 | } 19 | 20 | public void test_single_identifier() { 21 | Book book = new Book(); 22 | Identifier identifier = new Identifier(Identifier.Scheme.ISBN, "1234"); 23 | book.getMetadata().addIdentifier(identifier); 24 | FixIdentifierBookProcessor fixIdentifierBookProcessor = new FixIdentifierBookProcessor(); 25 | Book resultBook = fixIdentifierBookProcessor.processBook(book); 26 | assertEquals(1, resultBook.getMetadata().getIdentifiers().size()); 27 | Identifier actualIdentifier = CollectionUtil.first(resultBook.getMetadata().getIdentifiers()); 28 | assertEquals(identifier, actualIdentifier); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /epub4j-tools/src/test/java/io/documentnode/epub4j/utilities/HtmlSplitterTest.java: -------------------------------------------------------------------------------- 1 | package io.documentnode.epub4j.utilities; 2 | 3 | import io.documentnode.epub4j.Constants; 4 | import java.io.ByteArrayOutputStream; 5 | import java.io.InputStreamReader; 6 | import java.io.Reader; 7 | import java.util.List; 8 | 9 | import javax.xml.stream.XMLEventWriter; 10 | import javax.xml.stream.XMLOutputFactory; 11 | import javax.xml.stream.events.XMLEvent; 12 | 13 | import junit.framework.TestCase; 14 | 15 | public class HtmlSplitterTest extends TestCase { 16 | 17 | public void test1() { 18 | HtmlSplitter htmlSplitter = new HtmlSplitter(); 19 | try { 20 | String bookResourceName = "/holmes_scandal_bohemia.html"; 21 | Reader input = new InputStreamReader(HtmlSplitterTest.class.getResourceAsStream(bookResourceName), Constants.CHARACTER_ENCODING); 22 | int maxSize = 3000; 23 | List> result = htmlSplitter.splitHtml(input, maxSize); 24 | XMLOutputFactory xmlOutputFactory = XMLOutputFactory.newInstance(); 25 | for(int i = 0; i < result.size(); i++) { 26 | ByteArrayOutputStream out = new ByteArrayOutputStream(); 27 | XMLEventWriter writer = xmlOutputFactory.createXMLEventWriter(out); 28 | for(XMLEvent xmlEvent: result.get(i)) { 29 | writer.add(xmlEvent); 30 | } 31 | writer.close(); 32 | byte[] data = out.toByteArray(); 33 | assertTrue(data.length > 0); 34 | assertTrue(data.length <= maxSize); 35 | } 36 | } catch (Exception e) { 37 | // TODO Auto-generated catch block 38 | e.printStackTrace(); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /epub4j-tools/src/test/java/io/documentnode/epub4j/utilities/NumberSayerTest.java: -------------------------------------------------------------------------------- 1 | package io.documentnode.epub4j.utilities; 2 | 3 | import junit.framework.TestCase; 4 | 5 | public class NumberSayerTest extends TestCase { 6 | public void test1() { 7 | Object[] testinput = new Object[] { 8 | 1, "one", 9 | 42, "fourtytwo", 10 | 127, "hundredtwentyseven", 11 | 433, "fourhundredthirtythree" 12 | }; 13 | for(int i = 0; i < testinput.length; i += 2) { 14 | assertEquals((String) testinput[i + 1], NumberSayer.getNumberName((Integer) testinput[i])); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /epub4j-tools/src/test/java/io/documentnode/epub4j/utilities/ResourceUtilTest.java: -------------------------------------------------------------------------------- 1 | package io.documentnode.epub4j.utilities; 2 | 3 | import io.documentnode.epub4j.domain.MediaTypes; 4 | import junit.framework.TestCase; 5 | import io.documentnode.epub4j.domain.Resource; 6 | import io.documentnode.epub4j.util.ToolsResourceUtil; 7 | 8 | public class ResourceUtilTest extends TestCase { 9 | 10 | public void testFindTitle() { 11 | String[] testData = new String[] { 12 | "my title1

wrong title

", "my title1", 13 | "my title2

wrong title

", "my title2", 14 | "

my h1 title3

", "my h1 title3", 15 | "

my h1 title4

", "my h1 title4", 16 | "

my h1 title5

", "my h1 title5", 17 | "wrong title

test title 6

", "test title 6", 18 | }; 19 | for (int i = 0; i < testData.length; i+= 2) { 20 | Resource resource = new Resource(testData[i].getBytes(), MediaTypes.XHTML); 21 | String actualTitle = ToolsResourceUtil.findTitleFromXhtml(resource); 22 | assertEquals(testData[i + 1], actualTitle); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /epub4j-tools/src/test/resources/book1/book1.css: -------------------------------------------------------------------------------- 1 | @CHARSET "UTF-8"; 2 | 3 | body { 4 | font-family: "New Century Schoolbook", serif; 5 | } -------------------------------------------------------------------------------- /epub4j-tools/src/test/resources/book1/chapter1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Chapter 1 4 | 5 | 6 | 7 | 8 |

Introduction

9 |

10 | Welcome to Chapter 1 of the epub4j book1 test book.
11 | We hope you enjoy the test. 12 |

13 | 14 | -------------------------------------------------------------------------------- /epub4j-tools/src/test/resources/book1/chapter2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Chapter 2 4 | 5 | 6 | 7 |

Second chapter

8 |

9 | Welcome to Chapter 2 of the epub4j book1 test book.
10 | Pretty flowers:
11 | flowers
12 | We hope you are still enjoying the test. 13 |

14 | 15 | -------------------------------------------------------------------------------- /epub4j-tools/src/test/resources/book1/chapter3.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Chapter 3 4 | 5 | 6 | 7 |

Final chapter

8 |

9 | Welcome to Chapter 3 of the epub4j book1 test book.
10 | We hope you enjoyed the test. 11 |

12 | 13 | -------------------------------------------------------------------------------- /epub4j-tools/src/test/resources/book1/cover.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Cover 4 | 5 | 6 |
Cover
7 | 8 | -------------------------------------------------------------------------------- /epub4j-tools/src/test/resources/book1/cover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-tools/src/test/resources/book1/cover.png -------------------------------------------------------------------------------- /epub4j-tools/src/test/resources/book1/flowers_320x240.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-tools/src/test/resources/book1/flowers_320x240.jpg -------------------------------------------------------------------------------- /epub4j-tools/src/test/resources/chm1/#IDXHDR: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-tools/src/test/resources/chm1/#IDXHDR -------------------------------------------------------------------------------- /epub4j-tools/src/test/resources/chm1/#IVB: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-tools/src/test/resources/chm1/#IVB -------------------------------------------------------------------------------- /epub4j-tools/src/test/resources/chm1/#STRINGS: -------------------------------------------------------------------------------- 1 | mainOnline HelpCHM-example.hhcCHM-example.hhkindex.htmwndTopicNew Topic WindowContext-sensitive_example\contextID-10000.htmContext-sensitive_example\contextID-10010.htmContext-sensitive_example\contextID-20000.htmContext-sensitive_example\contextID-20010.htmWelcomeContext-sensitive exampleGardenHTMLHelp ExamplesContext sensitive help topic 10000Context sensitive help topic 10010Context sensitive help topic 20000Context sensitive help topic 20010FlowersHow one grows treesAttention (!) - Close Window automaticallyTopic split exampleUsing CHM shortcut linksHow to jump to a anchorHow to jump to a second anchorHow to create PopUpLinking from CHM with standard HTMLLinking to PDF from CHMExample load PDF from TOCHow to link to PDF (server)How to jump directly from here (e.g. VW)How to jump to a anchorTopic 2Topic 3Topic 4XP Style for RadioButton and Check BoxesExternal TopicUsing window.open -------------------------------------------------------------------------------- /epub4j-tools/src/test/resources/chm1/#SYSTEM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-tools/src/test/resources/chm1/#SYSTEM -------------------------------------------------------------------------------- /epub4j-tools/src/test/resources/chm1/#TOPICS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-tools/src/test/resources/chm1/#TOPICS -------------------------------------------------------------------------------- /epub4j-tools/src/test/resources/chm1/#URLSTR: -------------------------------------------------------------------------------- 1 | index.htmContext-sensitive_example/contextID-10000.htmContext-sensitive_example/contextID-10010.htmContext-sensitive_example/contextID-20000.htmContext-sensitive_example/contextID-20010.htmGarden/flowers.htmGarden/garden.htmGarden/tree.htmHTMLHelp_Examples/CloseWindowAutomatically.htmHTMLHelp_Examples/example-external-pdf.htmHTMLHelp_Examples/Jump_to_anchor.htmHTMLHelp_Examples/LinkPDFfromCHM.htmHTMLHelp_Examples/pop-up_example.htmHTMLHelp_Examples/shortcut_link.htmHTMLHelp_Examples/Simple_link_example.htmHTMLHelp_Examples/topic_split_example.htmHTMLHelp_Examples/topic-02.htmHTMLHelp_Examples/topic-03.htmHTMLHelp_Examples/topic-04.htmCHM-example.hhcCHM-example.hhkHTMLHelp_Examples/xp-style_radio-button_check-boxes.htmexternal_files/external_topic.htmHTMLHelp_Examples/using_window_open.htmHTMLHelp_Examples/Jump_to_anchor.htm#AnchorSampleHTMLHelp_Examples/Jump_to_anchor.htm#SecondAnchorhttp://www.help-info.de/download/pdf/example.pdfhttp://www.volkswagen.co.uk/home -------------------------------------------------------------------------------- /epub4j-tools/src/test/resources/chm1/#URLTBL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-tools/src/test/resources/chm1/#URLTBL -------------------------------------------------------------------------------- /epub4j-tools/src/test/resources/chm1/#WINDOWS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-tools/src/test/resources/chm1/#WINDOWS -------------------------------------------------------------------------------- /epub4j-tools/src/test/resources/chm1/$FIftiMain: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-tools/src/test/resources/chm1/$FIftiMain -------------------------------------------------------------------------------- /epub4j-tools/src/test/resources/chm1/$OBJINST: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-tools/src/test/resources/chm1/$OBJINST -------------------------------------------------------------------------------- /epub4j-tools/src/test/resources/chm1/$WWAssociativeLinks/BTree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-tools/src/test/resources/chm1/$WWAssociativeLinks/BTree -------------------------------------------------------------------------------- /epub4j-tools/src/test/resources/chm1/$WWAssociativeLinks/Data: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-tools/src/test/resources/chm1/$WWAssociativeLinks/Data -------------------------------------------------------------------------------- /epub4j-tools/src/test/resources/chm1/$WWAssociativeLinks/Map: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /epub4j-tools/src/test/resources/chm1/$WWAssociativeLinks/Property: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /epub4j-tools/src/test/resources/chm1/$WWKeywordLinks/BTree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-tools/src/test/resources/chm1/$WWKeywordLinks/BTree -------------------------------------------------------------------------------- /epub4j-tools/src/test/resources/chm1/$WWKeywordLinks/Data: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-tools/src/test/resources/chm1/$WWKeywordLinks/Data -------------------------------------------------------------------------------- /epub4j-tools/src/test/resources/chm1/$WWKeywordLinks/Map: -------------------------------------------------------------------------------- 1 | * -------------------------------------------------------------------------------- /epub4j-tools/src/test/resources/chm1/$WWKeywordLinks/Property: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /epub4j-tools/src/test/resources/chm1/Garden/flowers.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Flowers 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 |

Flowers

23 |

You can cultivate flowers in your garden. It is beautiful if one can give his 24 | wife a bunch of self-cultivated flowers.

25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 |
39 |

 

40 | 41 |

 

42 | 43 | 44 | 45 | 46 | 47 |
back to top ...
48 |
49 |

 

50 | 51 | -------------------------------------------------------------------------------- /epub4j-tools/src/test/resources/chm1/Garden/garden.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Garden 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 |

Own Garden

27 |

It is nice to have a garden near your home.

28 |

You can plant trees of one's own, lay out a pond with fish and cultivate flowers. 29 | For the children a game lawn can be laid out. You can learn much about botany.

30 |

 

31 | 32 | 33 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 |
A garden is good for your health and you can relax 34 | at the gardening.
46 |

 

47 |

 

48 |

 

49 |

 

50 | 51 | 52 | 53 | 54 | 55 |
back to top ...
56 |
57 |

 

58 | 59 | -------------------------------------------------------------------------------- /epub4j-tools/src/test/resources/chm1/Garden/tree.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | How one grows trees 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 |

How one grows trees

25 |

You must dig a big hole first.

26 |

Wonder well which kind of tree you want to plant.

27 |

(oak, beech, alder)

28 |

The tree planted newly has always to be watered with sufficient water.

29 |

30 |

 

31 | 32 |

 

33 | 34 | 35 | 36 | 37 | 38 | 39 |
back to top ...
40 |
41 |

 

42 | 43 | -------------------------------------------------------------------------------- /epub4j-tools/src/test/resources/chm1/HTMLHelp_Examples/LinkPDFfromCHM.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Linking to PDF from CHM 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 |

Linking to PDF from CHM

19 |

This topic is only used to show linking from a compiled CHM to other files 20 | and places. Open/Save dialog is used.

21 |

PDF

22 |

Link relative to PDF

23 |
24 | <p><a href="../embedded_files/example-embedded.pdf">Link relative to PDF</a></p>
25 | 
26 |

 

27 |

 

28 |

 

29 |

 

30 | 31 | 32 | 33 | 34 | 35 |
back to top ...
36 |
37 |

 

38 | 39 | 40 | -------------------------------------------------------------------------------- /epub4j-tools/src/test/resources/chm1/HTMLHelp_Examples/example-external-pdf.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | Example load PDF from TOC 4 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /epub4j-tools/src/test/resources/chm1/HTMLHelp_Examples/topic-02.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Topic 2 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 |

To do so insert following code to the HTML file at this place:

18 |
  <object type="application/x-oleobject"
19 |      classid="clsid:1e2a7bd0-dab9-1­1d0-b93a-00c04fc99f9
20 |      <param name="New HTML file" value="topic-02.htm">
21 |      <param name="New HTML title" value="Topic 2">
22 |   </object>
23 |

Split example - Topic 2

24 |

This example is used to show how the SPLIT function is working for generating 25 | sub-topics from one HTML file to the table of contents. This is the topic 26 | 2 of one HTML file.

27 |

28 |

Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam
29 |
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy 30 | eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. 31 | At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, 32 | no sea takimata sanctus est Lorem ipsum dolor sit amet.

33 | 34 | 35 | 36 | 37 |
back to top ...
38 |
39 | 40 | 41 | -------------------------------------------------------------------------------- /epub4j-tools/src/test/resources/chm1/HTMLHelp_Examples/topic-03.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Topic 3 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 |

To do so insert following code to the HTML file at this place:

18 |
  <object type="application/x-oleobject"
19 |      classid="clsid:1e2a7bd0-dab9-1­1d0-b93a-00c04fc99f9
20 |      <param name="New HTML file" value="topic-03.htm">
21 |      <param name="New HTML title" value="Topic 3">
22 |   </object>
23 |

Split example - Topic 3

24 |

This example is used to show how the SPLIT function is working for generating 25 | sub-topics from one HTML file to the table of contents. This is the topic 26 | 3 of one HTML file.

27 |

28 |

Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam
29 |
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy 30 | eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. 31 | At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, 32 | no sea takimata sanctus est Lorem ipsum dolor sit amet.

33 |

 

34 | 35 | 36 | 37 | 38 |
back to top ...
39 |
40 | 41 | -------------------------------------------------------------------------------- /epub4j-tools/src/test/resources/chm1/HTMLHelp_Examples/topic-04.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Topic 4 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 |

Split example - Topic 4

17 |

This is a short example text for Topic 4 for a small pop-up window.

18 |

See link at Topic 1.

19 |

 

20 |

 

21 |

 

22 | 23 | -------------------------------------------------------------------------------- /epub4j-tools/src/test/resources/chm1/design.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-tools/src/test/resources/chm1/design.css -------------------------------------------------------------------------------- /epub4j-tools/src/test/resources/chm1/embedded_files/example-embedded.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-tools/src/test/resources/chm1/embedded_files/example-embedded.pdf -------------------------------------------------------------------------------- /epub4j-tools/src/test/resources/chm1/external_files/external_topic.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | External Topic 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

External Topic

21 |

 

22 |

This is a external topic that resides relativ to the CHM files and isn't compiled 23 | into the CHM file. Here it's used to show how to link to external files in a 24 | CHM topic window.

25 |

Delete links in all HTML files of your project - otherwise the external file 26 | is compiled to the CHM file.

27 |

Make a copy of the external file and delete the file in your project structure 28 | before the last compile runs. So the file isn't compiled into the CHM file. 29 | But you have to install the external file on the customers PC.

30 |

To try this example you must download the complete 31 | project example to a local folder, delete all files excepting "CHM-example.chm" 32 | and folder "external_files".

33 |

Edit following date in the external HTML file "external_topic.htm" 34 | to check that you can update the HTML file without recompiling the CHM file:

35 |

 

36 |

2005-05-17

37 |

 

38 |
39 | 40 | 41 | 42 | 43 |
back to top ...
44 |
45 |

 

46 | 47 | -------------------------------------------------------------------------------- /epub4j-tools/src/test/resources/chm1/filelist.txt: -------------------------------------------------------------------------------- 1 | #IDXHDR 2 | #IVB 3 | #STRINGS 4 | #SYSTEM 5 | #TOPICS 6 | #URLSTR 7 | #URLTBL 8 | #WINDOWS 9 | $FIftiMain 10 | $OBJINST 11 | $WWAssociativeLinks/BTree 12 | $WWAssociativeLinks/Data 13 | $WWAssociativeLinks/Map 14 | $WWAssociativeLinks/Property 15 | $WWKeywordLinks/BTree 16 | $WWKeywordLinks/Data 17 | $WWKeywordLinks/Map 18 | $WWKeywordLinks/Property 19 | CHM-example.hhc 20 | CHM-example.hhk 21 | Context-sensitive_example/contextID-10000.htm 22 | Context-sensitive_example/contextID-10010.htm 23 | Context-sensitive_example/contextID-20000.htm 24 | Context-sensitive_example/contextID-20010.htm 25 | design.css 26 | embedded_files/example-embedded.pdf 27 | external_files/external_topic.htm 28 | Garden/flowers.htm 29 | Garden/garden.htm 30 | Garden/tree.htm 31 | HTMLHelp_Examples/CloseWindowAutomatically.htm 32 | HTMLHelp_Examples/example-external-pdf.htm 33 | HTMLHelp_Examples/Jump_to_anchor.htm 34 | HTMLHelp_Examples/LinkPDFfromCHM.htm 35 | HTMLHelp_Examples/pop-up_example.htm 36 | HTMLHelp_Examples/shortcut_link.htm 37 | HTMLHelp_Examples/Simple_link_example.htm 38 | HTMLHelp_Examples/topic-02.htm 39 | HTMLHelp_Examples/topic-03.htm 40 | HTMLHelp_Examples/topic-04.htm 41 | HTMLHelp_Examples/topic_split_example.htm 42 | HTMLHelp_Examples/using_window_open.htm 43 | HTMLHelp_Examples/xp-style_radio-button_check-boxes.htm 44 | images/blume.jpg 45 | images/ditzum.jpg 46 | images/eiche.jpg 47 | images/extlink.gif 48 | images/insekt.jpg 49 | images/list_arrow.gif 50 | images/lupine.jpg 51 | images/riffel_40px.jpg 52 | images/riffel_helpinformation.jpg 53 | images/riffel_home.jpg 54 | images/rotor_enercon.jpg 55 | images/screenshot_big.png 56 | images/screenshot_small.png 57 | images/up_rectangle.png 58 | images/verlauf-blau.jpg 59 | images/verlauf-gelb.jpg 60 | images/verlauf-rot.jpg 61 | images/welcome_small_big-en.gif 62 | images/wintertree.jpg 63 | index.htm 64 | topic.txt -------------------------------------------------------------------------------- /epub4j-tools/src/test/resources/chm1/images/blume.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-tools/src/test/resources/chm1/images/blume.jpg -------------------------------------------------------------------------------- /epub4j-tools/src/test/resources/chm1/images/ditzum.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-tools/src/test/resources/chm1/images/ditzum.jpg -------------------------------------------------------------------------------- /epub4j-tools/src/test/resources/chm1/images/eiche.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-tools/src/test/resources/chm1/images/eiche.jpg -------------------------------------------------------------------------------- /epub4j-tools/src/test/resources/chm1/images/extlink.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-tools/src/test/resources/chm1/images/extlink.gif -------------------------------------------------------------------------------- /epub4j-tools/src/test/resources/chm1/images/insekt.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-tools/src/test/resources/chm1/images/insekt.jpg -------------------------------------------------------------------------------- /epub4j-tools/src/test/resources/chm1/images/list_arrow.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-tools/src/test/resources/chm1/images/list_arrow.gif -------------------------------------------------------------------------------- /epub4j-tools/src/test/resources/chm1/images/lupine.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-tools/src/test/resources/chm1/images/lupine.jpg -------------------------------------------------------------------------------- /epub4j-tools/src/test/resources/chm1/images/riffel_40px.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-tools/src/test/resources/chm1/images/riffel_40px.jpg -------------------------------------------------------------------------------- /epub4j-tools/src/test/resources/chm1/images/riffel_helpinformation.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-tools/src/test/resources/chm1/images/riffel_helpinformation.jpg -------------------------------------------------------------------------------- /epub4j-tools/src/test/resources/chm1/images/riffel_home.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-tools/src/test/resources/chm1/images/riffel_home.jpg -------------------------------------------------------------------------------- /epub4j-tools/src/test/resources/chm1/images/rotor_enercon.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-tools/src/test/resources/chm1/images/rotor_enercon.jpg -------------------------------------------------------------------------------- /epub4j-tools/src/test/resources/chm1/images/screenshot_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-tools/src/test/resources/chm1/images/screenshot_big.png -------------------------------------------------------------------------------- /epub4j-tools/src/test/resources/chm1/images/screenshot_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-tools/src/test/resources/chm1/images/screenshot_small.png -------------------------------------------------------------------------------- /epub4j-tools/src/test/resources/chm1/images/up_rectangle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-tools/src/test/resources/chm1/images/up_rectangle.png -------------------------------------------------------------------------------- /epub4j-tools/src/test/resources/chm1/images/verlauf-blau.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-tools/src/test/resources/chm1/images/verlauf-blau.jpg -------------------------------------------------------------------------------- /epub4j-tools/src/test/resources/chm1/images/verlauf-gelb.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-tools/src/test/resources/chm1/images/verlauf-gelb.jpg -------------------------------------------------------------------------------- /epub4j-tools/src/test/resources/chm1/images/verlauf-rot.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-tools/src/test/resources/chm1/images/verlauf-rot.jpg -------------------------------------------------------------------------------- /epub4j-tools/src/test/resources/chm1/images/welcome_small_big-en.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-tools/src/test/resources/chm1/images/welcome_small_big-en.gif -------------------------------------------------------------------------------- /epub4j-tools/src/test/resources/chm1/images/wintertree.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/epub4j-tools/src/test/resources/chm1/images/wintertree.jpg -------------------------------------------------------------------------------- /epub4j-tools/src/test/resources/chm1/index.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Welcome 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Welcome

21 |

22 |

.. to CHM examples!

23 |

HTMLHelp is the current help system for Microsoft Windows. This file includes 24 | some examples how to use Microsoft HTMLHelp and is used to show how to work 25 | with HTMLHelp 1.x CHM files in Visual Basic Applications.

26 |

This "Welcome" page is the default page of the compiled help module 27 | (CHM).

28 |

 

29 |

 

30 |

Version Information:

31 |

Release: 2005-07-17

32 |

(c) help-info.de

33 |

 

34 |
35 | 36 | 37 | 38 | 39 |
back to top ...
40 |
41 |

 

42 | 43 | -------------------------------------------------------------------------------- /epub4j-tools/src/test/resources/chm1/topic.txt: -------------------------------------------------------------------------------- 1 | ;------------------------------------------------- 2 | ; topic.h file example for HTMLHelp (CHM) 3 | ; www.help-info.de 4 | ; 5 | ; 6 | ; This is a file including the ID and PopUp text 7 | ;------------------------------------------------- 8 | .topic 900;nohelp 9 | Sorry, no help available! 10 | 11 | .topic 100;PopUp_AddressData_btnOK 12 | This is context sensitive help text for a button (ID: IDH_100). 13 | 14 | .topic 110;PopUp_AddressData_txtFirstName 15 | This is context sensitive help text for a text box (ID: IDH_110). 16 | 17 | .topic 120;PopUp_AddressData_txtLastName 18 | This is context sensitive help text for a text box (ID: IDH_120). 19 | -------------------------------------------------------------------------------- /epub4j-tools/src/test/resources/opf/test1.opf: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | EPUB4J test book 1 5 | Joe Tester 6 | 2010-05-27 7 | en 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /epub4j-tools/src/test/resources/opf/test2.opf: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | This Dynamic Earth 5 | this_dynamic_earth-AAH813 6 | en 7 | W. Jacquelyne Kious, Robert I. Tilling 8 | 9 | Infogrid Pacific 10 | 11 | 12 | 13 | 22-01-2009 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /epub4j-tools/src/test/resources/toc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | EPUB4J test book 1 11 | 12 | 13 | Tester, Joe 14 | 15 | 16 | 17 | 18 | Introduction 19 | 20 | 21 | 22 | 23 | 24 | Second Chapter 25 | 26 | 27 | 28 | 29 | Chapter 2, section 1 30 | 31 | 32 | 33 | 34 | 35 | 36 | Conclusion 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | version=4.2.2 -------------------------------------------------------------------------------- /gradle/libs.versions.toml: -------------------------------------------------------------------------------- 1 | [versions] 2 | dn-minilog = "1.0" 3 | kxml2 = "2.3.0" 4 | xmlpull = "1.1.3.4d_b4_min" 5 | zip4j = "2.11.5" 6 | htmlcleaner = "2.2" 7 | commons-vfs = "1.0" 8 | commons-lang = "2.4" 9 | commons-io = "2.0.1" 10 | 11 | junit4 = "4.13.2" 12 | mockito = "3.6.0" 13 | 14 | # https://github.com/lessthanoptimal/gversion-plugin 15 | gversion-plugin = "1.10.3" 16 | # https://plugins.gradle.org/plugin/com.gradleup.shadow 17 | shadow-plugin = "8.3.5" 18 | # https://github.com/allegro/axion-release-plugin 19 | axion-release-plugin = "1.18.14" 20 | 21 | [libraries] 22 | dn-minilog = { module = "io.documentnode:minilog", version.ref = "dn-minilog" } 23 | kxml2 = { module = "net.sf.kxml:kxml2", version.ref = "kxml2" } 24 | xmlpull = { module = "xmlpull:xmlpull", version.ref = "xmlpull" } 25 | zip4j = { module = "net.lingala.zip4j:zip4j", version.ref = "zip4j" } 26 | htmlcleaner = { module = "net.sourceforge.htmlcleaner:htmlcleaner", version.ref = "htmlcleaner" } 27 | commons-vfs = { module = "commons-vfs:commons-vfs", version.ref = "commons-vfs" } 28 | commons-lang = { module = "commons-lang:commons-lang", version.ref = "commons-lang" } 29 | commons-io = { module = "commons-io:commons-io", version.ref = "commons-io" } 30 | 31 | junit4 = { module = "junit:junit", version.ref = "junit4" } 32 | mockito-core = { module = "org.mockito:mockito-core", version.ref = "mockito" } 33 | 34 | [plugins] 35 | gversion = { id = "com.peterabeles.gversion", version.ref = "gversion-plugin" } 36 | shadow = { id = "com.gradleup.shadow", version.ref = "shadow-plugin" } 37 | axion-release = { id = "pl.allegro.tech.build.axion-release", version.ref = "axion-release-plugin" } 38 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/documentnode/epub4j/75408bdfd2249bab5706f9a28d8fc05099501ccb/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by the Gradle 'init' task. 3 | * 4 | * The settings file is used to specify which projects to include in your build. 5 | * For more detailed information on multi-project builds, please refer to https://docs.gradle.org/8.10.2/userguide/multi_project_builds.html in the Gradle documentation. 6 | */ 7 | 8 | rootProject.name = 'epub4j' 9 | include('epub4j-core') 10 | include('epub4j-tools') 11 | --------------------------------------------------------------------------------