Skip to content

Commit

Permalink
Skip properties that are not readable; Added unit test (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
gwierzchowski authored and sambitdash committed Nov 11, 2018
1 parent c0c6a65 commit 17e8900
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/PDDoc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,13 @@ function pdDocGetInfo(doc::PDDoc)
dInfo = Dict{CDTextString, Union{CDTextString, CDDate, CosObject}}()
for (key, val) in get(obj)
skey = CDTextString(key)
dInfo[skey] = (skey == "CreationDate") ||
(skey == "ModDate") ? CDDate(val) :
(skey == "Trapped") ? val : CDTextString(val)
try
dInfo[skey] = (skey == "CreationDate") ||
(skey == "ModDate") ? CDDate(val) :
(skey == "Trapped") ? val : CDTextString(val)
catch
# no op: we skipp the key that cannot be properly decoded
end
end
return dInfo
end
Expand Down
Binary file added test/files/empty_property.pdf
Binary file not shown.
20 changes: 20 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,26 @@ include("debugIO.jl")
end
end

@testset "Document with empty property" begin
@test begin
filename="files/empty_property.pdf"
DEBUG && println(filename)
doc = pdDocOpen(filename)
DEBUG && println(pdDocGetCatalog(doc))
cosDoc = pdDocGetCosDoc(doc)
DEBUG && map(println, cosDoc.trailer)
info = pdDocGetInfo(doc)
@assert info == Dict(
"Producer" => "Scribus PDF Library 1.3.3.13",
"CreationDate" => CDDate("D:20090807192622"),
"ModDate" => CDDate("D:20090807192622"),
"Creator" => "Scribus 1.3.3.13",
"Trapped" => cn"False")
pdDocClose(doc)
length(utilPrintOpenFiles()) == 0
end
end

@testset "PDF File with ObjectStreams" begin
@test begin
filename="files/pdf-17.pdf"
Expand Down

0 comments on commit 17e8900

Please sign in to comment.