使用 ConTeXt 将 EPUB 转换为 PDF

使用 ConTeXt 将 EPUB 转换为 PDF

由于 ConTeXt 擅长处理 XML,因此它似乎也擅长处理 EPUB,因为这本质上是 HTML 和 CSS 文件的压缩集合。我想知道是否存在一个好的基于 ConTeXt 的系统可以将 EPUB 转换为 PDF? 康特克斯花园包含一些有关 EPUB 的信息,但仅限于 ConTeXt-EPUB 转换。

此类脚本有可能产生比目前大多数其他(IMO)平庸的 EPUB 到 PDF 转换脚本更好的结果。

答案1

ConTeXt 无法胜任 EPUB 排版任务。不过,有第三方解决方案可以将 EPUB 文件转换为 ConTeXt,例如潘多克。这是一个用 Haskell 编写的命令行工具,可以在多种标记文件格式之间进行转换。要从 EPUB 转换为 ConTeXt,请使用

pandoc -f epub -t context -o output.tex input.epub

-s如果您也想获得默认前导码,请添加该标志)。

如果您有兴趣尝试一下,您可以先运行 pandoc 存储库中的测试文件:https://github.com/jgm/pandoc/tree/master/test/epub

以下是前几行的摘录(不含序言)。看起来还不错。

\startalignment[middle]
  {\tfd EPUBTEST 0101 - Styling Tests}
  \smallskip
  {\tfa Ori Idan\crlf Matt Garrish\crlf Marisa DeMeglio\crlf Toshiaki Koike\crlf Vincent Gros\crlf Markus Gylling}
  \bigskip
\stopalignment

\section{EPUB 3 Styling Test Document: 0101}

\subsection{Status of this Document}

This publication is currently considered {[}UNDER DEVELOPMENT{]} by the
IDPF.

This publication is part of version X.X of the EPUB 3.0 Compliance Test
Suite released on TBD.

Before using this publication to evaluate reading systems, testers are
strongly encouraged to verify that they have the latest release by
checking the current release version and date of the test suite at
\useURL[url1][http://idpf.org/][][TBD]\from[url1]

This publication is one of several that currently comprise the EPUB 3
conformance test suite for reflowable content. The complete test suite
includes all of the following publications:

\startitemize[n,packed]
\item
  .
\stopitemize

\subsection{About this Document}

This document focuses on human-evaluated binary (pass/fail) tests in a
reflowable context. Tests for fixed-layout content and other individual
tests that require a dedicated epub file are available in additional
sibling documents; refer to the
\useURL[url2][https://github.com/mgylling/epub-testsuite/wiki/Overview][][test
suite wiki]\from[url2]
(\type{https://github.com/mgylling/epub-testsuite/wiki/Overview}) for
additional information.

\subsection{Conventions}

The following conventions are used throughout the document:

\startdescription{1. Locating a test}

  Tests for {\em required} Reading System functionality are preceded by
  the label: {[}REQUIRED{]}

  Tests for {\em optional} Reading System functionality are preceded by
  the label: {[}OPTIONAL{]}
\stopdescription

\startdescription{2. Performing the test}
  Each test includes a description of its purpose followed by the actual
  {\bf test statement, which can always be evaluated to true or false}.
  These statements typically have the form: "If {[}some condition{]},
  the test passes".
\stopdescription

\startdescription{3. Scoring in the results form}
  @@@TODO provide info on where to get the results form
\stopdescription

这是示例的编译输出formatting.epub

在此处输入图片描述

相关内容