File last modified on August 18, 2022

OPF Manifest

All contents within the OEBPS should be declared in the OPF's Manifest. If a hidden file exists it should be removed and should not be added to the Manifest. If any file exists and not referenced it will fail validation. If you would like all the supporting files in the OEBPS directory outputted to each directory's own file listing the contents try the application create-supporting-files.scpt.

XHTML

If you want to manually get a list of contents in your directories (such as the text, css or img directory) you can do this by dragging the directory in the terminal with the ls command and piping the output to a file, example with the text directory:

bash
1
cd && cd Desktop && ls /Users/codingChewie/<path to project>/<project name>/OEBPS/text >> text.xhtml

The above command will create a XHTML file with all the contents of the text directory piped to it. Open the file (text.xhtml) in BBEdit and you can build the XHTML references needed for the manifest with this regex command:

bash
1
## Find:
2
^(.*?)\.xhtml
3
4
## Replace:
5
\t\t<item id="\1" href="text/\1\.xhtml" media-type="application/xhtml+xml" />

Copy the converted contents of text.xhtml file and replace the titlepage line:

html
1
<item id="titlepage" href="titlepage.xhtml" media-type="application/xhtml+xml" />

should become:

html
1
<item
2
id="DS01_frontmatter01"
3
href="text/DS01_frontmatter01.xhtml"
4
media-type="application/xhtml+xml"
5
/>
6
<item
7
id="DS01_frontmatter02"
8
href="text/DS01_frontmatter02.xhtml"
9
media-type="application/xhtml+xml"
10
/>
11
<item id="DS02_chapter01" href="text/DS02_chapter01.xhtml" media-type="application/xhtml+xml" />
12
<item id="DS02_chapter02" href="text/DS02_chapter02.xhtml" media-type="application/xhtml+xml" />
13
<item id="DS02_chapter03" href="text/DS02_chapter03.xhtml" media-type="application/xhtml+xml" />
14
<item id="DS02_chapter04" href="text/DS02_chapter04.xhtml" media-type="application/xhtml+xml" />
15
<item
16
id="DS03_backmatter01"
17
href="text/DS03_backmatter01.xhtml"
18
media-type="application/xhtml+xml"
19
/>

There are two lines that come after the manifested XHTML files that must remain and should never be removed:

html
1
<item id="ncx" href="toc.ncx" media-type="application/x-dtbncx+xml" />
2
<item id="toc" href="toc.xhtml" media-type="application/xhtml+xml" properties="nav" />

The order in which these are declared doesn't matter so this could be placed above the declared XHTML but the template and apps place this after the XHTML declared.

CSS

All CSS in the CSS directory should be included in the Manifest. To get the contents of the CSS directory to a file in the terminal use the command:

bash
1
cd && cd Desktop && ls /Users/codingChewie/<path to project>/<project name>/OEBPS/css >> css.xhtml

open css.xhtml and format the contents of the file with BBEdit using the regex command:

bash
1
## Find:
2
^(.*?)\.css
3
4
## Replace:
5
\t\t<item id="\1.css" href="css/\1.css" media-type="text/css" />

If the CSS files are named differently than what is in the OPF template:

html
1
<item id="idGeneratedStyles.css" href="css/idGeneratedStyles.css" media-type="text/css" />
2
<item id="epub3.css" href="css/epub3.css" media-type="text/css" />

feel free to replace the above code with the correct files. For example, legacy titles might have been named content.css instead of idGeneratedStyles.css:

html
1
<item id="content.css" href="css/content.css" media-type="text/css" />

Fonts

All fonts should be declared in the Manifest but if a PostScript exists it should be removed and replaced with either an OpenType or TrueType font. If a PostScript font is added to an ePub the text will render as squares in some applications like Apple iBooks.

To get all the contents of the font directory use the terminal command:

bash
1
cd && cd Desktop && ls /Users/codingChewie/<path to project>/<project name>/OEBPS/font >> font.xhtml

Open font.xhtml in BBEdit and format the contents with:

OpenType

BBEdit regex command for OpenType font names:

bash
1
## Find:
2
^(.*?)\.otf
3
4
## Replace:
5
\t\t<item id="\1\.otf" href="font/\1\.otf" media-type="application/vnd.ms-opentype" />

TrueType

BBEdit regex command for TrueType font names:

bash
1
## Find:
2
^(^.*?)\.ttf
3
4
## Replace:
5
\t\t<item id="\1\.ttf" href="font/\1\.ttf" media-type="application/x-font-ttf" />

Once OpenType and TrueType fonts are converted in font.xhtml the line:

html
1
<item id="" href="" media-type="application/vnd.ms-opentype" />

can be replaced in your Manifest from the content.opf file.

Images

All images should be added to the Manifest and to get all images use the bash command:

bash
1
cd && cd Desktop && ls /Users/codingChewie/<path to project>/<project name>/OEBPS/img >> img.xhtml

Then open img.xhtml in BBEdit and run the regex command:

bash
1
## Find:
2
^(.*)\.png
3
4
## Replace:
5
\t\t<item id="\1.png" href="img/\1\.png" media-type="image\/png" \/>

Cover

All images in the img directory should be in PNG format excluding the cover. Instead of converting Cover.jpg use the line:

html
1
<item id="cover" href="image/Cover.jpg" media-type="image/jpeg" properties="cover-image" />

Note two important areas for the cover item:

  • id="cover" must be referenced as lowercase cover so it will not clash with Metdata's Cover declaration: <meta name="cover" content="Cover.jpg" />.
  • properties="cover-image" to declare that this is the cover image in the ePub.
Last build: Thursday, 08/18/2022, 01:01:08 AM