From b334bf712b0c7e4f762238635f9360ee6f8508d6 Mon Sep 17 00:00:00 2001 From: Hunter Achieng Date: Thu, 14 Aug 2025 20:44:30 +0300 Subject: [PATCH 1/5] fix: add pdf generator documentation Signed-off-by: Hunter Achieng --- adaptors/library/jobs/generate-pdf.js | 19 +++++++++++ adaptors/library/staticExamples.json | 5 +++ adaptors/pdfshift.md | 48 +++++++++++++++++++++++++++ 3 files changed, 72 insertions(+) create mode 100644 adaptors/library/jobs/generate-pdf.js create mode 100644 adaptors/pdfshift.md diff --git a/adaptors/library/jobs/generate-pdf.js b/adaptors/library/jobs/generate-pdf.js new file mode 100644 index 00000000000..28e289b5f4b --- /dev/null +++ b/adaptors/library/jobs/generate-pdf.js @@ -0,0 +1,19 @@ +// 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, +}); 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..055e24320f3 --- /dev/null +++ b/adaptors/pdfshift.md @@ -0,0 +1,48 @@ +--- +title: PDFShift Adaptor +--- + +## About PDFShift + +[PDFShift](https://pdfshift.io/) +is a solution designed to automate document conversion tasks. + +## Integration Options + +PDFShift supports 2 primary integration options with OpenFn: + +1. **Rest API:** 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. + +2. **Webhook:** Webhook or Data Forwarding to push data from PDFShift to + external systems (see + [docs](https://docs.pdfshift.io/#webhooks)). + This option is suited for real-time, event-based data integration. + +## 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. + +1. 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": "your-api-key", // e.g 12345678 +} +``` + +### Helpful Links + +1. [PDFShift Documentation](https://docs.pdfshift.io/#introduction) From aaadb3f4da56f4c4d1510a58967ef65d10b5dcd7 Mon Sep 17 00:00:00 2001 From: Hunter Achieng Date: Fri, 15 Aug 2025 16:31:23 +0300 Subject: [PATCH 2/5] fix: update docs and examples for pdfShift Signed-off-by: Hunter Achieng --- adaptors/library/jobs/generate-pdf.js | 4 ++++ adaptors/pdfshift.md | 9 +-------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/adaptors/library/jobs/generate-pdf.js b/adaptors/library/jobs/generate-pdf.js index 28e289b5f4b..104f07ab466 100644 --- a/adaptors/library/jobs/generate-pdf.js +++ b/adaptors/library/jobs/generate-pdf.js @@ -16,4 +16,8 @@ fn(state => { generatePDF($.pdfHTMLContent, { sandbox: true, + filename:'trials.pdf', // Returns a JSON response containing an url parameter to PDFShift's Amazon S3 bucket. + // The URL expires after 48 hours }); + + diff --git a/adaptors/pdfshift.md b/adaptors/pdfshift.md index 055e24320f3..5c060c48165 100644 --- a/adaptors/pdfshift.md +++ b/adaptors/pdfshift.md @@ -9,8 +9,6 @@ is a solution designed to automate document conversion tasks. ## Integration Options -PDFShift supports 2 primary integration options with OpenFn: - 1. **Rest API:** 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 @@ -18,11 +16,6 @@ PDFShift supports 2 primary integration options with OpenFn: [functions](/adaptors/packages/pdfshift-docs) for more on how to use this adaptor to work with the API. -2. **Webhook:** Webhook or Data Forwarding to push data from PDFShift to - external systems (see - [docs](https://docs.pdfshift.io/#webhooks)). - This option is suited for real-time, event-based data integration. - ## Authentication See [PDFShift docs](https://docs.pdfshift.io/#authentication) for the latest on @@ -39,7 +32,7 @@ JSON credential type, then your configuration will look something like this: ```json { - "apiKey": "your-api-key", // e.g 12345678 + "apiKey": "sk_563874gfvftdv2t28462763fy23d28", } ``` From e594c20f1bb3f3c1ff932d2994db3f57a842b1f0 Mon Sep 17 00:00:00 2001 From: Hunter Achieng Date: Fri, 15 Aug 2025 16:47:35 +0300 Subject: [PATCH 3/5] add pdf example Signed-off-by: Hunter Achieng --- adaptors/library/jobs/generate-pdf.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/adaptors/library/jobs/generate-pdf.js b/adaptors/library/jobs/generate-pdf.js index 104f07ab466..8692828ebba 100644 --- a/adaptors/library/jobs/generate-pdf.js +++ b/adaptors/library/jobs/generate-pdf.js @@ -16,8 +16,24 @@ fn(state => { generatePDF($.pdfHTMLContent, { sandbox: true, - filename:'trials.pdf', // Returns a JSON response containing an url parameter to PDFShift's Amazon S3 bucket. + filename: 'trials.pdf', // Returns a JSON response containing an url parameter to PDFShift's Amazon S3 bucket. // The URL expires after 48 hours }); +// Post generated PDF link to WhatsApp +fn(state => { + const { data } = state; + const pdfData = JSON.parse(data); + return { ...state, pdfData }; +}); +request('POST', 'messages', state => ({ + to: '254712345678', + body: `Please check on the PDF and download in 24hours. ${state.pdfData.url}`, + type: 'template', + template: { + name: 'hello_world', + language: { code: 'en_US' }, + }, + messaging_product: 'whatsapp', +})); From dc775a560d5d3f9c15ad52e68dababe3056e03f9 Mon Sep 17 00:00:00 2001 From: Hunter Achieng Date: Tue, 19 Aug 2025 11:07:45 +0300 Subject: [PATCH 4/5] fix pdf examples and docs Signed-off-by: Hunter Achieng --- adaptors/library/jobs/generate-pdf.js | 13 +------------ adaptors/pdfshift.md | 23 ++++++++++++----------- 2 files changed, 13 insertions(+), 23 deletions(-) diff --git a/adaptors/library/jobs/generate-pdf.js b/adaptors/library/jobs/generate-pdf.js index 8692828ebba..bb10c0b01b0 100644 --- a/adaptors/library/jobs/generate-pdf.js +++ b/adaptors/library/jobs/generate-pdf.js @@ -20,20 +20,9 @@ generatePDF($.pdfHTMLContent, { // The URL expires after 48 hours }); -// Post generated PDF link to WhatsApp fn(state => { const { data } = state; const pdfData = JSON.parse(data); + console.log(`Download PDF in 48 hours from ${pdfData.url}`); return { ...state, pdfData }; }); - -request('POST', 'messages', state => ({ - to: '254712345678', - body: `Please check on the PDF and download in 24hours. ${state.pdfData.url}`, - type: 'template', - template: { - name: 'hello_world', - language: { code: 'en_US' }, - }, - messaging_product: 'whatsapp', -})); diff --git a/adaptors/pdfshift.md b/adaptors/pdfshift.md index 5c060c48165..33fa18c7c93 100644 --- a/adaptors/pdfshift.md +++ b/adaptors/pdfshift.md @@ -4,17 +4,16 @@ title: PDFShift Adaptor ## About PDFShift -[PDFShift](https://pdfshift.io/) -is a solution designed to automate document conversion tasks. +[PDFShift](https://pdfshift.io/) is a solution designed to automate document +conversion tasks. ## Integration Options -1. **Rest API:** 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. +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 @@ -22,8 +21,10 @@ 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. -1. 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. +1. 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 @@ -32,7 +33,7 @@ JSON credential type, then your configuration will look something like this: ```json { - "apiKey": "sk_563874gfvftdv2t28462763fy23d28", + "apiKey": "sk_563874gfvftdv2t28462763fy23d28" } ``` From 0bca9b1c4b63a9afa3cfb5822ee5f78a464d2a14 Mon Sep 17 00:00:00 2001 From: Hunter Achieng Date: Mon, 25 Aug 2025 11:18:40 +0300 Subject: [PATCH 5/5] fix: update pdf docs docs Signed-off-by: Hunter Achieng --- adaptors/library/jobs/generate-pdf.js | 8 +++----- adaptors/pdfshift.md | 7 +++---- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/adaptors/library/jobs/generate-pdf.js b/adaptors/library/jobs/generate-pdf.js index bb10c0b01b0..6205e25c938 100644 --- a/adaptors/library/jobs/generate-pdf.js +++ b/adaptors/library/jobs/generate-pdf.js @@ -16,13 +16,11 @@ fn(state => { generatePDF($.pdfHTMLContent, { sandbox: true, - filename: 'trials.pdf', // Returns a JSON response containing an url parameter to PDFShift's Amazon S3 bucket. - // The URL expires after 48 hours + filename: 'trials.pdf', }); fn(state => { const { data } = state; - const pdfData = JSON.parse(data); - console.log(`Download PDF in 48 hours from ${pdfData.url}`); - return { ...state, pdfData }; + console.log(`Download PDF in 48 hours from ${data.url}`); + return { ...state, pdfData: data }; }); diff --git a/adaptors/pdfshift.md b/adaptors/pdfshift.md index 33fa18c7c93..601c383de99 100644 --- a/adaptors/pdfshift.md +++ b/adaptors/pdfshift.md @@ -21,10 +21,9 @@ 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. -1. 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. +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