File tree Expand file tree Collapse file tree 3 files changed +72
-0
lines changed Expand file tree Collapse file tree 3 files changed +72
-0
lines changed Original file line number Diff line number Diff line change
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
+ } ) ;
Original file line number Diff line number Diff line change 141
141
"adaptor" : " postgresql" ,
142
142
"name" : " Using findValue with an array of data"
143
143
},
144
+ {
145
+ "expressionPath" : " jobs/generate-pdf" ,
146
+ "adaptor" : " pdfshift" ,
147
+ "name" : " Generate a PDF from a HTML string"
148
+ },
144
149
{
145
150
"expressionPath" : " jobs/kobotoolbox-get-suspected-patients" ,
146
151
"adaptor" : " kobotoolbox" ,
Original file line number Diff line number Diff line change
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 )
You can’t perform that action at this time.
0 commit comments