Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
26 changes: 26 additions & 0 deletions adaptors/library/jobs/generate-pdf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// 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,
filename: 'trials.pdf',
});

fn(state => {
const { data } = state;
console.log(`Download PDF in 48 hours from ${data.url}`);
return { ...state, pdfData: data };
});
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
41 changes: 41 additions & 0 deletions adaptors/pdfshift.md
Original file line number Diff line number Diff line change
@@ -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)