esbenp / pdf-bot

🤖 A Node queue API for generating PDFs using headless Chrome. Comes with a CLI, S3 storage and webhooks for notifying subscribers about generated PDFs
MIT License
2.63k stars 142 forks source link

document specific configuration #25

Open hairylime opened 5 years ago

hairylime commented 5 years ago

I raised an issue to be able to configure multiple webhooks for different types, and this PR addresses that - however I ran into a more pressing related need.

We need different headers for different documents, but after reviewing the chrome print handling and html-chrome-pdf, the only way this seems possible is via the printOptions value in html-chrome-pdf - so I made this change to allow for configuring different headers. I left the existing configuration alone, so the webhook and generator configuration at the top level can be considered the default (if no doctype is specified or no webhook/generator is specified for a doctype.

Finally there didn't seem to be a way to select a s3 configuration, so I mapped this to doctype (otherwise it uses the full set as currently configured).