You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+32
Original file line number
Diff line number
Diff line change
@@ -17,6 +17,38 @@ Most commonly, pdfgen-core is used with templates, fonts, additional resources,
17
17
Check GitHub releases to find the latest `release` version
18
18
Check [Github releases](https://github.com/navikt/pdfgen-core/releases) to find the latest `release` version
19
19
20
+
In your own repository create subfolders in `templates` and `data`
21
+
```bash
22
+
mkdir {templates,data}/directory_name # directory_name can be anything, but it'll be a necessary part of the API later
23
+
````
24
+
*`templates/directory_name/` should then be populated with your .hbs-templates. the names of these templates will also decide parts of the API paths
25
+
*`data/directory_name/` should be populated with json files with names corresponding to a target .hbs-template, this can be used to test your PDFs during development of templates.
26
+
27
+
Additionally create subfolder `resources` containing additional resources which can be referred in your .hbs-templates
28
+
29
+
30
+
### Example usage
31
+
#### Generating HTML from predefined JSON data in data-folder
32
+
```kotlin
33
+
34
+
val html: String = createHtmlFromTemplateData(template, directoryName)
35
+
```
36
+
37
+
#### Generating PDF from predefined JSON data in data-folder
38
+
```kotlin
39
+
val html: String = createHtmlFromTemplateData(template, directoryName)
40
+
val pdfBytes: ByteArray = createPDFA(html)
41
+
```
42
+
43
+
#### Generating from JSON input data
44
+
```kotlin
45
+
val html: String = createHtmlFromTemplateData(template, directoryName, jsonNode)
46
+
val pdfBytes: ByteArray = createPDFA(html)
47
+
48
+
// Or directly
49
+
val pdfBytes: ByteArray = createPDFA(template, directoryName, jsonNode)
0 commit comments