@blockspoon/cert-badge-renderer 1.0.2 → 1.0.4

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.
package/test/test.js CHANGED
@@ -13,514 +13,173 @@ const { generateDesignFile } = require("../dist/utils/generateDesignFile");
13
13
  const test_object = {
14
14
  statusCode: 200,
15
15
  message: "인증서 양식이 조회되었습니다.",
16
- achievementForm: {
17
- id: 551,
18
- name: "sandbox-achievement",
19
- description: "sandbox-achievement",
20
- type: "completion",
21
- tags: ["sandbox", "test", "api"],
22
- prefix: "SAND",
23
- program_type: "community",
24
- program_name: "kolleges",
25
- program_url: "https://landing.kolleges.net/",
26
- course_begin_at: "2025-04-01T00:00:00.000Z",
27
- course_end_at: "2025-04-07T00:00:00.000Z",
28
- created_at: "2025-04-06T21:38:26.918Z",
29
- updated_at: "2025-04-06T21:38:26.918Z",
30
- club: {
31
- domain: "sandbox",
32
- customData: [],
33
- },
34
- clubInstitutions: [],
35
- representativeInstitution: null,
36
- requirements: [
37
- {
38
- type: "read",
39
- url: "https://landing.kolleges.net/",
40
- description: "kolleges landing",
41
- },
42
- {
43
- type: "submit_homework",
44
- url: "https://admin.kolleges.net/ko/onboard/sign_in",
45
- description: "kolleges main",
46
- },
47
- ],
48
- achievementCertificateDesign: {
49
- id: 165,
50
- name: "sandbox-certificate-v1",
51
- main_color: "#7657FA",
52
- sub_color: "#CABDFF",
53
- extra_color_1: null,
54
- extra_color_2: null,
55
- layout_json: [
56
- {
57
- controlType: "text",
58
- designType: "text",
59
- text: "CERTIFICATE of QUALIFICATION",
60
- fontSize: 20,
61
- fontWeight: "700",
62
- textAlign: "left",
63
- fontFamily: "'BR Firma', sans-serif",
64
- width: 500,
65
- height: 50,
66
- x: 83,
67
- y: 174,
68
- order: 0,
69
- id: "0",
70
- },
71
- {
72
- controlType: "text",
73
- designType: "props",
74
- type: "achievement",
75
- bindingKey: "name",
76
- text: "[인증서.제목]",
77
- fontSize: 40,
78
- fontWeight: "600",
79
- textAlign: "left",
80
- fontFamily: "Pretendard, sans-serif",
81
- width: 500,
82
- height: 50,
83
- x: 87,
84
- y: 214,
85
- order: 1,
86
- id: "1",
87
- },
88
- {
89
- controlType: "text",
90
- designType: "props",
91
- type: "user",
92
- bindingKey: "name",
93
- text: "[수령자.이름]",
94
- fontSize: 44,
95
- fontWeight: "600",
96
- textAlign: "left",
97
- fontFamily: "Pretendard, sans-serif",
98
- width: 500,
99
- height: 60,
100
- x: 87,
101
- y: 306,
102
- order: 2,
103
- id: "2",
104
- },
105
- {
106
- controlType: "text",
107
- designType: "props",
108
- type: "achievement",
109
- bindingKey: "description",
110
- text: "[인증서.설명]",
111
- fontSize: 24,
112
- fontWeight: "400",
113
- textAlign: "left",
114
- fontFamily: "Pretendard, sans-serif",
115
- width: 648,
116
- height: 68,
117
- x: 87,
118
- y: 392,
119
- order: 3,
120
- id: "3",
121
- },
122
- {
123
- controlType: "text",
124
- designType: "props",
125
- type: "achievement",
126
- bindingKey: "tags",
127
- text: "[인증서.스킬태그]",
128
- fontSize: 16,
129
- fontWeight: "400",
130
- textAlign: "left",
131
- color: "#6B7684",
132
- fontFamily: "Pretendard, sans-serif",
133
- width: 648,
134
- height: 68,
135
- x: 87,
136
- y: 501,
137
- order: 4,
138
- id: "4",
139
- },
140
- {
141
- controlType: "text",
142
- designType: "text",
143
- text: "수료기간",
144
- fontSize: 16,
145
- fontWeight: "600",
146
- textAlign: "left",
147
- fontFamily: "Pretendard, sans-serif",
148
- width: 150,
149
- height: 21,
150
- x: 87,
151
- y: 635,
152
- order: 5,
153
- id: "5",
154
- },
155
- {
156
- controlType: "text",
157
- designType: "props",
158
- type: "achievement",
159
- bindingKey: "period",
160
- text: "[인증서.수료기간]",
161
- fontSize: 16,
162
- fontWeight: "400",
163
- textAlign: "left",
164
- fontFamily: "Pretendard, sans-serif",
165
- width: 200,
166
- height: 21,
167
- x: 87,
168
- y: 664,
169
- order: 6,
170
- id: "6",
171
- },
172
- {
173
- controlType: "text",
174
- designType: "text",
175
- text: "발급일",
176
- fontSize: 16,
177
- fontWeight: "600",
178
- textAlign: "left",
179
- fontFamily: "Pretendard, sans-serif",
180
- width: 150,
181
- height: 21,
182
- x: 295,
183
- y: 635,
184
- order: 7,
185
- id: "7",
186
- },
187
- {
188
- controlType: "text",
189
- designType: "props",
190
- type: "achievement",
191
- bindingKey: "created_at",
192
- text: "[인증서.발급일]",
193
- fontSize: 16,
194
- fontWeight: "400",
195
- textAlign: "left",
196
- fontFamily: "Pretendard, sans-serif",
197
- width: 200,
198
- height: 21,
199
- x: 295,
200
- y: 664,
201
- order: 8,
202
- id: "8",
203
- },
204
- {
205
- controlType: "text",
206
- designType: "text",
207
- text: "발급기관",
208
- fontSize: 16,
209
- fontWeight: "600",
210
- textAlign: "left",
211
- fontFamily: "Pretendard, sans-serif",
212
- width: 150,
213
- height: 21,
214
- x: 487,
215
- y: 635,
216
- order: 9,
217
- id: "9",
218
- },
219
- {
220
- controlType: "text",
221
- designType: "props",
222
- type: "club",
223
- bindingKey: "name",
224
- text: "[발급기관[1].이름]",
225
- fontSize: 16,
226
- fontWeight: "400",
227
- textAlign: "left",
228
- fontFamily: "Pretendard, sans-serif",
229
- width: 160,
230
- height: 30,
231
- x: 487,
232
- y: 664,
233
- order: 10,
234
- id: "10",
235
- },
236
- {
237
- controlType: "text",
238
- designType: "props",
239
- type: "club",
240
- bindingKey: "name_1",
241
- text: "[발급기관[2].이름]",
242
- fontSize: 16,
243
- fontWeight: "400",
244
- textAlign: "left",
245
- fontFamily: "Pretendard, sans-serif",
246
- width: 160,
247
- height: 30,
248
- x: 640,
249
- y: 664,
250
- order: 11,
251
- id: "11",
252
- },
253
- {
254
- controlType: "text",
255
- designType: "props",
256
- type: "club",
257
- bindingKey: "name_2",
258
- text: "[발급기관[3].이름]",
259
- fontSize: 16,
260
- fontWeight: "400",
261
- textAlign: "left",
262
- fontFamily: "Pretendard, sans-serif",
263
- width: 160,
264
- height: 30,
265
- x: 487,
266
- y: 690,
267
- order: 12,
268
- id: "12",
269
- },
270
- {
271
- controlType: "text",
272
- designType: "props",
273
- type: "achievement",
274
- bindingKey: "certificate_number",
275
- text: "[인증서.발급코드]",
276
- fontSize: 16,
277
- fontWeight: "400",
278
- textAlign: "right",
279
- fontFamily: "Pretendard, sans-serif",
280
- width: 200,
281
- height: 70,
282
- x: 790,
283
- y: 701,
284
- order: 13,
285
- id: "13",
286
- },
287
- {
288
- controlType: "image",
289
- designType: "props",
290
- type: "club",
291
- bindingKey: "sign_image",
292
- src: "",
293
- text: "[발급기관[1].직인]",
294
- fontSize: 16,
295
- fontWeight: "400",
296
- textAlign: "center",
297
- fontFamily: "Pretendard, sans-serif",
298
- width: 80,
299
- height: 80,
300
- x: 549,
301
- y: 583,
302
- order: 14,
303
- id: "14",
304
- },
305
- {
306
- controlType: "image",
307
- designType: "props",
308
- type: "club",
309
- bindingKey: "sign_image_1",
310
- src: "",
311
- text: "[발급기관[2].직인]",
312
- fontSize: 16,
313
- fontWeight: "400",
314
- textAlign: "center",
315
- fontFamily: "Pretendard, sans-serif",
316
- width: 80,
317
- height: 80,
318
- x: 629,
319
- y: 583,
320
- order: 15,
321
- id: "15",
322
- },
323
- {
324
- controlType: "image",
325
- designType: "props",
326
- type: "club",
327
- bindingKey: "sign_image_2",
328
- src: "",
329
- text: "[발급기관[3].직인]",
330
- fontSize: 16,
331
- fontWeight: "400",
332
- textAlign: "center",
333
- fontFamily: "Pretendard, sans-serif",
334
- width: 80,
335
- height: 80,
336
- x: 709,
337
- y: 583,
338
- order: 16,
339
- id: "16",
340
- },
341
- {
342
- controlType: "image",
343
- designType: "props",
344
- type: "club",
345
- bindingKey: "club_symbol",
346
- src: "",
347
- text: "[발급기관[1].심볼]",
348
- fontSize: 16,
349
- fontWeight: "400",
350
- textAlign: "center",
351
- fontFamily: "Pretendard, sans-serif",
352
- width: 90,
353
- height: 90,
354
- x: 852,
355
- y: 92,
356
- order: 17,
357
- id: "17",
358
- },
359
- {
360
- controlType: "image",
361
- designType: "props",
362
- type: "club",
363
- bindingKey: "club_symbol_1",
364
- src: "",
365
- text: "[발급기관[2].심볼]",
366
- fontSize: 16,
367
- fontWeight: "400",
368
- textAlign: "center",
369
- fontFamily: "Pretendard, sans-serif",
370
- width: 90,
371
- height: 90,
372
- x: 974,
373
- y: 92,
374
- order: 18,
375
- id: "18",
376
- },
377
- {
378
- controlType: "image",
379
- designType: "props",
380
- type: "achievement",
381
- bindingKey: "qr_code",
382
- src: "",
383
- text: "[인증서.QR코드]",
384
- fontSize: 16,
385
- fontWeight: "400",
386
- textAlign: "center",
387
- fontFamily: "Pretendard, sans-serif",
388
- width: 90,
389
- height: 90,
390
- x: 989,
391
- y: 639,
392
- order: 19,
393
- id: "19",
394
- },
395
- {
396
- controlType: "image",
397
- designType: "props",
398
- type: "achievement",
399
- bindingKey: "badge",
400
- src: "",
401
- text: "[인증서.배지]",
402
- fontSize: 16,
403
- fontWeight: "400",
404
- textAlign: "center",
405
- fontFamily: "Pretendard, sans-serif",
406
- width: 280,
407
- height: 280,
408
- x: 784,
409
- y: 305.5,
410
- order: 20,
411
- id: "20",
412
- },
16
+ achievement: {
17
+ id: 1450,
18
+ certificate_number: "CERT-202504-123456",
19
+ expiration_date: "2025-12-02T00:00:00.000Z",
20
+ is_received: false,
21
+ issuance_method: "EMAIL",
22
+ created_at: "2025-04-18T00:00:00.000Z",
23
+ updated_at: "2025-04-06T18:17:39.116Z",
24
+ user: {
25
+ email: "eogks999@naver.com",
26
+ name: "김천재",
27
+ avatar: [
28
+ "https://ufcglnoegwgklehhpzlj.supabase.co/storage/v1/object/public/blockspoon_images/uploads/user/avatar/background.webp",
29
+ "https://ufcglnoegwgklehhpzlj.supabase.co/storage/v1/object/public/blockspoon_images/uploads/user/avatar/clothes.webp",
30
+ "https://ufcglnoegwgklehhpzlj.supabase.co/storage/v1/object/public/blockspoon_images/uploads/user/avatar/face.webp",
31
+ "https://ufcglnoegwgklehhpzlj.supabase.co/storage/v1/object/public/blockspoon_images/uploads/user/avatar/eye.webp",
32
+ "https://ufcglnoegwgklehhpzlj.supabase.co/storage/v1/object/public/blockspoon_images/uploads/user/avatar/hair.webp",
33
+ "https://ufcglnoegwgklehhpzlj.supabase.co/storage/v1/object/public/blockspoon_images/uploads/user/avatar/mouth.webp",
34
+ "https://ufcglnoegwgklehhpzlj.supabase.co/storage/v1/object/public/blockspoon_images/uploads/user/avatar/accessory.webp",
413
35
  ],
414
- template_type: "NewCertificateType7Single",
415
- created_at: "2025-04-09T18:37:39.696Z",
416
- updated_at: "2025-04-09T18:37:39.696Z",
36
+ deleted_at: null,
417
37
  image: null,
38
+ profileImageType: "avatar",
418
39
  },
419
- achievementBadgeDesign: {
420
- id: 83,
421
- name: "sandbox-badge-v1",
422
- main_color: "#322899",
423
- sub_color: "#7468E8",
424
- extra_color_1: null,
425
- extra_color_2: null,
426
- layout_json: [
427
- {
428
- controlType: "svg",
429
- designType: "badge",
430
- componentName: "BadgeType31",
431
- background: "transparent",
432
- width: 538,
433
- height: 594,
434
- x: 31.00006103515625,
435
- y: 3,
436
- text: "BadgeType31",
437
- mainColor: "#322899",
438
- subColor: "#7368E8",
439
- order: 0,
440
- id: "0",
441
- },
442
- {
443
- controlType: "svg",
444
- designType: "icon",
445
- componentName: "IconMortarboard3",
446
- background: "transparent",
447
- width: 240,
448
- height: 222,
449
- x: 188,
450
- y: 134,
451
- text: "IconMortarboard3",
452
- mainColor: "#322899",
453
- subColor: "#7468e8",
454
- extraColor1: "#ffffff",
455
- order: 1,
456
- id: "1",
457
- },
458
- {
459
- controlType: "text",
460
- designType: "text",
461
- text: "· CERTIFICATE of COMPLETION ·",
462
- fontSize: 16,
463
- fontWeight: "600",
464
- textAlign: "center",
465
- fontFamily: "Pretendard, sans-serif",
466
- color: "white",
467
- width: 332,
468
- height: 50,
469
- x: 135,
470
- y: 122,
471
- order: 2,
472
- id: "2",
473
- },
474
- {
475
- controlType: "text",
476
- designType: "props",
477
- type: "achievement",
478
- bindingKey: "name",
479
- text: "[인증서.제목]",
480
- fontSize: 40,
481
- fontWeight: "700",
482
- textAlign: "center",
483
- fontFamily: "Pretendard, sans-serif",
484
- color: "black",
485
- width: 375,
486
- height: 108,
487
- x: 115,
488
- y: 398,
489
- order: 3,
490
- id: "3",
491
- },
492
- {
493
- controlType: "image",
494
- designType: "props",
495
- type: "club",
496
- bindingKey: "club_symbol",
497
- src: "",
498
- text: "[발급기관[1].심볼]",
499
- fontSize: 16,
500
- fontWeight: "400",
501
- textAlign: "center",
502
- fontFamily: "Pretendard, sans-serif",
503
- width: 65,
504
- height: 65,
505
- x: 415,
506
- y: 243,
507
- order: 4,
508
- id: "4",
509
- },
510
- ],
511
- template_type: "NewBadgeType31",
512
- created_at: "2025-04-09T18:37:27.940Z",
513
- updated_at: "2025-04-09T18:37:27.940Z",
514
- image: null,
40
+ achievementForm: {
41
+ id: 496,
42
+ name: "OpenApi 테스트 인증서",
43
+ achievementBadgeDesign: {
44
+ id: 64,
45
+ name: "배지리본합체!",
46
+ main_color: "#FF1B64",
47
+ sub_color: "#FF8FB1",
48
+ extra_color_1: "#000000",
49
+ extra_color_2: "#000000",
50
+ layout_json: [
51
+ {
52
+ id: "badge-1742881999662",
53
+ controlType: "svg",
54
+ designType: "badge",
55
+ componentName: "BadgeType63",
56
+ background: "transparent",
57
+ width: 500,
58
+ height: 530,
59
+ x: 48,
60
+ y: 44,
61
+ order: 1,
62
+ text: "BadgeType63",
63
+ mainColor: "#FF1B64",
64
+ subColor: "#FF91B2",
65
+ extraColor1: "yellow",
66
+ extraColor2: "green",
67
+ },
68
+ {
69
+ id: "ribbon-1742881765599",
70
+ controlType: "svg",
71
+ designType: "ribbon",
72
+ componentName: "RibbonType7",
73
+ background: "transparent",
74
+ width: 510,
75
+ height: 210,
76
+ x: 45,
77
+ y: 195,
78
+ order: 2,
79
+ text: "RibbonType7",
80
+ mainColor: "#FF1B64",
81
+ subColor: "#FF91B2",
82
+ },
83
+ {
84
+ id: "2",
85
+ order: 3,
86
+ controlType: "text",
87
+ designType: "props",
88
+ type: "club",
89
+ bindingKey: "name",
90
+ text: "미세먼지 그만",
91
+ fontSize: 28,
92
+ fontWeight: "700",
93
+ textAlign: "center",
94
+ fontFamily: "Pretendard, sans-serif",
95
+ color: "black",
96
+ width: 335,
97
+ height: 50,
98
+ x: 135,
99
+ y: 405,
100
+ },
101
+ {
102
+ id: "club-symbol",
103
+ order: 3,
104
+ controlType: "image",
105
+ designType: "props",
106
+ type: "club",
107
+ bindingKey: "club_symbol",
108
+ src: "https://ufcglnoegwgklehhpzlj.supabase.co/storage/v1/object/public/blockspoon_images/uploads/club/symbol/8a4656a6-eda5-4356-8240-155e70982e0e",
109
+ text: "[발급기관[1].심볼]",
110
+ fontSize: 16,
111
+ fontWeight: "400",
112
+ textAlign: "center",
113
+ fontFamily: "Pretendard, sans-serif",
114
+ width: 90,
115
+ height: 90,
116
+ x: 423,
117
+ y: 86,
118
+ },
119
+ {
120
+ id: "0",
121
+ order: 4,
122
+ controlType: "text",
123
+ designType: "text",
124
+ text: "· CERTIFICATE of COMPLETION ·",
125
+ fontSize: 16,
126
+ fontWeight: "600",
127
+ textAlign: "center",
128
+ fontFamily: "Pretendard, sans-serif",
129
+ color: "black",
130
+ width: 279,
131
+ height: 38,
132
+ x: 162,
133
+ y: 172,
134
+ },
135
+ {
136
+ id: "1",
137
+ order: 5,
138
+ controlType: "text",
139
+ designType: "props",
140
+ type: "achievement",
141
+ bindingKey: "name",
142
+ text: "OpenApi 테스트 인증서",
143
+ fontSize: 48,
144
+ fontWeight: "700",
145
+ textAlign: "center",
146
+ fontFamily: "Pretendard, sans-serif",
147
+ width: 360,
148
+ height: 120,
149
+ x: 125,
150
+ y: 240,
151
+ },
152
+ ],
153
+ template_type: "NewBadgeTypeEmpty",
154
+ created_at: "2025-04-09T18:37:27.940Z",
155
+ updated_at: "2025-04-09T18:37:27.940Z",
156
+ },
157
+ club: {
158
+ domain: "ddenzu2",
159
+ name: "미세먼지 그만",
160
+ type: "school",
161
+ images: [
162
+ {
163
+ path: "https://ufcglnoegwgklehhpzlj.supabase.co/storage/v1/object/public/blockspoon_images/uploads/club/logo/5af4890f-8906-4562-92ee-d511742e5d39",
164
+ type: "club_logo",
165
+ },
166
+ {
167
+ path: "https://ufcglnoegwgklehhpzlj.supabase.co/storage/v1/object/public/blockspoon_images/uploads/club/symbol/8a4656a6-eda5-4356-8240-155e70982e0e",
168
+ type: "club_symbol",
169
+ },
170
+ {
171
+ path: "https://ufcglnoegwgklehhpzlj.supabase.co/storage/v1/object/public/blockspoon_images/uploads/achievement/form/sign/fb38b4e8-5a26-40a2-b827-7e8044f058a6",
172
+ type: "sign_image",
173
+ },
174
+ ],
175
+ },
515
176
  },
516
177
  },
517
178
  };
518
179
 
519
180
  const testCertificateData = {
520
181
  // user: test_object.achievement.user,
521
- user: {},
522
- kollegeInfo: test_object.achievementForm.club,
523
- achievementInfo: test_object.achievementForm,
182
+ achievementInfo: test_object.achievement,
524
183
  };
525
184
  const testOptions = {
526
185
  type: "badge",
@@ -528,71 +187,61 @@ const testOptions = {
528
187
  returnType: "base64",
529
188
  };
530
189
 
531
-
532
- const testDesignData = {
533
- layout_json: test_object.achievementForm.achievementBadgeDesign.layout_json,
534
- template_type:
535
- test_object.achievementForm.achievementBadgeDesign.template_type,
536
- main_color: test_object.achievementForm.achievementBadgeDesign.main_color,
537
- sub_color: test_object.achievementForm.achievementBadgeDesign.sub_color,
538
- };
539
-
540
-
541
190
  async function runTests() {
542
191
  try {
543
192
  // HTML 변환 테스트
544
- const htmlOutput = await generateDesignHTML(testDesignData, {
545
- size: 300,
546
- });
547
- fs.writeFileSync("test/certificate.html", htmlOutput, "utf8");
548
- console.log("✅ HTML 변환 완료: test/certificate.html");
549
-
550
- // PNG 변환 테스트
551
- const pngResult = await generateDesignFile(testDesignData, {
552
- size: 300,
553
- });
554
- fs.writeFileSync("test/certificate.png", pngResult.buffer);
555
- console.log("✅ PNG 변환 완료: test/certificate.png");
556
-
557
- // // HTML 변환 테스트
558
- // const htmlOutput = await generateAchievementHTML(testCertificateData, {
559
- // type: "badge",
193
+ // const htmlOutput = await generateDesignHTML(testDesignData, {
560
194
  // size: 300,
561
- // noSpace: false,
562
- // mainColor: "#322899",
563
- // subColor: "#7368E8",
564
195
  // });
565
196
  // fs.writeFileSync("test/certificate.html", htmlOutput, "utf8");
566
197
  // console.log("✅ HTML 변환 완료: test/certificate.html");
567
198
 
568
199
  // // PNG 변환 테스트
569
- // const pngResult = await generateAchievementFile(
570
- // testCertificateData,
571
- // testOptions
572
- // );
200
+ // const pngResult = await generateDesignFile(testDesignData, {
201
+ // size: 300,
202
+ // });
203
+ // fs.writeFileSync("test/certificate.png", pngResult.buffer);
204
+ // console.log("✅ PNG 변환 완료: test/certificate.png");
205
+
206
+ // // HTML 변환 테스트
207
+ const htmlOutput = await generateAchievementHTML(testCertificateData.achievementInfo, {
208
+ type: "badge",
209
+ size: 300,
210
+ noSpace: false,
211
+ mainColor: "#322899",
212
+ subColor: "#7368E8",
213
+ });
214
+ fs.writeFileSync("test/certificate.html", htmlOutput, "utf8");
215
+ // console.log("✅ HTML 변환 완료: test/certificate.html");
216
+
217
+ // PNG 변환 테스트
218
+ const pngResult = await generateAchievementFile(
219
+ testCertificateData.achievementInfo,
220
+ testOptions
221
+ );
573
222
 
574
- // if (testOptions.returnType === "base64") {
575
- // console.log("✅ Base64 변환 완료");
576
- // // base64 문자열에서 data:image/png;base64, 부분 제거
577
- // const base64Data = pngResult.base64.replace(
578
- // /^data:image\/png;base64,/,
579
- // ""
580
- // );
581
- // // base64를 버퍼로 변환
582
- // const buffer = Buffer.from(base64Data, "base64");
583
- // // 이미지 파일로 저장
584
- // await fsPromises.writeFile(
585
- // path.join(__dirname, "certificate_base64.png"),
586
- // buffer
587
- // );
588
- // console.log("✅ Base64 이미지 저장 완료: test/certificate_base64.png");
589
- // } else {
590
- // await fsPromises.writeFile(
591
- // path.join(__dirname, "certificate.png"),
592
- // pngResult.buffer
593
- // );
594
- // console.log("✅ PNG 변환 완료: test/certificate.png");
595
- // }
223
+ if (testOptions.returnType === "base64") {
224
+ console.log("✅ Base64 변환 완료");
225
+ // base64 문자열에서 data:image/png;base64, 부분 제거
226
+ const base64Data = pngResult.base64.replace(
227
+ /^data:image\/png;base64,/,
228
+ ""
229
+ );
230
+ // base64를 버퍼로 변환
231
+ const buffer = Buffer.from(base64Data, "base64");
232
+ // 이미지 파일로 저장
233
+ await fsPromises.writeFile(
234
+ path.join(__dirname, "certificate_base64.png"),
235
+ buffer
236
+ );
237
+ console.log("✅ Base64 이미지 저장 완료: test/certificate_base64.png");
238
+ } else {
239
+ await fsPromises.writeFile(
240
+ path.join(__dirname, "certificate.png"),
241
+ pngResult.buffer
242
+ );
243
+ console.log("✅ PNG 변환 완료: test/certificate.png");
244
+ }
596
245
  } catch (error) {
597
246
  console.error("❌ 테스트 실행 중 오류 발생:", error);
598
247
  }