Skip to content

Commit 99ac835

Browse files
committed
Added subtitles and context
1 parent 99926bf commit 99ac835

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

sites/cheerpj/src/content/docs/11-guides/library-mode.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,15 @@ description: Use Java libraries in JavaScript
55

66
Library mode allows you to directly use Java methods, objects, and arrays from JavaScript. This API has been designed to take advantage of async/await to feel more natural to use, without sacrificing any flexibility.
77

8+
# Getting started
9+
810
Loading a library is as simple as calling [`cheerpjRunLibrary`].
911

12+
- `await cheerpjRunLibrary("")` loads **only the Java standard library**
13+
- `await cheerpjRunLibrary("/path/to/some.jar")` loads the Java standard library **plus** that JAR
14+
15+
An example of using the standard Java library.
16+
1017
```js
1118
async function libraryModeTour() {
1219
await cheerpjInit();
@@ -54,7 +61,15 @@ async function libraryModeTour() {
5461
}
5562
```
5663

57-
Library mode can be used to integrate powerful Java libraries into your Web application. As a practical example, these few lines of code make it possible to generate a PDF from JavaScript using the popular iText library:
64+
# Example: generating a PDF with iText
65+
66+
Library mode can be used to integrate powerful Java libraries into your Web application. As a practical example, these few lines of code make it possible to generate a PDF from JavaScript using the popular iText library.
67+
68+
**This example:**
69+
70+
- Loads `itextpdf-5.5.13.3.jar`
71+
- Builds a PDF and writes it to `/files/HelloIText.pdf`
72+
- Reads it back as a blob and shows it in the page
5873

5974
```js
6075
async function iTextExample() {
@@ -91,7 +106,7 @@ async function iTextExample() {
91106
}
92107
```
93108

94-
## See also
109+
# See also
95110

96111
Library mode is also used for [native methods implemented in JavaScript][JNI]. A `native` is effectively just a shorter library mode session.
97112

0 commit comments

Comments
 (0)