sambitdash / PDFIO.jl

PDF Reader Library for Native Julia.
Other
127 stars 13 forks source link

pdPageExtractText() crash on file created using LaTex #44

Closed gwierzchowski closed 5 years ago

gwierzchowski commented 5 years ago

pdPageExtractText() raise following error when used on file created by Latex:

"/home/grzegorz-neo/Dokumenty/Projekty/MatFiz/pdfio-test/outline.pdf"
(v1.0) julia> doc = pdDocOpen(filename);
(v1.0) julia> item_pg = pdDocGetPage(doc, 3);
(v1.0) julia> buf = IOBuffer();
(v1.0) julia> pdPageExtractText(buf, item_pg)
ERROR: InexactError: Int64(Int64, 312.5)
Stacktrace:
 [1] Type at ./float.jl:700 [inlined]
 [2] convert at ./number.jl:7 [inlined]
 [3] setindex!(::Array{Int64,1}, ::Float32, ::Int64) at ./array.jl:769
 [4] get_font_widths(::PDFIO.Cos.CosDocImpl, ::PDFIO.Cos.CosIndirectObject{CosDict}) at /home/grzegorz-ubu/Dokumenty/Projekty/Julia/PDFIO.jl/src/PDFontMetrics.jl:164
....

Change: d[i+1] = widths[ix] into d[i+1] = round(Int,widths[ix]) in PDFontMetrics.jl fix this issue. Fix is included into PR with implementation for Outlines.

sambitdash commented 5 years ago

Pls. check-in fix for this separately from pdDocGetOutline(). It's best each individual check-in kept granular.