Skip to content

Commit 6830ca1

Browse files
pdfshift adaptor documentation (#698)
* fix: add pdf generator documentation Signed-off-by: Hunter Achieng <[email protected]> * fix: update docs and examples for pdfShift Signed-off-by: Hunter Achieng <[email protected]> * add pdf example Signed-off-by: Hunter Achieng <[email protected]> * fix pdf examples and docs Signed-off-by: Hunter Achieng <[email protected]> * fix: update pdf docs docs Signed-off-by: Hunter Achieng <[email protected]> --------- Signed-off-by: Hunter Achieng <[email protected]>
1 parent 6789d91 commit 6830ca1

File tree

3 files changed

+72
-0
lines changed

3 files changed

+72
-0
lines changed

adaptors/library/jobs/generate-pdf.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Generate a PDF document from a HTML string
2+
3+
fn(state => {
4+
const { data } = state;
5+
6+
state.pdfHTMLContent = `<html>
7+
<body style="font-family: Arial, sans-serif; font-size: 14px;">
8+
<h1>Sales Report</h1>
9+
<p>Date: ${data.date}</p>
10+
<p>Total Sales: $${data.totalSales}</p>
11+
</body>
12+
</html>`;
13+
14+
return state;
15+
});
16+
17+
generatePDF($.pdfHTMLContent, {
18+
sandbox: true,
19+
filename: 'trials.pdf',
20+
});
21+
22+
fn(state => {
23+
const { data } = state;
24+
console.log(`Download PDF in 48 hours from ${data.url}`);
25+
return { ...state, pdfData: data };
26+
});

adaptors/library/staticExamples.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,11 @@
141141
"adaptor": "postgresql",
142142
"name": "Using findValue with an array of data"
143143
},
144+
{
145+
"expressionPath": "jobs/generate-pdf",
146+
"adaptor": "pdfshift",
147+
"name": "Generate a PDF from a HTML string"
148+
},
144149
{
145150
"expressionPath": "jobs/kobotoolbox-get-suspected-patients",
146151
"adaptor": "kobotoolbox",

adaptors/pdfshift.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
title: PDFShift Adaptor
3+
---
4+
5+
## About PDFShift
6+
7+
[PDFShift](https://pdfshift.io/) is a solution designed to automate document
8+
conversion tasks.
9+
10+
## Integration Options
11+
12+
PDFShift has a REST API that enables external services like OpenFn to pull data
13+
from PDFShift, or push data from external apps to PDFShift. This option is
14+
suited for scheduled, bulk syncs or workflows that must update data in PDFShift
15+
with external information. See [functions](/adaptors/packages/pdfshift-docs) for
16+
more on how to use this adaptor to work with the API.
17+
18+
## Authentication
19+
20+
See [PDFShift docs](https://docs.pdfshift.io/#authentication) for the latest on
21+
supported authentication methods. When integrating with PDFShift via OpenFn,
22+
only one primary authentication method is supported.
23+
24+
Api Key (requires api key created after authenticating in PDFShift). See this
25+
adaptor's [Configuration docs](/adaptors/packages/pdfshift-configuration-schema)
26+
for the required authentication parameters.
27+
28+
See platform docs on
29+
[managing credentials](/documentation/manage-projects/manage-credentials) for
30+
how to configure a credential in OpenFn. If working locally or if using a Raw
31+
JSON credential type, then your configuration will look something like this:
32+
33+
```json
34+
{
35+
"apiKey": "sk_563874gfvftdv2t28462763fy23d28"
36+
}
37+
```
38+
39+
### Helpful Links
40+
41+
1. [PDFShift Documentation](https://docs.pdfshift.io/#introduction)

0 commit comments

Comments
 (0)