Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add info option to print_to_pdf/2 #200

Open
maltoe opened this issue Dec 22, 2022 · 2 comments
Open

Add info option to print_to_pdf/2 #200

maltoe opened this issue Dec 22, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@maltoe
Copy link
Collaborator

maltoe commented Dec 22, 2022

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
  • Move the info_option to pdf_option and add it as optional flag to print_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)
@maltoe maltoe added the enhancement New feature or request label Dec 22, 2022
@maltoe
Copy link
Collaborator Author

maltoe commented Jan 11, 2023

  1. Split the postscript snippet (PDFA_def_ext.ps.eex or so)
  2. Optionally render the postscript info snippet in the GhostscriptWorker.join/2 function
  3. Render both snippets in GhostscriptWorker.convert/2

@ammancilla
Copy link

ammancilla commented Jan 11, 2023

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/
    1. Add behaviour.ex specifying its behaviour
    2. Add impl.ex (or a better name if you can think of one) and move the code from ChromicPDF::API here.
    3. Update ChromicPDF::API to delegate function calls to ChromicPDF::API::V1::Impl

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/

    1. Add behaviour.ex specifying its behaviour

    2. Add impl.ex (or a better name if you can think of one) and move the code from ChromicPDF::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 a archival 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 a pdf or
      a pdfa file should be printed and wether goshscript should be used or not.

    ```elixir
    @type opts :: {
         archival: map() | true,
         annotations: { title: atom() ... }
    }
    ```
    
    1. Update ChromicPDF::API to delegate function calls to ChromicPDF::API::V2::Impl.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants