-
Notifications
You must be signed in to change notification settings - Fork 16
pdfshift adaptor documentation #698
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// 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', // Returns a JSON response containing an url parameter to PDFShift's Amazon S3 bucket. | ||
// The URL expires after 48 hours | ||
}); | ||
|
||
fn(state => { | ||
const { data } = state; | ||
const pdfData = JSON.parse(data); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hey this is weird - why are we JSON parsing this? I think we need to update Also, I think we need to better document what There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It returns a PDF buffer or a base64. But if you want a url that is hosted on
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, but my surprise and confusion here is a problem. Where is this stuff documented? How is the user supposed to know? |
||
console.log(`Download PDF in 48 hours from ${pdfData.url}`); | ||
return { ...state, pdfData }; | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--- | ||
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. | ||
|
||
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": "sk_563874gfvftdv2t28462763fy23d28" | ||
} | ||
``` | ||
|
||
### Helpful Links | ||
|
||
1. [PDFShift Documentation](https://docs.pdfshift.io/#introduction) |
Uh oh!
There was an error while loading. Please reload this page.