1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Julia: PDF を読む

Last updated at Posted at 2022-01-29

こちらのサンプルをプログラムとして実行してみました。
sambitdash/PDFIO.jl

pdf_to_text.jl
# ! /usr/bin/julia
#
#	pdf_to_text.jl
#
#						Jan/30/2022
# --------------------------------------------------------------------
using PDFIO
# --------------------------------------------------------------------
function getPDFText(src, out)
	doc = pdDocOpen(src)
	docinfo = pdDocGetInfo(doc) 
#
	open(out, "w") do io
		npage = pdDocGetPageCount(doc)
#
		for it=1:npage
			page = pdDocGetPage(doc, it)
			pdPageExtractText(io, page)
		end
	end
#
	pdDocClose(doc)
	return docinfo
end

# --------------------------------------------------------------------
println(stderr,"*** 開始 ***")
#
src = ARGS[1]
out = ARGS[2]
println(src) 
println(out) 
#
getPDFText(src, out)
#
println(stderr,"*** 終了 ***")
# --------------------------------------------------------------------

実行結果

$ ./pdf_to_text.jl cities.pdf out01.txt
*** 開始 ***
cities.pdf
out01.txt
*** 終了 ***

入力データ
cities_jan30.png

出力結果

$ head out01.txt 
     t2381              名古屋             72534             2002-5-14

     t2382              豊橋               63473             2002-8-12

     t2383              岡崎               57982             2002-9-01

     t2384              一宮               46329             2002-10-29

     t2385              蒲郡               31765             2002-7-14

パッケージのインストール方法

julia> using Pkg
julia> Pkg.add("PDFIO")
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?