chromic_pdf
chromic_pdf copied to clipboard
Add info option to print_to_pdf/2
Now that we're calling Ghostscript from print_to_pdf/2
(optionally, for multiple sources), we may as well benefit from it.
- Make the embedding of metadata pieces a separate logic in Ghostscript*
- While you're at it, refactor the
GhostscriptWorker/Interface/Impl
mess
- While you're at it, refactor the
- Move the
info_option
topdf_option
and add it as optional flag toprint_to_pdf/2
- Mention in the docs that this requires ghostscript
- And writing the file to disk (mention this for the "join multiple sources" section as well)
- Split the postscript snippet (
PDFA_def_ext.ps.eex
or so) - Optionally render the postscript
info
snippet in theGhostscriptWorker.join/2
function - Render both snippets in
GhostscriptWorker.convert/2
With the limited knowledge I have about the code base, I tried to come up with a (high level) plan about how to "smoothly" introduce a unified/smart print_to_pdf/3
that allows to print both pdf
or pdfa
files.
Implementation Details
Version ChromicPDF::API
- Add
lib/chromic_pdf/api/v1/
- Add
behaviour.ex
specifying its behaviour - Add
impl.ex
(or a better name if you can think of one) and move the code fromChromicPDF::API
here. - Update
ChromicPDF::API
to delegate function calls toChromicPDF::API::V1::Impl
- Add
Add V2
The goal of the second version is to have a unified/smart print_to_pdf/3
, capable to print both pdf
and pdfa
files based on the given function parameters. This version is also smart enough to know when to use Ghoshscript
.
-
Add
lib/chromic_pdf/api/v2/
-
Add
behaviour.ex
specifying its behaviour -
Add
impl.ex
(or a better name if you can think of one) and move the code fromChromicPDF::API
here.How should a unified
print_to_pdf
looks like?The key is to have a well defined type for the
opts
that can be passed.For example:
- any options related to
pdfa
files could be passed through aarchival
key. - any related to annotating a the file (author, title etc), could be passed through
annotations
key. - and so on ...
The presence of one (or a combination) of the top level key of the
opts
map suffice to determine wether apdf
or apdfa
file should be printed and wethergoshscript
should be used or not. - any options related to
```elixir @type opts :: { archival: map() | true, annotations: { title: atom() ... } } ```
- Update
ChromicPDF::API
to delegate function calls toChromicPDF::API::V2::Impl
.
-