@@ -1607,6 +1607,55 @@ describe("annotation", function () {
1607
1607
} , done . fail ) ;
1608
1608
} ) ;
1609
1609
1610
+ it ( "should render regular text for printing using normal appearance" , function ( done ) {
1611
+ const textWidgetRef = Ref . get ( 271 , 0 ) ;
1612
+
1613
+ const appearanceStatesDict = new Dict ( ) ;
1614
+ const normalAppearanceDict = new Dict ( ) ;
1615
+
1616
+ const normalAppearanceStream = new StringStream ( "0.1 0.2 0.3 rg" ) ;
1617
+ normalAppearanceStream . dict = normalAppearanceDict ;
1618
+
1619
+ appearanceStatesDict . set ( "N" , normalAppearanceStream ) ;
1620
+ textWidgetDict . set ( "AP" , appearanceStatesDict ) ;
1621
+
1622
+ const xref = new XRefMock ( [
1623
+ { ref : textWidgetRef , data : textWidgetDict } ,
1624
+ fontRefObj ,
1625
+ ] ) ;
1626
+ const task = new WorkerTask ( "test print" ) ;
1627
+ partialEvaluator . xref = xref ;
1628
+
1629
+ AnnotationFactory . create (
1630
+ xref ,
1631
+ textWidgetRef ,
1632
+ pdfManagerMock ,
1633
+ idFactoryMock
1634
+ )
1635
+ . then ( annotation => {
1636
+ const annotationStorage = { } ;
1637
+ return annotation . getOperatorList (
1638
+ partialEvaluator ,
1639
+ task ,
1640
+ false ,
1641
+ annotationStorage
1642
+ ) ;
1643
+ } )
1644
+ . then ( opList => {
1645
+ expect ( opList . argsArray . length ) . toEqual ( 3 ) ;
1646
+ expect ( opList . fnArray ) . toEqual ( [
1647
+ OPS . beginAnnotation ,
1648
+ OPS . setFillRGBColor ,
1649
+ OPS . endAnnotation ,
1650
+ ] ) ;
1651
+ expect ( opList . argsArray [ 1 ] ) . toEqual (
1652
+ new Uint8ClampedArray ( [ 26 , 51 , 76 ] )
1653
+ ) ;
1654
+ done ( ) ;
1655
+ } )
1656
+ . catch ( done . fail ) ;
1657
+ } ) ;
1658
+
1610
1659
it ( "should render auto-sized text for printing" , function ( done ) {
1611
1660
textWidgetDict . set ( "DA" , "/Helv 0 Tf" ) ;
1612
1661
@@ -2045,6 +2094,64 @@ describe("annotation", function () {
2045
2094
} , done . fail ) ;
2046
2095
} ) ;
2047
2096
2097
+ it ( "should render checkboxes for printing using normal appearance" , function ( done ) {
2098
+ const appearanceStatesDict = new Dict ( ) ;
2099
+ const normalAppearanceDict = new Dict ( ) ;
2100
+ const checkedAppearanceDict = new Dict ( ) ;
2101
+ const uncheckedAppearanceDict = new Dict ( ) ;
2102
+
2103
+ const checkedStream = new StringStream ( "0.1 0.2 0.3 rg" ) ;
2104
+ checkedStream . dict = checkedAppearanceDict ;
2105
+
2106
+ const uncheckedStream = new StringStream ( "0.3 0.2 0.1 rg" ) ;
2107
+ uncheckedStream . dict = uncheckedAppearanceDict ;
2108
+
2109
+ checkedAppearanceDict . set ( "BBox" , [ 0 , 0 , 8 , 8 ] ) ;
2110
+ checkedAppearanceDict . set ( "FormType" , 1 ) ;
2111
+ checkedAppearanceDict . set ( "Matrix" , [ 1 , 0 , 0 , 1 , 0 , 0 ] ) ;
2112
+ normalAppearanceDict . set ( "Checked" , checkedStream ) ;
2113
+ normalAppearanceDict . set ( "Off" , uncheckedStream ) ;
2114
+ appearanceStatesDict . set ( "N" , normalAppearanceDict ) ;
2115
+
2116
+ buttonWidgetDict . set ( "AP" , appearanceStatesDict ) ;
2117
+ buttonWidgetDict . set ( "AS" , Name . get ( "Checked" ) ) ;
2118
+
2119
+ const buttonWidgetRef = Ref . get ( 124 , 0 ) ;
2120
+ const xref = new XRefMock ( [
2121
+ { ref : buttonWidgetRef , data : buttonWidgetDict } ,
2122
+ ] ) ;
2123
+ const task = new WorkerTask ( "test print" ) ;
2124
+
2125
+ AnnotationFactory . create (
2126
+ xref ,
2127
+ buttonWidgetRef ,
2128
+ pdfManagerMock ,
2129
+ idFactoryMock
2130
+ )
2131
+ . then ( annotation => {
2132
+ const annotationStorage = { } ;
2133
+ return annotation . getOperatorList (
2134
+ partialEvaluator ,
2135
+ task ,
2136
+ false ,
2137
+ annotationStorage
2138
+ ) ;
2139
+ } )
2140
+ . then ( opList => {
2141
+ expect ( opList . argsArray . length ) . toEqual ( 3 ) ;
2142
+ expect ( opList . fnArray ) . toEqual ( [
2143
+ OPS . beginAnnotation ,
2144
+ OPS . setFillRGBColor ,
2145
+ OPS . endAnnotation ,
2146
+ ] ) ;
2147
+ expect ( opList . argsArray [ 1 ] ) . toEqual (
2148
+ new Uint8ClampedArray ( [ 26 , 51 , 76 ] )
2149
+ ) ;
2150
+ done ( ) ;
2151
+ } )
2152
+ . catch ( done . fail ) ;
2153
+ } ) ;
2154
+
2048
2155
it ( "should save checkboxes" , function ( done ) {
2049
2156
const appearanceStatesDict = new Dict ( ) ;
2050
2157
const normalAppearanceDict = new Dict ( ) ;
@@ -2280,6 +2387,65 @@ describe("annotation", function () {
2280
2387
} , done . fail ) ;
2281
2388
} ) ;
2282
2389
2390
+ it ( "should render radio buttons for printing using normal appearance" , function ( done ) {
2391
+ const appearanceStatesDict = new Dict ( ) ;
2392
+ const normalAppearanceDict = new Dict ( ) ;
2393
+ const checkedAppearanceDict = new Dict ( ) ;
2394
+ const uncheckedAppearanceDict = new Dict ( ) ;
2395
+
2396
+ const checkedStream = new StringStream ( "0.1 0.2 0.3 rg" ) ;
2397
+ checkedStream . dict = checkedAppearanceDict ;
2398
+
2399
+ const uncheckedStream = new StringStream ( "0.3 0.2 0.1 rg" ) ;
2400
+ uncheckedStream . dict = uncheckedAppearanceDict ;
2401
+
2402
+ checkedAppearanceDict . set ( "BBox" , [ 0 , 0 , 8 , 8 ] ) ;
2403
+ checkedAppearanceDict . set ( "FormType" , 1 ) ;
2404
+ checkedAppearanceDict . set ( "Matrix" , [ 1 , 0 , 0 , 1 , 0 , 0 ] ) ;
2405
+ normalAppearanceDict . set ( "Checked" , checkedStream ) ;
2406
+ normalAppearanceDict . set ( "Off" , uncheckedStream ) ;
2407
+ appearanceStatesDict . set ( "N" , normalAppearanceDict ) ;
2408
+
2409
+ buttonWidgetDict . set ( "Ff" , AnnotationFieldFlag . RADIO ) ;
2410
+ buttonWidgetDict . set ( "AP" , appearanceStatesDict ) ;
2411
+ buttonWidgetDict . set ( "AS" , Name . get ( "Off" ) ) ;
2412
+
2413
+ const buttonWidgetRef = Ref . get ( 124 , 0 ) ;
2414
+ const xref = new XRefMock ( [
2415
+ { ref : buttonWidgetRef , data : buttonWidgetDict } ,
2416
+ ] ) ;
2417
+ const task = new WorkerTask ( "test print" ) ;
2418
+
2419
+ AnnotationFactory . create (
2420
+ xref ,
2421
+ buttonWidgetRef ,
2422
+ pdfManagerMock ,
2423
+ idFactoryMock
2424
+ )
2425
+ . then ( annotation => {
2426
+ const annotationStorage = { } ;
2427
+ return annotation . getOperatorList (
2428
+ partialEvaluator ,
2429
+ task ,
2430
+ false ,
2431
+ annotationStorage
2432
+ ) ;
2433
+ } )
2434
+ . then ( opList => {
2435
+ expect ( opList . argsArray . length ) . toEqual ( 3 ) ;
2436
+ expect ( opList . fnArray ) . toEqual ( [
2437
+ OPS . beginAnnotation ,
2438
+ OPS . setFillRGBColor ,
2439
+ OPS . endAnnotation ,
2440
+ ] ) ;
2441
+ expect ( opList . argsArray [ 1 ] ) . toEqual (
2442
+ new Uint8ClampedArray ( [ 76 , 51 , 26 ] )
2443
+ ) ;
2444
+ done ( ) ;
2445
+ } )
2446
+ . catch ( done . fail ) ;
2447
+ } ) ;
2448
+
2283
2449
it ( "should save radio buttons" , function ( done ) {
2284
2450
const appearanceStatesDict = new Dict ( ) ;
2285
2451
const normalAppearanceDict = new Dict ( ) ;
0 commit comments