Skip to content

Commit

Permalink
Merge pull request #20 from antoniskalou/master
Browse files Browse the repository at this point in the history
Handle missing page numbers in PDF
  • Loading branch information
dunyakirkali committed Mar 15, 2020
2 parents 0d55f4a + bce7f1c commit a588eff
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/format_parser/document.ex
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@ defmodule FormatParser.Document do
end

defp parse_pdf(<<x :: binary>>) do
page_count = Regex.run(~r/<<\/Linearized.+\/N\s([0-9]+)/, x) |> List.last |> String.to_integer
page_count =
case Regex.run(~r/<<\/Linearized.+\/N\s([0-9]+)/, x) do
nil -> 0
match -> match |> List.last() |> String.to_integer()
end

%Document{format: :pdf, intrinsics: %{page_count: page_count}}
end
end

0 comments on commit a588eff

Please sign in to comment.