@things-factory/integration-headless 8.0.0-alpha.1 → 8.0.0-alpha.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,6 +6,8 @@
6
6
 
7
7
  - **accessor**: PDF生成のためのデータにアクセスするためのパスを指定します。このパスは、データ構造から必要な情報を抽出するために使用されます。
8
8
 
9
+ - [アクセッサー](../../integration/concept/data-accessor.md)
10
+
9
11
  - **coverPage**: PDFドキュメントの最初のページとして使用するHTMLテンプレートです。HTMLを使用してPDFのカバーページを定義できます。
10
12
 
11
13
  - **lastPage**: PDFドキュメントの最後のページとして使用するHTMLテンプレートです。最後のページは後で追加されます。
@@ -18,6 +20,8 @@
18
20
 
19
21
  - **fileName**: 生成されたPDFファイルの名前を指定します。指定しない場合は、デフォルトで`output.pdf`という名前が使用されます。
20
22
 
23
+ - [アクセッサー](../../integration/concept/data-accessor.md)
24
+
21
25
  - **format**: PDFページのサイズを指定します。`A4`、`A3`、`Letter`、`Legal`などから選択できます。
22
26
 
23
27
  - **width**: ページの幅を指定します。例: `"8.5in"`、`"21cm"`、`"600px"`。指定しない場合、`format`に従って自動的に設定されます。
@@ -6,6 +6,8 @@
6
6
 
7
7
  - **accessor**: PDF 생성을 위한 데이터에 접근하기 위한 경로를 지정합니다. 이 경로는 데이터 구조에서 원하는 정보를 추출하는 데 사용됩니다.
8
8
 
9
+ - [접근자](../../integration/concept/data-accessor.md)
10
+
9
11
  - **coverPage**: PDF 문서의 첫 페이지로 사용할 HTML 템플릿입니다. HTML을 사용하여 PDF의 커버 페이지를 정의할 수 있습니다.
10
12
 
11
13
  - **lastPage**: PDF 문서의 마지막 페이지로 사용할 HTML 템플릿입니다. 마지막 페이지는 이후에 추가됩니다.
@@ -18,6 +20,8 @@
18
20
 
19
21
  - **fileName**: 생성된 PDF 파일의 이름을 지정합니다. 지정하지 않으면 기본적으로 `output.pdf`라는 이름이 사용됩니다.
20
22
 
23
+ - [접근자](../../integration/concept/data-accessor.md) 기능을 사용할 수 있습니다.
24
+
21
25
  - **format**: PDF 페이지의 크기를 지정합니다. `A4`, `A3`, `Letter`, `Legal` 등의 값 중에서 선택할 수 있습니다.
22
26
 
23
27
  - **width**: 페이지의 폭을 지정합니다. 예: `"8.5in"`, `"21cm"`, `"600px"`. 지정하지 않으면 `format`에 따라 자동으로 설정됩니다.
@@ -5,7 +5,7 @@
5
5
  #### Parameter Descriptions
6
6
 
7
7
  - **accessor**: Specifies the path to access the data for PDF generation. This path is used to extract the desired information from the data structure.
8
-
8
+ - [accessor](../../integration/concept/data-accessor.md)
9
9
  - **coverPage**: An HTML template used as the first page of the PDF document. You can define the cover page of the PDF using HTML.
10
10
 
11
11
  - **lastPage**: An HTML template used as the last page of the PDF document. The last page is added later.
@@ -17,7 +17,7 @@
17
17
  - **watermark**: Defines the watermark text to display on each page. Common texts include "DRAFT" or "CONFIDENTIAL."
18
18
 
19
19
  - **fileName**: Specifies the name of the generated PDF file. If not specified, the default name `output.pdf` is used.
20
-
20
+ - [accessor](../../integration/concept/data-accessor.md)
21
21
  - **format**: Specifies the size of the PDF page. Values like `A4`, `A3`, `Letter`, and `Legal` can be chosen.
22
22
 
23
23
  - **width**: Specifies the width of the page, e.g., `"8.5in"`, `"21cm"`, `"600px"`. If not specified, it is automatically set according to the `format`.
@@ -8,6 +8,8 @@ muka (cover page) dan halaman akhir, serta menjalankan tetapan PDF asas yang mer
8
8
 
9
9
  - **accessor**: Menetapkan laluan untuk mengakses data bagi penjanaan PDF. Laluan ini digunakan untuk mengekstrak maklumat yang dikehendaki daripada struktur data.
10
10
 
11
+ - [aksesor](../../integration/concept/data-accessor.md)
12
+
11
13
  - **coverPage**: Templat HTML yang akan digunakan sebagai halaman pertama dokumen PDF. Anda boleh menggunakan HTML untuk mentakrifkan halaman muka PDF.
12
14
 
13
15
  - **lastPage**: Templat HTML yang akan digunakan sebagai halaman terakhir dokumen PDF. Halaman terakhir akan ditambah kemudian.
@@ -20,6 +22,8 @@ muka (cover page) dan halaman akhir, serta menjalankan tetapan PDF asas yang mer
20
22
 
21
23
  - **fileName**: Menetapkan nama fail PDF yang dihasilkan. Jika tidak ditetapkan, nama `output.pdf` akan digunakan secara lalai.
22
24
 
25
+ - [aksesor](../../integration/concept/data-accessor.md)
26
+
23
27
  - **format**: Menetapkan saiz halaman PDF. Anda boleh memilih nilai seperti `A4`, `A3`, `Letter`, `Legal`.
24
28
 
25
29
  - **width**: Menetapkan lebar halaman. Contoh: `"8.5in"``, `"21cm"``, `"600px"`. Jika tidak ditetapkan, ia akan diselaraskan secara automatik berdasarkan `format`.
@@ -6,6 +6,8 @@
6
6
 
7
7
  - **accessor**: 指定用于生成PDF的数据的访问路径。该路径用于从数据结构中提取所需信息。
8
8
 
9
+ - [访问器](../../integration/concept/data-accessor.md)
10
+
9
11
  - **coverPage**: 用作PDF文档封面的HTML模板。可以使用HTML定义PDF的封面页。
10
12
 
11
13
  - **lastPage**: 用作PDF文档最后一页的HTML模板。最后一页将在后续添加。
@@ -18,6 +20,8 @@
18
20
 
19
21
  - **fileName**: 指定生成的PDF文件名。如果未指定,默认使用`output.pdf`。
20
22
 
23
+ - [访问器](../../integration/concept/data-accessor.md)
24
+
21
25
  - **format**: 指定PDF页面的大小。可以选择`A4`、`A3`、`Letter`、`Legal`等值。
22
26
 
23
27
  - **width**: 指定页面的宽度。例如:`"8.5in"`、`"21cm"`、`"600px"`。如果未指定,将根据`format`自动设置。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/integration-headless",
3
- "version": "8.0.0-alpha.1",
3
+ "version": "8.0.0-alpha.11",
4
4
  "main": "dist-server/index.js",
5
5
  "things-factory": true,
6
6
  "author": "heartyoh <heartyoh@hatiolab.com>",
@@ -22,12 +22,12 @@
22
22
  "clean": "npm run clean:server"
23
23
  },
24
24
  "dependencies": {
25
- "@things-factory/attachment-base": "^8.0.0-alpha.1",
26
- "@things-factory/board-service": "^8.0.0-alpha.1",
27
- "@things-factory/integration-base": "^8.0.0-alpha.1",
28
- "@things-factory/shell": "^8.0.0-alpha.1",
25
+ "@things-factory/attachment-base": "^8.0.0-alpha.11",
26
+ "@things-factory/board-service": "^8.0.0-alpha.11",
27
+ "@things-factory/integration-base": "^8.0.0-alpha.11",
28
+ "@things-factory/shell": "^8.0.0-alpha.8",
29
29
  "ejs": "^3.1.10",
30
30
  "pdf-lib": "^1.17.1"
31
31
  },
32
- "gitHead": "fda153ff6e86ef5ee7ace788739a100f3f413f08"
32
+ "gitHead": "5b3e364a968d79cc971e485601ebcab704e5b7d2"
33
33
  }
@@ -12,19 +12,20 @@ async function HeadlessPDFOpen(step, context) {
12
12
  // Create a new PDF document using pdf-lib
13
13
  const pdfDoc = await PDFDocument.create()
14
14
 
15
- const pdfInfo = {
16
- pdfDoc,
17
- watermark,
18
- fileName,
19
- pageCount: 0
20
- } as any
15
+ try {
16
+ const fileNameEncoded = fileName ? new TextEncoder().encode(access(fileName, data)) : undefined
21
17
 
22
- context.__headless_pdf = pdfInfo
18
+ const pdfInfo = {
19
+ pdfDoc,
20
+ watermark,
21
+ fileName: fileNameEncoded,
22
+ pageCount: 0
23
+ } as any
24
+ context.__headless_pdf = pdfInfo
23
25
 
24
- const pdfUtil = new PDFCaptureUtil(context)
25
- await pdfUtil.initBrowser(connectionName)
26
+ var pdfUtil = new PDFCaptureUtil(context)
27
+ await pdfUtil.initBrowser(connectionName)
26
28
 
27
- try {
28
29
  const templateInput = access(accessor, data)
29
30
 
30
31
  // Convert Cover Page to PDF and add it to the document (if provided)
@@ -41,8 +42,6 @@ async function HeadlessPDFOpen(step, context) {
41
42
  lastPageBuffer = await pdfUtil.generateLastPageBuffer(stepOptions, renderedLastPage)
42
43
  }
43
44
 
44
- await pdfUtil.closeBrowser()
45
-
46
45
  pdfInfo.lastPageBuffer = lastPageBuffer
47
46
  pdfInfo.pageCount = pdfDoc.getPageCount()
48
47
  pdfInfo.header = header
@@ -52,8 +51,9 @@ async function HeadlessPDFOpen(step, context) {
52
51
  data: pdfInfo
53
52
  }
54
53
  } catch (error) {
55
- await pdfUtil.closeBrowser()
56
54
  throw error
55
+ } finally {
56
+ await pdfUtil?.closeBrowser()
57
57
  }
58
58
  }
59
59