我想在保存OCR的同时将djvu转换成pdf。这个页面描述了如何做到这一点,但是我得到了一个空白的html文件。
在/home/steven/Documents/djvu2pdf/1/中,djvu2hocr -p 1 Intro.djvu给了我以下内容:
Converting 'Intro.djvu':
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="ocr-system" content="djvu2hocr 0.7.9" />
<meta name="ocr-capabilities" content="ocr_carea ocr_page ocr_par ocrx_block ocrx_line ocrx_word" />
<title>DjVu hidden text layer</title>
</head>
<body>
*** [1-11711] Failed to open 'Intro.djvu': No such file or directory.
*** (ByteStream.cpp:693)
*** 'DJVU::GUTF8String DJVU::ByteStream::Stdio::init(const DJVU::GURL&, const char*)'
</body>
</html>
Traceback (most recent call last):
File "/usr/bin/djvu2hocr", line 7, in <module>
_.main(sys.argv)
File "/usr/share/ocrodjvu/lib/cli/djvu2hocr.py", line 325, in main
djvused.wait()
File "/usr/share/ocrodjvu/lib/ipc.py", line 114, in wait
raise CalledProcessError(return_code, self.__command)
subprocess.CalledProcessError: Command 'djvused' returned non-zero exit status 10导致一个空html文件,所以当我运行
sed 's/ocrx/ocr/g' > pg1.html
它只是在不确定的循环中运行。
我还有一个名为djvu2pdf的辅助程序,我在http://0x2a.at/s/projects/djvu2pdf上找到了这个程序,但是
djvu2pdf Intro.djvu
给我
-e Error: /usr/bin/djvu2pdf: File 'Intro.djvu' not found
OCR文件很好地打开。
发布于 2013-03-27 01:46:02
我修复了文件/home/steven/Documents/djvu2pdf 2pdf/1/Intro.djvo。原来我所有的似曾相识文件都没有扩展名,但是linux无论如何都会打开它们。
用单页文档进行测试
我第一次运行cd /home/steven/Documents/djvu2pdf/1/
然后ran:djvu2hocr -p 1 1.djvu
`DjVu hidden text layer - Page #1 Traceback (most recent call last): File "/usr/bin/djvu2hocr", line 7, in _.main(sys.argv) File "/usr/share/ocrodjvu/lib/cli/djvu2hocr.py", line 323, in main process_page(page_zone, options) File "/usr/share/ocrodjvu/lib/cli/djvu2hocr.py", line 263, in process_page result = process_zone(None, page_text, last=True, options=options) File "/usr/share/ocrodjvu/lib/cli/djvu2hocr.py", line 238, in process_zone parent.append(child) AttributeError: 'NoneType' object has no attribute 'append'` 命令:djvu2hocr -p 1 1.djvu > tmp.html做了同样的事情,Converting '1.djvu': - Page #1 Traceback (most recent call last): File "/usr/bin/djvu2hocr", line 7, in _.main(sys.argv) File "/usr/share/ocrodjvu/lib/cli/djvu2hocr.py", line 323, in main process_page(page_zone, options) File "/usr/share/ocrodjvu/lib/cli/djvu2hocr.py", line 263, in process_page result = process_zone(None, page_text, last=True, options=options) File "/usr/share/ocrodjvu/lib/cli/djvu2hocr.py", line 238, in process_zone parent.append(child) AttributeError: 'NoneType' object has no attribute 'append'
sed 's/ocrx/ocr/g' tmp.html > pg1.html
我有个html & tmp.html这么说
http://pastebin.com/APwUPwk4
因为这个网站不允许我发布那些代码,使用html,代码,预标签,它们都不起作用,更重要的是,我在那篇文章中错过了什么?我是linux终端的新手,只是通过google搜索来学习。
发布于 2013-03-25 10:50:41
首先,尝试使用文件的完整路径运行程序。运行以下命令以确保文件的存在
file /home/steven/Documents/djvu2pdf/1/Intro.djvu然后试着
djvu2hocr -p 1 /home/steven/Documents/djvu2pdf/1/Intro.djvu其次,以下命令本身存在问题:
sed 's/ocrx/ocr/g' > pg1.html这不会“在无限循环中”运行,而只是等待标准输入(在您的情况下是键盘),因为您没有使用参数或管道的一部分运行sed。sed不知道要处理哪个文件。
您所引用的页面明确指定应将其作为管道的一部分运行。或者,您也可以这样做:
djvu2hocr -p 10 /home/steven/Documents/djvu2pdf/1/Intro.djvu > tmp.html
sed 's/ocrx/ocr/g' tmp.html > pg10.htmlhttps://askubuntu.com/questions/272154
复制相似问题