最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】pdftohtml生成的html中丢失了表格信息

工作和技术 crifan 3195浏览 0评论

【背景】

折腾:

【未解决】将不可拷贝复制的PDF中的表格数据导出并转换为xml格式数据

期间,虽然可以用pdftohtml通过加-nodrm参数而使得将不可复制的pdf生成html。

但是生成的html中,丢失了原先pdf中有个那些表格的数据,只剩文字内容了。

现在要去想办法,把表格的格式信息也要保留出来。

【折腾过程】

1.看了看原先的help:

crifan@crifan-Ubuntu:~/develop/pdf_to_html$ pdftohtml -h
pdftohtml version 0.20.5
Copyright 2005-2012 The Poppler Developers - http://poppler.freedesktop.org
Copyright 1999-2003 Gueorgui Ovtcharov and Rainer Dorsch
Copyright 1996-2011 Glyph & Cog, LLC

Usage: pdftohtml [options] <PDF-file> [<html-file> <xml-file>]
  -f <int>          : first page to convert
  -l <int>          : last page to convert
  -q                : don't print any messages or errors
  -h                : print usage information
  -help             : print usage information
  -p                : exchange .pdf links by .html
  -c                : generate complex document
  -s                : generate single document that includes all pages
  -i                : ignore images
  -noframes         : generate no frames
  -stdout           : use standard output
  -zoom <fp>        : zoom the pdf document (default 1.5)
  -xml              : output for XML post-processing
  -hidden           : output hidden text
  -nomerge          : do not merge paragraphs
  -enc <string>     : output text encoding name
  -dev <string>     : output device name for Ghostscript (png16m, jpeg etc)
  -fmt <string>     : image file format for Splash output (png or jpg)
  -v                : print copyright and version info
  -opw <string>     : owner password (for encrypted files)
  -upw <string>     : user password (for encrypted files)
  -nodrm            : override document DRM settings
  -wbt <fp>         : word break threshold (default 10 percent)

所以去试试加上-c参数试试效果:

crifan@crifan-Ubuntu:~/develop/pdf_to_html$ mkdir /media/sf_win7_to_ubuntu/pdf_to_html_withTable
crifan@crifan-Ubuntu:~/develop/pdf_to_html$ pdftohtml -nodrm /media/sf_win7_to_ubuntu/spec183r21.0.pdf hart18^Chtml
crifan@crifan-Ubuntu:~/develop/pdf_to_html$ pdftohtml -c -nodrm /media/sf_win7_to_ubuntu/spec183r21.0.pdf /media/sf_win7_to_ubuntu/pdf_to_html_withTable/hart183WithTable.html
Document has copy-protection bit set.
Page-1
Page-2
Page-3
Page-4
Page-5
Page-6
Page-7
Page-8
Page-9
Page-10
Page-11
Page-12
Page-13
Page-14
Page-15
Page-16
Page-17
Page-18
Page-19
Page-20
Page-21
Page-22
Page-23
Page-24
Page-25
Page-26
Page-27
Page-28
Page-29
Page-30
Page-31
Page-32
Page-33
Page-34
Page-35
Page-36
Page-37
Page-38
Page-39
Page-40
 link to page 41 Page-41
Page-42
Page-43
Page-44
Page-45
Page-46
Page-47
Page-48
Page-49
Page-50
Page-51
Page-52
Page-53
Page-54
Page-55
Page-56
Page-57
Page-58
Page-59
Page-60
Page-61
Page-62
Page-63
Page-64
Page-65
Page-66
Page-67
Page-68
Page-69
Page-70
Page-71
Page-72
Page-73
Page-74
Page-75
Page-76
Page-77
Page-78
Page-79
Page-80
Page-81
Page-82
Page-83
Page-84
Page-85
Page-86
Page-87
Page-88
Page-89
Page-90
Page-91
Page-92
Page-93
Page-94
Page-95
Page-96
Page-97
crifan@crifan-Ubuntu:~/develop/pdf_to_html$ 

去看看是否有效:

生成了一堆的文件:

generated bunch of html files

打开后,果然是可以了:

generated html containing table format

即:

用pdftohtml将pdf转换为html,同时保留了原先的表格。

 

【总结】

pdftohtml,真是很好用的说。

转载请注明:在路上 » 【已解决】pdftohtml生成的html中丢失了表格信息

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
80 queries in 0.166 seconds, using 22.14MB memory