-
-
Notifications
You must be signed in to change notification settings - Fork 101
/
Copy pathscript.js
1304 lines (1171 loc) · 50.4 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import init, {
Pdf_HtmlToDocument,
Pdf_BytesToDocument,
Pdf_PageToSvg,
Pdf_DocumentToBytes,
Pdf_ResourcesForPage,
} from './pkg/printpdf.js';
await init(); // Initialize WASM
let pdfDocument = null; // Store the PdfDocument object
let currentTab = 'html-to-pdf';
let currentPageNumber = 1;
let images = {}; // Store uploaded images (filename => base64)
let fonts = {}; // Store uploaded fonts (filename => base64)
let signatureImageBase64 = null;
// HTML Examples
const htmlExamples = {
'ramen-recipe': `<!DOCTYPE html>
<html title="Japanese Ramen Recipe">
<head>
<style>
body { font-family: "NotoSansJP", sans-serif; padding: 20mm; }
h1, h2 { color: #D63031; }
.section { margin-bottom: 15mm; }
.ingredients { background: #FFF7E0; padding: 10px; border-radius: 5px; }
.steps { background: #F1F9FF; padding: 10px; border-radius: 5px; }
.tip { background: #E8FDF5; padding: 5px; border-radius: 3px; margin-top: 10px; }
img { border-radius: 5px; }
table { width: 100%; border-collapse: collapse; }
td, th { border: 1px solid #ddd; padding: 8px; }
th { background-color: #f2f2f2; }
</style>
<header exclude-pages="1">
<div style="text-align: right; color: #888; font-size: 10px;">
Japanese Cuisine Recipes - Page <page-number/>
</div>
<hr style="color: #ddd;">
</header>
<footer>
<hr style="color: #ddd;">
<div style="text-align: center; color: #888; font-size: 10px;">
© 2025 Japanese Cuisine Recipes Collection
</div>
</footer>
</head>
<body>
<div class="section">
<h1 style="text-align: center; font-size: 24px;">とんこつラーメン</h1>
<h2 style="text-align: center; font-size: 18px;">Tonkotsu Ramen</h2>
<div style="text-align: center; margin: 20px 0;">
<img src="ramen.png" style="width: 80%; max-width: 500px; height: auto;"></img>
</div>
<p style="text-align: center; font-style: italic;">
とんこつラーメンは、豚骨を長時間煮込んで作るクリーミーで濃厚なスープが特徴の日本の伝統的な麺料理です。
</p>
<p style="text-align: center; font-style: italic;">
Tonkotsu ramen is a traditional Japanese noodle dish featuring a creamy, rich soup made by simmering pork bones for many hours.
</p>
</div>
<div class="section ingredients">
<h2>材料 (4人分) / Ingredients (Serves 4)</h2>
<table>
<tr>
<th>日本語 / Japanese</th>
<th>英語 / English</th>
<th>量 / Amount</th>
</tr>
<tr>
<td>豚骨</td>
<td>Pork Bones</td>
<td>1.5 kg</td>
</tr>
<tr>
<td>ラーメン麺</td>
<td>Ramen Noodles</td>
<td>4 portions</td>
</tr>
<tr>
<td>チャーシュー</td>
<td>Chashu (Braised Pork Belly)</td>
<td>200g</td>
</tr>
<tr>
<td>味玉</td>
<td>Ajitama (Marinated Soft-Boiled Egg)</td>
<td>4</td>
</tr>
<tr>
<td>長ねぎ</td>
<td>Green Onions</td>
<td>2 stalks</td>
</tr>
<tr>
<td>もやし</td>
<td>Bean Sprouts</td>
<td>200g</td>
</tr>
<tr>
<td>にんにく</td>
<td>Garlic</td>
<td>4 cloves</td>
</tr>
<tr>
<td>生姜</td>
<td>Ginger</td>
<td>30g</td>
</tr>
<tr>
<td>醤油</td>
<td>Soy Sauce</td>
<td>100ml</td>
</tr>
<tr>
<td>みりん</td>
<td>Mirin</td>
<td>50ml</td>
</tr>
<tr>
<td>料理酒</td>
<td>Cooking Sake</td>
<td>50ml</td>
</tr>
</table>
</div>
<div class="section steps">
<h2>作り方 / Instructions</h2>
<ol>
<li>
<p><strong>豚骨スープを作る / Prepare the tonkotsu broth</strong></p>
<p>豚骨を水で洗い、冷水から鍋に入れて強火で沸騰させます。沸騰したら一度ゆで汁を捨て、豚骨を洗います。</p>
<p>Wash the pork bones, place them in a pot with cold water, and bring to a boil over high heat. Once boiling, discard the water and wash the bones.</p>
</li>
<li>
<p><strong>スープを煮込む / Simmer the broth</strong></p>
<p>豚骨と新しい水、にんにく、生姜を鍋に入れ、弱火で8〜12時間煮込みます。途中で水を足して適切な量を維持します。</p>
<p>Place the bones in the pot with fresh water, garlic, and ginger. Simmer on low heat for 8-12 hours, adding water as needed to maintain the proper level.</p>
</li>
<li>
<p><strong>タレを作る / Make the tare (seasoning base)</strong></p>
<p>醤油、みりん、料理酒を小鍋に入れて沸騰させ、アルコール分を飛ばします。</p>
<p>Combine soy sauce, mirin, and cooking sake in a small pot. Bring to a boil to cook off the alcohol.</p>
</li>
<li>
<p><strong>麺を茹でる / Cook the noodles</strong></p>
<p>ラーメン麺を袋の指示に従って茹でます。通常は2〜3分です。</p>
<p>Cook the ramen noodles according to package instructions, typically 2-3 minutes.</p>
</li>
<li>
<p><strong>ラーメンを組み立てる / Assemble the ramen</strong></p>
<p>丼にタレを入れ、スープを注ぎ、麺を入れます。その上にチャーシュー、味玉、長ねぎ、もやしをのせて完成です。</p>
<p>Place tare in a bowl, pour in the broth, and add the noodles. Top with chashu, ajitama, green onions, and bean sprouts to serve.</p>
</li>
</ol>
<div class="tip">
<p><strong>ヒント / Tip:</strong> 本格的な豚骨スープを作るには、最低でも8時間、できれば12時間煮込むことをお勧めします。豚骨から十分にコラーゲンとうま味を抽出するために必要です。</p>
<p>For authentic tonkotsu broth, simmer for at least 8 hours, preferably 12 hours. This is necessary to extract sufficient collagen and umami from the pork bones.</p>
</div>
</div>
</body>
</html>`,
'synthwave-gallery': `<!DOCTYPE html>
<html title="Synthwave Digital Art Gallery">
<head>
<style>
body {
background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
color: #fff;
font-family: 'Orbitron', sans-serif;
padding: 10mm;
}
h1, h2 {
color: #ff00cc;
text-shadow: 0 0 10px #ff00cc, 0 0 20px #ff00cc;
}
.gallery {
display: flex;
flex-wrap: wrap;
justify-content: space-around;
}
.gallery-item {
margin: 5mm;
background: rgba(0, 0, 0, 0.5);
border-radius: 5px;
overflow: hidden;
box-shadow: 0 0 20px rgba(255, 0, 204, 0.5);
transition: transform 0.3s;
width: 45%;
}
.gallery-item img {
width: 100%;
display: block;
}
.gallery-caption {
padding: 10px;
text-align: center;
background: rgba(0, 0, 0, 0.7);
}
.grid-container {
display: flex;
flex-wrap: wrap;
gap: 10px;
margin-top: 10mm;
}
.grid-item {
flex: 1;
min-width: 30%;
height: 80px;
background: linear-gradient(45deg, #fc00ff, #00dbde);
border-radius: 5px;
}
.intro {
border-left: 5px solid #ff00cc;
padding-left: 10px;
margin: 20px 0;
}
</style>
<header>
<div style="display: flex; justify-content: space-between; align-items: center;">
<div style="font-size: 12px; color: #00eeff;">DIGITAL ART COLLECTION</div>
<div style="font-size: 12px; color: #00eeff;">PAGE <page-number/></div>
</div>
<hr style="border-color: #ff00cc; height: 2px; background-color: #ff00cc; border: none;">
</header>
<footer>
<hr style="border-color: #00eeff; height: 1px; background-color: #00eeff; border: none;">
<div style="text-align: center; color: #00eeff; font-size: 10px;">
© 2025 SYNTHWAVE ARCHIVES
</div>
</footer>
</head>
<body>
<h1 style="text-align: center; font-size: 36px; letter-spacing: 5px;">SYNTHWAVE</h1>
<h2 style="text-align: center; font-size: 24px; letter-spacing: 3px;">DIGITAL ART COLLECTION</h2>
<div class="intro">
<p>Welcome to the definitive collection of synthwave and retrowave digital art. This gallery showcases the neon-soaked aesthetics of 80s-inspired futurism, featuring stunning works from the most innovative digital artists in the scene.</p>
</div>
<div class="gallery">
<div class="gallery-item">
<img src="neon_city.png" alt="Neon City"></img>
<div class="gallery-caption">
<h3>NEON CITY</h3>
<p>Digital artwork featuring a futuristic cityscape with glowing neon lights</p>
</div>
</div>
<div class="gallery-item">
<img src="cyber_sunset.png" alt="Cyber Sunset"></img>
<div class="gallery-caption">
<h3>CYBER SUNSET</h3>
<p>Retrowave sun setting over a digital grid landscape</p>
</div>
</div>
<div class="gallery-item">
<img src="digital_highway.png" alt="Digital Highway"></img>
<div class="gallery-caption">
<h3>DIGITAL HIGHWAY</h3>
<p>Endless road through a neon-lit digital universe</p>
</div>
</div>
<div class="gallery-item">
<img src="retro_arcade.png" alt="Retro Arcade"></img>
<div class="gallery-caption">
<h3>RETRO ARCADE</h3>
<p>80s-inspired gaming environment with classic arcade machines</p>
</div>
</div>
</div>
<h2 style="text-align: center; margin-top: 20mm;">COLOR PALETTES</h2>
<div class="grid-container">
<div class="grid-item" style="background: linear-gradient(45deg, #fc00ff, #00dbde);"></div>
<div class="grid-item" style="background: linear-gradient(45deg, #3f5efb, #fc466b);"></div>
<div class="grid-item" style="background: linear-gradient(45deg, #0072ff, #00c6ff);"></div>
<div class="grid-item" style="background: linear-gradient(45deg, #f953c6, #b91d73);"></div>
<div class="grid-item" style="background: linear-gradient(45deg, #7f00ff, #e100ff);"></div>
<div class="grid-item" style="background: linear-gradient(45deg, #ff0099, #493240);"></div>
</div>
<div style="margin-top: 15mm; text-align: center;">
<p>The synthwave aesthetic draws inspiration from 1980s pop culture, combining the visual elements of that era with modern digital art techniques. At its core are vibrant neon colors contrasted against dark backgrounds.</p>
</div>
<div style="page-break-before: always;">
<h2 style="text-align: center; margin-top: 10mm;">FEATURED TECHNIQUES</h2>
<div style="display: flex; justify-content: space-between; margin-top: 10mm;">
<div style="width: 48%;">
<img src="wireframe_technique.png" alt="Wireframe Technique" style="width: 100%;"></img>
<h3 style="color: #00eeff;">WIREFRAMES</h3>
<p>The use of simple wireframe models creates depth while maintaining the retro-digital aesthetic that defines synthwave art.</p>
</div>
<div style="width: 48%;">
<img src="scanline_technique.png" alt="Scanline Technique" style="width: 100%;"></img>
<h3 style="color: #00eeff;">SCANLINES</h3>
<p>Scanlines invoke the feel of vintage CRT monitors, adding an authentic retro quality to digital compositions.</p>
</div>
</div>
<div style="display: flex; justify-content: space-between; margin-top: 10mm;">
<div style="width: 48%;">
<img src="chrome_technique.png" alt="Chrome Technique" style="width: 100%;"></img>
<h3 style="color: #ff00cc;">CHROME EFFECTS</h3>
<p>Reflective chrome surfaces were a staple of 80s futurism, representing the sleek design aesthetics of the period.</p>
</div>
<div style="width: 48%;">
<img src="grid_technique.png" alt="Grid Technique" style="width: 100%;"></img>
<h3 style="color: #ff00cc;">GRID PERSPECTIVES</h3>
<p>Infinite grids extending to the horizon create the illusion of digital landscapes that stretch endlessly.</p>
</div>
</div>
</div>
</body>
</html>`,
'business-report': `<!DOCTYPE html>
<html title="Q1 2025 Financial Performance Report">
<head>
<style>
body {
font-family: 'Arial', sans-serif;
color: #333;
line-height: 1.5;
padding: 15mm;
}
h1 {
color: #1a5276;
border-bottom: 2px solid #1a5276;
padding-bottom: 5px;
}
h2 {
color: #2874a6;
margin-top: 15mm;
}
h3 {
color: #3498db;
}
.executive-summary {
background-color: #f8f9fa;
border-left: 5px solid #2874a6;
padding: 10px;
margin: 15px 0;
}
table {
width: 100%;
border-collapse: collapse;
margin: 15px 0;
}
th {
background-color: #1a5276;
color: white;
font-weight: bold;
text-align: left;
padding: 8px;
border: 1px solid #ddd;
}
td {
padding: 8px;
border: 1px solid #ddd;
}
tr:nth-child(even) {
background-color: #f2f2f2;
}
.highlight {
background-color: #e8f4f8;
padding: 5px;
border-radius: 3px;
}
.chart-container {
text-align: center;
margin: 20px 0;
}
.footer-note {
font-size: 10px;
color: #777;
font-style: italic;
text-align: center;
margin-top: 10mm;
}
.kpi-cards {
display: flex;
justify-content: space-between;
margin: 20px 0;
}
.kpi-card {
width: 30%;
padding: 15px;
border-radius: 5px;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
text-align: center;
}
.positive {
color: #27ae60;
font-weight: bold;
}
.negative {
color: #c0392b;
font-weight: bold;
}
.neutral {
color: #f39c12;
font-weight: bold;
}
</style>
<header exclude-pages="1">
<div style="display: flex; justify-content: space-between; align-items: center;">
<div>ACME Corporation</div>
<div>Q1 2025 Financial Report - Page <page-number/></div>
</div>
<hr>
</header>
<footer>
<hr>
<div style="display: flex; justify-content: space-between; align-items: center;">
<div>Confidential & Proprietary</div>
<div>© 2025 ACME Corporation</div>
</div>
</footer>
</head>
<body>
<div style="text-align: center; margin-bottom: 20mm;">
<h1 style="font-size: 24px; border: none;">ACME CORPORATION</h1>
<h2 style="font-size: 20px; margin-top: 5px;">Q1 2025 Financial Performance Report</h2>
<p style="font-style: italic;">Prepared for: Board of Directors and Shareholders</p>
<p>March 31, 2025</p>
</div>
<div class="executive-summary">
<h3>Executive Summary</h3>
<p>ACME Corporation delivered strong financial performance in Q1 2025, with revenue growth of 12.3% year-over-year, exceeding our forecast of 10%. Operating margins improved by 2.1 percentage points to 18.5%, driven by operational efficiencies and strategic pricing initiatives. Our Technology segment continues to be the primary growth driver, while the Consumer Products division showed signs of recovery after two challenging quarters.</p>
</div>
<h2>Key Performance Indicators</h2>
<div class="kpi-cards">
<div class="kpi-card" style="background-color: #e8f8f5;">
<h3>Revenue</h3>
<p style="font-size: 24px;">$287.5M</p>
<p class="positive">+12.3% YoY</p>
</div>
<div class="kpi-card" style="background-color: #fef9e7;">
<h3>Operating Margin</h3>
<p style="font-size: 24px;">18.5%</p>
<p class="positive">+2.1pts YoY</p>
</div>
<div class="kpi-card" style="background-color: #ebf5fb;">
<h3>Net Income</h3>
<p style="font-size: 24px;">$42.3M</p>
<p class="positive">+15.7% YoY</p>
</div>
</div>
<h2>Financial Performance by Segment</h2>
<table>
<tr>
<th>Business Unit</th>
<th>Revenue ($M)</th>
<th>YoY Growth</th>
<th>Operating Margin</th>
<th>YoY Change</th>
</tr>
<tr>
<td>Technology</td>
<td>143.2</td>
<td class="positive">+18.7%</td>
<td>24.3%</td>
<td class="positive">+3.2pts</td>
</tr>
<tr>
<td>Manufacturing</td>
<td>82.5</td>
<td class="positive">+8.4%</td>
<td>15.8%</td>
<td class="positive">+1.5pts</td>
</tr>
<tr>
<td>Consumer Products</td>
<td>45.3</td>
<td class="positive">+5.2%</td>
<td>12.1%</td>
<td class="positive">+0.8pts</td>
</tr>
<tr>
<td>Services</td>
<td>16.5</td>
<td class="neutral">+2.1%</td>
<td>14.5%</td>
<td class="negative">-0.5pts</td>
</tr>
</table>
<div class="chart-container">
<img src="revenue_chart.png" alt="Revenue by Segment" style="width: 80%; max-width: 600px;"></img>
<p style="font-size: 12px; color: #777;">Revenue distribution by business segment, Q1 2025</p>
</div>
<h2>Financial Statement Highlights</h2>
<h3>Income Statement</h3>
<table>
<tr>
<th>Metric ($M)</th>
<th>Q1 2025</th>
<th>Q1 2024</th>
<th>YoY Change</th>
</tr>
<tr>
<td>Revenue</td>
<td>287.5</td>
<td>256.0</td>
<td class="positive">+12.3%</td>
</tr>
<tr>
<td>Gross Profit</td>
<td>143.8</td>
<td>122.9</td>
<td class="positive">+17.0%</td>
</tr>
<tr>
<td>Operating Income</td>
<td>53.2</td>
<td>42.0</td>
<td class="positive">+26.7%</td>
</tr>
<tr>
<td>Net Income</td>
<td>42.3</td>
<td>36.6</td>
<td class="positive">+15.7%</td>
</tr>
<tr>
<td>EPS (Diluted)</td>
<td>$2.15</td>
<td>$1.87</td>
<td class="positive">+15.0%</td>
</tr>
</table>
<h3>Balance Sheet Highlights</h3>
<table>
<tr>
<th>Metric ($M)</th>
<th>Mar 31, 2025</th>
<th>Dec 31, 2024</th>
<th>Change</th>
</tr>
<tr>
<td>Cash & Equivalents</td>
<td>175.3</td>
<td>156.8</td>
<td class="positive">+11.8%</td>
</tr>
<tr>
<td>Total Assets</td>
<td>842.7</td>
<td>825.4</td>
<td class="positive">+2.1%</td>
</tr>
<tr>
<td>Total Debt</td>
<td>215.0</td>
<td>230.0</td>
<td class="positive">-6.5%</td>
</tr>
<tr>
<td>Shareholders' Equity</td>
<td>498.4</td>
<td>462.1</td>
<td class="positive">+7.9%</td>
</tr>
</table>
<div style="page-break-before: always;">
<h2>Market Analysis & Outlook</h2>
<p>The global market environment remains favorable for our core business segments, despite ongoing geopolitical uncertainties and supply chain challenges. Technology spending continues to show resilience, particularly in digital transformation initiatives and cloud migration projects, which aligns with our strategic focus areas.</p>
<div class="highlight">
<h3>Key Market Trends</h3>
<ul>
<li><strong>AI Integration:</strong> Increasing demand for AI-powered solutions across industries, particularly in process automation and analytics.</li>
<li><strong>Sustainability:</strong> Growing customer preference for eco-friendly products and services, creating new opportunities in our Manufacturing and Consumer Products segments.</li>
<li><strong>Digital Experience:</strong> Continued investment in enhanced digital experiences, benefiting our Technology and Services divisions.</li>
</ul>
</div>
<h3>FY 2025 Guidance</h3>
<table>
<tr>
<th>Metric</th>
<th>Previous Guidance</th>
<th>Updated Guidance</th>
</tr>
<tr>
<td>Revenue Growth</td>
<td>9-11%</td>
<td class="positive">10-12%</td>
</tr>
<tr>
<td>Operating Margin</td>
<td>17.5-18.5%</td>
<td class="positive">18.0-19.0%</td>
</tr>
<tr>
<td>EPS (Diluted)</td>
<td>$8.50-$8.75</td>
<td class="positive">$8.75-$9.00</td>
</tr>
<tr>
<td>Free Cash Flow ($M)</td>
<td>$130-$140</td>
<td class="positive">$140-$150</td>
</tr>
</table>
<h2>Strategic Initiatives Update</h2>
<h3>Digital Transformation Program</h3>
<p>Our enterprise-wide digital transformation initiative is progressing on schedule and within budget. Key achievements in Q1 include:</p>
<ul>
<li>Deployment of advanced analytics platform across 75% of business units, exceeding our target of 65%</li>
<li>Successful migration of core ERP modules to cloud infrastructure, reducing operational costs by approximately $3.2M annually</li>
<li>Launch of AI-powered customer service platform, improving response times by 35%</li>
</ul>
<h3>Product Innovation</h3>
<p>R&D investments continue to yield positive results, with several new product launches planned for Q2 and Q3. Our innovation pipeline remains strong, with 28 active development projects across all business segments.</p>
<div class="chart-container">
<img src="pipeline_chart.png" alt="Innovation Pipeline" style="width: 80%; max-width: 600px;"></img>
<p style="font-size: 12px; color: #777;">Innovation pipeline by development stage and business segment</p>
</div>
<div class="footer-note">
<p>This report contains forward-looking statements based on current expectations and projections about future events. These statements are subject to risks and uncertainties that could cause actual results to differ materially from those projected.</p>
</div>
</div>
</body>
</html>`
};
// Event listener for example selection
document.getElementById('html-examples').addEventListener('change', (event) => {
if (event.target.value) {
htmlEditorPre.textContent = htmlExamples[event.target.value];
updateLineNumbers(htmlEditorPre, htmlLineNumbersDiv);
updatePdfFromHtml();
}
});
const actionTabSelect = document.getElementById('action-tab');
const tabContents = {
'html-to-pdf': document.getElementById('html-to-pdf-tab'),
'parse-edit-pdf': document.getElementById('parse-edit-pdf-tab'),
'sign-pdf': document.getElementById('sign-pdf-tab'),
};
const htmlEditorPre = document.getElementById('html-editor');
const htmlLineNumbersDiv = document.querySelector('#html-to-pdf-tab .line-numbers');
const jsonEditorPre = document.getElementById('json-editor');
const jsonLineNumbersDiv = document.querySelector('#parse-edit-pdf-tab .line-numbers');
const pdfViewerDiv = document.getElementById('pdf-viewer');
const pageNumberInput = document.getElementById('page-number');
const prevPageButton = document.getElementById('prev-page');
const nextPageButton = document.getElementById('next-page');
const savePdfButton = document.getElementById('save-pdf');
const minimapViewDiv = document.getElementById('minimap-view');
const sidebarModeButtons = document.querySelectorAll('.sidebar-modes button');
const sidebarContents = {
'minimap': document.getElementById('minimap-view'),
'layers': document.getElementById('layers-view'),
'bookmarks': document.getElementById('bookmarks-view'),
};
const imageUploadInput = document.getElementById('image-upload');
const fontUploadInput = document.getElementById('font-upload');
const pdfFileUploadInput = document.getElementById('pdf-file-upload');
const signatureImageUploadInput = document.getElementById('signature-image-upload');
const pdfViewerErrorText = document.getElementById('pdf-viewer-error');
// Create resource previews container for parse tab
const parseResourcesContainer = document.createElement('div');
parseResourcesContainer.className = 'resources-container';
document.querySelector('#parse-edit-pdf-tab .controls').appendChild(parseResourcesContainer);
// Add config file upload input
const configFileInput = document.createElement('input');
configFileInput.type = 'file';
configFileInput.id = 'config-file-upload';
configFileInput.accept = '.json';
configFileInput.style.display = 'none';
document.body.appendChild(configFileInput);
document.getElementById('add-image-html').addEventListener('click', () => imageUploadInput.click());
document.getElementById('add-font-html').addEventListener('click', () => fontUploadInput.click());
document.getElementById('add-image-parse').addEventListener('click', () => imageUploadInput.click());
document.getElementById('add-font-parse').addEventListener('click', () => fontUploadInput.click());
document.getElementById('upload-pdf').addEventListener('click', () => pdfFileUploadInput.click());
document.getElementById('save-config').addEventListener('click', saveConfig);
document.getElementById('load-config').addEventListener('click', () => configFileInput.click());
sidebarModeButtons.forEach(button => {
button.addEventListener('click', () => {
sidebarModeButtons.forEach(btn => btn.classList.remove('active'));
button.classList.add('active');
const mode = button.dataset.mode;
Object.values(sidebarContents).forEach(content => content.classList.add('hidden'));
sidebarContents[mode].classList.remove('hidden');
});
});
actionTabSelect.addEventListener('change', (event) => {
currentTab = event.target.value;
Object.values(tabContents).forEach(content => content.classList.add('hidden'));
tabContents[currentTab].classList.remove('hidden');
if (currentTab === 'html-to-pdf') {
updatePdfFromHtml(); // Initial PDF generation on tab switch if needed
} else if (currentTab === 'parse-edit-pdf') {
updateResourcePreviews(parseResourcesContainer, true);
} else if (currentTab === 'sign-pdf') {
updatePdfViewer(); // Re-render to show signature if present
}
});
// Function to base64 encode files
const encodeFileToBase64 = (file, keep_mime) => {
return new Promise((resolve, reject) => {
const reader = new FileReader();
if (keep_mime === true) {
reader.onload = () => resolve(reader.result);
} else {
reader.onload = () => resolve(reader.result.split(',')[1]); // Remove data:base64 prefix
}
reader.onerror = reject;
reader.readAsDataURL(file);
});
};
imageUploadInput.addEventListener('change', async (event) => {
const file = event.target.files[0];
if (file) {
const base64 = await encodeFileToBase64(file);
images[file.name] = base64;
event.target.value = ''; // Reset input
if (currentTab === 'html-to-pdf') {
updateResourcePreviews(htmlResourcesContainer);
updatePdfFromHtml();
} else if (currentTab === 'parse-edit-pdf') {
updateResourcePreviews(parseResourcesContainer, true);
updatePdfFromJsonEditor();
}
}
});
fontUploadInput.addEventListener('change', async (event) => {
const file = event.target.files[0];
if (file) {
const base64 = await encodeFileToBase64(file);
fonts[file.name] = base64;
event.target.value = ''; // Reset input
if (currentTab === 'html-to-pdf') {
updateResourcePreviews(htmlResourcesContainer);
updatePdfFromHtml();
} else if (currentTab === 'parse-edit-pdf') {
updateResourcePreviews(parseResourcesContainer, true);
updatePdfFromJsonEditor();
}
}
});
pdfFileUploadInput.addEventListener('change', async (event) => {
const file = event.target.files[0];
if (!file) return;
const arrayBuffer = await file.arrayBuffer();
const base64Pdf = await bufferToBase64(new Uint8Array(arrayBuffer));
try {
const inputParse = { bytes: base64Pdf, options: {} };
const inputParseJson = JSON.stringify(inputParse);
const parseResultJson = await Pdf_BytesToDocument(inputParseJson);
const parseResult = JSON.parse(parseResultJson);
if (parseResult.status === 0) {
pdfDocument = parseResult.data.doc; // Changed from 'pdf' to 'doc'
for (let i = 0; i < parseResult.data.warnings.length; i++) {
console.warn(parseResult.data.warnings[i]);
}
jsonEditorPre.textContent = JSON.stringify(pdfDocument, null, 2); // Display JSON in editor
updateLineNumbers(jsonEditorPre, jsonLineNumbersDiv);
updateResourcePreviews(parseResourcesContainer, true);
updatePdfViewer();
} else {
alert2("PDF Parsing Error: " + parseResult.data);
}
} catch (error) {
alert2("Error parsing PDF: " + error);
} finally {
event.target.value = ''; // Reset input
}
});
configFileInput.addEventListener('change', async (event) => {
const file = event.target.files[0];
if (!file) return;
try {
const text = await file.text();
const config = JSON.parse(text);
// Load saved configuration
if (config.images) {
images = config.images;
}
if (config.fonts) {
fonts = config.fonts;
}
if (config.html) {
htmlEditorPre.textContent = config.html;
updateLineNumbers(htmlEditorPre, htmlLineNumbersDiv);
}
updateResourcePreviews(htmlResourcesContainer);
await updatePdfFromHtml();
} catch (error) {
alert2("Error loading configuration: " + error);
} finally {
event.target.value = ''; // Reset input
}
});
signatureImageUploadInput.addEventListener('change', async (event) => {
const file = event.target.files[0];
if (file) {
signatureImageBase64 = await encodeFileToBase64(file, true);
// Update PDF viewer immediately to preview signature
await updatePdfViewer();
}
});
// Update resource previews
function updateResourcePreviews(container, isParseTab = false) {
container.innerHTML = '';
// Create scrollable container
const scrollContainer = document.createElement('div');
scrollContainer.className = 'resources-scroll-container';
// Add images section
if (Object.keys(images).length > 0) {
const imagesSection = document.createElement('div');
imagesSection.className = 'resources-section';
imagesSection.innerHTML = '<h4>Images</h4>';
const imagesGrid = document.createElement('div');
imagesGrid.className = 'resources-grid';
Object.entries(images).forEach(([name, base64]) => {
const resourceItem = createResourceItem(name, `data:image/png;base64,${base64}`, 'image', isParseTab);
imagesGrid.appendChild(resourceItem);
});
imagesSection.appendChild(imagesGrid);
scrollContainer.appendChild(imagesSection);
}
// Add fonts section
if (Object.keys(fonts).length > 0) {
const fontsSection = document.createElement('div');
fontsSection.className = 'resources-section';
fontsSection.innerHTML = '<h4>Fonts</h4>';
const fontsGrid = document.createElement('div');
fontsGrid.className = 'resources-grid';
Object.entries(fonts).forEach(([name, base64]) => {
const resourceItem = createResourceItem(name, null, 'font', isParseTab);
fontsGrid.appendChild(resourceItem);
});
fontsSection.appendChild(fontsGrid);
scrollContainer.appendChild(fontsSection);
}
container.appendChild(scrollContainer);
}
function createResourceItem(name, src, type, isReadOnly = false) {
const resourceItem = document.createElement('div');
resourceItem.className = 'resource-item';
// Preview box
const preview = document.createElement('div');
preview.className = 'resource-preview';
if (type === 'image' && src) {
const img = document.createElement('img');
img.src = src;
img.alt = name;
preview.appendChild(img);
} else if (type === 'font') {
preview.textContent = 'Aa';
preview.className += ' font-preview';
}
// Name with truncation
const nameEl = document.createElement('div');
nameEl.className = 'resource-name';
nameEl.title = name; // Full name on hover
nameEl.textContent = name.length > 12 ? name.substring(0, 9) + '...' : name;
// Delete button (only for non-readonly)
if (!isReadOnly) {
const deleteBtn = document.createElement('button');
deleteBtn.className = 'resource-delete';
deleteBtn.innerHTML = '×';
deleteBtn.title = 'Remove resource';
deleteBtn.addEventListener('click', async () => {
if (type === 'image') {
delete images[name];
} else if (type === 'font') {
delete fonts[name];
}
// Update previews and re-render PDF
if (currentTab === 'html-to-pdf') {
updateResourcePreviews(htmlResourcesContainer);
await updatePdfFromHtml();
} else if (currentTab === 'parse-edit-pdf') {
updateResourcePreviews(parseResourcesContainer, true);
await updatePdfFromJsonEditor();
}
});
resourceItem.appendChild(deleteBtn);
}
resourceItem.appendChild(preview);
resourceItem.appendChild(nameEl);
return resourceItem;
}
// Function to update PDF viewer with SVGs from pdfDocument
async function updatePdfViewer() {
if (!pdfDocument) return;
pdfViewerDiv.innerHTML = ''; // Clear existing viewer
minimapViewDiv.innerHTML = ''; // Clear minimap
for (let i = 0; i < pdfDocument.pages.length; i++) {
const page = pdfDocument.pages[i];
try {
const resourcesInput = JSON.stringify({ page: page });
const resourcesJson = await Pdf_ResourcesForPage(resourcesInput);
const resourcesResult = JSON.parse(resourcesJson);
if (resourcesResult.status !== 0) {
console.error("Error getting resources for page:", resourcesResult.data);
continue; // Skip page rendering if resources fail
}
let res = pdfDocument.resources; // Use document resources directly
// Apply signature if in "Sign PDF" tab and on correct page
let modifiedPage = page;
if (signatureImageBase64 != null && currentTab === 'sign-pdf' && (i + 1) === parseInt(document.getElementById('signature-page').value)) {
const applied = applySignatureToPage(page, pdfDocument.resources);
modifiedPage = applied.data;
res = applied.resources;
resourcesResult.data.xobjects.push('user-signature-image');
}
const svgI = {
page: modifiedPage,
resources: copyResourcesForPage(res, resourcesResult.data),
options: { imageFormats: ["png", "jpeg"] } // Changed from image_formats to imageFormats
};
const svgInput = JSON.stringify(svgI);
const svgJson = await Pdf_PageToSvg(svgInput);