Skip to content

Commit

Permalink
v0.5.6:
Browse files Browse the repository at this point in the history
- **BUGFIX:** fix A4 and A5 paper sizes in inches for **chrome-headless**:
  it's not 8.5 x 11.0 (US letter) but 8.26772 x 11.695 (DIN A4), the former
  being chrome-headless defaults. This is important if you want to create
  proper A4 pages
- Users printing **US letter** sized PDFs, please use `page_size: :letter`
  • Loading branch information
gutschilla committed Jun 18, 2019
1 parent 0ef5009 commit e5f4f7a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 deletions.
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changes

- 0.5.6
- **BUGFIX:** fix A4 and A5 paper sizes in inches for **chrome-headless**:
it's not 8.5 x 11.0 (US letter) but 8.26772 x 11.695 (DIN A4), the former
being chrome-headless defaults. This is important if you want to create
proper A4 pages
- Users printing **US letter** sized PDFs, please use `page_size: :letter`
- 0.5.5
- improved documentation on `prefer_system_executable: true` for chrome.
Thanks to [Martin Richer](https://github.com/richeterre) for rasining this
Expand Down
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,14 @@ encryption) for use in Elixir projects.
{:ok, pdf} = PdfGenerator.generate_binary("<html><body><h1>Yay!</h1></body></html>")
```

# Latest release v0.5.5 on 2019-06-18

# Latest release v0.5.5 and v0.5.6 on 2019-06-18

- 0.5.6
- **BUGFIX:** fix A4 and A5 paper sizes in inches for **chrome-headless**:
it's not 8.5 x 11.0 (US letter) but 8.26772 x 11.695 (DIN A4), the former
being chrome-headless defaults. This is important if you want to create
proper A4 pages
- Users printing **US letter** sized PDFs, please use `page_size: :letter`
- 0.5.5
- improved documentation on `prefer_system_executable: true` for chrome.
Thanks to [Martin Richer](https://github.com/richeterre) for rasining this
Expand Down Expand Up @@ -180,8 +186,7 @@ config :pdf_generator,

- `page_size`:
* defaults to `A4`, see `wkhtmltopdf` for more options
* A4 will be translated to `page-height 11` and `page-width 8.5` when
chrome-headless is used
* `letter` (for US letter) be translated to 8x11.5 inches (currently, only in chrome).

- `open_password`: requires `pdftk`, set password to encrypt PDFs with

Expand Down
13 changes: 7 additions & 6 deletions lib/pdf_generator.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ defmodule PdfGenerator do

require Logger

@vsn "0.5.5"
@vsn "0.5.6"

@moduledoc """
# PdfGenerator
Expand Down Expand Up @@ -89,7 +89,7 @@ defmodule PdfGenerator do
* `:prefer_system_executable` - set to `true` if you installed
chrome-headless-render-pdf globally
* `:no_sandbox` – disable sandbox for chrome, required to run as root (read: _docker_)
* `:page_size` - output page size, defaults to "A4"
* `:page_size` - output page size, defaults to "A4", other options are "letter" (US letter) and "A5"
* `:open_password` - password required to open PDF. Will apply encryption to PDF
* `:edit_password` - password required to edit PDF
* `:shell_params` - list of command-line arguments to wkhtmltopdf or chrome
Expand All @@ -104,7 +104,7 @@ defmodule PdfGenerator do
pdf_path_1 = PdfGenerator.generate "<html><body><h1>Boom</h1></body></html>"
pdf_path_2 = PdfGenerator.generate(
"<html><body><h1>Boom</h1></body></html>",
page_size: "A5",
page_size: "letter",
open_password: "secret",
edit_password: "g3h31m",
shell_params: [ "--outline", "--outline-depth3", "3" ],
Expand Down Expand Up @@ -167,11 +167,12 @@ defmodule PdfGenerator do

@doc ~s"""
Returns `{width, height}` tuple for page sizes either as given or for A4 and
A5. Defaults to A4 sizes.
A5. Defaults to A4 sizes. In inches. Because chrome wants imperial.
"""
def dimensions_for(%{page_width: width, page_height: height}), do: {width, height}
def dimensions_for(%{page_size: "A4"}), do: {"8.50", "11.0"}
def dimensions_for(%{page_size: "A5"}), do: {"4.25", "5.5"}
def dimensions_for(%{page_size: "A4"}), do: {"8.26772", "11.695"}
def dimensions_for(%{page_size: "A5"}), do: {"5.8475", "8.26772"}
def dimensions_for(%{page_size: "letter"}), do: {"8.5", "11"}
def dimensions_for(_map), do: dimensions_for(%{page_size: "A4"})

@spec make_command(generator, opts, content, {html_path, pdf_path}) :: {path, list()}
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ defmodule PdfGenerator.Mixfile do
[
app: :pdf_generator,
name: "PDF Generator",
version: "0.5.5",
version: "0.5.6",
elixir: ">= 1.1.0",
deps: deps(),
description: description(),
Expand Down

0 comments on commit e5f4f7a

Please sign in to comment.