@pixldocs/canvas-renderer 0.4.0 → 0.4.2

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/dist/index.cjs CHANGED
@@ -10774,14 +10774,14 @@ class PixldocsRenderer {
10774
10774
  async renderPdf(templateConfig, options) {
10775
10775
  const svgs = await this.renderAllPageSvgs(templateConfig);
10776
10776
  const { assemblePdfFromSvgs: assemblePdfFromSvgs2 } = await Promise.resolve().then(() => pdfExport);
10777
- return assemblePdfFromSvgs2(svgs, { title: options == null ? void 0 : options.title });
10777
+ return assemblePdfFromSvgs2(svgs, { title: options == null ? void 0 : options.title, fontBaseUrl: options == null ? void 0 : options.fontBaseUrl });
10778
10778
  }
10779
10779
  /**
10780
10780
  * Resolve from V2 sectionState and render a vector PDF.
10781
10781
  * This is the primary PDF export API — mirrors renderFromForm() but returns a PDF.
10782
10782
  */
10783
10783
  async renderPdfFromForm(options) {
10784
- const { templateId, formSchemaId, sectionState, themeId, watermark, title } = options;
10784
+ const { templateId, formSchemaId, sectionState, themeId, watermark, title, fontBaseUrl } = options;
10785
10785
  const resolved = await resolveFromForm({
10786
10786
  templateId,
10787
10787
  formSchemaId,
@@ -10798,7 +10798,7 @@ class PixldocsRenderer {
10798
10798
  }
10799
10799
  const svgs = await this.renderAllPageSvgs(configToRender);
10800
10800
  const { assemblePdfFromSvgs: assemblePdfFromSvgs2 } = await Promise.resolve().then(() => pdfExport);
10801
- return assemblePdfFromSvgs2(svgs, { title: title ?? resolved.config.name });
10801
+ return assemblePdfFromSvgs2(svgs, { title: title ?? resolved.config.name, fontBaseUrl });
10802
10802
  }
10803
10803
  async renderById(templateId, formData, options) {
10804
10804
  const resolved = await resolveTemplateData({
@@ -11252,6 +11252,740 @@ class PixldocsRenderer {
11252
11252
  return null;
11253
11253
  }
11254
11254
  }
11255
+ const FONT_WEIGHT_LABELS = {
11256
+ 300: "Light",
11257
+ 400: "Regular",
11258
+ 500: "Medium",
11259
+ 600: "SemiBold",
11260
+ 700: "Bold"
11261
+ };
11262
+ function resolveFontWeight(weight) {
11263
+ if (weight <= 350) return 300;
11264
+ if (weight <= 450) return 400;
11265
+ if (weight <= 550) return 500;
11266
+ if (weight <= 650) return 600;
11267
+ return 700;
11268
+ }
11269
+ const FONT_FALLBACK_SYMBOLS = "Noto Sans";
11270
+ const FONT_FALLBACK_DEVANAGARI = "Hind";
11271
+ const FONT_FILES = {
11272
+ "Playfair Display": {
11273
+ regular: "PlayfairDisplay-Regular.ttf",
11274
+ bold: "PlayfairDisplay-Bold.ttf",
11275
+ italic: "PlayfairDisplay-Italic.ttf",
11276
+ boldItalic: "PlayfairDisplay-BoldItalic.ttf"
11277
+ },
11278
+ "Merriweather": {
11279
+ regular: "Merriweather-Regular.ttf",
11280
+ bold: "Merriweather-Bold.ttf",
11281
+ light: "Merriweather-Light.ttf",
11282
+ italic: "Merriweather-Italic.ttf",
11283
+ boldItalic: "Merriweather-BoldItalic.ttf",
11284
+ lightItalic: "Merriweather-LightItalic.ttf"
11285
+ },
11286
+ "Lora": {
11287
+ regular: "Lora-Regular.ttf",
11288
+ bold: "Lora-Bold.ttf",
11289
+ italic: "Lora-Italic.ttf",
11290
+ boldItalic: "Lora-BoldItalic.ttf"
11291
+ },
11292
+ "Montserrat": {
11293
+ regular: "Montserrat-Regular.ttf",
11294
+ bold: "Montserrat-Bold.ttf",
11295
+ light: "Montserrat-Light.ttf",
11296
+ medium: "Montserrat-Medium.ttf",
11297
+ semibold: "Montserrat-SemiBold.ttf",
11298
+ italic: "Montserrat-Italic.ttf",
11299
+ boldItalic: "Montserrat-BoldItalic.ttf",
11300
+ lightItalic: "Montserrat-LightItalic.ttf",
11301
+ mediumItalic: "Montserrat-MediumItalic.ttf",
11302
+ semiboldItalic: "Montserrat-SemiBoldItalic.ttf"
11303
+ },
11304
+ "Open Sans": {
11305
+ regular: "OpenSans-Regular.ttf",
11306
+ bold: "OpenSans-Bold.ttf",
11307
+ light: "OpenSans-Light.ttf",
11308
+ semibold: "OpenSans-SemiBold.ttf",
11309
+ italic: "OpenSans-Italic.ttf",
11310
+ boldItalic: "OpenSans-BoldItalic.ttf",
11311
+ lightItalic: "OpenSans-LightItalic.ttf",
11312
+ semiboldItalic: "OpenSans-SemiBoldItalic.ttf"
11313
+ },
11314
+ "Roboto": {
11315
+ regular: "Roboto-Regular.ttf",
11316
+ bold: "Roboto-Bold.ttf",
11317
+ light: "Roboto-Light.ttf",
11318
+ medium: "Roboto-Medium.ttf",
11319
+ italic: "Roboto-Italic.ttf",
11320
+ boldItalic: "Roboto-BoldItalic.ttf",
11321
+ lightItalic: "Roboto-LightItalic.ttf",
11322
+ mediumItalic: "Roboto-MediumItalic.ttf"
11323
+ },
11324
+ "Lato": {
11325
+ regular: "Lato-Regular.ttf",
11326
+ bold: "Lato-Bold.ttf",
11327
+ light: "Lato-Light.ttf",
11328
+ italic: "Lato-Italic.ttf",
11329
+ boldItalic: "Lato-BoldItalic.ttf",
11330
+ lightItalic: "Lato-LightItalic.ttf"
11331
+ },
11332
+ "Raleway": {
11333
+ regular: "Raleway-Regular.ttf",
11334
+ bold: "Raleway-Bold.ttf",
11335
+ light: "Raleway-Light.ttf",
11336
+ medium: "Raleway-Medium.ttf",
11337
+ semibold: "Raleway-SemiBold.ttf",
11338
+ italic: "Raleway-Italic.ttf",
11339
+ boldItalic: "Raleway-BoldItalic.ttf",
11340
+ lightItalic: "Raleway-LightItalic.ttf"
11341
+ },
11342
+ "Poppins": {
11343
+ regular: "Poppins-Regular.ttf",
11344
+ bold: "Poppins-Bold.ttf",
11345
+ light: "Poppins-Light.ttf",
11346
+ medium: "Poppins-Medium.ttf",
11347
+ semibold: "Poppins-SemiBold.ttf",
11348
+ italic: "Poppins-Italic.ttf",
11349
+ boldItalic: "Poppins-BoldItalic.ttf",
11350
+ lightItalic: "Poppins-LightItalic.ttf",
11351
+ mediumItalic: "Poppins-MediumItalic.ttf",
11352
+ semiboldItalic: "Poppins-SemiBoldItalic.ttf"
11353
+ },
11354
+ "Inter": {
11355
+ regular: "Inter-Regular.ttf",
11356
+ bold: "Inter-Bold.ttf",
11357
+ italic: "Inter-Italic.ttf",
11358
+ boldItalic: "Inter-BoldItalic.ttf"
11359
+ },
11360
+ "Nunito": {
11361
+ regular: "Nunito-Regular.ttf",
11362
+ bold: "Nunito-Bold.ttf",
11363
+ light: "Nunito-Light.ttf",
11364
+ medium: "Nunito-Medium.ttf",
11365
+ semibold: "Nunito-SemiBold.ttf",
11366
+ italic: "Nunito-Italic.ttf",
11367
+ boldItalic: "Nunito-BoldItalic.ttf"
11368
+ },
11369
+ "Source Sans Pro": {
11370
+ regular: "SourceSansPro-Regular.ttf",
11371
+ bold: "SourceSansPro-Bold.ttf",
11372
+ light: "SourceSansPro-Light.ttf",
11373
+ italic: "SourceSansPro-Italic.ttf",
11374
+ boldItalic: "SourceSansPro-BoldItalic.ttf"
11375
+ },
11376
+ "Work Sans": {
11377
+ regular: "WorkSans-Regular.ttf",
11378
+ bold: "WorkSans-Bold.ttf",
11379
+ italic: "WorkSans-Italic.ttf",
11380
+ boldItalic: "WorkSans-BoldItalic.ttf"
11381
+ },
11382
+ "Oswald": { regular: "Oswald-Regular.ttf", bold: "Oswald-Bold.ttf" },
11383
+ "Bebas Neue": { regular: "BebasNeue-Regular.ttf" },
11384
+ "Abril Fatface": { regular: "AbrilFatface-Regular.ttf" },
11385
+ "Dancing Script": { regular: "DancingScript-Regular.ttf", bold: "DancingScript-Bold.ttf" },
11386
+ "Pacifico": { regular: "Pacifico-Regular.ttf" },
11387
+ "Great Vibes": { regular: "GreatVibes-Regular.ttf" },
11388
+ "DM Sans": {
11389
+ regular: "DMSans-Regular.ttf",
11390
+ bold: "DMSans-Bold.ttf",
11391
+ light: "DMSans-Light.ttf",
11392
+ medium: "DMSans-Medium.ttf",
11393
+ semibold: "DMSans-SemiBold.ttf",
11394
+ italic: "DMSans-RegularItalic.ttf",
11395
+ boldItalic: "DMSans-BoldItalic.ttf",
11396
+ lightItalic: "DMSans-LightItalic.ttf",
11397
+ mediumItalic: "DMSans-MediumItalic.ttf",
11398
+ semiboldItalic: "DMSans-SemiBoldItalic.ttf"
11399
+ },
11400
+ "Outfit": {
11401
+ regular: "Outfit-Regular.ttf",
11402
+ bold: "Outfit-Bold.ttf",
11403
+ light: "Outfit-Light.ttf",
11404
+ medium: "Outfit-Medium.ttf",
11405
+ semibold: "Outfit-SemiBold.ttf"
11406
+ },
11407
+ "Figtree": {
11408
+ regular: "Figtree-Regular.ttf",
11409
+ bold: "Figtree-Bold.ttf",
11410
+ light: "Figtree-Light.ttf",
11411
+ medium: "Figtree-Medium.ttf",
11412
+ semibold: "Figtree-SemiBold.ttf",
11413
+ italic: "Figtree-RegularItalic.ttf",
11414
+ boldItalic: "Figtree-BoldItalic.ttf",
11415
+ lightItalic: "Figtree-LightItalic.ttf",
11416
+ mediumItalic: "Figtree-MediumItalic.ttf",
11417
+ semiboldItalic: "Figtree-SemiBoldItalic.ttf"
11418
+ },
11419
+ "Manrope": {
11420
+ regular: "Manrope-Regular.ttf",
11421
+ bold: "Manrope-Bold.ttf",
11422
+ light: "Manrope-Light.ttf",
11423
+ medium: "Manrope-Medium.ttf",
11424
+ semibold: "Manrope-SemiBold.ttf"
11425
+ },
11426
+ "Space Grotesk": {
11427
+ regular: "SpaceGrotesk-Regular.ttf",
11428
+ bold: "SpaceGrotesk-Bold.ttf",
11429
+ light: "SpaceGrotesk-Light.ttf",
11430
+ medium: "SpaceGrotesk-Medium.ttf",
11431
+ semibold: "SpaceGrotesk-SemiBold.ttf"
11432
+ },
11433
+ "League Spartan": {
11434
+ regular: "LeagueSpartan-Regular.ttf",
11435
+ bold: "LeagueSpartan-Bold.ttf",
11436
+ light: "LeagueSpartan-Light.ttf",
11437
+ medium: "LeagueSpartan-Medium.ttf",
11438
+ semibold: "LeagueSpartan-SemiBold.ttf"
11439
+ },
11440
+ "EB Garamond": {
11441
+ regular: "EBGaramond-Regular.ttf",
11442
+ bold: "EBGaramond-Bold.ttf",
11443
+ medium: "EBGaramond-Medium.ttf",
11444
+ semibold: "EBGaramond-SemiBold.ttf",
11445
+ italic: "EBGaramond-RegularItalic.ttf",
11446
+ boldItalic: "EBGaramond-BoldItalic.ttf",
11447
+ mediumItalic: "EBGaramond-MediumItalic.ttf",
11448
+ semiboldItalic: "EBGaramond-SemiBoldItalic.ttf"
11449
+ },
11450
+ "Libre Baskerville": {
11451
+ regular: "LibreBaskerville-Regular.ttf",
11452
+ bold: "LibreBaskerville-Bold.ttf",
11453
+ italic: "LibreBaskerville-RegularItalic.ttf",
11454
+ boldItalic: "LibreBaskerville-BoldItalic.ttf"
11455
+ },
11456
+ "Crimson Text": {
11457
+ regular: "CrimsonText-Regular.ttf",
11458
+ bold: "CrimsonText-Bold.ttf",
11459
+ italic: "CrimsonText-Italic.ttf",
11460
+ boldItalic: "CrimsonText-BoldItalic.ttf"
11461
+ },
11462
+ "DM Serif Display": {
11463
+ regular: "DMSerifDisplay-Regular.ttf",
11464
+ italic: "DMSerifDisplay-Italic.ttf"
11465
+ },
11466
+ "Libre Franklin": {
11467
+ regular: "LibreFranklin-Regular.ttf",
11468
+ bold: "LibreFranklin-Bold.ttf",
11469
+ light: "LibreFranklin-Light.ttf",
11470
+ medium: "LibreFranklin-Medium.ttf",
11471
+ semibold: "LibreFranklin-SemiBold.ttf",
11472
+ italic: "LibreFranklin-RegularItalic.ttf",
11473
+ boldItalic: "LibreFranklin-BoldItalic.ttf",
11474
+ lightItalic: "LibreFranklin-LightItalic.ttf",
11475
+ mediumItalic: "LibreFranklin-MediumItalic.ttf",
11476
+ semiboldItalic: "LibreFranklin-SemiBoldItalic.ttf"
11477
+ },
11478
+ "Mulish": {
11479
+ regular: "Mulish-Regular.ttf",
11480
+ bold: "Mulish-Bold.ttf",
11481
+ light: "Mulish-Light.ttf",
11482
+ medium: "Mulish-Medium.ttf",
11483
+ semibold: "Mulish-SemiBold.ttf",
11484
+ italic: "Mulish-RegularItalic.ttf",
11485
+ boldItalic: "Mulish-BoldItalic.ttf",
11486
+ lightItalic: "Mulish-LightItalic.ttf",
11487
+ mediumItalic: "Mulish-MediumItalic.ttf",
11488
+ semiboldItalic: "Mulish-SemiBoldItalic.ttf"
11489
+ },
11490
+ "Quicksand": {
11491
+ regular: "Quicksand-Regular.ttf",
11492
+ bold: "Quicksand-Bold.ttf",
11493
+ light: "Quicksand-Light.ttf",
11494
+ medium: "Quicksand-Medium.ttf",
11495
+ semibold: "Quicksand-SemiBold.ttf"
11496
+ },
11497
+ "Rubik": {
11498
+ regular: "Rubik-Regular.ttf",
11499
+ bold: "Rubik-Bold.ttf",
11500
+ light: "Rubik-Light.ttf",
11501
+ medium: "Rubik-Medium.ttf",
11502
+ semibold: "Rubik-SemiBold.ttf",
11503
+ italic: "Rubik-RegularItalic.ttf",
11504
+ boldItalic: "Rubik-BoldItalic.ttf",
11505
+ lightItalic: "Rubik-LightItalic.ttf",
11506
+ mediumItalic: "Rubik-MediumItalic.ttf",
11507
+ semiboldItalic: "Rubik-SemiBoldItalic.ttf"
11508
+ },
11509
+ "Karla": {
11510
+ regular: "Karla-Regular.ttf",
11511
+ bold: "Karla-Bold.ttf",
11512
+ light: "Karla-Light.ttf",
11513
+ medium: "Karla-Medium.ttf",
11514
+ semibold: "Karla-SemiBold.ttf",
11515
+ italic: "Karla-RegularItalic.ttf",
11516
+ boldItalic: "Karla-BoldItalic.ttf",
11517
+ lightItalic: "Karla-LightItalic.ttf",
11518
+ mediumItalic: "Karla-MediumItalic.ttf",
11519
+ semiboldItalic: "Karla-SemiBoldItalic.ttf"
11520
+ },
11521
+ "Plus Jakarta Sans": {
11522
+ regular: "PlusJakartaSans-Regular.ttf",
11523
+ bold: "PlusJakartaSans-Bold.ttf",
11524
+ light: "PlusJakartaSans-Light.ttf",
11525
+ medium: "PlusJakartaSans-Medium.ttf",
11526
+ semibold: "PlusJakartaSans-SemiBold.ttf",
11527
+ italic: "PlusJakartaSans-RegularItalic.ttf",
11528
+ boldItalic: "PlusJakartaSans-BoldItalic.ttf",
11529
+ lightItalic: "PlusJakartaSans-LightItalic.ttf",
11530
+ mediumItalic: "PlusJakartaSans-MediumItalic.ttf",
11531
+ semiboldItalic: "PlusJakartaSans-SemiBoldItalic.ttf"
11532
+ },
11533
+ "Sora": {
11534
+ regular: "Sora-Regular.ttf",
11535
+ bold: "Sora-Bold.ttf",
11536
+ light: "Sora-Light.ttf",
11537
+ medium: "Sora-Medium.ttf",
11538
+ semibold: "Sora-SemiBold.ttf"
11539
+ },
11540
+ "Urbanist": {
11541
+ regular: "Urbanist-Regular.ttf",
11542
+ bold: "Urbanist-Bold.ttf",
11543
+ light: "Urbanist-Light.ttf",
11544
+ medium: "Urbanist-Medium.ttf",
11545
+ semibold: "Urbanist-SemiBold.ttf",
11546
+ italic: "Urbanist-RegularItalic.ttf",
11547
+ boldItalic: "Urbanist-BoldItalic.ttf",
11548
+ lightItalic: "Urbanist-LightItalic.ttf",
11549
+ mediumItalic: "Urbanist-MediumItalic.ttf",
11550
+ semiboldItalic: "Urbanist-SemiBoldItalic.ttf"
11551
+ },
11552
+ "Lexend": {
11553
+ regular: "Lexend-Regular.ttf",
11554
+ bold: "Lexend-Bold.ttf",
11555
+ light: "Lexend-Light.ttf",
11556
+ medium: "Lexend-Medium.ttf",
11557
+ semibold: "Lexend-SemiBold.ttf"
11558
+ },
11559
+ "Albert Sans": {
11560
+ regular: "AlbertSans-Regular.ttf",
11561
+ bold: "AlbertSans-Bold.ttf",
11562
+ light: "AlbertSans-Light.ttf",
11563
+ medium: "AlbertSans-Medium.ttf",
11564
+ semibold: "AlbertSans-SemiBold.ttf",
11565
+ italic: "AlbertSans-RegularItalic.ttf",
11566
+ boldItalic: "AlbertSans-BoldItalic.ttf",
11567
+ lightItalic: "AlbertSans-LightItalic.ttf",
11568
+ mediumItalic: "AlbertSans-MediumItalic.ttf",
11569
+ semiboldItalic: "AlbertSans-SemiBoldItalic.ttf"
11570
+ },
11571
+ "Noto Sans": {
11572
+ regular: "NotoSans-Regular.ttf",
11573
+ bold: "NotoSans-Bold.ttf",
11574
+ light: "NotoSans-Light.ttf",
11575
+ medium: "NotoSans-Medium.ttf",
11576
+ semibold: "NotoSans-SemiBold.ttf",
11577
+ italic: "NotoSans-RegularItalic.ttf",
11578
+ boldItalic: "NotoSans-BoldItalic.ttf",
11579
+ lightItalic: "NotoSans-LightItalic.ttf",
11580
+ mediumItalic: "NotoSans-MediumItalic.ttf",
11581
+ semiboldItalic: "NotoSans-SemiBoldItalic.ttf"
11582
+ },
11583
+ "Cabin": {
11584
+ regular: "Cabin-Regular.ttf",
11585
+ bold: "Cabin-Bold.ttf",
11586
+ medium: "Cabin-Medium.ttf",
11587
+ semibold: "Cabin-SemiBold.ttf",
11588
+ italic: "Cabin-RegularItalic.ttf",
11589
+ boldItalic: "Cabin-BoldItalic.ttf",
11590
+ mediumItalic: "Cabin-MediumItalic.ttf",
11591
+ semiboldItalic: "Cabin-SemiBoldItalic.ttf"
11592
+ },
11593
+ "Barlow": {
11594
+ regular: "Barlow-Regular.ttf",
11595
+ bold: "Barlow-Bold.ttf",
11596
+ light: "Barlow-Light.ttf",
11597
+ medium: "Barlow-Medium.ttf",
11598
+ semibold: "Barlow-SemiBold.ttf",
11599
+ italic: "Barlow-Italic.ttf",
11600
+ boldItalic: "Barlow-BoldItalic.ttf"
11601
+ },
11602
+ "Josefin Sans": {
11603
+ regular: "JosefinSans-Regular.ttf",
11604
+ bold: "JosefinSans-Bold.ttf",
11605
+ light: "JosefinSans-Light.ttf",
11606
+ medium: "JosefinSans-Medium.ttf",
11607
+ semibold: "JosefinSans-SemiBold.ttf",
11608
+ italic: "JosefinSans-RegularItalic.ttf",
11609
+ boldItalic: "JosefinSans-BoldItalic.ttf",
11610
+ lightItalic: "JosefinSans-LightItalic.ttf",
11611
+ mediumItalic: "JosefinSans-MediumItalic.ttf",
11612
+ semiboldItalic: "JosefinSans-SemiBoldItalic.ttf"
11613
+ },
11614
+ "Archivo": {
11615
+ regular: "Archivo-Regular.ttf",
11616
+ bold: "Archivo-Bold.ttf",
11617
+ light: "Archivo-Light.ttf",
11618
+ medium: "Archivo-Medium.ttf",
11619
+ semibold: "Archivo-SemiBold.ttf",
11620
+ italic: "Archivo-RegularItalic.ttf",
11621
+ boldItalic: "Archivo-BoldItalic.ttf",
11622
+ lightItalic: "Archivo-LightItalic.ttf",
11623
+ mediumItalic: "Archivo-MediumItalic.ttf",
11624
+ semiboldItalic: "Archivo-SemiBoldItalic.ttf"
11625
+ },
11626
+ "Overpass": {
11627
+ regular: "Overpass-Regular.ttf",
11628
+ bold: "Overpass-Bold.ttf",
11629
+ light: "Overpass-Light.ttf",
11630
+ medium: "Overpass-Medium.ttf",
11631
+ semibold: "Overpass-SemiBold.ttf",
11632
+ italic: "Overpass-RegularItalic.ttf",
11633
+ boldItalic: "Overpass-BoldItalic.ttf",
11634
+ lightItalic: "Overpass-LightItalic.ttf",
11635
+ mediumItalic: "Overpass-MediumItalic.ttf",
11636
+ semiboldItalic: "Overpass-SemiBoldItalic.ttf"
11637
+ },
11638
+ "Exo 2": {
11639
+ regular: "Exo2-Regular.ttf",
11640
+ bold: "Exo2-Bold.ttf",
11641
+ light: "Exo2-Light.ttf",
11642
+ medium: "Exo2-Medium.ttf",
11643
+ semibold: "Exo2-SemiBold.ttf",
11644
+ italic: "Exo2-RegularItalic.ttf",
11645
+ boldItalic: "Exo2-BoldItalic.ttf",
11646
+ lightItalic: "Exo2-LightItalic.ttf",
11647
+ mediumItalic: "Exo2-MediumItalic.ttf",
11648
+ semiboldItalic: "Exo2-SemiBoldItalic.ttf"
11649
+ },
11650
+ "Roboto Mono": {
11651
+ regular: "RobotoMono-Regular.ttf",
11652
+ bold: "RobotoMono-Bold.ttf",
11653
+ light: "RobotoMono-Light.ttf",
11654
+ medium: "RobotoMono-Medium.ttf",
11655
+ semibold: "RobotoMono-SemiBold.ttf",
11656
+ italic: "RobotoMono-RegularItalic.ttf",
11657
+ boldItalic: "RobotoMono-BoldItalic.ttf",
11658
+ lightItalic: "RobotoMono-LightItalic.ttf",
11659
+ mediumItalic: "RobotoMono-MediumItalic.ttf",
11660
+ semiboldItalic: "RobotoMono-SemiBoldItalic.ttf"
11661
+ },
11662
+ "Fira Code": {
11663
+ regular: "FiraCode-Regular.ttf",
11664
+ bold: "FiraCode-Bold.ttf",
11665
+ light: "FiraCode-Light.ttf",
11666
+ medium: "FiraCode-Medium.ttf",
11667
+ semibold: "FiraCode-SemiBold.ttf"
11668
+ },
11669
+ "JetBrains Mono": {
11670
+ regular: "JetBrainsMono-Regular.ttf",
11671
+ bold: "JetBrainsMono-Bold.ttf",
11672
+ light: "JetBrainsMono-Light.ttf",
11673
+ medium: "JetBrainsMono-Medium.ttf",
11674
+ semibold: "JetBrainsMono-SemiBold.ttf",
11675
+ italic: "JetBrainsMono-RegularItalic.ttf",
11676
+ boldItalic: "JetBrainsMono-BoldItalic.ttf",
11677
+ lightItalic: "JetBrainsMono-LightItalic.ttf",
11678
+ mediumItalic: "JetBrainsMono-MediumItalic.ttf",
11679
+ semiboldItalic: "JetBrainsMono-SemiBoldItalic.ttf"
11680
+ },
11681
+ "Source Code Pro": {
11682
+ regular: "SourceCodePro-Regular.ttf",
11683
+ bold: "SourceCodePro-Bold.ttf",
11684
+ light: "SourceCodePro-Light.ttf",
11685
+ medium: "SourceCodePro-Medium.ttf",
11686
+ semibold: "SourceCodePro-SemiBold.ttf",
11687
+ italic: "SourceCodePro-RegularItalic.ttf",
11688
+ boldItalic: "SourceCodePro-BoldItalic.ttf",
11689
+ lightItalic: "SourceCodePro-LightItalic.ttf",
11690
+ mediumItalic: "SourceCodePro-MediumItalic.ttf",
11691
+ semiboldItalic: "SourceCodePro-SemiBoldItalic.ttf"
11692
+ },
11693
+ "IBM Plex Mono": {
11694
+ regular: "IBMPlexMono-Regular.ttf",
11695
+ bold: "IBMPlexMono-Bold.ttf"
11696
+ },
11697
+ "Space Mono": {
11698
+ regular: "SpaceMono-Regular.ttf",
11699
+ bold: "SpaceMono-Bold.ttf",
11700
+ italic: "SpaceMono-Italic.ttf",
11701
+ boldItalic: "SpaceMono-BoldItalic.ttf"
11702
+ },
11703
+ "Sacramento": { regular: "Sacramento-Regular.ttf" },
11704
+ "Alex Brush": { regular: "AlexBrush-Regular.ttf" },
11705
+ "Allura": { regular: "Allura-Regular.ttf" },
11706
+ "Caveat": {
11707
+ regular: "Caveat-Regular.ttf",
11708
+ bold: "Caveat-Bold.ttf",
11709
+ medium: "Caveat-Medium.ttf",
11710
+ semibold: "Caveat-SemiBold.ttf"
11711
+ },
11712
+ "Lobster": { regular: "Lobster-Regular.ttf" },
11713
+ "Comfortaa": {
11714
+ regular: "Comfortaa-Regular.ttf",
11715
+ bold: "Comfortaa-Bold.ttf",
11716
+ light: "Comfortaa-Light.ttf",
11717
+ medium: "Comfortaa-Medium.ttf",
11718
+ semibold: "Comfortaa-SemiBold.ttf"
11719
+ },
11720
+ "Anton": { regular: "Anton-Regular.ttf" },
11721
+ "Teko": {
11722
+ regular: "Teko-Regular.ttf",
11723
+ bold: "Teko-Bold.ttf",
11724
+ light: "Teko-Light.ttf",
11725
+ medium: "Teko-Medium.ttf",
11726
+ semibold: "Teko-SemiBold.ttf"
11727
+ },
11728
+ "Noto Sans Devanagari": {
11729
+ regular: "NotoSansDevanagari-Regular.ttf",
11730
+ bold: "NotoSansDevanagari-Bold.ttf",
11731
+ light: "NotoSansDevanagari-Light.ttf",
11732
+ medium: "NotoSansDevanagari-Medium.ttf",
11733
+ semibold: "NotoSansDevanagari-SemiBold.ttf"
11734
+ },
11735
+ "Hind": {
11736
+ regular: "Hind-Regular.ttf",
11737
+ bold: "Hind-Bold.ttf",
11738
+ light: "Hind-Light.ttf",
11739
+ medium: "Hind-Medium.ttf",
11740
+ semibold: "Hind-SemiBold.ttf"
11741
+ },
11742
+ "Cinzel": { regular: "Cinzel-Regular.ttf", bold: "Cinzel-Bold.ttf" },
11743
+ "Cormorant Garamond": {
11744
+ regular: "CormorantGaramond-Regular.ttf",
11745
+ bold: "CormorantGaramond-Bold.ttf",
11746
+ light: "CormorantGaramond-Light.ttf",
11747
+ medium: "CormorantGaramond-Medium.ttf",
11748
+ semibold: "CormorantGaramond-SemiBold.ttf",
11749
+ italic: "CormorantGaramond-Italic.ttf",
11750
+ boldItalic: "CormorantGaramond-BoldItalic.ttf"
11751
+ }
11752
+ };
11753
+ const WEIGHT_TO_KEYS = {
11754
+ 300: ["light", "regular"],
11755
+ 400: ["regular"],
11756
+ 500: ["medium", "regular"],
11757
+ 600: ["semibold", "bold", "regular"],
11758
+ 700: ["bold", "regular"]
11759
+ };
11760
+ const WEIGHT_TO_ITALIC_KEYS = {
11761
+ 300: ["lightItalic", "italic", "light", "regular"],
11762
+ 400: ["italic", "regular"],
11763
+ 500: ["mediumItalic", "italic", "medium", "regular"],
11764
+ 600: ["semiboldItalic", "boldItalic", "italic", "semibold", "bold", "regular"],
11765
+ 700: ["boldItalic", "italic", "bold", "regular"]
11766
+ };
11767
+ function getFontPathForWeight(files, weight, isItalic = false) {
11768
+ const keys = isItalic ? WEIGHT_TO_ITALIC_KEYS[weight] : WEIGHT_TO_KEYS[weight];
11769
+ if (!keys) return files.regular;
11770
+ for (const k of keys) {
11771
+ const path = files[k];
11772
+ if (path) return path;
11773
+ }
11774
+ return files.regular;
11775
+ }
11776
+ function isItalicPath(files, path) {
11777
+ return path === files.italic || path === files.boldItalic || path === files.lightItalic || path === files.mediumItalic || path === files.semiboldItalic;
11778
+ }
11779
+ function getJsPDFFontName(fontName) {
11780
+ return fontName.replace(/\s+/g, "");
11781
+ }
11782
+ function getEmbeddedJsPDFFontName(fontName, weight, isItalic = false) {
11783
+ const resolved = resolveFontWeight(weight);
11784
+ const label = FONT_WEIGHT_LABELS[resolved];
11785
+ const italicSuffix = isItalic ? "Italic" : "";
11786
+ return `${getJsPDFFontName(fontName)}-${label}${italicSuffix}`;
11787
+ }
11788
+ function isFontAvailable(fontName) {
11789
+ return fontName in FONT_FILES;
11790
+ }
11791
+ const ttfCache = /* @__PURE__ */ new Map();
11792
+ async function fetchTTFAsBase64(url) {
11793
+ const cached = ttfCache.get(url);
11794
+ if (cached) return cached;
11795
+ try {
11796
+ const res = await fetch(url);
11797
+ if (!res.ok) return null;
11798
+ const buf = await res.arrayBuffer();
11799
+ const bytes = new Uint8Array(buf);
11800
+ let binary = "";
11801
+ for (let i = 0; i < bytes.length; i++) {
11802
+ binary += String.fromCharCode(bytes[i]);
11803
+ }
11804
+ const b64 = btoa(binary);
11805
+ ttfCache.set(url, b64);
11806
+ return b64;
11807
+ } catch {
11808
+ return null;
11809
+ }
11810
+ }
11811
+ async function embedFont(pdf, fontName, weight, fontBaseUrl, isItalic = false) {
11812
+ const fontFiles = FONT_FILES[fontName];
11813
+ if (!fontFiles) return false;
11814
+ const baseUrl = fontBaseUrl.endsWith("/") ? fontBaseUrl : fontBaseUrl + "/";
11815
+ const resolvedWeight = resolveFontWeight(weight);
11816
+ const fontPath = getFontPathForWeight(fontFiles, resolvedWeight, isItalic);
11817
+ if (!fontPath) return false;
11818
+ const hasItalicFile = isItalic && isItalicPath(fontFiles, fontPath);
11819
+ const jsPdfFontName = getEmbeddedJsPDFFontName(fontName, weight, hasItalicFile);
11820
+ const label = FONT_WEIGHT_LABELS[resolvedWeight];
11821
+ const italicSuffix = hasItalicFile ? "Italic" : "";
11822
+ const fileName = `${getJsPDFFontName(fontName)}-${label}${italicSuffix}.ttf`;
11823
+ const url = baseUrl + fontPath;
11824
+ try {
11825
+ const b64 = await fetchTTFAsBase64(url);
11826
+ if (!b64) return false;
11827
+ pdf.addFileToVFS(fileName, b64);
11828
+ pdf.addFont(fileName, jsPdfFontName, "normal");
11829
+ if (fontName !== jsPdfFontName) {
11830
+ try {
11831
+ pdf.addFont(fileName, fontName, "normal");
11832
+ } catch {
11833
+ }
11834
+ }
11835
+ return true;
11836
+ } catch (e) {
11837
+ console.warn(`[pdf-fonts] Failed to embed ${fontName} w${weight}:`, e);
11838
+ return false;
11839
+ }
11840
+ }
11841
+ async function embedFontsForConfig(pdf, config, fontBaseUrl) {
11842
+ const fontKeys = /* @__PURE__ */ new Set();
11843
+ const SEP = "";
11844
+ const walkElements = (elements) => {
11845
+ for (const el of elements) {
11846
+ if (el.fontFamily) {
11847
+ const w = resolveFontWeight(el.fontWeight ?? 400);
11848
+ fontKeys.add(`${el.fontFamily}${SEP}${w}`);
11849
+ }
11850
+ if (el.styles && typeof el.styles === "object") {
11851
+ for (const lineKey of Object.keys(el.styles)) {
11852
+ const lineStyles = el.styles[lineKey];
11853
+ if (lineStyles && typeof lineStyles === "object") {
11854
+ for (const charKey of Object.keys(lineStyles)) {
11855
+ const s = lineStyles[charKey];
11856
+ if (s == null ? void 0 : s.fontFamily) {
11857
+ const w = resolveFontWeight(s.fontWeight ?? 400);
11858
+ fontKeys.add(`${s.fontFamily}${SEP}${w}`);
11859
+ }
11860
+ }
11861
+ }
11862
+ }
11863
+ }
11864
+ if (el.children) walkElements(el.children);
11865
+ if (el.objects) walkElements(el.objects);
11866
+ }
11867
+ };
11868
+ for (const page of (config == null ? void 0 : config.pages) || []) {
11869
+ if (page.children) walkElements(page.children);
11870
+ if (page.elements) walkElements(page.elements);
11871
+ }
11872
+ fontKeys.add(`${FONT_FALLBACK_SYMBOLS}${SEP}400`);
11873
+ for (const w of [300, 400, 500, 600, 700]) {
11874
+ fontKeys.add(`${FONT_FALLBACK_DEVANAGARI}${SEP}${w}`);
11875
+ }
11876
+ const embedded = /* @__PURE__ */ new Set();
11877
+ const tasks = [];
11878
+ for (const key of fontKeys) {
11879
+ const sep = key.indexOf(SEP);
11880
+ const fontName = key.slice(0, sep);
11881
+ const weight = parseInt(key.slice(sep + 1), 10);
11882
+ if (!isFontAvailable(fontName)) continue;
11883
+ tasks.push(
11884
+ embedFont(pdf, fontName, weight, fontBaseUrl).then((ok) => {
11885
+ if (ok) embedded.add(key);
11886
+ })
11887
+ );
11888
+ }
11889
+ await Promise.all(tasks);
11890
+ console.log(`[pdf-fonts] Embedded ${embedded.size} font variants from config`);
11891
+ return embedded;
11892
+ }
11893
+ function rewriteSvgFontsForJsPDF(svgStr) {
11894
+ var _a;
11895
+ const parser = new DOMParser();
11896
+ const doc = parser.parseFromString(svgStr, "image/svg+xml");
11897
+ const textEls = doc.querySelectorAll("text, tspan, textPath");
11898
+ const readStyleToken = (style, prop) => {
11899
+ var _a2;
11900
+ const match = style.match(new RegExp(`${prop}\\s*:\\s*([^;]+)`, "i"));
11901
+ return ((_a2 = match == null ? void 0 : match[1]) == null ? void 0 : _a2.trim()) || null;
11902
+ };
11903
+ const resolveInheritedValue = (el, attr, styleProp = attr) => {
11904
+ var _a2;
11905
+ let current = el;
11906
+ while (current) {
11907
+ const attrVal = (_a2 = current.getAttribute(attr)) == null ? void 0 : _a2.trim();
11908
+ if (attrVal) return attrVal;
11909
+ const styleVal = readStyleToken(current.getAttribute("style") || "", styleProp);
11910
+ if (styleVal) return styleVal;
11911
+ current = current.parentElement;
11912
+ }
11913
+ return null;
11914
+ };
11915
+ for (const el of textEls) {
11916
+ const inlineStyle = el.getAttribute("style") || "";
11917
+ const rawFf = resolveInheritedValue(el, "font-family");
11918
+ if (!rawFf) continue;
11919
+ const clean = (_a = rawFf.split(",")[0]) == null ? void 0 : _a.replace(/['"]/g, "").trim();
11920
+ if (!isFontAvailable(clean)) continue;
11921
+ const weightRaw = resolveInheritedValue(el, "font-weight") || "400";
11922
+ const styleRaw = resolveInheritedValue(el, "font-style") || "normal";
11923
+ const parsedWeight = Number.parseInt(weightRaw, 10);
11924
+ const weight = Number.isFinite(parsedWeight) ? parsedWeight : /bold/i.test(weightRaw) ? 700 : /medium/i.test(weightRaw) ? 500 : /semi/i.test(weightRaw) ? 600 : /light/i.test(weightRaw) ? 300 : 400;
11925
+ const resolved = resolveFontWeight(weight);
11926
+ const isItalic = /italic|oblique/i.test(styleRaw);
11927
+ const jsPdfName = getEmbeddedJsPDFFontName(clean, resolved, isItalic);
11928
+ el.setAttribute("font-family", jsPdfName);
11929
+ el.setAttribute("font-weight", "normal");
11930
+ el.setAttribute("font-style", "normal");
11931
+ const stylePairs = inlineStyle.split(";").map((part) => part.trim()).filter(Boolean).filter((part) => !/^font-family\s*:/i.test(part) && !/^font-weight\s*:/i.test(part) && !/^font-style\s*:/i.test(part));
11932
+ stylePairs.push(`font-family: ${jsPdfName}`);
11933
+ stylePairs.push(`font-weight: normal`);
11934
+ stylePairs.push(`font-style: normal`);
11935
+ el.setAttribute("style", stylePairs.join("; "));
11936
+ }
11937
+ return new XMLSerializer().serializeToString(doc.documentElement);
11938
+ }
11939
+ function extractFontFamiliesFromSvgs(svgs) {
11940
+ const families = /* @__PURE__ */ new Set();
11941
+ const regex = /font-family[=:]\s*["']?([^"';},]+)/gi;
11942
+ for (const svg of svgs) {
11943
+ let m;
11944
+ while ((m = regex.exec(svg)) !== null) {
11945
+ const raw = m[1].trim().split(",")[0].trim().replace(/^['"]|['"]$/g, "");
11946
+ if (raw && raw !== "serif" && raw !== "sans-serif" && raw !== "monospace") {
11947
+ families.add(raw);
11948
+ }
11949
+ }
11950
+ }
11951
+ return families;
11952
+ }
11953
+ async function embedFontsInPdf(pdf, fontFamilies, fontBaseUrl) {
11954
+ const embedded = /* @__PURE__ */ new Set();
11955
+ const weights = [300, 400, 500, 600, 700];
11956
+ const tasks = [];
11957
+ for (const family of fontFamilies) {
11958
+ if (!isFontAvailable(family)) {
11959
+ console.warn(`[pdf-fonts] No TTF mapping for "${family}" — will use Helvetica fallback`);
11960
+ continue;
11961
+ }
11962
+ for (const w of weights) {
11963
+ tasks.push(
11964
+ embedFont(pdf, family, w, fontBaseUrl).then((ok) => {
11965
+ if (ok) embedded.add(`${family}${w}`);
11966
+ })
11967
+ );
11968
+ }
11969
+ }
11970
+ await Promise.all(tasks);
11971
+ console.log(`[pdf-fonts] Embedded ${embedded.size} font variants for ${fontFamilies.size} families`);
11972
+ return embedded;
11973
+ }
11974
+ const pdfFonts = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
11975
+ __proto__: null,
11976
+ FONT_FALLBACK_DEVANAGARI,
11977
+ FONT_FALLBACK_SYMBOLS,
11978
+ FONT_FILES,
11979
+ FONT_WEIGHT_LABELS,
11980
+ embedFont,
11981
+ embedFontsForConfig,
11982
+ embedFontsInPdf,
11983
+ extractFontFamiliesFromSvgs,
11984
+ getEmbeddedJsPDFFontName,
11985
+ isFontAvailable,
11986
+ resolveFontWeight,
11987
+ rewriteSvgFontsForJsPDF
11988
+ }, Symbol.toStringTag, { value: "Module" }));
11255
11989
  const SVG_DRAWABLE_TAGS = /* @__PURE__ */ new Set([
11256
11990
  "path",
11257
11991
  "rect",
@@ -11513,8 +12247,9 @@ function inlineSvgStyleBlockDeclarations(svg) {
11513
12247
  });
11514
12248
  });
11515
12249
  const normalizePresentationValue = (key, value) => {
11516
- if (["fill", "stroke", "clip-path", "mask", "filter"].includes(key)) return normalizeGradientPaintRef(value);
11517
- return value;
12250
+ const cleaned = value.replace(/\s*!important\s*$/i, "").trim();
12251
+ if (["fill", "stroke", "clip-path", "mask", "filter"].includes(key)) return normalizeGradientPaintRef(cleaned);
12252
+ return cleaned;
11518
12253
  };
11519
12254
  const applyDeclarations = (elements, declarations) => {
11520
12255
  for (const el of elements) {
@@ -11980,6 +12715,14 @@ function inlineComputedStyles(svg) {
11980
12715
  if (wrap.parentNode) document.body.removeChild(wrap);
11981
12716
  }
11982
12717
  }
12718
+ function disambiguateNestedSvgIds(rootSvg) {
12719
+ const nestedSvgs = Array.from(rootSvg.querySelectorAll("svg"));
12720
+ const toProcess = nestedSvgs.filter((s) => s !== rootSvg);
12721
+ if (toProcess.length < 2) return;
12722
+ toProcess.forEach((nested, idx) => {
12723
+ prefixSvgIds(nested, `n${idx}`);
12724
+ });
12725
+ }
11983
12726
  function prefixSvgIds(svg, prefix) {
11984
12727
  const safePrefix = String(prefix).replace(/[^a-zA-Z0-9-]/g, "_");
11985
12728
  const idMap = /* @__PURE__ */ new Map();
@@ -12131,6 +12874,63 @@ async function svg2pdfWithDomMount(svg, pdf, opts) {
12131
12874
  if (wrap.parentNode) document.body.removeChild(wrap);
12132
12875
  }
12133
12876
  }
12877
+ function convertTextDecorationsToLines(svg) {
12878
+ const doc = svg.ownerDocument;
12879
+ if (!doc) return;
12880
+ let measureCanvas = null;
12881
+ let ctx = null;
12882
+ try {
12883
+ measureCanvas = doc.createElement("canvas");
12884
+ ctx = measureCanvas.getContext("2d");
12885
+ } catch {
12886
+ }
12887
+ const textEls = Array.from(svg.querySelectorAll("text"));
12888
+ for (const textEl of textEls) {
12889
+ const tspans = Array.from(textEl.querySelectorAll("tspan"));
12890
+ if (tspans.length === 0) continue;
12891
+ const textDecOnText = (textEl.getAttribute("text-decoration") || "").toLowerCase();
12892
+ const textStyleDec = (getInlineStyleValue(textEl, "text-decoration") || "").toLowerCase();
12893
+ const textHasUnderline = textDecOnText.includes("underline") || textStyleDec.includes("underline");
12894
+ for (const tspan of tspans) {
12895
+ const tspanDec = (tspan.getAttribute("text-decoration") || "").toLowerCase();
12896
+ const tspanStyleDec = (getInlineStyleValue(tspan, "text-decoration") || "").toLowerCase();
12897
+ const hasUnderline = tspanDec.includes("underline") || tspanStyleDec.includes("underline") || textHasUnderline;
12898
+ if (!hasUnderline) continue;
12899
+ const content = tspan.textContent || "";
12900
+ if (!content.trim()) continue;
12901
+ const xAttr = tspan.getAttribute("x") ?? textEl.getAttribute("x") ?? "0";
12902
+ const yAttr = tspan.getAttribute("y") ?? textEl.getAttribute("y") ?? "0";
12903
+ const x = parseFloat(xAttr) || 0;
12904
+ const y = parseFloat(yAttr) || 0;
12905
+ const fontSize = parseFloat(
12906
+ tspan.getAttribute("font-size") || textEl.getAttribute("font-size") || "16"
12907
+ );
12908
+ const fontFamily = tspan.getAttribute("font-family") || textEl.getAttribute("font-family") || "sans-serif";
12909
+ const fontWeight = tspan.getAttribute("font-weight") || textEl.getAttribute("font-weight") || "normal";
12910
+ const fill = tspan.getAttribute("fill") || textEl.getAttribute("fill") || "#000000";
12911
+ let textWidth;
12912
+ if (ctx) {
12913
+ ctx.font = `${fontWeight} ${fontSize}px ${fontFamily.replace(/'/g, "")}`;
12914
+ textWidth = ctx.measureText(content).width;
12915
+ } else {
12916
+ textWidth = content.length * fontSize * 0.6;
12917
+ }
12918
+ const underlineY = y + fontSize * 0.15;
12919
+ const thickness = Math.max(0.5, fontSize * 0.066667);
12920
+ const line = doc.createElementNS("http://www.w3.org/2000/svg", "line");
12921
+ line.setAttribute("x1", String(x));
12922
+ line.setAttribute("y1", String(underlineY));
12923
+ line.setAttribute("x2", String(x + textWidth));
12924
+ line.setAttribute("y2", String(underlineY));
12925
+ line.setAttribute("stroke", fill.startsWith("url(") ? "#000000" : fill);
12926
+ line.setAttribute("stroke-width", String(thickness));
12927
+ line.setAttribute("fill", "none");
12928
+ if (textEl.parentElement) {
12929
+ textEl.parentElement.insertBefore(line, textEl.nextSibling);
12930
+ }
12931
+ }
12932
+ }
12933
+ }
12134
12934
  function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey, options) {
12135
12935
  try {
12136
12936
  const parser = new DOMParser();
@@ -12154,11 +12954,13 @@ function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey, opti
12154
12954
  sanitizeSvgTreeForPdf(svgToDraw);
12155
12955
  normalizeSvgGradientStopOffsets(svgToDraw);
12156
12956
  expandSvgGradientHrefs(svgToDraw);
12957
+ disambiguateNestedSvgIds(svgToDraw);
12157
12958
  prefixSvgIds(svgToDraw, pageKey);
12158
12959
  bakeGroupOpacityIntoChildren(svgToDraw);
12159
12960
  stripSuspiciousFullPageOverlayNodes(svgToDraw);
12160
12961
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
12161
12962
  sanitizeSvgTreeForPdf(svgToDraw);
12963
+ convertTextDecorationsToLines(svgToDraw);
12162
12964
  return svgToDraw;
12163
12965
  } catch {
12164
12966
  return null;
@@ -12246,6 +13048,12 @@ async function assemblePdfFromSvgs(svgResults, options = {}) {
12246
13048
  compress: true
12247
13049
  });
12248
13050
  if (title) pdf.setProperties({ title, creator: "Pixldocs" });
13051
+ const fontBaseUrl = options.fontBaseUrl ?? (typeof window !== "undefined" ? window.location.origin + "/fonts/" : "/fonts/");
13052
+ const { extractFontFamiliesFromSvgs: extractFontFamiliesFromSvgs2 } = await Promise.resolve().then(() => pdfFonts);
13053
+ const fontFamilies = extractFontFamiliesFromSvgs2(svgResults.map((s) => s.svg));
13054
+ if (fontFamilies.size > 0) {
13055
+ await embedFontsInPdf(pdf, fontFamilies, fontBaseUrl);
13056
+ }
12249
13057
  for (let i = 0; i < svgResults.length; i++) {
12250
13058
  const page = svgResults[i];
12251
13059
  if (i > 0) {
@@ -12255,15 +13063,22 @@ async function assemblePdfFromSvgs(svgResults, options = {}) {
12255
13063
  const hasGradient = !!((_b = (_a = page.backgroundGradient) == null ? void 0 : _a.stops) == null ? void 0 : _b.length);
12256
13064
  drawPageBackground(pdf, i, page.width, page.height, page.backgroundColor, page.backgroundGradient);
12257
13065
  const shouldStripBg = stripPageBackground ?? hasGradient;
12258
- const svgToDraw = prepareLiveCanvasSvgForPdf(page.svg, page.width, page.height, `page-${i + 1}`, {
13066
+ let processedSvg = prepareLiveCanvasSvgForPdf(page.svg, page.width, page.height, `page-${i + 1}`, {
12259
13067
  stripPageBackground: shouldStripBg
12260
13068
  });
12261
- if (svgToDraw) {
13069
+ if (processedSvg) {
13070
+ const svgStr = new XMLSerializer().serializeToString(processedSvg);
13071
+ const rewrittenSvg = rewriteSvgFontsForJsPDF(svgStr);
13072
+ const reParser = new DOMParser();
13073
+ const reDoc = reParser.parseFromString(rewrittenSvg, "image/svg+xml");
13074
+ processedSvg = reDoc.documentElement;
13075
+ }
13076
+ if (processedSvg) {
12262
13077
  pdf.setFillColor(0, 0, 0);
12263
13078
  pdf.setDrawColor(0, 0, 0);
12264
13079
  pdf.saveGraphicsState();
12265
- setPdfColorFromSvg(pdf, svgToDraw);
12266
- await svg2pdfWithDomMount(svgToDraw, pdf, svg2pdfOpts(0, 0, page.width, page.height));
13080
+ setPdfColorFromSvg(pdf, processedSvg);
13081
+ await svg2pdfWithDomMount(processedSvg, pdf, svg2pdfOpts(0, 0, page.width, page.height));
12267
13082
  pdf.restoreGraphicsState();
12268
13083
  pdf.setFillColor(0, 0, 0);
12269
13084
  pdf.setDrawColor(0, 0, 0);
@@ -12358,6 +13173,9 @@ async function warmTemplateFromForm(options) {
12358
13173
  if (signal == null ? void 0 : signal.aborted) return;
12359
13174
  await warmResolvedTemplateForPreview(resolved.config, { signal, imageProxyUrl });
12360
13175
  }
13176
+ exports.FONT_FALLBACK_DEVANAGARI = FONT_FALLBACK_DEVANAGARI;
13177
+ exports.FONT_FALLBACK_SYMBOLS = FONT_FALLBACK_SYMBOLS;
13178
+ exports.FONT_FILES = FONT_FILES;
12361
13179
  exports.PixldocsPreview = PixldocsPreview;
12362
13180
  exports.PixldocsRenderer = PixldocsRenderer;
12363
13181
  exports.applyThemeToConfig = applyThemeToConfig;
@@ -12365,11 +13183,19 @@ exports.assemblePdfFromSvgs = assemblePdfFromSvgs;
12365
13183
  exports.collectFontDescriptorsFromConfig = collectFontDescriptorsFromConfig;
12366
13184
  exports.collectFontsFromConfig = collectFontsFromConfig;
12367
13185
  exports.collectImageUrls = collectImageUrls;
13186
+ exports.embedFont = embedFont;
13187
+ exports.embedFontsForConfig = embedFontsForConfig;
13188
+ exports.embedFontsInPdf = embedFontsInPdf;
12368
13189
  exports.ensureFontsForResolvedConfig = ensureFontsForResolvedConfig;
13190
+ exports.extractFontFamiliesFromSvgs = extractFontFamiliesFromSvgs;
13191
+ exports.getEmbeddedJsPDFFontName = getEmbeddedJsPDFFontName;
13192
+ exports.isFontAvailable = isFontAvailable;
12369
13193
  exports.loadGoogleFontCSS = loadGoogleFontCSS;
12370
13194
  exports.normalizeFontFamily = normalizeFontFamily;
13195
+ exports.resolveFontWeight = resolveFontWeight;
12371
13196
  exports.resolveFromForm = resolveFromForm;
12372
13197
  exports.resolveTemplateData = resolveTemplateData;
13198
+ exports.rewriteSvgFontsForJsPDF = rewriteSvgFontsForJsPDF;
12373
13199
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
12374
13200
  exports.warmTemplateFromForm = warmTemplateFromForm;
12375
13201
  //# sourceMappingURL=index.cjs.map