- Some of the types have been renamed, e.g.
ChromicPDF.export_option
toshared_option
.
- Small fix
:chrome_version
config switch allowing to passChrome x.y.z.zz
instead of justx.y.z.zz
- Support custom protocols through
:protocol
option onprint_to_pdf/2
andcapture_screenshot
, as well as newChromicPDF.run_protocol/2
function. These features are considered internal API.
- Extend
chrome_args
to allow removal of conflicting default args. Allows for use cases which were previously blocked by defaults such as rendering WebGL images. See #314 (@walter)
- Removed the
-dCompatibilityLevel=1.4
default switch from the ghostscript processor. Ghostscript has defaulted to to 1.7 for a long time now and we have been keeping this flag since GS 9.xx which likely not many people are using anymore. If anyone needs it, a new:compatibility_level
option can used to set it back to 1.4.
- Expand
phoenix_html
dependency to include version 4 (@idabmat)
- Explicitly pick keys in
ChromicPDF.Template
to fix Dialyzer "no local return" errors in clients.
- Recover missing custom footer templates by making sure we do not add any
@page
CSS rule to the header or footer templates inChromicPDF.Template.source_and_options/1
. (#290) - Drop the default
zoom: 0.75
rule from header and footer templates for Chrome >= v120. They removed the default scale-up by 4/3, see chromium bug #1509917.
Note that for remote chrome users this means they will have to explicitly specify the chrome version in the application config.
config :chromic_pdf, chrome_version: "Google Chrome 120.0.6099.71"
- Add
ChromicPDF.Plug
to forward Chrome requests on an internal endpoint to a template. - Add
Template.options/1
that returns the options for page dimensions, header, and footer, but does not require the content.
- Drop
-dNEWPDF=false
switch from Ghostscript >= 10.2. The old PDF interpreter has been removed and using the switch results in a warning now. - Split
Chromic.Template.styles/1
intopage_styles/1
andheader_footer_styles/1
, and trim the stylesheets. - Cookies set via
:set_cookie
are nowhttpOnly: true
by default.
- Dropped the outdated Phoenix example in
examples/
. - Deprecated
ChromicPDF.styles/1
.
- Configurable pool checkout timeout via new global option
:checkout_timeout
.
- Add support for named session pools. These can be used to give persistent session options (
offline
,disable_scripts
, ...) different values, for example to have one template that is not allowed to execute JavaScript and while others can use JavaScript.
- Deprecate
:max_session_uses
option in favor ofsession_pool: [max_uses: ...]
. - Drop
--no-zygote
command line switch when usingno_sandbox: true
option. The switch causes session crashes in recent Chrome versions and was never needed for--no-sandbox
in the first place. See #270.
no_sandbox: true
, dropping --no-zygote
means Chrome will spawn an additional OS process (the "zygote" process), which could be considered a break of backwards compatibility. Please monitor your next deployment. However, we believe this change is safe, meaning except for the additional process, it will not be noticable. Hence we concluded to drop the switch without a major version bump, in order not to disturb too many people. If you are not using :no_sandbox
, this does not affect you.
- Add
:console_api_calls
option to configure handling ofconsole.foo
calls in JS runtime (ignore, log, raise). - Document fixes for font rendering issues, and give
ChromicPDF.Template
atext_rendering
option to allow applyingtext-rendering: geometricPrecision;
on all elements.
- Add experimental support for connecting to running chrome instances via inet-based debugging (usually on port 9222). Controlled by option
:chrome_address
. Requires optionalwebsockex
dependency.
- Add
--hide-scrollbars
to default command line options, to hide scrollbars on screenshots.
- Add
:full_page
option toChromicPDF.capture_screenshot/2
to increase the viewport size to match the content.
- Handle
ChromicPDF.Template.source_and_options/1
tuples inChromicPDF.capture_screenshot/2
.
- Error handling for call responses in protocol steps, e.g. invalid options for printToPDF. (@tonnenpinguin)
- Allow
nimble_pool
1.0.
- Add
unhandled_runtime_exceptions
option that allows to raise on unhandled JavaScript exceptions in templates. Default to warn about them in log.
- Simplified
on_demand
mode. Instead of spawning the entire supervision tree temporarily, we now only spawn theBrowser
process. Also instead of giving the normalChromicPDF
name to the temporary supervisor, which effectively prevented concurrent access to ChromicPDF when configured withon_demand: true
, the temporaryBrowser
process remains anonymous.
- Add
ChromicPDF.put_dynamic_name/1
andname
option toChromicPDF.Supervisor.start_link/2
for dynamic process names. (@dvic)
- Handle
DOWN
reason inSessionPool.terminate_worker/3
callback. Fixes #219.
- Filename quoting (like
-sOutputFile="/some/path"
) doesn't work anymore in GS 9.56+. Dropped as we didn't need it anyway. GS 9.56 and 10.0 are supported now.
- Add
permit_read
option toconvert_to_pdfa/2
andprint_to_pdfa/2
to allow adding user-provided--permit-file-read
options.
- Removed unnecessary Ghostscript step to embed fonts. Instead, the relevant arguments are now part of our default set of
pdfwrite
arguments, and hence are also applied to the PDF concatenation added in 1.5.0. - Made PDF concatenation take into account
SAFER
mode.
- Add automatic PDF concatenation when passing a list to
print_to_pdf/2
orprint_to_pdfa/2
. (@xaviRodri) - Add
warm_up/1
to allow one-off launches of the Chrome executable with our default arguments, to mitigate random CI failures on Github Actions.
- Add error details on failure to checkout worker from pool.
- Add a whole list of new default command line options following Puppeteer's example.
wait_for
andevaluate
options can now be combined, as thewait_for
script is appended to the user-givenevaluate
expression.
- Make sure to close a browser target when the worker in the pool is terminated. Previously, when a worker was terminated due to an exception (e.g. the timeout error), the target wasn't cleaned up, potentially leading to memory exhaustion.
- Actually inspect the current state of the protocol in the timeout exception, instead of the (pretty useless) initial parameter.
- Make sure the
inspectorCrashed
warning is only printed once.
- Included the inspected
ChromicPDF.Protocol
in the timeout exception to improve debugging. - Bump jason to 1.3
- Bump telemetry to 1.1
- Updated dev dependencies
- Add
disable_scripts
global option. (@MaeIsBad) - Add error details about potential shared memory exhaustion. (@WilliamVenner)
- Use old pdf interpreter with ghostscript > 9.56 to avoid segfaults (see #158)
- Incompatibility with ghostscript 9.56.1 (fixes #153)
- Added search paths for chrome executable (fixes #151)
- Improved docs on header/footer templates saying that external URLs don't work.
- Added a logger call when we receive the
Inspector.targetCrashed
message, so users can tell that their Chrome target has died for some reason. - Add more paper sizes to
ChromicPDF.Template
. (@williamthome) - Add
:landscape
option toChromicPDF.Template
. (@williamthome) - Add
:init_timeout
option toChromicPDF.Browser.SessionPool
. (@dvic)
- Documentation updates (@kianmeng)
- Relaxed telemetry dependency to avoid blocking dependency update (@leandrocp)
- Add chromium path on macOS when installed via homebrew (@shamanime)
- Improved error message when Chrome dies at startup.
- Improved docs on the
no_sandbox
option.
- Added
chrome_executable
option to allow specifying path to chrome executable.
- Added
evaluate
option to run client-side scripts before printing. - Added a few options (
evaluate
,set_cookie
,wait_for
) tocapture_screenshot/2
.
- Reimplemented
wait_for
option based on a JS script and theevaluate
option to overcome race condition issues of original solution. Behaviour remains the same.
- Enforced telemetry version 0.4.2 (fixes #108)
- To determine the session pool / ghostscript pool size, if not specified in the options, we now fetch the number of schedulers at runtime, not compile time. Makes more sense. We also set a minimum of 1 in case there is only 1 scheduler online.
- Added option
wait_for
to wait for DOM element attribute to be set dynamically. (@jarimatti) - New global
timeout
option for session pool allows to configure timeout of print processes. - New global
ignore_certificate_errors
option allows to bypass SSL certificate verification. - New global
chrome_args
option allows to pass custom flags to chrome command.
- When sending HTML to Chrome with
{:html, <content>}
, wait for thePage.loadEventFired
notification to allow external resources (images, scripts, ...) to be fetched. (#80)
- Reverted to file descriptor redirection to mitigate weird Port behaviour (#76).
- Elixir version housekeeping. Fixed a warning on Elixir 1.11 by adding
:eex
to:extra_applications
. ChromicPDF now requires Elixir >= 1.10 for its use ofApplication.compile_env/3
. - Dropped
poolboy
in favour ofnimble_pool
. This renders themax_overflow
poolboy option without effect. - Made "online mode" the default. Chrome will resolve all URL references unless the global
option
offline: false
is set.
- Added telemetry events for the PDF generation & PDF/A conversion.
- "On Demand" mode allows to start & stop Chrome as needed, much like puppeteer does. This helps in development to prevent leaving behind zombie processes when the BEAM is aborted with Ctrl+C.
- New global option
discard_stderr
allows to enable Chrome's stderr logging which is by default piped to/dev/null
.
- Graceful shutdown is now actually graceful in that it waits for Chrome to clean up the debugging sessions and close the pipe on its end.
- Moved static files required for PDF/A generation to /priv so they are embedded into releases.
- Moved logo files out of /priv so they are not included in releases.
- Fixed typespecs for
Template.source_and_options/1
.[content_option]
weren't allowed as call tostyles/1
narrowed type to[style_option]
. - Added missing keys to
style_option
.
- Removed the
:width
and:height
options fromTemplate.styles/1
andTemplate.source_and_options/1
as it turns out that Chrome does not pay attention to@page
dimensions and instead still sets the size of the produced PDF to US letter. Since it does not seem possible to the PDF size in Chrome headless besides using thepaperWidth
andpaperHeight
options, moved to a:size
option instead that accepts names like:a4
,:us_letter
, and tuples of{<width>, <height>}
in inches. These are then passed topaperWidth
andpaperHeight
. - Ditched the
preferCssPageSize
option fromTemplate.source_and_options/1
as it did not seem to have any effect. See above.
- Added
zoom: 0.75
to both#header
and#footer
in the template as this seems to be exactly what is needed to reverse the viewport scaling that Chrome uses on them by default. With this, headers & footers and the content can use the same CSS styles. - Included
-webkit-print-color-adjust: exact
rule to template sobackground-color
rules are enabled by default.
- Make
print_to_pdfa/2
actually acceptsource_and_options()
map fromTemplate
.
- Allow
{:url, <path>}
input tuples where path is only a path, and not afile://
URL.
- When passing a function to the
:output
parameter, the function result will now be returned as part of theprint_to_pdf
& friends result as{:ok, <callback_result>}
instead of:ok
.
- Handle
{:safe, iolist()}
tuples in API and Template (for content coming from Phoenix.View). ExposeTemplate.html_concat
as potentially useful helper. - Reset navigation history after each print job to avoid leaking information.
- Create new empty browser context for each target (similar to incognito tab).
- Restart browser target after a maximum number of PDFs have been printed to avoid memory bloat.
- Set user agent to custom string.
- Default number of sessions in pool to half the number of available cores.
- HTML source and header and footer template accept iolists now
- New
Template
module contains basic CSS skeleton to easily dimension & layout pages (header & footer margins)
- Add
set_cookie
option toprint_to_pdf/2
. - Targets now navigate to
about:blank
after PDF prints. - Fixed the temporary file yielding way of calling
print_to_pdf/2
.
- First release to hex.pm