Skip to content

Commit

Permalink
Enable configurable PDF version
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewtimberlake committed Oct 5, 2024
1 parent 97f0816 commit 19de6f3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@ def deps do
end
```

## PDF Version

By default, the PDF version is set to `1.7`.

If needed, the PDF version can be set by using the `:version` compile-time option.

**NOTE:** All functionality in this library is developed against the 1.7 specification, it is up to you to ensure that you use only the functionality that is available in the version you choose.

```elixir
config :pdf, :version, "1.7"
```

## Copyright and License

Copyright (c) 2016 Andrew Timberlake
Expand Down
5 changes: 4 additions & 1 deletion lib/pdf/document.ex
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ defmodule Pdf.Document do
Text
}

@header <<"%PDF-1.7\n%", 304, 345, 362, 345, 353, 247, 363, 240, 320, 304, 306, 10>>
@version Application.compile_env(:pdf, :version, "1.7")
# 7.5.2 the header line shall be immediately followed by a comment line containing
# at least four binary characters-that is, characters whose codes are 128 or greater.
@header <<"%PDF-#{@version}\n%", 0xE2, 0xE3, 0xCF, 0xD3, "\r\n">>
@header_size byte_size(@header)

def new(opts \\ []) do
Expand Down

0 comments on commit 19de6f3

Please sign in to comment.