Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions adaptors/library/jobs/generate-pdf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Generate a PDF document from a HTML string

fn(state => {
const { data } = state;

state.pdfHTMLContent = `<html>
<body style="font-family: Arial, sans-serif; font-size: 14px;">
<h1>Sales Report</h1>
<p>Date: ${data.date}</p>
<p>Total Sales: $${data.totalSales}</p>
</body>
</html>`;

return state;
});

generatePDF($.pdfHTMLContent, {
sandbox: true,
});
5 changes: 5 additions & 0 deletions adaptors/library/staticExamples.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
48 changes: 48 additions & 0 deletions adaptors/pdfshift.md
Original file line number Diff line number Diff line change
@@ -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)