Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PDF 图书内容转换 #5

Closed
Dream4ever opened this issue May 17, 2018 · 0 comments
Closed

PDF 图书内容转换 #5

Dream4ever opened this issue May 17, 2018 · 0 comments
Labels
Back-end Where data really come and go Front-end Everything you see and experience

Comments

@Dream4ever
Copy link
Owner

Dream4ever commented May 17, 2018

需求描述

现有的图书资源以 PDF 格式为主,要使用这些资源,就需要先把它们转换成可用的格式。

转换成 XML

PDF 电子书可以通过 Adobe Acrobat 导出为 XML 1.0 格式的文档,XML 文档整体结构如下。

<?xml version="1.0" encoding="UTF-8" ?>
<TaggedPDF-doc>
<?xpacket begin='' id='W5M0MpCehiHzreSzNTczkc9d'?>
<?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?>
  这里是文档元信息,如创建/修改时间,标题、作者等等
<?xpacket end="w"?>
<?xpacket end='r'?>
  这里是文档内容
</TaggedPDF-doc>

但是有个问题:在文档内容中,出现 Ruby 标签对的地方,标签对内的 RB 标签和 RT 标签在 XML 文档里的顺序,和在 PDF 文档里的顺序是相反的。而且所有出现 Ruby 标签的地方,都是汉字在前面的 RB 标签中,单个的左/右双引号在 RT 标签中。

转换成 TXT

也可以直接把 PDF 导出成 TXT 格式的纯文本文档并复制到浏览器中,然后在浏览器中用自定义的编辑器给每一段文字刷上对应的格式,再增加插入图片、视频之类的功能(需要在服务器上搭建文件服务,Nginx 也要做对应的配置,不是个小工程),编辑完成的文档导入 MongoDB 即可。

方案调研

PDF 转换

  • modesty/pdf2json
  • 手动在本地把 PDF 导出成 TXT 格式的纯文本文档

文本编辑

  • GitHub: text editor
    • 更具体一点:markdown 编辑器?带 UI 的更好,方便使用。
    • 继续:还需要考虑如何将页面中设置好格式的富文本传入后端数据库,比如标题、段落、引用等类型的内容,都要设置对应的标签,这个标签是包在文本的外面放在同一个字段中,还是说放在不同的字段中,都是需要好好考虑的事情。
    • 富文本中嵌入的图片、音频、视频等资源,还需要传入下面的 seaweedfs 中,传入之后会生成资源文件的链接,这个链接也要更新到上面编辑的富文本中,这么一看,工作量很大啊。

文件服务

  • chrislusf/seaweedfs
    • 不只是文件服务搭建起来就行,应该还需要 Nginx 进行相关配置才能正常使用。

XML to HTML

应用过程

要点总结

@Dream4ever Dream4ever added Front-end Everything you see and experience Webpage Back-end Where data really come and go labels May 17, 2018
@Dream4ever Dream4ever removed the Webpage label Jun 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Back-end Where data really come and go Front-end Everything you see and experience
Projects
None yet
Development

No branches or pull requests

1 participant