diff --git a/adaptors/library/jobs/generate-pdf.js b/adaptors/library/jobs/generate-pdf.js new file mode 100644 index 00000000000..6205e25c938 --- /dev/null +++ b/adaptors/library/jobs/generate-pdf.js @@ -0,0 +1,26 @@ +// Generate a PDF document from a HTML string + +fn(state => { + const { data } = state; + + state.pdfHTMLContent = ` + +

Sales Report

+

Date: ${data.date}

+

Total Sales: $${data.totalSales}

+ + `; + + return state; +}); + +generatePDF($.pdfHTMLContent, { + sandbox: true, + filename: 'trials.pdf', +}); + +fn(state => { + const { data } = state; + console.log(`Download PDF in 48 hours from ${data.url}`); + return { ...state, pdfData: data }; +}); diff --git a/adaptors/library/staticExamples.json b/adaptors/library/staticExamples.json index 755faaf8c8c..81447aed609 100644 --- a/adaptors/library/staticExamples.json +++ b/adaptors/library/staticExamples.json @@ -141,6 +141,11 @@ "adaptor": "postgresql", "name": "Using findValue with an array of data" }, + { + "expressionPath": "jobs/generate-pdf", + "adaptor": "pdfshift", + "name": "Generate a PDF from a HTML string" + }, { "expressionPath": "jobs/kobotoolbox-get-suspected-patients", "adaptor": "kobotoolbox", diff --git a/adaptors/pdfshift.md b/adaptors/pdfshift.md new file mode 100644 index 00000000000..601c383de99 --- /dev/null +++ b/adaptors/pdfshift.md @@ -0,0 +1,41 @@ +--- +title: PDFShift Adaptor +--- + +## About PDFShift + +[PDFShift](https://pdfshift.io/) is a solution designed to automate document +conversion tasks. + +## Integration Options + +PDFShift has a REST API that enables external services like OpenFn to pull data +from PDFShift, or push data from external apps to PDFShift. This option is +suited for scheduled, bulk syncs or workflows that must update data in PDFShift +with external information. See [functions](/adaptors/packages/pdfshift-docs) for +more on how to use this adaptor to work with the API. + +## Authentication + +See [PDFShift docs](https://docs.pdfshift.io/#authentication) for the latest on +supported authentication methods. When integrating with PDFShift via OpenFn, +only one primary authentication method is supported. + +Api Key (requires api key created after authenticating in PDFShift). See this +adaptor's [Configuration docs](/adaptors/packages/pdfshift-configuration-schema) +for the required authentication parameters. + +See platform docs on +[managing credentials](/documentation/manage-projects/manage-credentials) for +how to configure a credential in OpenFn. If working locally or if using a Raw +JSON credential type, then your configuration will look something like this: + +```json +{ + "apiKey": "sk_563874gfvftdv2t28462763fy23d28" +} +``` + +### Helpful Links + +1. [PDFShift Documentation](https://docs.pdfshift.io/#introduction)