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
|
//
// Copyright 2020 FoxyUtils ehf. All rights reserved.
//
// This is a commercial product and requires a license to operate.
// A trial license can be obtained at https://unidoc.io
//
// DO NOT EDIT: generated by unitwist Go source code obfuscator.
//
// Use of this source code is governed by the UniDoc End User License Agreement
// terms that can be accessed at https://unidoc.io/eula/
// Package contentstream provides functionality for parsing and creating content streams for PDF files.
//
// For processing and manipulating content streams, it allows parse the content stream into a list of
// operands that can then be processed further for rendering or extraction of information.
// The ContentStreamProcessor offers a basic engine for processing the content stream and can be used
// to render or modify the contents.
//
// For creating content streams, see NewContentCreator. It allows adding multiple operands and then can
// be converted to a string for embedding in a PDF file.
//
// The contentstream package uses the core and model packages.
package contentstream ;import (_dd "bufio";_cc "bytes";_eb "encoding/hex";_d "errors";_c "fmt";_ege "github.com/unidoc/unipdf/v4/common";_dc "github.com/unidoc/unipdf/v4/core";_de "github.com/unidoc/unipdf/v4/internal/imageutil";_cg "github.com/unidoc/unipdf/v4/internal/transform";
_a "github.com/unidoc/unipdf/v4/model";_eg "image/color";_b "image/jpeg";_ebb "io";_bf "math";_f "regexp";_g "strconv";);func _edgd (_ebca []int64 )[]_dc .PdfObject {var _ecec []_dc .PdfObject ;for _ ,_bdgf :=range _ebca {_ecec =append (_ecec ,_dc .MakeInteger (_bdgf ));
};return _ecec ;};
// Add_G appends 'G' operand to the content stream:
// Set the stroking colorspace to DeviceGray and sets the gray level (0-1).
//
// See section 8.6.8 "Colour Operators" and Table 74 (p. 179-180 PDF32000_2008).
func (_abgb *ContentCreator )Add_G (gray float64 )*ContentCreator {_cdg :=ContentStreamOperation {};_cdg .Operand ="\u0047";_cdg .Params =_acfc ([]float64 {gray });_abgb ._fcb =append (_abgb ._fcb ,&_cdg );return _abgb ;};
// Add_Tc appends 'Tc' operand to the content stream:
// Set character spacing.
//
// See section 9.3 "Text State Parameters and Operators" and
// Table 105 (pp. 251-252 PDF32000_2008).
func (_bg *ContentCreator )Add_Tc (charSpace float64 )*ContentCreator {_abcg :=ContentStreamOperation {};_abcg .Operand ="\u0054\u0063";_abcg .Params =_acfc ([]float64 {charSpace });_bg ._fcb =append (_bg ._fcb ,&_abcg );return _bg ;};
// Add_re appends 're' operand to the content stream:
// Append a rectangle to the current path as a complete subpath, with lower left corner (x,y).
//
// See section 8.5.2 "Path Construction Operators" and Table 59 (pp. 140-141 PDF32000_2008).
func (_aed *ContentCreator )Add_re (x ,y ,width ,height float64 )*ContentCreator {_faf :=ContentStreamOperation {};_faf .Operand ="\u0072\u0065";_faf .Params =_acfc ([]float64 {x ,y ,width ,height });_aed ._fcb =append (_aed ._fcb ,&_faf );return _aed ;
};func (_fgdcg *ContentStreamProcessor )handleCommand_K (_ceed *ContentStreamOperation ,_ *_a .PdfPageResources )error {_ede :=_a .NewPdfColorspaceDeviceCMYK ();if len (_ceed .Params )!=_ede .GetNumComponents (){_ege .Log .Debug ("I\u006e\u0076\u0061\u006c\u0069\u0064 \u006e\u0075\u006d\u0062\u0065\u0072 \u006f\u0066\u0020\u0070\u0061\u0072\u0061m\u0065\u0074\u0065\u0072\u0073\u0020\u0066\u006f\u0072\u0020S\u0043");
_ege .Log .Debug ("\u004e\u0075mb\u0065\u0072\u0020%\u0064\u0020\u006e\u006ft m\u0061tc\u0068\u0069\u006e\u0067\u0020\u0063\u006flo\u0072\u0073\u0070\u0061\u0063\u0065\u0020%\u0054",len (_ceed .Params ),_ede );return _d .New ("\u0069\u006e\u0076\u0061l\u0069\u0064\u0020\u006e\u0075\u006d\u0062\u0065\u0072\u0020o\u0066 \u0070\u0061\u0072\u0061\u006d\u0065\u0074e\u0072\u0073");
};_dgbg ,_cecb :=_ede .ColorFromPdfObjects (_ceed .Params );if _cecb !=nil {return _cecb ;};_fgdcg ._fgfc .ColorspaceStroking =_ede ;_fgdcg ._fgfc .ColorStroking =_dgbg ;return nil ;};
// Add_J adds 'J' operand to the content stream: Set the line cap style (graphics state).
//
// See section 8.4.4 "Graphic State Operators" and Table 57 (pp. 135-136 PDF32000_2008).
func (_dae *ContentCreator )Add_J (lineCapStyle string )*ContentCreator {_dfe :=ContentStreamOperation {};_dfe .Operand ="\u004a";_dfe .Params =_bedg ([]_dc .PdfObjectName {_dc .PdfObjectName (lineCapStyle )});_dae ._fcb =append (_dae ._fcb ,&_dfe );return _dae ;
};func _cdgg (_fad *ContentStreamInlineImage )(*_dc .DCTEncoder ,error ){_dfa :=_dc .NewDCTEncoder ();_ebd :=_cc .NewReader (_fad ._dddg );_fdcc ,_bcfg :=_b .DecodeConfig (_ebd );if _bcfg !=nil {_ege .Log .Debug ("\u0045\u0072\u0072or\u0020\u0064\u0065\u0063\u006f\u0064\u0069\u006e\u0067\u0020\u0066\u0069\u006c\u0065\u003a\u0020\u0025\u0073",_bcfg );
return nil ,_bcfg ;};switch _fdcc .ColorModel {case _eg .RGBAModel :_dfa .BitsPerComponent =8;_dfa .ColorComponents =3;case _eg .RGBA64Model :_dfa .BitsPerComponent =16;_dfa .ColorComponents =3;case _eg .GrayModel :_dfa .BitsPerComponent =8;_dfa .ColorComponents =1;
case _eg .Gray16Model :_dfa .BitsPerComponent =16;_dfa .ColorComponents =1;case _eg .CMYKModel :_dfa .BitsPerComponent =8;_dfa .ColorComponents =4;case _eg .YCbCrModel :_dfa .BitsPerComponent =8;_dfa .ColorComponents =3;default:return nil ,_d .New ("\u0075\u006e\u0073up\u0070\u006f\u0072\u0074\u0065\u0064\u0020\u0063\u006f\u006c\u006f\u0072\u0020\u006d\u006f\u0064\u0065\u006c");
};_dfa .Width =_fdcc .Width ;_dfa .Height =_fdcc .Height ;_ege .Log .Trace ("\u0044\u0043T\u0020\u0045\u006ec\u006f\u0064\u0065\u0072\u003a\u0020\u0025\u002b\u0076",_dfa );return _dfa ,nil ;};
// GraphicStateStack represents a stack of GraphicsState.
type GraphicStateStack []GraphicsState ;
// Add_BMC appends 'BMC' operand to the content stream:
// Begins a marked-content sequence terminated by a balancing EMC operator.
// `tag` shall be a name object indicating the role or significance of
// the sequence.
//
// See section 14.6 "Marked Content" and Table 320 (p. 561 PDF32000_2008).
func (_abd *ContentCreator )Add_BMC (tag _dc .PdfObjectName )*ContentCreator {_gbc :=ContentStreamOperation {};_gbc .Operand ="\u0042\u004d\u0043";_gbc .Params =_bedg ([]_dc .PdfObjectName {tag });_abd ._fcb =append (_abd ._fcb ,&_gbc );return _abd ;};
// Add_Tw appends 'Tw' operand to the content stream:
// Set word spacing.
//
// See section 9.3 "Text State Parameters and Operators" and
// Table 105 (pp. 251-252 PDF32000_2008).
func (_gff *ContentCreator )Add_Tw (wordSpace float64 )*ContentCreator {_gge :=ContentStreamOperation {};_gge .Operand ="\u0054\u0077";_gge .Params =_acfc ([]float64 {wordSpace });_gff ._fcb =append (_gff ._fcb ,&_gge );return _gff ;};
// Add_quotes appends `"` operand to the content stream:
// Move to next line and show a string, using `aw` and `ac` as word
// and character spacing respectively.
//
// See section 9.4.3 "Text Showing Operators" and
// Table 209 (pp. 258-259 PDF32000_2008).
func (_fdc *ContentCreator )Add_quotes (textstr _dc .PdfObjectString ,aw ,ac float64 )*ContentCreator {_gfaf :=ContentStreamOperation {};_gfaf .Operand ="\u0022";_gfaf .Params =_acfc ([]float64 {aw ,ac });_gfaf .Params =append (_gfaf .Params ,_dfda ([]_dc .PdfObjectString {textstr })...);
_fdc ._fcb =append (_fdc ._fcb ,&_gfaf );return _fdc ;};
// Add_B appends 'B' operand to the content stream:
// Fill and then stroke the path (nonzero winding number rule).
//
// See section 8.5.3 "Path Painting Operators" and Table 60 (p. 143 PDF32000_2008).
func (_dcfcg *ContentCreator )Add_B ()*ContentCreator {_fee :=ContentStreamOperation {};_fee .Operand ="\u0042";_dcfcg ._fcb =append (_dcfcg ._fcb ,&_fee );return _dcfcg ;};
// ExtractText parses and extracts all text data in content streams and returns as a string.
// Does not take into account Encoding table, the output is simply the character codes.
//
// Deprecated: More advanced text extraction is offered in package extractor with character encoding support.
func (_ac *ContentStreamParser )ExtractText ()(string ,error ){_aba ,_ee :=_ac .Parse ();if _ee !=nil {return "",_ee ;};_dca :=false ;_dfd ,_bdd :=float64 (-1),float64 (-1);_eec :="";for _ ,_ae :=range *_aba {switch _ae .Operand {case "\u0042\u0054":_dca =true ;
case "\u0045\u0054":_dca =false ;};if _ae .Operand =="\u0054\u0064"||_ae .Operand =="\u0054\u0044"||_ae .Operand =="\u0054\u002a"{_eec +="\u000a";};if _ae .Operand =="\u0054\u006d"{if len (_ae .Params )!=6{continue ;};_abe ,_fac :=_ae .Params [4].(*_dc .PdfObjectFloat );
if !_fac {_abg ,_bc :=_ae .Params [4].(*_dc .PdfObjectInteger );if !_bc {continue ;};_abe =_dc .MakeFloat (float64 (*_abg ));};_ed ,_fac :=_ae .Params [5].(*_dc .PdfObjectFloat );if !_fac {_bb ,_fc :=_ae .Params [5].(*_dc .PdfObjectInteger );if !_fc {continue ;
};_ed =_dc .MakeFloat (float64 (*_bb ));};if _bdd ==-1{_bdd =float64 (*_ed );}else if _bdd > float64 (*_ed ){_eec +="\u000a";_dfd =float64 (*_abe );_bdd =float64 (*_ed );continue ;};if _dfd ==-1{_dfd =float64 (*_abe );}else if _dfd < float64 (*_abe ){_eec +="\u0009";
_dfd =float64 (*_abe );};};if _dca &&_ae .Operand =="\u0054\u004a"{if len (_ae .Params )< 1{continue ;};_be ,_ce :=_ae .Params [0].(*_dc .PdfObjectArray );if !_ce {return "",_c .Errorf ("\u0069\u006ev\u0061\u006c\u0069\u0064 \u0070\u0061r\u0061\u006d\u0065\u0074\u0065\u0072\u0020\u0074y\u0070\u0065\u002c\u0020\u006e\u006f\u0020\u0061\u0072\u0072\u0061\u0079 \u0028\u0025\u0054\u0029",_ae .Params [0]);
};for _ ,_gfc :=range _be .Elements (){switch _cad :=_gfc .(type ){case *_dc .PdfObjectString :_eec +=_cad .Str ();case *_dc .PdfObjectFloat :if *_cad < -100{_eec +="\u0020";};case *_dc .PdfObjectInteger :if *_cad < -100{_eec +="\u0020";};};};}else if _dca &&_ae .Operand =="\u0054\u006a"{if len (_ae .Params )< 1{continue ;
};_fd ,_dcf :=_ae .Params [0].(*_dc .PdfObjectString );if !_dcf {return "",_c .Errorf ("\u0069\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u0070\u0061\u0072\u0061\u006de\u0074\u0065\u0072\u0020\u0074\u0079p\u0065\u002c\u0020\u006e\u006f\u0074\u0020\u0073\u0074\u0072\u0069\u006e\u0067 \u0028\u0025\u0054\u0029",_ae .Params [0]);
};_eec +=_fd .Str ();};};return _eec ,nil ;};func (_aeeg *ContentStreamProcessor )handleCommand_cs (_dcaab *ContentStreamOperation ,_ecfg *_a .PdfPageResources )error {if len (_dcaab .Params )< 1{_ege .Log .Debug ("\u0049\u006e\u0076\u0061\u006c\u0069d\u0020\u0043\u0053\u0020\u0063\u006f\u006d\u006d\u0061\u006e\u0064\u002c\u0020s\u006b\u0069\u0070\u0070\u0069\u006e\u0067 \u006f\u0076\u0065\u0072");
return _d .New ("\u0074o\u006f \u0066\u0065\u0077\u0020\u0070a\u0072\u0061m\u0065\u0074\u0065\u0072\u0073");};if len (_dcaab .Params )> 1{_ege .Log .Debug ("\u0043\u0053\u0020\u0063\u006f\u006d\u006d\u0061n\u0064\u0020\u0077it\u0068\u0020\u0074\u006f\u006f\u0020m\u0061\u006e\u0079\u0020\u0070\u0061\u0072\u0061\u006d\u0065\u0074\u0065\u0072\u0073\u0020-\u0020\u0063\u006f\u006e\u0074\u0069\u006e\u0075i\u006e\u0067");
return _d .New ("\u0074\u006f\u006f\u0020ma\u006e\u0079\u0020\u0070\u0061\u0072\u0061\u006d\u0065\u0074\u0065\u0072\u0073");};_affa ,_aedea :=_dcaab .Params [0].(*_dc .PdfObjectName );if !_aedea {_ege .Log .Debug ("\u0045\u0052\u0052\u004f\u0052\u003a\u0020C\u0053\u0020\u0063o\u006d\u006d\u0061n\u0064\u0020w\u0069\u0074\u0068\u0020\u0069\u006ev\u0061li\u0064\u0020\u0070\u0061\u0072\u0061\u006d\u0065\u0074\u0065\u0072\u002c\u0020\u0073\u006b\u0069\u0070\u0070\u0069\u006e\u0067\u0020\u006f\u0076\u0065\u0072");
return _d .New ("\u0074\u0079p\u0065\u0020\u0063h\u0065\u0063\u006b\u0020\u0065\u0072\u0072\u006f\u0072");};_acf ,_cfcd :=_aeeg .getColorspace (string (*_affa ),_ecfg );if _cfcd !=nil {return _cfcd ;};_aeeg ._fgfc .ColorspaceNonStroking =_acf ;_agb ,_cfcd :=_aeeg .getInitialColor (_acf );
if _cfcd !=nil {return _cfcd ;};_aeeg ._fgfc .ColorNonStroking =_agb ;return nil ;};
// Add_Ts appends 'Ts' operand to the content stream:
// Set text rise.
//
// See section 9.3 "Text State Parameters and Operators" and
// Table 105 (pp. 251-252 PDF32000_2008).
func (_gcb *ContentCreator )Add_Ts (rise float64 )*ContentCreator {_gbb :=ContentStreamOperation {};_gbb .Operand ="\u0054\u0073";_gbb .Params =_acfc ([]float64 {rise });_gcb ._fcb =append (_gcb ._fcb ,&_gbb );return _gcb ;};
// Add_Tj appends 'Tj' operand to the content stream:
// Show a text string.
//
// See section 9.4.3 "Text Showing Operators" and
// Table 209 (pp. 258-259 PDF32000_2008).
func (_gfcb *ContentCreator )Add_Tj (textstr _dc .PdfObjectString )*ContentCreator {_adg :=ContentStreamOperation {};_adg .Operand ="\u0054\u006a";_adg .Params =_dfda ([]_dc .PdfObjectString {textstr });_gfcb ._fcb =append (_gfcb ._fcb ,&_adg );return _gfcb ;
};
// Add_n appends 'n' operand to the content stream:
// End the path without filling or stroking.
//
// See section 8.5.3 "Path Painting Operators" and Table 60 (p. 143 PDF32000_2008).
func (_afd *ContentCreator )Add_n ()*ContentCreator {_egbf :=ContentStreamOperation {};_egbf .Operand ="\u006e";_afd ._fcb =append (_afd ._fcb ,&_egbf );return _afd ;};func (_bcbf *ContentStreamInlineImage )toImageBase (_gfdf *_a .PdfPageResources )(*_de .ImageBase ,error ){if _bcbf ._fffg !=nil {return _bcbf ._fffg ,nil ;
};_ebe :=_de .ImageBase {};if _bcbf .Height ==nil {return nil ,_d .New ("\u0068e\u0069\u0067\u0068\u0074\u0020\u0061\u0074\u0074\u0072\u0069\u0062u\u0074\u0065\u0020\u006d\u0069\u0073\u0073\u0069\u006e\u0067");};_dbd ,_bcd :=_bcbf .Height .(*_dc .PdfObjectInteger );
if !_bcd {return nil ,_d .New ("\u0069\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u0068e\u0069\u0067\u0068\u0074");};_ebe .Height =int (*_dbd );if _bcbf .Width ==nil {return nil ,_d .New ("\u0077\u0069\u0064th\u0020\u0061\u0074\u0074\u0072\u0069\u0062\u0075\u0074\u0065\u0020\u006d\u0069\u0073\u0073\u0069\u006e\u0067");
};_eeb ,_bcd :=_bcbf .Width .(*_dc .PdfObjectInteger );if !_bcd {return nil ,_d .New ("\u0069\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u0077\u0069\u0064\u0074\u0068");};_ebe .Width =int (*_eeb );_cebd ,_cfbc :=_bcbf .IsMask ();if _cfbc !=nil {return nil ,_cfbc ;
};if _cebd {_ebe .BitsPerComponent =1;_ebe .ColorComponents =1;}else {if _bcbf .BitsPerComponent ==nil {_ege .Log .Debug ("\u0049\u006el\u0069\u006e\u0065\u0020\u0042\u0069\u0074\u0073\u0020\u0070\u0065\u0072\u0020\u0063\u006f\u006d\u0070\u006f\u006e\u0065\u006e\u0074\u0020\u006d\u0069\u0073\u0073\u0069\u006e\u0067\u0020\u002d\u0020\u0061\u0073\u0073\u0075\u006d\u0069\u006e\u0067\u0020\u0038");
_ebe .BitsPerComponent =8;}else {_ccfg ,_baa :=_bcbf .BitsPerComponent .(*_dc .PdfObjectInteger );if !_baa {_ege .Log .Debug ("E\u0072\u0072\u006f\u0072\u0020\u0069\u006e\u0076\u0061l\u0069\u0064\u0020\u0062\u0069\u0074\u0073 p\u0065\u0072\u0020\u0063o\u006d\u0070\u006f\u006e\u0065\u006e\u0074\u0020\u0076al\u0075\u0065,\u0020\u0074\u0079\u0070\u0065\u0020\u0025\u0054",_bcbf .BitsPerComponent );
return nil ,_d .New ("\u0042\u0050\u0043\u0020\u0054\u0079\u0070\u0065\u0020e\u0072\u0072\u006f\u0072");};_ebe .BitsPerComponent =int (*_ccfg );};if _bcbf .ColorSpace !=nil {_fdbd ,_efd :=_bcbf .GetColorSpace (_gfdf );if _efd !=nil {return nil ,_efd ;};
_ebe .ColorComponents =_fdbd .GetNumComponents ();}else {_ege .Log .Debug ("\u0049\u006el\u0069\u006e\u0065\u0020\u0049\u006d\u0061\u0067\u0065\u0020\u0063\u006f\u006c\u006f\u0072\u0073\u0070\u0061\u0063e\u0020\u006e\u006f\u0074\u0020\u0073p\u0065\u0063\u0069\u0066\u0069\u0065\u0064\u0020\u002d\u0020\u0061\u0073\u0073\u0075m\u0069\u006eg\u0020\u0031\u0020\u0063o\u006c\u006f\u0072\u0020\u0063o\u006d\u0070\u006f\u006e\u0065\u006e\u0074");
_ebe .ColorComponents =1;};};if _gcg ,_eefa :=_dc .GetArray (_bcbf .Decode );_eefa {_ebe .Decode ,_cfbc =_gcg .ToFloat64Array ();if _cfbc !=nil {return nil ,_cfbc ;};};_bcbf ._fffg =&_ebe ;return _bcbf ._fffg ,nil ;};func (_gcba *ContentStreamParser )parseString ()(*_dc .PdfObjectString ,error ){_gcba ._aga .ReadByte ();
var _bgcf []byte ;_gebf :=1;for {_gbbe ,_bfg :=_gcba ._aga .Peek (1);if _bfg !=nil {return _dc .MakeString (string (_bgcf )),_bfg ;};if _gbbe [0]=='\\'{_gcba ._aga .ReadByte ();_cebgfg ,_fdd :=_gcba ._aga .ReadByte ();if _fdd !=nil {return _dc .MakeString (string (_bgcf )),_fdd ;
};if _dc .IsOctalDigit (_cebgfg ){_ced ,_efac :=_gcba ._aga .Peek (2);if _efac !=nil {return _dc .MakeString (string (_bgcf )),_efac ;};var _adga []byte ;_adga =append (_adga ,_cebgfg );for _ ,_ffee :=range _ced {if _dc .IsOctalDigit (_ffee ){_adga =append (_adga ,_ffee );
}else {break ;};};_gcba ._aga .Discard (len (_adga )-1);_ege .Log .Trace ("\u004e\u0075\u006d\u0065ri\u0063\u0020\u0073\u0074\u0072\u0069\u006e\u0067\u0020\u0022\u0025\u0073\u0022",_adga );_cdc ,_efac :=_g .ParseUint (string (_adga ),8,32);if _efac !=nil {return _dc .MakeString (string (_bgcf )),_efac ;
};_bgcf =append (_bgcf ,byte (_cdc ));continue ;};switch _cebgfg {case 'n':_bgcf =append (_bgcf ,'\n');case 'r':_bgcf =append (_bgcf ,'\r');case 't':_bgcf =append (_bgcf ,'\t');case 'b':_bgcf =append (_bgcf ,'\b');case 'f':_bgcf =append (_bgcf ,'\f');case '(':_bgcf =append (_bgcf ,'(');
case ')':_bgcf =append (_bgcf ,')');case '\\':_bgcf =append (_bgcf ,'\\');};continue ;}else if _gbbe [0]=='('{_gebf ++;}else if _gbbe [0]==')'{_gebf --;if _gebf ==0{_gcba ._aga .ReadByte ();break ;};};_edag ,_ :=_gcba ._aga .ReadByte ();_bgcf =append (_bgcf ,_edag );
};return _dc .MakeString (string (_bgcf )),nil ;};
// All returns true if `hce` is equivalent to HandlerConditionEnumAllOperands.
func (_bgbg HandlerConditionEnum )All ()bool {return _bgbg ==HandlerConditionEnumAllOperands };func (_dgg *ContentStreamProcessor )handleCommand_SC (_afdb *ContentStreamOperation ,_ *_a .PdfPageResources )error {_geff :=_dgg ._fgfc .ColorspaceStroking ;
if len (_afdb .Params )!=_geff .GetNumComponents (){_ege .Log .Debug ("I\u006e\u0076\u0061\u006c\u0069\u0064 \u006e\u0075\u006d\u0062\u0065\u0072 \u006f\u0066\u0020\u0070\u0061\u0072\u0061m\u0065\u0074\u0065\u0072\u0073\u0020\u0066\u006f\u0072\u0020S\u0043");
_ege .Log .Debug ("\u004e\u0075mb\u0065\u0072\u0020%\u0064\u0020\u006e\u006ft m\u0061tc\u0068\u0069\u006e\u0067\u0020\u0063\u006flo\u0072\u0073\u0070\u0061\u0063\u0065\u0020%\u0054",len (_afdb .Params ),_geff );if !_dgg ._deff {return _d .New ("\u0069\u006e\u0076\u0061l\u0069\u0064\u0020\u006e\u0075\u006d\u0062\u0065\u0072\u0020o\u0066 \u0070\u0061\u0072\u0061\u006d\u0065\u0074e\u0072\u0073");
};_cga ,_eadg :=_edbb (_afdb .Params );if _eadg !=nil {_ege .Log .Debug ("\u0045\u0052\u0052\u004f\u0052:\u0020\u0046\u0061\u0069\u006c\u0020\u0074\u006f\u0020\u0063\u006f\u006e\u0076e\u0072\u0074\u0020\u0063\u006f\u006c\u006f\u0072\u0020\u0074\u006f\u0020\u0067\u0072\u0061\u0079\u003a\u0020\u0025\u002b\u0076",_afdb .Params );
return _eadg ;};_afdb .Params =[]_dc .PdfObject {_cga };};_bda ,_gddc :=_geff .ColorFromPdfObjects (_afdb .Params );if _gddc !=nil {return _gddc ;};_dgg ._fgfc .ColorStroking =_bda ;return nil ;};
// Add_Tstar appends 'T*' operand to the content stream:
// Move to the start of next line.
//
// See section 9.4.2 "Text Positioning Operators" and
// Table 108 (pp. 257-258 PDF32000_2008).
func (_cge *ContentCreator )Add_Tstar ()*ContentCreator {_cfe :=ContentStreamOperation {};_cfe .Operand ="\u0054\u002a";_cge ._fcb =append (_cge ._fcb ,&_cfe );return _cge ;};
// Add_d adds 'd' operand to the content stream: Set the line dash pattern.
//
// See section 8.4.4 "Graphic State Operators" and Table 57 (pp. 135-136 PDF32000_2008).
func (_gdf *ContentCreator )Add_d (dashArray []int64 ,dashPhase int64 )*ContentCreator {_gfd :=ContentStreamOperation {};_gfd .Operand ="\u0064";_gfd .Params =[]_dc .PdfObject {};_gfd .Params =append (_gfd .Params ,_dc .MakeArrayFromIntegers64 (dashArray ));
_gfd .Params =append (_gfd .Params ,_dc .MakeInteger (dashPhase ));_gdf ._fcb =append (_gdf ._fcb ,&_gfd );return _gdf ;};
// Bytes converts the content stream operations to a content stream byte presentation, i.e. the kind that can be
// stored as a PDF stream or string format.
func (_cf *ContentCreator )Bytes ()[]byte {return _cf ._fcb .Bytes ()};
// Add_f appends 'f' operand to the content stream:
// Fill the path using the nonzero winding number rule to determine fill region.
//
// See section 8.5.3 "Path Painting Operators" and Table 60 (p. 143 PDF32000_2008).
func (_faa *ContentCreator )Add_f ()*ContentCreator {_caf :=ContentStreamOperation {};_caf .Operand ="\u0066";_faa ._fcb =append (_faa ._fcb ,&_caf );return _faa ;};func _afceb (_ccde _a .PdfColorspace )bool {_ ,_daca :=_ccde .(*_a .PdfColorspaceSpecialPattern );
return _daca ;};
// AddHandler adds a new ContentStreamProcessor `handler` of type `condition` for `operand`.
func (_bgd *ContentStreamProcessor )AddHandler (condition HandlerConditionEnum ,operand string ,handler HandlerFunc ){_ddc :=handlerEntry {};_ddc .Condition =condition ;_ddc .Operand =operand ;_ddc .Handler =handler ;_bgd ._cebf =append (_bgd ._cebf ,_ddc );
};
// Add_s appends 's' operand to the content stream: Close and stroke the path.
//
// See section 8.5.3 "Path Painting Operators" and Table 60 (p. 143 PDF32000_2008).
func (_age *ContentCreator )Add_s ()*ContentCreator {_dcfc :=ContentStreamOperation {};_dcfc .Operand ="\u0073";_age ._fcb =append (_age ._fcb ,&_dcfc );return _age ;};
// Transform returns coordinates x, y transformed by the CTM.
func (_bdfc *GraphicsState )Transform (x ,y float64 )(float64 ,float64 ){return _bdfc .CTM .Transform (x ,y );};
// Add_Td appends 'Td' operand to the content stream:
// Move to start of next line with offset (`tx`, `ty`).
//
// See section 9.4.2 "Text Positioning Operators" and
// Table 108 (pp. 257-258 PDF32000_2008).
func (_gfe *ContentCreator )Add_Td (tx ,ty float64 )*ContentCreator {_bge :=ContentStreamOperation {};_bge .Operand ="\u0054\u0064";_bge .Params =_acfc ([]float64 {tx ,ty });_gfe ._fcb =append (_gfe ._fcb ,&_bge );return _gfe ;};
// HasUnclosedQ checks if all the `q` operator is properly closed by `Q` operator.
func (_ga *ContentStreamOperations )HasUnclosedQ ()bool {_da :=0;for _ ,_af :=range *_ga {switch _af .Operand {case "\u0071":_da ++;case "\u0051":_da --;};};return _da !=0;};
// Add_v appends 'v' operand to the content stream: Append a Bezier curve to the current path from the
// current point to (x3,y3) with the current point and (x2,y2) as control points.
//
// See section 8.5.2 "Path Construction Operators" and Table 59 (pp. 140-141 PDF32000_2008).
func (_bcf *ContentCreator )Add_v (x2 ,y2 ,x3 ,y3 float64 )*ContentCreator {_dcaf :=ContentStreamOperation {};_dcaf .Operand ="\u0076";_dcaf .Params =_acfc ([]float64 {x2 ,y2 ,x3 ,y3 });_bcf ._fcb =append (_bcf ._fcb ,&_dcaf );return _bcf ;};func _bedg (_dagef []_dc .PdfObjectName )[]_dc .PdfObject {var _dbga []_dc .PdfObject ;
for _ ,_gdce :=range _dagef {_dbga =append (_dbga ,_dc .MakeName (string (_gdce )));};return _dbga ;};
// Add_RG appends 'RG' operand to the content stream:
// Set the stroking colorspace to DeviceRGB and sets the r,g,b colors (0-1 each).
//
// See section 8.6.8 "Colour Operators" and Table 74 (p. 179-180 PDF32000_2008).
func (_cdb *ContentCreator )Add_RG (r ,g ,b float64 )*ContentCreator {_fafc :=ContentStreamOperation {};_fafc .Operand ="\u0052\u0047";_fafc .Params =_acfc ([]float64 {r ,g ,b });_cdb ._fcb =append (_cdb ._fcb ,&_fafc );return _cdb ;};var _gebg =map[string ]struct{}{"\u0062":{},"\u0042":{},"\u0062\u002a":{},"\u0042\u002a":{},"\u0042\u0044\u0043":{},"\u0042\u0049":{},"\u0042\u004d\u0043":{},"\u0042\u0054":{},"\u0042\u0058":{},"\u0063":{},"\u0063\u006d":{},"\u0043\u0053":{},"\u0063\u0073":{},"\u0064":{},"\u0064\u0030":{},"\u0064\u0031":{},"\u0044\u006f":{},"\u0044\u0050":{},"\u0045\u0049":{},"\u0045\u004d\u0043":{},"\u0045\u0054":{},"\u0045\u0058":{},"\u0066":{},"\u0046":{},"\u0066\u002a":{},"\u0047":{},"\u0067":{},"\u0067\u0073":{},"\u0068":{},"\u0069":{},"\u0049\u0044":{},"\u006a":{},"\u004a":{},"\u004b":{},"\u006b":{},"\u006c":{},"\u006d":{},"\u004d":{},"\u004d\u0050":{},"\u006e":{},"\u0071":{},"\u0051":{},"\u0072\u0065":{},"\u0052\u0047":{},"\u0072\u0067":{},"\u0072\u0069":{},"\u0073":{},"\u0053":{},"\u0053\u0043":{},"\u0073\u0063":{},"\u0053\u0043\u004e":{},"\u0073\u0063\u006e":{},"\u0073\u0068":{},"\u0054\u002a":{},"\u0054\u0063":{},"\u0054\u0064":{},"\u0054\u0044":{},"\u0054\u0066":{},"\u0054\u006a":{},"\u0054\u004a":{},"\u0054\u004c":{},"\u0054\u006d":{},"\u0054\u0072":{},"\u0054\u0073":{},"\u0054\u0077":{},"\u0054\u007a":{},"\u0076":{},"\u0077":{},"\u0057":{},"\u0057\u002a":{},"\u0079":{},"\u0027":{},"\u0022":{}};
// NewInlineImageFromImage makes a new content stream inline image object from an image.
func NewInlineImageFromImage (img _a .Image ,encoder _dc .StreamEncoder )(*ContentStreamInlineImage ,error ){if encoder ==nil {encoder =_dc .NewRawEncoder ();};encoder .UpdateParams (img .GetParamsDict ());_beed :=ContentStreamInlineImage {};switch img .ColorComponents {case 1:_beed .ColorSpace =_dc .MakeName ("\u0047");
case 3:_beed .ColorSpace =_dc .MakeName ("\u0052\u0047\u0042");case 4:_beed .ColorSpace =_dc .MakeName ("\u0043\u004d\u0059\u004b");default:_ege .Log .Debug ("\u0049\u006e\u0076\u0061\u006c\u0069\u0064 \u006e\u0075\u006db\u0065\u0072\u0020o\u0066\u0020c\u006f\u006c\u006f\u0072\u0020\u0063o\u006dpo\u006e\u0065\u006e\u0074\u0073\u0020\u0066\u006f\u0072\u0020\u0069\u006e\u006c\u0069\u006e\u0065\u0020\u0069\u006d\u0061\u0067\u0065\u003a\u0020\u0025\u0064",img .ColorComponents );
return nil ,_d .New ("\u0069\u006e\u0076al\u0069\u0064\u0020\u006e\u0075\u006d\u0062\u0065\u0072 \u006ff\u0020c\u006fl\u006f\u0072\u0020\u0063\u006f\u006d\u0070\u006f\u006e\u0065\u006e\u0074\u0073");};_beed .BitsPerComponent =_dc .MakeInteger (img .BitsPerComponent );
_beed .Width =_dc .MakeInteger (img .Width );_beed .Height =_dc .MakeInteger (img .Height );_eca ,_cafc :=encoder .EncodeBytes (img .Data );if _cafc !=nil {return nil ,_cafc ;};_beed ._dddg =_eca ;_ddda :=encoder .GetFilterName ();if _ddda !=_dc .StreamEncodingFilterNameRaw {_beed .Filter =_dc .MakeName (_ddda );
};return &_beed ,nil ;};func _gfdc (_gab *ContentStreamInlineImage ,_bbc *_dc .PdfObjectDictionary )(*_dc .FlateEncoder ,error ){_gaf :=_dc .NewFlateEncoder ();if _gab ._fffg !=nil {_gaf .SetImage (_gab ._fffg );};if _bbc ==nil {_eda :=_gab .DecodeParms ;
if _eda !=nil {_eba ,_ebag :=_dc .GetDict (_eda );if !_ebag {_ege .Log .Debug ("E\u0072\u0072\u006f\u0072\u003a\u0020\u0044\u0065\u0063\u006f\u0064\u0065\u0050\u0061\u0072\u006d\u0073\u0020n\u006f\u0074\u0020\u0061\u0020\u0064\u0069\u0063\u0074\u0069on\u0061\u0072\u0079 \u0028%\u0054\u0029",_eda );
return nil ,_c .Errorf ("\u0069\u006e\u0076\u0061li\u0064\u0020\u0044\u0065\u0063\u006f\u0064\u0065\u0050\u0061\u0072\u006d\u0073");};_bbc =_eba ;};};if _bbc ==nil {return _gaf ,nil ;};_ege .Log .Trace ("\u0064\u0065\u0063\u006f\u0064\u0065\u0020\u0070\u0061\u0072\u0061\u006ds\u003a\u0020\u0025\u0073",_bbc .String ());
_bae :=_bbc .Get ("\u0050r\u0065\u0064\u0069\u0063\u0074\u006fr");if _bae ==nil {_ege .Log .Debug ("E\u0072\u0072o\u0072\u003a\u0020\u0050\u0072\u0065\u0064\u0069\u0063\u0074\u006f\u0072\u0020\u006d\u0069\u0073\u0073\u0069\u006e\u0067 \u0066\u0072\u006f\u006d\u0020\u0044\u0065\u0063\u006f\u0064\u0065\u0050\u0061\u0072\u006d\u0073 \u002d\u0020\u0043\u006f\u006e\u0074\u0069\u006e\u0075\u0065\u0020\u0077\u0069t\u0068\u0020\u0064\u0065\u0066\u0061\u0075\u006c\u0074\u0020\u00281\u0029");
}else {_gcd ,_bca :=_bae .(*_dc .PdfObjectInteger );if !_bca {_ege .Log .Debug ("E\u0072\u0072\u006f\u0072\u003a\u0020\u0050\u0072\u0065d\u0069\u0063\u0074\u006f\u0072\u0020\u0073pe\u0063\u0069\u0066\u0069e\u0064\u0020\u0062\u0075\u0074\u0020\u006e\u006f\u0074 n\u0075\u006de\u0072\u0069\u0063\u0020\u0028\u0025\u0054\u0029",_bae );
return nil ,_c .Errorf ("\u0069\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u0050\u0072\u0065\u0064i\u0063\u0074\u006f\u0072");};_gaf .Predictor =int (*_gcd );};_bae =_bbc .Get ("\u0042\u0069t\u0073\u0050\u0065r\u0043\u006f\u006d\u0070\u006f\u006e\u0065\u006e\u0074");
if _bae !=nil {_fde ,_efa :=_bae .(*_dc .PdfObjectInteger );if !_efa {_ege .Log .Debug ("\u0045\u0052\u0052O\u0052\u003a\u0020\u0049n\u0076\u0061\u006c\u0069\u0064\u0020\u0042i\u0074\u0073\u0050\u0065\u0072\u0043\u006f\u006d\u0070\u006f\u006e\u0065\u006e\u0074");
return nil ,_c .Errorf ("\u0069n\u0076\u0061\u006c\u0069\u0064\u0020\u0042\u0069\u0074\u0073\u0050e\u0072\u0043\u006f\u006d\u0070\u006f\u006e\u0065\u006e\u0074");};_gaf .BitsPerComponent =int (*_fde );};if _gaf .Predictor > 1{_gaf .Columns =1;_bae =_bbc .Get ("\u0043o\u006c\u0075\u006d\u006e\u0073");
if _bae !=nil {_eaaf ,_gbd :=_bae .(*_dc .PdfObjectInteger );if !_gbd {return nil ,_c .Errorf ("\u0070r\u0065\u0064\u0069\u0063\u0074\u006f\u0072\u0020\u0063\u006f\u006cu\u006d\u006e\u0020\u0069\u006e\u0076\u0061\u006c\u0069\u0064");};_gaf .Columns =int (*_eaaf );
};_gaf .Colors =1;_fab :=_bbc .Get ("\u0043\u006f\u006c\u006f\u0072\u0073");if _fab !=nil {_adde ,_ffb :=_fab .(*_dc .PdfObjectInteger );if !_ffb {return nil ,_c .Errorf ("\u0070\u0072\u0065d\u0069\u0063\u0074\u006fr\u0020\u0063\u006f\u006c\u006f\u0072\u0073 \u006e\u006f\u0074\u0020\u0061\u006e\u0020\u0069\u006e\u0074\u0065\u0067\u0065\u0072");
};_gaf .Colors =int (*_adde );};};return _gaf ,nil ;};
// RotateDeg applies a rotation to the transformation matrix.
func (_abc *ContentCreator )RotateDeg (angle float64 )*ContentCreator {_db :=_bf .Cos (angle *_bf .Pi /180.0);_cfc :=_bf .Sin (angle *_bf .Pi /180.0);_gg :=-_bf .Sin (angle *_bf .Pi /180.0);_gee :=_bf .Cos (angle *_bf .Pi /180.0);return _abc .Add_cm (_db ,_cfc ,_gg ,_gee ,0,0);
};
// Add_Tf appends 'Tf' operand to the content stream:
// Set font and font size specified by font resource `fontName` and `fontSize`.
//
// See section 9.3 "Text State Parameters and Operators" and
// Table 105 (pp. 251-252 PDF32000_2008).
func (_cfd *ContentCreator )Add_Tf (fontName _dc .PdfObjectName ,fontSize float64 )*ContentCreator {_bfc :=ContentStreamOperation {};_bfc .Operand ="\u0054\u0066";_bfc .Params =_bedg ([]_dc .PdfObjectName {fontName });_bfc .Params =append (_bfc .Params ,_acfc ([]float64 {fontSize })...);
_cfd ._fcb =append (_cfd ._fcb ,&_bfc );return _cfd ;};
// Add_rg appends 'rg' operand to the content stream:
// Same as RG but used for nonstroking operations.
//
// See section 8.6.8 "Colour Operators" and Table 74 (p. 179-180 PDF32000_2008).
func (_fdba *ContentCreator )Add_rg (r ,g ,b float64 )*ContentCreator {_ccd :=ContentStreamOperation {};_ccd .Operand ="\u0072\u0067";_ccd .Params =_acfc ([]float64 {r ,g ,b });_fdba ._fcb =append (_fdba ._fcb ,&_ccd );return _fdba ;};
// Pop pops and returns the topmost GraphicsState off the `gsStack`.
func (_accd *GraphicStateStack )Pop ()GraphicsState {_acg :=(*_accd )[len (*_accd )-1];*_accd =(*_accd )[:len (*_accd )-1];return _acg ;};
// Add_h appends 'h' operand to the content stream:
// Close the current subpath by adding a line between the current position and the starting position.
//
// See section 8.5.2 "Path Construction Operators" and Table 59 (pp. 140-141 PDF32000_2008).
func (_bea *ContentCreator )Add_h ()*ContentCreator {_ffc :=ContentStreamOperation {};_ffc .Operand ="\u0068";_bea ._fcb =append (_bea ._fcb ,&_ffc );return _bea ;};
// Add_m adds 'm' operand to the content stream: Move the current point to (x,y).
//
// See section 8.5.2 "Path Construction Operators" and Table 59 (pp. 140-141 PDF32000_2008).
func (_dbg *ContentCreator )Add_m (x ,y float64 )*ContentCreator {_fe :=ContentStreamOperation {};_fe .Operand ="\u006d";_fe .Params =_acfc ([]float64 {x ,y });_dbg ._fcb =append (_dbg ._fcb ,&_fe );return _dbg ;};func _eaaa (_cbb *ContentStreamInlineImage ,_ggb *_dc .PdfObjectDictionary )(*_dc .LZWEncoder ,error ){_afdc :=_dc .NewLZWEncoder ();
if _ggb ==nil {if _cbb .DecodeParms !=nil {_bbcb ,_egeg :=_dc .GetDict (_cbb .DecodeParms );if !_egeg {_ege .Log .Debug ("E\u0072\u0072\u006f\u0072\u003a\u0020\u0044\u0065\u0063\u006f\u0064\u0065\u0050\u0061\u0072\u006d\u0073\u0020n\u006f\u0074\u0020\u0061\u0020\u0064\u0069\u0063\u0074\u0069on\u0061\u0072\u0079 \u0028%\u0054\u0029",_cbb .DecodeParms );
return nil ,_c .Errorf ("\u0069\u006e\u0076\u0061li\u0064\u0020\u0044\u0065\u0063\u006f\u0064\u0065\u0050\u0061\u0072\u006d\u0073");};_ggb =_bbcb ;};};if _ggb ==nil {return _afdc ,nil ;};_bed :=_ggb .Get ("E\u0061\u0072\u006c\u0079\u0043\u0068\u0061\u006e\u0067\u0065");
if _bed !=nil {_gef ,_cea :=_bed .(*_dc .PdfObjectInteger );if !_cea {_ege .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u003a \u0045\u0061\u0072\u006c\u0079\u0043\u0068\u0061\u006e\u0067\u0065\u0020\u0073\u0070\u0065\u0063\u0069\u0066\u0069\u0065d\u0020\u0062\u0075\u0074\u0020\u006e\u006f\u0074\u0020\u006e\u0075\u006d\u0065\u0072i\u0063 \u0028\u0025\u0054\u0029",_bed );
return nil ,_c .Errorf ("\u0069\u006e\u0076\u0061li\u0064\u0020\u0045\u0061\u0072\u006c\u0079\u0043\u0068\u0061\u006e\u0067\u0065");};if *_gef !=0&&*_gef !=1{return nil ,_c .Errorf ("\u0069\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u0045\u0061\u0072\u006c\u0079\u0043\u0068\u0061\u006e\u0067\u0065\u0020\u0076\u0061\u006c\u0075e\u0020\u0028\u006e\u006f\u0074 \u0030\u0020o\u0072\u0020\u0031\u0029");
};_afdc .EarlyChange =int (*_gef );}else {_afdc .EarlyChange =1;};_bed =_ggb .Get ("\u0050r\u0065\u0064\u0069\u0063\u0074\u006fr");if _bed !=nil {_fff ,_bbf :=_bed .(*_dc .PdfObjectInteger );if !_bbf {_ege .Log .Debug ("E\u0072\u0072\u006f\u0072\u003a\u0020\u0050\u0072\u0065d\u0069\u0063\u0074\u006f\u0072\u0020\u0073pe\u0063\u0069\u0066\u0069e\u0064\u0020\u0062\u0075\u0074\u0020\u006e\u006f\u0074 n\u0075\u006de\u0072\u0069\u0063\u0020\u0028\u0025\u0054\u0029",_bed );
return nil ,_c .Errorf ("\u0069\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u0050\u0072\u0065\u0064i\u0063\u0074\u006f\u0072");};_afdc .Predictor =int (*_fff );};_bed =_ggb .Get ("\u0042\u0069t\u0073\u0050\u0065r\u0043\u006f\u006d\u0070\u006f\u006e\u0065\u006e\u0074");
if _bed !=nil {_ecf ,_caba :=_bed .(*_dc .PdfObjectInteger );if !_caba {_ege .Log .Debug ("\u0045\u0052\u0052O\u0052\u003a\u0020\u0049n\u0076\u0061\u006c\u0069\u0064\u0020\u0042i\u0074\u0073\u0050\u0065\u0072\u0043\u006f\u006d\u0070\u006f\u006e\u0065\u006e\u0074");
return nil ,_c .Errorf ("\u0069n\u0076\u0061\u006c\u0069\u0064\u0020\u0042\u0069\u0074\u0073\u0050e\u0072\u0043\u006f\u006d\u0070\u006f\u006e\u0065\u006e\u0074");};_afdc .BitsPerComponent =int (*_ecf );};if _afdc .Predictor > 1{_afdc .Columns =1;_bed =_ggb .Get ("\u0043o\u006c\u0075\u006d\u006e\u0073");
if _bed !=nil {_afb ,_gdc :=_bed .(*_dc .PdfObjectInteger );if !_gdc {return nil ,_c .Errorf ("\u0070r\u0065\u0064\u0069\u0063\u0074\u006f\u0072\u0020\u0063\u006f\u006cu\u006d\u006e\u0020\u0069\u006e\u0076\u0061\u006c\u0069\u0064");};_afdc .Columns =int (*_afb );
};_afdc .Colors =1;_bed =_ggb .Get ("\u0043\u006f\u006c\u006f\u0072\u0073");if _bed !=nil {_cbf ,_cde :=_bed .(*_dc .PdfObjectInteger );if !_cde {return nil ,_c .Errorf ("\u0070\u0072\u0065d\u0069\u0063\u0074\u006fr\u0020\u0063\u006f\u006c\u006f\u0072\u0073 \u006e\u006f\u0074\u0020\u0061\u006e\u0020\u0069\u006e\u0074\u0065\u0067\u0065\u0072");
};_afdc .Colors =int (*_cbf );};};_ege .Log .Trace ("\u0064\u0065\u0063\u006f\u0064\u0065\u0020\u0070\u0061\u0072\u0061\u006ds\u003a\u0020\u0025\u0073",_ggb .String ());return _afdc ,nil ;};
// Add_scn appends 'scn' operand to the content stream:
// Same as SC but for nonstroking operations.
//
// See section 8.6.8 "Colour Operators" and Table 74 (p. 179-180 PDF32000_2008).
func (_dg *ContentCreator )Add_scn (c ...float64 )*ContentCreator {_cebg :=ContentStreamOperation {};_cebg .Operand ="\u0073\u0063\u006e";_cebg .Params =_acfc (c );_dg ._fcb =append (_dg ._fcb ,&_cebg );return _dg ;};
// String returns `ops.Bytes()` as a string.
func (_agf *ContentStreamOperations )String ()string {return string (_agf .Bytes ())};
// Add_Tm appends 'Tm' operand to the content stream:
// Set the text line matrix.
//
// See section 9.4.2 "Text Positioning Operators" and
// Table 108 (pp. 257-258 PDF32000_2008).
func (_ccf *ContentCreator )Add_Tm (a ,b ,c ,d ,e ,f float64 )*ContentCreator {_bba :=ContentStreamOperation {};_bba .Operand ="\u0054\u006d";_bba .Params =_acfc ([]float64 {a ,b ,c ,d ,e ,f });_ccf ._fcb =append (_ccf ._fcb ,&_bba );return _ccf ;};
// Add_cs appends 'cs' operand to the content stream:
// Same as CS but for non-stroking operations.
//
// See section 8.6.8 "Colour Operators" and Table 74 (p. 179-180 PDF32000_2008).
func (_fg *ContentCreator )Add_cs (name _dc .PdfObjectName )*ContentCreator {_bcc :=ContentStreamOperation {};_bcc .Operand ="\u0063\u0073";_bcc .Params =_bedg ([]_dc .PdfObjectName {name });_fg ._fcb =append (_fg ._fcb ,&_bcc );return _fg ;};
// ContentStreamParser represents a content stream parser for parsing content streams in PDFs.
type ContentStreamParser struct{_aga *_dd .Reader };func (_dff *ContentStreamParser )skipSpaces ()(int ,error ){_debg :=0;for {_cdef ,_dagg :=_dff ._aga .Peek (1);if _dagg !=nil {return 0,_dagg ;};if _dc .IsWhiteSpace (_cdef [0]){_dff ._aga .ReadByte ();
_debg ++;}else {break ;};};return _debg ,nil ;};
// Add_W_starred appends 'W*' operand to the content stream:
// Modify the current clipping path by intersecting with the current path (even odd rule).
//
// See section 8.5.4 "Clipping Path Operators" and Table 61 (p. 146 PDF32000_2008).
func (_bee *ContentCreator )Add_W_starred ()*ContentCreator {_gfb :=ContentStreamOperation {};_gfb .Operand ="\u0057\u002a";_bee ._fcb =append (_bee ._fcb ,&_gfb );return _bee ;};
// HandlerFunc is the function syntax that the ContentStreamProcessor handler must implement.
type HandlerFunc func (_fbab *ContentStreamOperation ,_dbgd GraphicsState ,_edd *_a .PdfPageResources )error ;
// Add_TL appends 'TL' operand to the content stream:
// Set leading.
//
// See section 9.3 "Text State Parameters and Operators" and
// Table 105 (pp. 251-252 PDF32000_2008).
func (_aede *ContentCreator )Add_TL (leading float64 )*ContentCreator {_daa :=ContentStreamOperation {};_daa .Operand ="\u0054\u004c";_daa .Params =_acfc ([]float64 {leading });_aede ._fcb =append (_aede ._fcb ,&_daa );return _aede ;};
// Add_k appends 'k' operand to the content stream:
// Same as K but used for nonstroking operations.
//
// See section 8.6.8 "Colour Operators" and Table 74 (p. 179-180 PDF32000_2008).
func (_adb *ContentCreator )Add_k (c ,m ,y ,k float64 )*ContentCreator {_gdge :=ContentStreamOperation {};_gdge .Operand ="\u006b";_gdge .Params =_acfc ([]float64 {c ,m ,y ,k });_adb ._fcb =append (_adb ._fcb ,&_gdge );return _adb ;};
// HandlerConditionEnum represents the type of operand content stream processor (handler).
// The handler may process a single specific named operand or all operands.
type HandlerConditionEnum int ;
// Add_ri adds 'ri' operand to the content stream, which sets the color rendering intent.
//
// See section 8.4.4 "Graphic State Operators" and Table 57 (pp. 135-136 PDF32000_2008).
func (_agfd *ContentCreator )Add_ri (intent _dc .PdfObjectName )*ContentCreator {_daf :=ContentStreamOperation {};_daf .Operand ="\u0072\u0069";_daf .Params =_bedg ([]_dc .PdfObjectName {intent });_agfd ._fcb =append (_agfd ._fcb ,&_daf );return _agfd ;
};
// Add_sh appends 'sh' operand to the content stream:
// Paints the shape and colour shading described by a shading dictionary specified by `name`,
// subject to the current clipping path
//
// See section 8.7.4 "Shading Patterns" and Table 77 (p. 190 PDF32000_2008).
func (_bac *ContentCreator )Add_sh (name _dc .PdfObjectName )*ContentCreator {_dgc :=ContentStreamOperation {};_dgc .Operand ="\u0073\u0068";_dgc .Params =_bedg ([]_dc .PdfObjectName {name });_bac ._fcb =append (_bac ._fcb ,&_dgc );return _bac ;};
// Add_BT appends 'BT' operand to the content stream:
// Begin text.
//
// See section 9.4 "Text Objects" and Table 107 (p. 256 PDF32000_2008).
func (_bdg *ContentCreator )Add_BT ()*ContentCreator {_fbc :=ContentStreamOperation {};_fbc .Operand ="\u0042\u0054";_bdg ._fcb =append (_bdg ._fcb ,&_fbc );return _bdg ;};func (_eede *ContentStreamProcessor )handleCommand_G (_bdfg *ContentStreamOperation ,_ *_a .PdfPageResources )error {_bede :=_a .NewPdfColorspaceDeviceGray ();
if len (_bdfg .Params )!=_bede .GetNumComponents (){_ege .Log .Debug ("I\u006e\u0076\u0061\u006c\u0069\u0064 \u006e\u0075\u006d\u0062\u0065\u0072 \u006f\u0066\u0020\u0070\u0061\u0072\u0061m\u0065\u0074\u0065\u0072\u0073\u0020\u0066\u006f\u0072\u0020S\u0043");
_ege .Log .Debug ("\u004e\u0075mb\u0065\u0072\u0020%\u0064\u0020\u006e\u006ft m\u0061tc\u0068\u0069\u006e\u0067\u0020\u0063\u006flo\u0072\u0073\u0070\u0061\u0063\u0065\u0020%\u0054",len (_bdfg .Params ),_bede );if !_eede ._deff {return _d .New ("\u0069\u006e\u0076\u0061l\u0069\u0064\u0020\u006e\u0075\u006d\u0062\u0065\u0072\u0020o\u0066 \u0070\u0061\u0072\u0061\u006d\u0065\u0074e\u0072\u0073");
};_aaee ,_ffff :=_edbb (_bdfg .Params );if _ffff !=nil {_ege .Log .Debug ("\u0045\u0052\u0052\u004f\u0052:\u0020\u0046\u0061\u0069\u006c\u0020\u0074\u006f\u0020\u0063\u006f\u006e\u0076e\u0072\u0074\u0020\u0063\u006f\u006c\u006f\u0072\u0020\u0074\u006f\u0020\u0067\u0072\u0061\u0079\u003a\u0020\u0025\u002b\u0076",_bdfg .Params );
return _ffff ;};_bdfg .Params =[]_dc .PdfObject {_aaee };};_abeb ,_fbf :=_bede .ColorFromPdfObjects (_bdfg .Params );if _fbf !=nil {return _fbf ;};_eede ._fgfc .ColorspaceStroking =_bede ;_eede ._fgfc .ColorStroking =_abeb ;return nil ;};
// Add_TJ appends 'TJ' operand to the content stream:
// Show one or more text string. Array of numbers (displacement) and strings.
//
// See section 9.4.3 "Text Showing Operators" and
// Table 209 (pp. 258-259 PDF32000_2008).
func (_acd *ContentCreator )Add_TJ (vals ..._dc .PdfObject )*ContentCreator {_deb :=ContentStreamOperation {};_deb .Operand ="\u0054\u004a";_deb .Params =[]_dc .PdfObject {_dc .MakeArray (vals ...)};_acd ._fcb =append (_acd ._fcb ,&_deb );return _acd ;
};
// WrapIfNeeded wraps the entire contents within q ... Q. If unbalanced, then adds extra Qs at the end.
// Only does if needed. Ensures that when adding new content, one start with all states
// in the default condition.
func (_gf *ContentStreamOperations )WrapIfNeeded ()*ContentStreamOperations {if len (*_gf )==0{return _gf ;};if _gf .isWrapped (){return _gf ;};*_gf =append ([]*ContentStreamOperation {{Operand :"\u0071"}},*_gf ...);_ef :=0;for _ ,_ag :=range *_gf {switch _ag .Operand {case "\u0071":_ef ++;
case "\u0051":_ef --;};};for _ef > 0{*_gf =append (*_gf ,&ContentStreamOperation {Operand :"\u0051"});_ef --;};return _gf ;};
// GetEncoder returns the encoder of the inline image.
func (_baf *ContentStreamInlineImage )GetEncoder ()(_dc .StreamEncoder ,error ){return _gffd (_baf )};
// Add_g appends 'g' operand to the content stream:
// Same as G but used for nonstroking operations.
//
// See section 8.6.8 "Colour Operators" and Table 74 (p. 179-180 PDF32000_2008).
func (_dcaa *ContentCreator )Add_g (gray float64 )*ContentCreator {_ead :=ContentStreamOperation {};_ead .Operand ="\u0067";_ead .Params =_acfc ([]float64 {gray });_dcaa ._fcb =append (_dcaa ._fcb ,&_ead );return _dcaa ;};func (_fddb *ContentStreamParser )parseDict ()(*_dc .PdfObjectDictionary ,error ){_ege .Log .Trace ("\u0052\u0065\u0061\u0064i\u006e\u0067\u0020\u0063\u006f\u006e\u0074\u0065\u006e\u0074 \u0073t\u0072\u0065\u0061\u006d\u0020\u0064\u0069c\u0074\u0021");
_agca :=_dc .MakeDict ();_bgca ,_ :=_fddb ._aga .ReadByte ();if _bgca !='<'{return nil ,_d .New ("\u0069\u006e\u0076a\u006c\u0069\u0064\u0020\u0064\u0069\u0063\u0074");};_bgca ,_ =_fddb ._aga .ReadByte ();if _bgca !='<'{return nil ,_d .New ("\u0069\u006e\u0076a\u006c\u0069\u0064\u0020\u0064\u0069\u0063\u0074");
};for {_fddb .skipSpaces ();_cbc ,_adgc :=_fddb ._aga .Peek (2);if _adgc !=nil {return nil ,_adgc ;};_ege .Log .Trace ("D\u0069c\u0074\u0020\u0070\u0065\u0065\u006b\u003a\u0020%\u0073\u0020\u0028\u0025 x\u0029\u0021",string (_cbc ),string (_cbc ));if (_cbc [0]=='>')&&(_cbc [1]=='>'){_ege .Log .Trace ("\u0045\u004f\u0046\u0020\u0064\u0069\u0063\u0074\u0069o\u006e\u0061\u0072\u0079");
_fddb ._aga .ReadByte ();_fddb ._aga .ReadByte ();break ;};_ege .Log .Trace ("\u0050a\u0072s\u0065\u0020\u0074\u0068\u0065\u0020\u006e\u0061\u006d\u0065\u0021");_aec ,_adgc :=_fddb .parseName ();_ege .Log .Trace ("\u004be\u0079\u003a\u0020\u0025\u0073",_aec );
if _adgc !=nil {_ege .Log .Debug ("E\u0052\u0052\u004f\u0052\u0020\u0052e\u0074\u0075\u0072\u006e\u0069\u006e\u0067\u0020\u006ea\u006d\u0065\u0020e\u0072r\u0020\u0025\u0073",_adgc );return nil ,_adgc ;};if len (_aec )> 4&&_aec [len (_aec )-4:]=="\u006e\u0075\u006c\u006c"{_abda :=_aec [0:len (_aec )-4];
_ege .Log .Trace ("\u0054\u0061\u006b\u0069n\u0067\u0020\u0063\u0061\u0072\u0065\u0020\u006f\u0066\u0020n\u0075l\u006c\u0020\u0062\u0075\u0067\u0020\u0028%\u0073\u0029",_aec );_ege .Log .Trace ("\u004e\u0065\u0077\u0020ke\u0079\u0020\u0022\u0025\u0073\u0022\u0020\u003d\u0020\u006e\u0075\u006c\u006c",_abda );
_fddb .skipSpaces ();_bbe ,_ :=_fddb ._aga .Peek (1);if _bbe [0]=='/'{_agca .Set (_abda ,_dc .MakeNull ());continue ;};};_fddb .skipSpaces ();_cce ,_ ,_adgc :=_fddb .parseObject ();if _adgc !=nil {return nil ,_adgc ;};_agca .Set (_aec ,_cce );_ege .Log .Trace ("\u0064\u0069\u0063\u0074\u005b\u0025\u0073\u005d\u0020\u003d\u0020\u0025\u0073",_aec ,_cce .String ());
};return _agca ,nil ;};
// Add_SCN_pattern appends 'SCN' operand to the content stream for pattern `name`:
// SCN with name attribute (for pattern). Syntax: c1 ... cn name SCN.
//
// See section 8.6.8 "Colour Operators" and Table 74 (p. 179-180 PDF32000_2008).
func (_gfa *ContentCreator )Add_SCN_pattern (name _dc .PdfObjectName ,c ...float64 )*ContentCreator {_add :=ContentStreamOperation {};_add .Operand ="\u0053\u0043\u004e";_add .Params =_acfc (c );_add .Params =append (_add .Params ,_dc .MakeName (string (name )));
_gfa ._fcb =append (_gfa ._fcb ,&_add );return _gfa ;};func (_efag *ContentStreamParser )parseOperand ()(*_dc .PdfObjectString ,error ){var _gbag []byte ;for {_ccg ,_bbdd :=_efag ._aga .Peek (1);if _bbdd !=nil {return _dc .MakeString (string (_gbag )),_bbdd ;
};if _dc .IsDelimiter (_ccg [0]){break ;};if _dc .IsWhiteSpace (_ccg [0]){break ;};_deg ,_ :=_efag ._aga .ReadByte ();_gbag =append (_gbag ,_deg );};return _dc .MakeString (string (_gbag )),nil ;};
// Add_scn_pattern appends 'scn' operand to the content stream for pattern `name`:
// scn with name attribute (for pattern). Syntax: c1 ... cn name scn.
//
// See section 8.6.8 "Colour Operators" and Table 74 (p. 179-180 PDF32000_2008).
func (_cdd *ContentCreator )Add_scn_pattern (name _dc .PdfObjectName ,c ...float64 )*ContentCreator {_ebfa :=ContentStreamOperation {};_ebfa .Operand ="\u0073\u0063\u006e";_ebfa .Params =_acfc (c );_ebfa .Params =append (_ebfa .Params ,_dc .MakeName (string (name )));
_cdd ._fcb =append (_cdd ._fcb ,&_ebfa );return _cdd ;};func _dfcc (_edbf string )bool {_ ,_bbbe :=_gebg [_edbf ];return _bbbe };func (_cabc *ContentStreamInlineImage )String ()string {var _fga _cc .Buffer ;_fga .WriteString (_c .Sprintf ("I\u006el\u0069\u006e\u0065\u0049\u006d\u0061\u0067\u0065(\u006c\u0065\u006e\u003d%d\u0029\u000a",len (_cabc ._dddg )));
if _cabc .BitsPerComponent !=nil {_fga .WriteString ("\u002f\u0042\u0050C\u0020");_fga .Write (_cabc .BitsPerComponent .Write ());_fga .WriteByte ('\n');};if _cabc .ColorSpace !=nil {_fga .WriteString ("\u002f\u0043\u0053\u0020");_fga .Write (_cabc .ColorSpace .Write ());
_fga .WriteByte ('\n');};if _cabc .Decode !=nil {_fga .WriteString ("\u002f\u0044\u0020");_fga .Write (_cabc .Decode .Write ());_fga .WriteByte ('\n');};if _cabc .DecodeParms !=nil {_fga .WriteString ("\u002f\u0044\u0050\u0020");_fga .Write (_cabc .DecodeParms .Write ());
_fga .WriteByte ('\n');};if _cabc .Filter !=nil {_fga .WriteString ("\u002f\u0046\u0020");_fga .Write (_cabc .Filter .Write ());_fga .WriteByte ('\n');};if _cabc .Height !=nil {_fga .WriteString ("\u002f\u0048\u0020");_fga .Write (_cabc .Height .Write ());
_fga .WriteByte ('\n');};if _cabc .ImageMask !=nil {_fga .WriteString ("\u002f\u0049\u004d\u0020");_fga .Write (_cabc .ImageMask .Write ());_fga .WriteByte ('\n');};if _cabc .Intent !=nil {_fga .WriteString ("\u002f\u0049\u006e\u0074\u0065\u006e\u0074\u0020");
_fga .Write (_cabc .Intent .Write ());_fga .WriteByte ('\n');};if _cabc .Interpolate !=nil {_fga .WriteString ("\u002f\u0049\u0020");_fga .Write (_cabc .Interpolate .Write ());_fga .WriteByte ('\n');};if _cabc .Width !=nil {_fga .WriteString ("\u002f\u0057\u0020");
_fga .Write (_cabc .Width .Write ());_fga .WriteByte ('\n');};return _fga .String ();};
// Wrap ensures that the contentstream is wrapped within a balanced q ... Q expression.
func (_bab *ContentCreator )Wrap (){_bab ._fcb .WrapIfNeeded ()};
// Add_b_starred appends 'b*' operand to the content stream:
// Close, fill and then stroke the path (even-odd winding number rule).
//
// See section 8.5.3 "Path Painting Operators" and Table 60 (p. 143 PDF32000_2008).
func (_edb *ContentCreator )Add_b_starred ()*ContentCreator {_egc :=ContentStreamOperation {};_egc .Operand ="\u0062\u002a";_edb ._fcb =append (_edb ._fcb ,&_egc );return _edb ;};
// ParseInlineImage parses an inline image from a content stream, both reading its properties and binary data.
// When called, "BI" has already been read from the stream. This function
// finishes reading through "EI" and then returns the ContentStreamInlineImage.
func (_ecd *ContentStreamParser )ParseInlineImage ()(*ContentStreamInlineImage ,error ){_gage :=ContentStreamInlineImage {};for {_ecd .skipSpaces ();_fgdc ,_dbfb ,_dfc :=_ecd .parseObject ();if _dfc !=nil {return nil ,_dfc ;};if !_dbfb {_egg ,_afe :=_dc .GetName (_fgdc );
if !_afe {_ege .Log .Debug ("\u0049\u006e\u0076\u0061\u006ci\u0064\u0020\u0069\u006e\u006c\u0069\u006e\u0065\u0020\u0069\u006d\u0061\u0067e\u0020\u0070\u0072\u006f\u0070\u0065\u0072\u0074\u0079\u0020\u0028\u0065\u0078\u0070\u0065\u0063\u0074\u0069\u006e\u0067\u0020\u006e\u0061\u006d\u0065\u0029\u0020\u002d\u0020\u0025T",_fgdc );
return nil ,_c .Errorf ("\u0069\u006e\u0076\u0061\u006ci\u0064\u0020\u0069\u006e\u006c\u0069\u006e\u0065\u0020\u0069\u006d\u0061\u0067e\u0020\u0070\u0072\u006f\u0070\u0065\u0072\u0074\u0079\u0020\u0028\u0065\u0078\u0070\u0065\u0063\u0074\u0069\u006e\u0067\u0020\u006e\u0061\u006d\u0065\u0029\u0020\u002d\u0020\u0025T",_fgdc );
};_eac ,_ecac ,_fafa :=_ecd .parseObject ();if _fafa !=nil {return nil ,_fafa ;};if _ecac {return nil ,_c .Errorf ("\u006eo\u0074\u0020\u0065\u0078\u0070\u0065\u0063\u0074\u0069\u006e\u0067 \u0061\u006e\u0020\u006f\u0070\u0065\u0072\u0061\u006e\u0064");
};switch *_egg {case "\u0042\u0050\u0043","\u0042\u0069t\u0073\u0050\u0065r\u0043\u006f\u006d\u0070\u006f\u006e\u0065\u006e\u0074":_gage .BitsPerComponent =_eac ;case "\u0043\u0053","\u0043\u006f\u006c\u006f\u0072\u0053\u0070\u0061\u0063\u0065":_gage .ColorSpace =_eac ;
case "\u0044","\u0044\u0065\u0063\u006f\u0064\u0065":_gage .Decode =_eac ;case "\u0044\u0050","D\u0065\u0063\u006f\u0064\u0065\u0050\u0061\u0072\u006d\u0073":_gage .DecodeParms =_eac ;case "\u0046","\u0046\u0069\u006c\u0074\u0065\u0072":_gage .Filter =_eac ;
case "\u0048","\u0048\u0065\u0069\u0067\u0068\u0074":_gage .Height =_eac ;case "\u0049\u004d","\u0049m\u0061\u0067\u0065\u004d\u0061\u0073k":_gage .ImageMask =_eac ;case "\u0049\u006e\u0074\u0065\u006e\u0074":_gage .Intent =_eac ;case "\u0049","I\u006e\u0074\u0065\u0072\u0070\u006f\u006c\u0061\u0074\u0065":_gage .Interpolate =_eac ;
case "\u0057","\u0057\u0069\u0064t\u0068":_gage .Width =_eac ;case "\u004c\u0065\u006e\u0067\u0074\u0068","\u004c","\u0053u\u0062\u0074\u0079\u0070\u0065","\u0054\u0079\u0070\u0065":_ege .Log .Debug ("\u0049\u0067\u006e\u006fr\u0069\u006e\u0067\u0020\u0069\u006e\u006c\u0069\u006e\u0065 \u0070a\u0072\u0061\u006d\u0065\u0074\u0065\u0072 \u0025\u0073",*_egg );
default:return nil ,_c .Errorf ("\u0075\u006e\u006b\u006e\u006f\u0077n\u0020\u0069\u006e\u006c\u0069\u006e\u0065\u0020\u0069\u006d\u0061\u0067\u0065 \u0070\u0061\u0072\u0061\u006d\u0065\u0074e\u0072\u0020\u0025\u0073",*_egg );};};if _dbfb {_bec ,_bfa :=_fgdc .(*_dc .PdfObjectString );
if !_bfa {return nil ,_c .Errorf ("\u0066a\u0069\u006ce\u0064\u0020\u0074o\u0020\u0072\u0065\u0061\u0064\u0020\u0069n\u006c\u0069\u006e\u0065\u0020\u0069m\u0061\u0067\u0065\u0020\u002d\u0020\u0069\u006e\u0076\u0061\u006ci\u0064\u0020\u006f\u0070\u0065\u0072\u0061\u006e\u0064");
};if _bec .Str ()=="\u0045\u0049"{_ege .Log .Trace ("\u0049n\u006c\u0069\u006e\u0065\u0020\u0069\u006d\u0061\u0067\u0065\u0020f\u0069\u006e\u0069\u0073\u0068\u0065\u0064\u002e\u002e\u002e");return &_gage ,nil ;}else if _bec .Str ()=="\u0049\u0044"{_ege .Log .Trace ("\u0049\u0044\u0020\u0073\u0074\u0061\u0072\u0074");
_cfgf ,_dfcb :=_ecd ._aga .Peek (1);if _dfcb !=nil {return nil ,_dfcb ;};if _dc .IsWhiteSpace (_cfgf [0]){_ecd ._aga .Discard (1);};_gage ._dddg =[]byte {};_dba :=0;var _aab []byte ;for {_dab ,_fgf :=_ecd ._aga .ReadByte ();if _fgf !=nil {_ege .Log .Debug ("\u0055\u006e\u0061\u0062\u006ce\u0020\u0074\u006f\u0020\u0066\u0069\u006e\u0064\u0020\u0065\u006e\u0064\u0020o\u0066\u0020\u0069\u006d\u0061\u0067\u0065\u0020\u0045\u0049\u0020\u0069\u006e\u0020\u0069\u006e\u006c\u0069\u006e\u0065\u0020\u0069\u006d\u0061\u0067\u0065\u0020\u0064\u0061\u0074a");
return nil ,_fgf ;};if _dba ==0{if _dc .IsWhiteSpace (_dab ){_aab =[]byte {};_aab =append (_aab ,_dab );_dba =1;}else if _dab =='E'{_aab =append (_aab ,_dab );_dba =2;}else {_gage ._dddg =append (_gage ._dddg ,_dab );};}else if _dba ==1{_aab =append (_aab ,_dab );
if _dab =='E'{_dba =2;}else {_gage ._dddg =append (_gage ._dddg ,_aab ...);_aab =[]byte {};if _dc .IsWhiteSpace (_dab ){_dba =1;}else {_dba =0;};};}else if _dba ==2{_aab =append (_aab ,_dab );if _dab =='I'{_dba =3;}else {_gage ._dddg =append (_gage ._dddg ,_aab ...);
_aab =[]byte {};_dba =0;};}else if _dba ==3{_aab =append (_aab ,_dab );if _dc .IsWhiteSpace (_dab ){_agd ,_adda :=_ecd ._aga .Peek (20);if _adda !=nil &&_adda !=_ebb .EOF {return nil ,_adda ;};_fdad :=NewContentStreamParser (string (_agd ));_efb :=true ;
for _debf :=0;_debf < 3;_debf ++{_ecab ,_gbgc ,_fabg :=_fdad .parseObject ();if _fabg !=nil {if _fabg ==_ebb .EOF {break ;};_efb =false ;continue ;};if _gbgc &&!_dfcc (_ecab .String ()){_efb =false ;break ;};};if _efb {if len (_gage ._dddg )> 100{_ege .Log .Trace ("\u0049\u006d\u0061\u0067\u0065\u0020\u0073\u0074\u0072\u0065\u0061m\u0020\u0028\u0025\u0064\u0029\u003a\u0020\u0025\u0020\u0078 \u002e\u002e\u002e",len (_gage ._dddg ),_gage ._dddg [:100]);
}else {_ege .Log .Trace ("\u0049\u006d\u0061\u0067e \u0073\u0074\u0072\u0065\u0061\u006d\u0020\u0028\u0025\u0064\u0029\u003a\u0020\u0025 \u0078",len (_gage ._dddg ),_gage ._dddg );};return &_gage ,nil ;};};_gage ._dddg =append (_gage ._dddg ,_aab ...);
_aab =[]byte {};_dba =0;};};};};};};
// Add_w adds 'w' operand to the content stream, which sets the line width.
//
// See section 8.4.4 "Graphic State Operators" and Table 57 (pp. 135-136 PDF32000_2008).
func (_dee *ContentCreator )Add_w (lineWidth float64 )*ContentCreator {_ebf :=ContentStreamOperation {};_ebf .Operand ="\u0077";_ebf .Params =_acfc ([]float64 {lineWidth });_dee ._fcb =append (_dee ._fcb ,&_ebf );return _dee ;};func (_gdbf *ContentStreamParser )parseObject ()(_gce _dc .PdfObject ,_cbgb bool ,_bcef error ){_gdbf .skipSpaces ();
for {_fgfg ,_cae :=_gdbf ._aga .Peek (2);if _cae !=nil {return nil ,false ,_cae ;};_ege .Log .Trace ("\u0050e\u0065k\u0020\u0073\u0074\u0072\u0069\u006e\u0067\u003a\u0020\u0025\u0073",string (_fgfg ));if _fgfg [0]=='%'{_gdbf .skipComments ();continue ;
}else if _fgfg [0]=='/'{_gfbf ,_gagf :=_gdbf .parseName ();_ege .Log .Trace ("\u002d\u003e\u004ea\u006d\u0065\u003a\u0020\u0027\u0025\u0073\u0027",_gfbf );return &_gfbf ,false ,_gagf ;}else if _fgfg [0]=='('{_ege .Log .Trace ("\u002d>\u0053\u0074\u0072\u0069\u006e\u0067!");
_fagde ,_fefc :=_gdbf .parseString ();return _fagde ,false ,_fefc ;}else if _fgfg [0]=='<'&&_fgfg [1]!='<'{_ege .Log .Trace ("\u002d\u003e\u0048\u0065\u0078\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0021");_ebff ,_gca :=_gdbf .parseHexString ();return _ebff ,false ,_gca ;
}else if _fgfg [0]=='['{_ege .Log .Trace ("\u002d\u003e\u0041\u0072\u0072\u0061\u0079\u0021");_cee ,_gbe :=_gdbf .parseArray ();return _cee ,false ,_gbe ;}else if _dc .IsFloatDigit (_fgfg [0])||(_fgfg [0]=='-'&&_dc .IsFloatDigit (_fgfg [1]))||(_fgfg [0]=='+'&&_dc .IsFloatDigit (_fgfg [1])){_ege .Log .Trace ("\u002d>\u004e\u0075\u006d\u0062\u0065\u0072!");
_gaa ,_egac :=_gdbf .parseNumber ();return _gaa ,false ,_egac ;}else if _fgfg [0]=='<'&&_fgfg [1]=='<'{_ged ,_gfaa :=_gdbf .parseDict ();return _ged ,false ,_gfaa ;}else {_ege .Log .Trace ("\u002d>\u004fp\u0065\u0072\u0061\u006e\u0064 \u006f\u0072 \u0062\u006f\u006f\u006c\u003f");
_fgfg ,_ =_gdbf ._aga .Peek (5);_bbdfg :=string (_fgfg );_ege .Log .Trace ("\u0063\u006f\u006e\u0074\u0020\u0050\u0065\u0065\u006b\u0020\u0073\u0074r\u003a\u0020\u0025\u0073",_bbdfg );if (len (_bbdfg )> 3)&&(_bbdfg [:4]=="\u006e\u0075\u006c\u006c"){_egedg ,_bdbf :=_gdbf .parseNull ();
return &_egedg ,false ,_bdbf ;}else if (len (_bbdfg )> 4)&&(_bbdfg [:5]=="\u0066\u0061\u006cs\u0065"){_ccdc ,_dcfa :=_gdbf .parseBool ();return &_ccdc ,false ,_dcfa ;}else if (len (_bbdfg )> 3)&&(_bbdfg [:4]=="\u0074\u0072\u0075\u0065"){_aef ,_gggc :=_gdbf .parseBool ();
return &_aef ,false ,_gggc ;};_dccb ,_fdbf :=_gdbf .parseOperand ();if _fdbf !=nil {return _dccb ,false ,_fdbf ;};if len (_dccb .String ())< 1{return _dccb ,false ,ErrInvalidOperand ;};return _dccb ,true ,nil ;};};};func (_dbde *ContentStreamProcessor )handleCommand_rg (_gdfa *ContentStreamOperation ,_ *_a .PdfPageResources )error {_becf :=_a .NewPdfColorspaceDeviceRGB ();
if len (_gdfa .Params )!=_becf .GetNumComponents (){_ege .Log .Debug ("I\u006e\u0076\u0061\u006c\u0069\u0064 \u006e\u0075\u006d\u0062\u0065\u0072 \u006f\u0066\u0020\u0070\u0061\u0072\u0061m\u0065\u0074\u0065\u0072\u0073\u0020\u0066\u006f\u0072\u0020S\u0043");
_ege .Log .Debug ("\u004e\u0075mb\u0065\u0072\u0020%\u0064\u0020\u006e\u006ft m\u0061tc\u0068\u0069\u006e\u0067\u0020\u0063\u006flo\u0072\u0073\u0070\u0061\u0063\u0065\u0020%\u0054",len (_gdfa .Params ),_becf );if !_dbde ._deff {return _d .New ("\u0069\u006e\u0076\u0061l\u0069\u0064\u0020\u006e\u0075\u006d\u0062\u0065\u0072\u0020o\u0066 \u0070\u0061\u0072\u0061\u006d\u0065\u0074e\u0072\u0073");
};_bcdf ,_efaga :=_edbb (_gdfa .Params );if _efaga !=nil {_ege .Log .Debug ("\u0045\u0052\u0052\u004f\u0052:\u0020\u0046\u0061\u0069\u006c\u0020\u0074\u006f\u0020\u0063\u006f\u006e\u0076e\u0072\u0074\u0020\u0063\u006f\u006c\u006f\u0072\u0020\u0074\u006f\u0020\u0067\u0072\u0061\u0079\u003a\u0020\u0025\u002b\u0076",_gdfa .Params );
return _efaga ;};_gdfa .Params =[]_dc .PdfObject {_bcdf };};_fgg ,_befg :=_becf .ColorFromPdfObjects (_gdfa .Params );if _befg !=nil {return _befg ;};_dbde ._fgfc .ColorspaceNonStroking =_becf ;_dbde ._fgfc .ColorNonStroking =_fgg ;return nil ;};
// Add_S appends 'S' operand to the content stream: Stroke the path.
//
// See section 8.5.3 "Path Painting Operators" and Table 60 (p. 143 PDF32000_2008).
func (_beb *ContentCreator )Add_S ()*ContentCreator {_ccb :=ContentStreamOperation {};_ccb .Operand ="\u0053";_beb ._fcb =append (_beb ._fcb ,&_ccb );return _beb ;};func (_gafa *ContentStreamProcessor )handleCommand_k (_bbab *ContentStreamOperation ,_ *_a .PdfPageResources )error {_gaeaa :=_a .NewPdfColorspaceDeviceCMYK ();
if len (_bbab .Params )!=_gaeaa .GetNumComponents (){_ege .Log .Debug ("I\u006e\u0076\u0061\u006c\u0069\u0064 \u006e\u0075\u006d\u0062\u0065\u0072 \u006f\u0066\u0020\u0070\u0061\u0072\u0061m\u0065\u0074\u0065\u0072\u0073\u0020\u0066\u006f\u0072\u0020S\u0043");
_ege .Log .Debug ("\u004e\u0075mb\u0065\u0072\u0020%\u0064\u0020\u006e\u006ft m\u0061tc\u0068\u0069\u006e\u0067\u0020\u0063\u006flo\u0072\u0073\u0070\u0061\u0063\u0065\u0020%\u0054",len (_bbab .Params ),_gaeaa );return _d .New ("\u0069\u006e\u0076\u0061l\u0069\u0064\u0020\u006e\u0075\u006d\u0062\u0065\u0072\u0020o\u0066 \u0070\u0061\u0072\u0061\u006d\u0065\u0074e\u0072\u0073");
};_bbee ,_aedec :=_gaeaa .ColorFromPdfObjects (_bbab .Params );if _aedec !=nil {return _aedec ;};_gafa ._fgfc .ColorspaceNonStroking =_gaeaa ;_gafa ._fgfc .ColorNonStroking =_bbee ;return nil ;};
// ContentStreamOperation represents an operation in PDF contentstream which consists of
// an operand and parameters.
type ContentStreamOperation struct{Params []_dc .PdfObject ;Operand string ;};func _acfc (_aeee []float64 )[]_dc .PdfObject {var _egedb []_dc .PdfObject ;for _ ,_fbd :=range _aeee {_egedb =append (_egedb ,_dc .MakeFloat (_fbd ));};return _egedb ;};func (_eeda *ContentStreamParser )parseArray ()(*_dc .PdfObjectArray ,error ){_ccba :=_dc .MakeArray ();
_eeda ._aga .ReadByte ();for {_eeda .skipSpaces ();_eegb ,_baad :=_eeda ._aga .Peek (1);if _baad !=nil {return _ccba ,_baad ;};if _eegb [0]==']'{_eeda ._aga .ReadByte ();break ;};_bcaa ,_ ,_baad :=_eeda .parseObject ();if _baad !=nil {return _ccba ,_baad ;
};_ccba .Append (_bcaa );};return _ccba ,nil ;};func (_ffcc *ContentStreamParser )parseHexString ()(*_dc .PdfObjectString ,error ){_ffcc ._aga .ReadByte ();_ebbb :=[]byte ("\u0030\u0031\u0032\u003345\u0036\u0037\u0038\u0039\u0061\u0062\u0063\u0064\u0065\u0066\u0041\u0042\u0043\u0044E\u0046");
var _gbac []byte ;for {_ffcc .skipSpaces ();_bbgf ,_dcd :=_ffcc ._aga .Peek (1);if _dcd !=nil {return _dc .MakeString (""),_dcd ;};if _bbgf [0]=='>'{_ffcc ._aga .ReadByte ();break ;};_bgbc ,_ :=_ffcc ._aga .ReadByte ();if _cc .IndexByte (_ebbb ,_bgbc )>=0{_gbac =append (_gbac ,_bgbc );
};};if len (_gbac )%2==1{_gbac =append (_gbac ,'0');};_fbee ,_ :=_eb .DecodeString (string (_gbac ));return _dc .MakeHexString (string (_fbee )),nil ;};
// Add_ET appends 'ET' operand to the content stream:
// End text.
//
// See section 9.4 "Text Objects" and Table 107 (p. 256 PDF32000_2008).
func (_ecb *ContentCreator )Add_ET ()*ContentCreator {_ega :=ContentStreamOperation {};_ega .Operand ="\u0045\u0054";_ecb ._fcb =append (_ecb ._fcb ,&_ega );return _ecb ;};
// Add_b appends 'b' operand to the content stream:
// Close, fill and then stroke the path (nonzero winding number rule).
//
// See section 8.5.3 "Path Painting Operators" and Table 60 (p. 143 PDF32000_2008).
func (_eef *ContentCreator )Add_b ()*ContentCreator {_gdgg :=ContentStreamOperation {};_gdgg .Operand ="\u0062";_eef ._fcb =append (_eef ._fcb ,&_gdgg );return _eef ;};func (_cfgc *ContentStreamProcessor )handleCommand_SCN (_aeb *ContentStreamOperation ,_ *_a .PdfPageResources )error {_ebcd :=_cfgc ._fgfc .ColorspaceStroking ;
if !_afceb (_ebcd ){if len (_aeb .Params )!=_ebcd .GetNumComponents (){_ege .Log .Debug ("I\u006e\u0076\u0061\u006c\u0069\u0064 \u006e\u0075\u006d\u0062\u0065\u0072 \u006f\u0066\u0020\u0070\u0061\u0072\u0061m\u0065\u0074\u0065\u0072\u0073\u0020\u0066\u006f\u0072\u0020S\u0043");
_ege .Log .Debug ("\u004e\u0075mb\u0065\u0072\u0020%\u0064\u0020\u006e\u006ft m\u0061tc\u0068\u0069\u006e\u0067\u0020\u0063\u006flo\u0072\u0073\u0070\u0061\u0063\u0065\u0020%\u0054",len (_aeb .Params ),_ebcd );if !_cfgc ._deff {return _d .New ("\u0069\u006e\u0076\u0061l\u0069\u0064\u0020\u006e\u0075\u006d\u0062\u0065\u0072\u0020o\u0066 \u0070\u0061\u0072\u0061\u006d\u0065\u0074e\u0072\u0073");
};_adf ,_aedb :=_edbb (_aeb .Params );if _aedb !=nil {_ege .Log .Debug ("\u0045\u0052\u0052\u004f\u0052:\u0020\u0046\u0061\u0069\u006c\u0020\u0074\u006f\u0020\u0063\u006f\u006e\u0076e\u0072\u0074\u0020\u0063\u006f\u006c\u006f\u0072\u0020\u0074\u006f\u0020\u0067\u0072\u0061\u0079\u003a\u0020\u0025\u002b\u0076",_aeb .Params );
return _aedb ;};_aeb .Params =[]_dc .PdfObject {_adf };};};_fbeb ,_bbeg :=_ebcd .ColorFromPdfObjects (_aeb .Params );if _bbeg !=nil {return _bbeg ;};_cfgc ._fgfc .ColorStroking =_fbeb ;return nil ;};
// GetColorSpace returns the colorspace of the inline image.
func (_afc *ContentStreamInlineImage )GetColorSpace (resources *_a .PdfPageResources )(_a .PdfColorspace ,error ){if _afc .ColorSpace ==nil {_ege .Log .Debug ("\u0049\u006e\u006c\u0069\u006e\u0065\u0020\u0069\u006d\u0061\u0067\u0065\u0020\u006e\u006f\u0074\u0020\u0068\u0061\u0076i\u006e\u0067\u0020\u0073\u0070\u0065\u0063\u0069\u0066\u0069\u0065\u0064\u0020\u0063\u006f\u006c\u006f\u0072\u0073\u0070\u0061\u0063\u0065\u002c\u0020\u0061\u0073\u0073\u0075\u006di\u006e\u0067\u0020\u0047\u0072a\u0079");
return _a .NewPdfColorspaceDeviceGray (),nil ;};if _bcbg ,_cccc :=_afc .ColorSpace .(*_dc .PdfObjectArray );_cccc {return _ebbbc (_bcbg );};_eecea ,_ccbg :=_afc .ColorSpace .(*_dc .PdfObjectName );if !_ccbg {_ege .Log .Debug ("E\u0072\u0072\u006f\u0072\u003a\u0020I\u006e\u0076\u0061\u006c\u0069\u0064 \u006f\u0062\u006a\u0065\u0063\u0074\u0020t\u0079\u0070\u0065\u0020\u0028\u0025\u0054\u003b\u0025\u002bv\u0029",_afc .ColorSpace ,_afc .ColorSpace );
return nil ,_d .New ("\u0074\u0079p\u0065\u0020\u0063h\u0065\u0063\u006b\u0020\u0065\u0072\u0072\u006f\u0072");};switch *_eecea {case "\u0047","\u0044\u0065\u0076\u0069\u0063\u0065\u0047\u0072\u0061\u0079":return _a .NewPdfColorspaceDeviceGray (),nil ;
case "\u0052\u0047\u0042","\u0044e\u0076\u0069\u0063\u0065\u0052\u0047B":return _a .NewPdfColorspaceDeviceRGB (),nil ;case "\u0043\u004d\u0059\u004b","\u0044\u0065\u0076\u0069\u0063\u0065\u0043\u004d\u0059\u004b":return _a .NewPdfColorspaceDeviceCMYK (),nil ;
case "\u0049","\u0049n\u0064\u0065\u0078\u0065\u0064":return nil ,_d .New ("\u0075\u006e\u0073\u0075p\u0070\u006f\u0072\u0074\u0065\u0064\u0020\u0049\u006e\u0064e\u0078 \u0063\u006f\u006c\u006f\u0072\u0073\u0070a\u0063\u0065");default:if resources .ColorSpace ==nil {_ege .Log .Debug ("\u0045\u0072r\u006f\u0072\u002c\u0020\u0075\u006e\u0073\u0075\u0070\u0070\u006f\u0072\u0074\u0065\u0064\u0020\u0069\u006e\u006c\u0069\u006e\u0065\u0020\u0069\u006d\u0061\u0067\u0065\u0020\u0063\u006f\u006c\u006f\u0072\u0073\u0070\u0061\u0063\u0065\u003a\u0020\u0025\u0073",*_eecea );
return nil ,_d .New ("\u0075n\u006bn\u006f\u0077\u006e\u0020\u0063o\u006c\u006fr\u0073\u0070\u0061\u0063\u0065");};_gae ,_gaea :=resources .GetColorspaceByName (*_eecea );if !_gaea {_ege .Log .Debug ("\u0045\u0072r\u006f\u0072\u002c\u0020\u0075\u006e\u0073\u0075\u0070\u0070\u006f\u0072\u0074\u0065\u0064\u0020\u0069\u006e\u006c\u0069\u006e\u0065\u0020\u0069\u006d\u0061\u0067\u0065\u0020\u0063\u006f\u006c\u006f\u0072\u0073\u0070\u0061\u0063\u0065\u003a\u0020\u0025\u0073",*_eecea );
return nil ,_d .New ("\u0075n\u006bn\u006f\u0077\u006e\u0020\u0063o\u006c\u006fr\u0073\u0070\u0061\u0063\u0065");};return _gae ,nil ;};};
// ContentStreamInlineImage is a representation of an inline image in a Content stream. Everything between the BI and EI operands.
// ContentStreamInlineImage implements the core.PdfObject interface although strictly it is not a PDF object.
type ContentStreamInlineImage struct{BitsPerComponent _dc .PdfObject ;ColorSpace _dc .PdfObject ;Decode _dc .PdfObject ;DecodeParms _dc .PdfObject ;Filter _dc .PdfObject ;Height _dc .PdfObject ;ImageMask _dc .PdfObject ;Intent _dc .PdfObject ;Interpolate _dc .PdfObject ;
Width _dc .PdfObject ;_dddg []byte ;_fffg *_de .ImageBase ;};
// Add_CS appends 'CS' operand to the content stream:
// Set the current colorspace for stroking operations.
//
// See section 8.6.8 "Colour Operators" and Table 74 (p. 179-180 PDF32000_2008).
func (_cd *ContentCreator )Add_CS (name _dc .PdfObjectName )*ContentCreator {_bbb :=ContentStreamOperation {};_bbb .Operand ="\u0043\u0053";_bbb .Params =_bedg ([]_dc .PdfObjectName {name });_cd ._fcb =append (_cd ._fcb ,&_bbb );return _cd ;};
// Write outputs the object as a byte array.
func (_abab *ContentStreamInlineImage )Write ()[]byte {var _gga _cc .Buffer ;if _abab .BitsPerComponent !=nil {_gga .WriteString ("\u002f\u0042\u0050C\u0020");_gga .Write (_abab .BitsPerComponent .Write ());_gga .WriteByte ('\n');};if _abab .ColorSpace !=nil {_gga .WriteString ("\u002f\u0043\u0053\u0020");
_gga .Write (_abab .ColorSpace .Write ());_gga .WriteByte ('\n');};if _abab .Decode !=nil {_gga .WriteString ("\u002f\u0044\u0020");_gga .Write (_abab .Decode .Write ());_gga .WriteByte ('\n');};if _abab .DecodeParms !=nil {_gga .WriteString ("\u002f\u0044\u0050\u0020");
_gga .Write (_abab .DecodeParms .Write ());_gga .WriteByte ('\n');};if _abab .Filter !=nil {_gga .WriteString ("\u002f\u0046\u0020");_gga .Write (_abab .Filter .Write ());_gga .WriteByte ('\n');};if _abab .Height !=nil {_gga .WriteString ("\u002f\u0048\u0020");
_gga .Write (_abab .Height .Write ());_gga .WriteByte ('\n');};if _abab .ImageMask !=nil {_gga .WriteString ("\u002f\u0049\u004d\u0020");_gga .Write (_abab .ImageMask .Write ());_gga .WriteByte ('\n');};if _abab .Intent !=nil {_gga .WriteString ("\u002f\u0049\u006e\u0074\u0065\u006e\u0074\u0020");
_gga .Write (_abab .Intent .Write ());_gga .WriteByte ('\n');};if _abab .Interpolate !=nil {_gga .WriteString ("\u002f\u0049\u0020");_gga .Write (_abab .Interpolate .Write ());_gga .WriteByte ('\n');};if _abab .Width !=nil {_gga .WriteString ("\u002f\u0057\u0020");
_gga .Write (_abab .Width .Write ());_gga .WriteByte ('\n');};_gga .WriteString ("\u0049\u0044\u0020");_gga .Write (_abab ._dddg );_gga .WriteString ("\u000a\u0045\u0049\u000a");return _gga .Bytes ();};
// Bytes converts a set of content stream operations to a content stream byte presentation,
// i.e. the kind that can be stored as a PDF stream or string format.
func (_fa *ContentStreamOperations )Bytes ()[]byte {var _ba _cc .Buffer ;for _ ,_ab :=range *_fa {if _ab ==nil {continue ;};if _ab .Operand =="\u0042\u0049"{_ba .WriteString (_ab .Operand +"\u000a");_ba .Write (_ab .Params [0].Write ());}else {for _ ,_egb :=range _ab .Params {_ba .Write (_egb .Write ());
_ba .WriteString ("\u0020");};_ba .WriteString (_ab .Operand +"\u000a");};};return _ba .Bytes ();};
// ContentCreator is a builder for PDF content streams.
type ContentCreator struct{_fcb ContentStreamOperations };
// IsMask checks if an image is a mask.
// The image mask entry in the image dictionary specifies that the image data shall be used as a stencil
// mask for painting in the current color. The mask data is 1bpc, grayscale.
func (_bbdc *ContentStreamInlineImage )IsMask ()(bool ,error ){if _bbdc .ImageMask !=nil {_bga ,_geeb :=_bbdc .ImageMask .(*_dc .PdfObjectBool );if !_geeb {_ege .Log .Debug ("\u0049m\u0061\u0067\u0065\u0020\u006d\u0061\u0073\u006b\u0020\u006e\u006ft\u0020\u0061\u0020\u0062\u006f\u006f\u006c\u0065\u0061\u006e");
return false ,_d .New ("\u0069\u006e\u0076\u0061li\u0064\u0020\u006f\u0062\u006a\u0065\u0063\u0074\u0020\u0074\u0079\u0070\u0065");};return bool (*_bga ),nil ;};return false ,nil ;};func (_faeb *ContentStreamProcessor )getInitialColor (_gbabc _a .PdfColorspace )(_a .PdfColor ,error ){switch _eceb :=_gbabc .(type ){case *_a .PdfColorspaceDeviceGray :return _a .NewPdfColorDeviceGray (0.0),nil ;
case *_a .PdfColorspaceDeviceRGB :return _a .NewPdfColorDeviceRGB (0.0,0.0,0.0),nil ;case *_a .PdfColorspaceDeviceCMYK :return _a .NewPdfColorDeviceCMYK (0.0,0.0,0.0,1.0),nil ;case *_a .PdfColorspaceCalGray :return _a .NewPdfColorCalGray (0.0),nil ;case *_a .PdfColorspaceCalRGB :return _a .NewPdfColorCalRGB (0.0,0.0,0.0),nil ;
case *_a .PdfColorspaceLab :_caeg :=0.0;_dce :=0.0;_dfdb :=0.0;if _eceb .Range [0]> 0{_caeg =_eceb .Range [0];};if _eceb .Range [2]> 0{_dce =_eceb .Range [2];};return _a .NewPdfColorLab (_caeg ,_dce ,_dfdb ),nil ;case *_a .PdfColorspaceICCBased :if _eceb .Alternate ==nil {_ege .Log .Trace ("\u0049\u0043\u0043\u0020\u0042\u0061\u0073\u0065\u0064\u0020\u006eo\u0074\u0020\u0064\u0065\u0066\u0069\u006e\u0065d\u0020-\u0020\u0061\u0074\u0074\u0065\u006d\u0070\u0074\u0069\u006e\u0067\u0020\u0066\u0061\u006c\u006c\u0020\u0062a\u0063\u006b\u0020\u0028\u004e\u0020\u003d\u0020\u0025\u0064\u0029",_eceb .N );
switch _eceb .N {case 1:_ege .Log .Trace ("\u0046\u0061\u006c\u006c\u0069\u006e\u0067\u0020\u0062\u0061\u0063k\u0020\u0074\u006f\u0020\u0044\u0065\u0076\u0069\u0063\u0065G\u0072\u0061\u0079");return _faeb .getInitialColor (_a .NewPdfColorspaceDeviceGray ());
case 3:_ege .Log .Trace ("\u0046a\u006c\u006c\u0069\u006eg\u0020\u0062\u0061\u0063\u006b \u0074o\u0020D\u0065\u0076\u0069\u0063\u0065\u0052\u0047B");return _faeb .getInitialColor (_a .NewPdfColorspaceDeviceRGB ());case 4:_ege .Log .Trace ("\u0046\u0061\u006c\u006c\u0069\u006e\u0067\u0020\u0062\u0061\u0063k\u0020\u0074\u006f\u0020\u0044\u0065\u0076\u0069\u0063\u0065C\u004d\u0059\u004b");
return _faeb .getInitialColor (_a .NewPdfColorspaceDeviceCMYK ());default:return nil ,_d .New ("a\u006c\u0074\u0065\u0072\u006e\u0061t\u0065\u0020\u0073\u0070\u0061\u0063e\u0020\u006e\u006f\u0074\u0020\u0064\u0065f\u0069\u006e\u0065\u0064\u0020\u0066\u006f\u0072\u0020\u0049C\u0043");
};};return _faeb .getInitialColor (_eceb .Alternate );case *_a .PdfColorspaceSpecialIndexed :if _eceb .Base ==nil {return nil ,_d .New ("\u0069\u006e\u0064\u0065\u0078\u0065\u0064\u0020\u0062\u0061\u0073e\u0020\u006e\u006f\u0074\u0020\u0073\u0070\u0065\u0063\u0069f\u0069\u0065\u0064");
};return _faeb .getInitialColor (_eceb .Base );case *_a .PdfColorspaceSpecialSeparation :if _eceb .AlternateSpace ==nil {return nil ,_d .New ("\u0061\u006ct\u0065\u0072\u006e\u0061\u0074\u0065\u0020\u0073\u0070\u0061\u0063\u0065\u0020\u006e\u006f\u0074\u0020\u0073\u0070\u0065\u0063\u0069fi\u0065\u0064");
};return _faeb .getInitialColor (_eceb .AlternateSpace );case *_a .PdfColorspaceDeviceN :if _eceb .AlternateSpace ==nil {return nil ,_d .New ("\u0061\u006ct\u0065\u0072\u006e\u0061\u0074\u0065\u0020\u0073\u0070\u0061\u0063\u0065\u0020\u006e\u006f\u0074\u0020\u0073\u0070\u0065\u0063\u0069fi\u0065\u0064");
};return _faeb .getInitialColor (_eceb .AlternateSpace );case *_a .PdfColorspaceSpecialPattern :return _a .NewPdfColorPattern (),nil ;};_ege .Log .Debug ("Un\u0061\u0062l\u0065\u0020\u0074\u006f\u0020\u0064\u0065\u0074\u0065r\u006d\u0069\u006e\u0065\u0020\u0069\u006e\u0069\u0074\u0069\u0061\u006c\u0020\u0063\u006f\u006c\u006f\u0072\u0020\u0066\u006f\u0072\u0020\u0075\u006e\u006b\u006e\u006fw\u006e \u0063\u006f\u006c\u006f\u0072\u0073\u0070\u0061c\u0065:\u0020\u0025T",_gbabc );
return nil ,_d .New ("\u0075\u006e\u0073\u0075pp\u006f\u0072\u0074\u0065\u0064\u0020\u0063\u006f\u006c\u006f\u0072\u0073\u0070\u0061c\u0065");};func _edbb (_fccd []_dc .PdfObject )(_dc .PdfObject ,error ){_ege .Log .Debug ("\u0041\u0075t\u006f\u0020\u0063o\u006e\u0076\u0065\u0072\u0074 \u0063\u006f\u006c\u006f\u0072 t\u006f\u0020\u0067\u0072\u0061\u0079\u0073\u0063\u0061\u006c\u0065\u002c\u0020\u0079\u006f\u0075\u0020\u0063a\u006e \u0074\u0075\u0072\u006e\u0020\u006fff \u0074\u0068\u0069\u0073\u0020\u0062\u0079\u0020\u0073\u0065\u0074\u0074in\u0067 \u0052\u0065\u006c\u0061x\u0065d\u004do\u0064\u0065 \u0074\u006f f\u0061\u006c\u0073\u0065");
if len (_fccd )!=3{return nil ,_d .New ("\u0069\u006e\u0076\u0061l\u0069\u0064\u0020\u006e\u0075\u006d\u0062\u0065\u0072\u0020o\u0066 \u0070\u0061\u0072\u0061\u006d\u0065\u0074e\u0072\u0073");};_efad ,_beee :=_dc .GetNumbersAsFloat (_fccd );if _beee !=nil {return nil ,_beee ;
};_cca :=int (_bf .Round (_efad [0]*255));_eee :=int (_bf .Round (_efad [1]*255));_gcbac :=int (_bf .Round (_efad [2]*255));_ade :=_dc .RGBToGrayscale (_cca ,_eee ,_gcbac );return _dc .MakeFloat (float64 (_ade )/255.0),nil ;};
// Add_gs adds 'gs' operand to the content stream: Set the graphics state.
//
// See section 8.4.4 "Graphic State Operators" and Table 57 (pp. 135-136 PDF32000_2008).
func (_gag *ContentCreator )Add_gs (dictName _dc .PdfObjectName )*ContentCreator {_fda :=ContentStreamOperation {};_fda .Operand ="\u0067\u0073";_fda .Params =_bedg ([]_dc .PdfObjectName {dictName });_gag ._fcb =append (_gag ._fcb ,&_fda );return _gag ;
};func _ceg (_gfcg *ContentStreamInlineImage )(*_dc .MultiEncoder ,error ){_gcda :=_dc .NewMultiEncoder ();var _aae *_dc .PdfObjectDictionary ;var _bdb []_dc .PdfObject ;if _bacb :=_gfcg .DecodeParms ;_bacb !=nil {_aee ,_acc :=_bacb .(*_dc .PdfObjectDictionary );
if _acc {_aae =_aee ;};_dage ,_ebc :=_bacb .(*_dc .PdfObjectArray );if _ebc {for _ ,_ccc :=range _dage .Elements (){if _gbab ,_gebb :=_ccc .(*_dc .PdfObjectDictionary );_gebb {_bdb =append (_bdb ,_gbab );}else {_bdb =append (_bdb ,nil );};};};};_fbe :=_gfcg .Filter ;
if _fbe ==nil {return nil ,_c .Errorf ("\u0066\u0069\u006c\u0074\u0065\u0072\u0020\u006d\u0069s\u0073\u0069\u006e\u0067");};_bbg ,_gbgb :=_fbe .(*_dc .PdfObjectArray );if !_gbgb {return nil ,_c .Errorf ("m\u0075\u006c\u0074\u0069\u0020\u0066\u0069\u006c\u0074\u0065\u0072\u0020\u0063\u0061\u006e\u0020\u006f\u006el\u0079\u0020\u0062\u0065\u0020\u006d\u0061\u0064\u0065\u0020fr\u006f\u006d\u0020a\u0072r\u0061\u0079");
};for _gbdd ,_fgd :=range _bbg .Elements (){_eadd ,_ggd :=_fgd .(*_dc .PdfObjectName );if !_ggd {return nil ,_c .Errorf ("\u006d\u0075l\u0074\u0069\u0020\u0066i\u006c\u0074e\u0072\u0020\u0061\u0072\u0072\u0061\u0079\u0020e\u006c\u0065\u006d\u0065\u006e\u0074\u0020\u006e\u006f\u0074\u0020\u0061 \u006e\u0061\u006d\u0065");
};var _aca _dc .PdfObject ;if _aae !=nil {_aca =_aae ;}else {if len (_bdb )> 0{if _gbdd >=len (_bdb ){return nil ,_c .Errorf ("\u006d\u0069\u0073\u0073\u0069\u006e\u0067\u0020\u0065\u006c\u0065\u006d\u0065n\u0074\u0073\u0020\u0069\u006e\u0020d\u0065\u0063\u006f\u0064\u0065\u0020\u0070\u0061\u0072\u0061\u006d\u0073\u0020a\u0072\u0072\u0061\u0079");
};_aca =_bdb [_gbdd ];};};var _bgc *_dc .PdfObjectDictionary ;if _ecg ,_cbg :=_aca .(*_dc .PdfObjectDictionary );_cbg {_bgc =_ecg ;};switch *_eadd {case _dc .StreamEncodingFilterNameFlate ,"\u0046\u006c":_bbd ,_fade :=_gfdc (_gfcg ,_bgc );if _fade !=nil {return nil ,_fade ;
};_gcda .AddEncoder (_bbd );case _dc .StreamEncodingFilterNameLZW :_abb ,_fef :=_eaaa (_gfcg ,_bgc );if _fef !=nil {return nil ,_fef ;};_gcda .AddEncoder (_abb );case _dc .StreamEncodingFilterNameASCIIHex :_def :=_dc .NewASCIIHexEncoder ();_gcda .AddEncoder (_def );
case _dc .StreamEncodingFilterNameASCII85 ,"\u0041\u0038\u0035":_fae :=_dc .NewASCII85Encoder ();_gcda .AddEncoder (_fae );default:_ege .Log .Error ("U\u006e\u0073\u0075\u0070po\u0072t\u0065\u0064\u0020\u0066\u0069l\u0074\u0065\u0072\u0020\u0025\u0073",*_eadd );
return nil ,_c .Errorf ("\u0069\u006eva\u006c\u0069\u0064 \u0066\u0069\u006c\u0074er \u0069n \u006d\u0075\u006c\u0074\u0069\u0020\u0066il\u0074\u0065\u0072\u0020\u0061\u0072\u0072a\u0079");};};return _gcda ,nil ;};
// NewContentCreator returns a new initialized ContentCreator.
func NewContentCreator ()*ContentCreator {_ddd :=&ContentCreator {};_ddd ._fcb =ContentStreamOperations {};return _ddd ;};
// NewContentStreamProcessor returns a new ContentStreamProcessor for operations `ops`.
func NewContentStreamProcessor (ops []*ContentStreamOperation )*ContentStreamProcessor {_dde :=ContentStreamProcessor {};_dde ._feba =GraphicStateStack {};_deee :=GraphicsState {};_dde ._fgfc =_deee ;_dde ._cebf =[]handlerEntry {};_dde ._gcgf =0;_dde ._fbeg =ops ;
return &_dde ;};
// Process processes the entire list of operations. Maintains the graphics state that is passed to any
// handlers that are triggered during processing (either on specific operators or all).
func (_bgf *ContentStreamProcessor )Process (resources *_a .PdfPageResources )error {_bgf ._fgfc .ColorspaceStroking =_a .NewPdfColorspaceDeviceGray ();_bgf ._fgfc .ColorspaceNonStroking =_a .NewPdfColorspaceDeviceGray ();_bgf ._fgfc .ColorStroking =_a .NewPdfColorDeviceGray (0);
_bgf ._fgfc .ColorNonStroking =_a .NewPdfColorDeviceGray (0);_bgf ._fgfc .CTM =_cg .IdentityMatrix ();for _ ,_dga :=range _bgf ._fbeg {var _cdgc error ;switch _dga .Operand {case "\u0071":_bgf ._feba .Push (_bgf ._fgfc );case "\u0051":if len (_bgf ._feba )==0{_ege .Log .Debug ("\u0057\u0041\u0052\u004e\u003a\u0020\u0069\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u0060\u0051\u0060\u0020\u006f\u0070e\u0072\u0061\u0074\u006f\u0072\u002e\u0020\u0047\u0072\u0061\u0070\u0068\u0069\u0063\u0073\u0020\u0073\u0074\u0061\u0074\u0065 \u0073\u0074\u0061\u0063\u006b\u0020\u0069\u0073\u0020\u0065\u006d\u0070\u0074\u0079.\u0020\u0053\u006bi\u0070\u0070\u0069\u006e\u0067\u002e");
continue ;};_bgf ._fgfc =_bgf ._feba .Pop ();case "\u0043\u0053":_cdgc =_bgf .handleCommand_CS (_dga ,resources );case "\u0063\u0073":_cdgc =_bgf .handleCommand_cs (_dga ,resources );case "\u0053\u0043":_cdgc =_bgf .handleCommand_SC (_dga ,resources );
case "\u0053\u0043\u004e":_cdgc =_bgf .handleCommand_SCN (_dga ,resources );case "\u0073\u0063":_cdgc =_bgf .handleCommand_sc (_dga ,resources );case "\u0073\u0063\u006e":_cdgc =_bgf .handleCommand_scn (_dga ,resources );case "\u0047":_cdgc =_bgf .handleCommand_G (_dga ,resources );
case "\u0067":_cdgc =_bgf .handleCommand_g (_dga ,resources );case "\u0052\u0047":_cdgc =_bgf .handleCommand_RG (_dga ,resources );case "\u0072\u0067":_cdgc =_bgf .handleCommand_rg (_dga ,resources );case "\u004b":_cdgc =_bgf .handleCommand_K (_dga ,resources );
case "\u006b":_cdgc =_bgf .handleCommand_k (_dga ,resources );case "\u0063\u006d":_cdgc =_bgf .handleCommand_cm (_dga ,resources );};if _cdgc !=nil {_ege .Log .Debug ("\u0050\u0072\u006f\u0063\u0065\u0073s\u006f\u0072\u0020\u0068\u0061\u006e\u0064\u006c\u0069\u006e\u0067\u0020\u0065r\u0072\u006f\u0072\u0020\u0028\u0025\u0073)\u003a\u0020\u0025\u0076",_dga .Operand ,_cdgc );
_ege .Log .Debug ("\u004f\u0070\u0065r\u0061\u006e\u0064\u003a\u0020\u0025\u0023\u0076",_dga .Operand );return _cdgc ;};for _ ,_cegca :=range _bgf ._cebf {var _fdef error ;if _cegca .Condition .All (){_fdef =_cegca .Handler (_dga ,_bgf ._fgfc ,resources );
}else if _cegca .Condition .Operand ()&&_dga .Operand ==_cegca .Operand {_fdef =_cegca .Handler (_dga ,_bgf ._fgfc ,resources );};if _fdef !=nil {_ege .Log .Debug ("P\u0072\u006f\u0063\u0065\u0073\u0073o\u0072\u0020\u0068\u0061\u006e\u0064\u006c\u0065\u0072 \u0065\u0072\u0072o\u0072:\u0020\u0025\u0076",_fdef );
return _fdef ;};};};return nil ;};func (_afce *ContentStreamProcessor )handleCommand_CS (_fcbf *ContentStreamOperation ,_aea *_a .PdfPageResources )error {if len (_fcbf .Params )< 1{_ege .Log .Debug ("\u0049\u006e\u0076\u0061\u006c\u0069d\u0020\u0063\u0073\u0020\u0063\u006f\u006d\u006d\u0061\u006e\u0064\u002c\u0020s\u006b\u0069\u0070\u0070\u0069\u006e\u0067 \u006f\u0076\u0065\u0072");
return _d .New ("\u0074o\u006f \u0066\u0065\u0077\u0020\u0070a\u0072\u0061m\u0065\u0074\u0065\u0072\u0073");};if len (_fcbf .Params )> 1{_ege .Log .Debug ("\u0063\u0073\u0020\u0063\u006f\u006d\u006d\u0061n\u0064\u0020\u0077it\u0068\u0020\u0074\u006f\u006f\u0020m\u0061\u006e\u0079\u0020\u0070\u0061\u0072\u0061\u006d\u0065\u0074\u0065\u0072\u0073\u0020-\u0020\u0063\u006f\u006e\u0074\u0069\u006e\u0075i\u006e\u0067");
return _d .New ("\u0074\u006f\u006f\u0020ma\u006e\u0079\u0020\u0070\u0061\u0072\u0061\u006d\u0065\u0074\u0065\u0072\u0073");};_dgb ,_eefg :=_fcbf .Params [0].(*_dc .PdfObjectName );if !_eefg {_ege .Log .Debug ("\u0045\u0052\u0052\u004f\u0052\u003a\u0020c\u0073\u0020\u0063o\u006d\u006d\u0061n\u0064\u0020w\u0069\u0074\u0068\u0020\u0069\u006ev\u0061li\u0064\u0020\u0070\u0061\u0072\u0061\u006d\u0065\u0074\u0065\u0072\u002c\u0020\u0073\u006b\u0069\u0070\u0070\u0069\u006e\u0067\u0020\u006f\u0076\u0065\u0072");
return _d .New ("\u0074\u0079p\u0065\u0020\u0063h\u0065\u0063\u006b\u0020\u0065\u0072\u0072\u006f\u0072");};_dbae ,_egd :=_afce .getColorspace (string (*_dgb ),_aea );if _egd !=nil {return _egd ;};_afce ._fgfc .ColorspaceStroking =_dbae ;_cba ,_egd :=_afce .getInitialColor (_dbae );
if _egd !=nil {return _egd ;};_afce ._fgfc .ColorStroking =_cba ;return nil ;};func (_fefa *ContentStreamProcessor )handleCommand_RG (_cec *ContentStreamOperation ,_ *_a .PdfPageResources )error {_fbada :=_a .NewPdfColorspaceDeviceRGB ();if len (_cec .Params )!=_fbada .GetNumComponents (){_ege .Log .Debug ("I\u006e\u0076\u0061\u006c\u0069\u0064 \u006e\u0075\u006d\u0062\u0065\u0072 \u006f\u0066\u0020\u0070\u0061\u0072\u0061m\u0065\u0074\u0065\u0072\u0073\u0020\u0066\u006f\u0072\u0020R\u0047");
_ege .Log .Debug ("\u004e\u0075mb\u0065\u0072\u0020%\u0064\u0020\u006e\u006ft m\u0061tc\u0068\u0069\u006e\u0067\u0020\u0063\u006flo\u0072\u0073\u0070\u0061\u0063\u0065\u0020%\u0054",len (_cec .Params ),_fbada );if !_fefa ._deff {return _d .New ("\u0069\u006e\u0076\u0061l\u0069\u0064\u0020\u006e\u0075\u006d\u0062\u0065\u0072\u0020o\u0066 \u0070\u0061\u0072\u0061\u006d\u0065\u0074e\u0072\u0073");
};_bgg ,_beba :=_edbb (_cec .Params );if _beba !=nil {_ege .Log .Debug ("\u0045\u0052\u0052\u004f\u0052:\u0020\u0046\u0061\u0069\u006c\u0020\u0074\u006f\u0020\u0063\u006f\u006e\u0076e\u0072\u0074\u0020\u0063\u006f\u006c\u006f\u0072\u0020\u0074\u006f\u0020\u0067\u0072\u0061\u0079\u003a\u0020\u0025\u002b\u0076",_cec .Params );
return _beba ;};_cec .Params =[]_dc .PdfObject {_bgg };};_bged ,_fgb :=_fbada .ColorFromPdfObjects (_cec .Params );if _fgb !=nil {return _fgb ;};_fefa ._fgfc .ColorspaceStroking =_fbada ;_fefa ._fgfc .ColorStroking =_bged ;return nil ;};
// Add_SCN appends 'SCN' operand to the content stream:
// Same as SC but supports more colorspaces.
//
// See section 8.6.8 "Colour Operators" and Table 74 (p. 179-180 PDF32000_2008).
func (_fbg *ContentCreator )Add_SCN (c ...float64 )*ContentCreator {_ggg :=ContentStreamOperation {};_ggg .Operand ="\u0053\u0043\u004e";_ggg .Params =_acfc (c );_fbg ._fcb =append (_fbg ._fcb ,&_ggg );return _fbg ;};
// SetNonStrokingColor sets the non-stroking `color` where color can be one of
// PdfColorDeviceGray, PdfColorDeviceRGB, or PdfColorDeviceCMYK.
func (_eed *ContentCreator )SetNonStrokingColor (color _a .PdfColor )*ContentCreator {switch _egcb :=color .(type ){case *_a .PdfColorDeviceGray :_eed .Add_g (_egcb .Val ());case *_a .PdfColorDeviceRGB :_eed .Add_rg (_egcb .R (),_egcb .G (),_egcb .B ());
case *_a .PdfColorDeviceCMYK :_eed .Add_k (_egcb .C (),_egcb .M (),_egcb .Y (),_egcb .K ());case *_a .PdfColorPatternType2 :_eed .Add_cs (*_dc .MakeName ("\u0050a\u0074\u0074\u0065\u0072\u006e"));_eed .Add_scn_pattern (_egcb .PatternName );case *_a .PdfColorPatternType3 :_eed .Add_cs (*_dc .MakeName ("\u0050a\u0074\u0074\u0065\u0072\u006e"));
_eed .Add_scn_pattern (_egcb .PatternName );default:_ege .Log .Debug ("\u0053\u0065\u0074N\u006f\u006e\u0053\u0074\u0072\u006f\u006b\u0069\u006e\u0067\u0043\u006f\u006c\u006f\u0072\u003a\u0020\u0075\u006e\u0073\u0075\u0070\u0070\u006f\u0072\u0074\u0065\u0064\u0020c\u006f\u006c\u006f\u0072\u003a\u0020\u0025\u0054",_egcb );
};return _eed ;};
// Add_EMC appends 'EMC' operand to the content stream:
// Ends a marked-content sequence.
//
// See section 14.6 "Marked Content" and Table 320 (p. 561 PDF32000_2008).
func (_afdg *ContentCreator )Add_EMC ()*ContentCreator {_ada :=ContentStreamOperation {};_ada .Operand ="\u0045\u004d\u0043";_afdg ._fcb =append (_afdg ._fcb ,&_ada );return _afdg ;};type handlerEntry struct{Condition HandlerConditionEnum ;Operand string ;
Handler HandlerFunc ;};
// GraphicsState is a basic graphics state implementation for PDF processing.
// Initially only implementing and tracking a portion of the information specified. Easy to add more.
type GraphicsState struct{ColorspaceStroking _a .PdfColorspace ;ColorspaceNonStroking _a .PdfColorspace ;ColorStroking _a .PdfColor ;ColorNonStroking _a .PdfColor ;CTM _cg .Matrix ;};func (_ggba *ContentStreamProcessor )handleCommand_cm (_affg *ContentStreamOperation ,_ *_a .PdfPageResources )error {if len (_affg .Params )!=6{_ege .Log .Debug ("\u0045\u0052R\u004f\u0052\u003a\u0020\u0049\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u006e\u0075\u006d\u0062\u0065\u0072\u0020\u006f\u0066\u0020\u0070\u0061\u0072\u0061\u006d\u0065\u0074\u0065\u0072\u0073\u0020\u0066\u006f\u0072\u0020\u0063\u006d\u003a\u0020\u0025\u0064",len (_affg .Params ));
return _d .New ("\u0069\u006e\u0076\u0061l\u0069\u0064\u0020\u006e\u0075\u006d\u0062\u0065\u0072\u0020o\u0066 \u0070\u0061\u0072\u0061\u006d\u0065\u0074e\u0072\u0073");};_egbd ,_ceec :=_dc .GetNumbersAsFloat (_affg .Params );if _ceec !=nil {return _ceec ;
};_ageb :=_cg .NewMatrix (_egbd [0],_egbd [1],_egbd [2],_egbd [3],_egbd [4],_egbd [5]);_ggba ._fgfc .CTM .Concat (_ageb );return nil ;};
// AddOperand adds a specified operand.
func (_eeg *ContentCreator )AddOperand (op ContentStreamOperation )*ContentCreator {_eeg ._fcb =append (_eeg ._fcb ,&op );return _eeg ;};
// Operand returns true if `hce` is equivalent to HandlerConditionEnumOperand.
func (_aaed HandlerConditionEnum )Operand ()bool {return _aaed ==HandlerConditionEnumOperand };
// Push pushes `gs` on the `gsStack`.
func (_egbg *GraphicStateStack )Push (gs GraphicsState ){*_egbg =append (*_egbg ,gs )};func _dfda (_ccccc []_dc .PdfObjectString )[]_dc .PdfObject {var _edgf []_dc .PdfObject ;for _ ,_cfbd :=range _ccccc {_edgf =append (_edgf ,_dc .MakeString (_cfbd .Str ()));
};return _edgf ;};
// Add_B_starred appends 'B*' operand to the content stream:
// Fill and then stroke the path (even-odd rule).
//
// See section 8.5.3 "Path Painting Operators" and Table 60 (p. 143 PDF32000_2008).
func (_dec *ContentCreator )Add_B_starred ()*ContentCreator {_bad :=ContentStreamOperation {};_bad .Operand ="\u0042\u002a";_dec ._fcb =append (_dec ._fcb ,&_bad );return _dec ;};
// Add_Q adds 'Q' operand to the content stream: Pops the most recently stored state from the stack.
//
// See section 8.4.4 "Graphic State Operators" and Table 57 (pp. 135-136 PDF32000_2008).
func (_gac *ContentCreator )Add_Q ()*ContentCreator {_bfd :=ContentStreamOperation {};_bfd .Operand ="\u0051";_gac ._fcb =append (_gac ._fcb ,&_bfd );return _gac ;};
// NewContentStreamParser creates a new instance of the content stream parser from an input content
// stream string.
func NewContentStreamParser (contentStr string )*ContentStreamParser {_cegf :=ContentStreamParser {};contentStr =string (_bece .ReplaceAll ([]byte (contentStr ),[]byte ("\u002f")));_cbgf :=_cc .NewBufferString (contentStr +"\u000a");_cegf ._aga =_dd .NewReader (_cbgf );
return &_cegf ;};
// Add_W appends 'W' operand to the content stream:
// Modify the current clipping path by intersecting with the current path (nonzero winding rule).
//
// See section 8.5.4 "Clipping Path Operators" and Table 61 (p. 146 PDF32000_2008).
func (_cfb *ContentCreator )Add_W ()*ContentCreator {_geba :=ContentStreamOperation {};_geba .Operand ="\u0057";_cfb ._fcb =append (_cfb ._fcb ,&_geba );return _cfb ;};var (ErrInvalidOperand =_d .New ("\u0069n\u0076a\u006c\u0069\u0064\u0020\u006f\u0070\u0065\u0072\u0061\u006e\u0064");
ErrEarlyExit =_d .New ("\u0074\u0065\u0072\u006di\u006e\u0061\u0074\u0065\u0020\u0070\u0072\u006f\u0063\u0065s\u0073 \u0065\u0061\u0072\u006c\u0079\u0020\u0065x\u0069\u0074"););
// ToImage exports the inline image to Image which can be transformed or exported easily.
// Page resources are needed to look up colorspace information.
func (_fcd *ContentStreamInlineImage )ToImage (resources *_a .PdfPageResources )(*_a .Image ,error ){_bbca ,_fcbd :=_fcd .toImageBase (resources );if _fcbd !=nil {return nil ,_fcbd ;};_bdeg ,_fcbd :=_gffd (_fcd );if _fcbd !=nil {return nil ,_fcbd ;};_fba ,_aff :=_dc .GetDict (_fcd .DecodeParms );
if _aff {_bdeg .UpdateParams (_fba );};_ege .Log .Trace ("\u0065n\u0063o\u0064\u0065\u0072\u003a\u0020\u0025\u002b\u0076\u0020\u0025\u0054",_bdeg ,_bdeg );_ege .Log .Trace ("\u0069\u006e\u006c\u0069\u006e\u0065\u0020\u0069\u006d\u0061\u0067\u0065:\u0020\u0025\u002b\u0076",_fcd );
_cebgf ,_fcbd :=_bdeg .DecodeBytes (_fcd ._dddg );if _fcbd !=nil {return nil ,_fcbd ;};_ffe :=&_a .Image {Width :int64 (_bbca .Width ),Height :int64 (_bbca .Height ),BitsPerComponent :int64 (_bbca .BitsPerComponent ),ColorComponents :_bbca .ColorComponents ,Data :_cebgf };
if len (_bbca .Decode )> 0{for _ecaa :=0;_ecaa < len (_bbca .Decode );_ecaa ++{_bbca .Decode [_ecaa ]*=float64 ((int (1)<<uint (_bbca .BitsPerComponent ))-1);};_ffe .SetDecode (_bbca .Decode );};return _ffe ,nil ;};
// ContentStreamProcessor defines a data structure and methods for processing a content stream, keeping track of the
// current graphics state, and allowing external handlers to define their own functions as a part of the processing,
// for example rendering or extracting certain information.
type ContentStreamProcessor struct{_feba GraphicStateStack ;_fbeg []*ContentStreamOperation ;_fgfc GraphicsState ;_cebf []handlerEntry ;_gcgf int ;_deff bool ;};
// Add_l adds 'l' operand to the content stream:
// Append a straight line segment from the current point to (x,y).
//
// See section 8.5.2 "Path Construction Operators" and Table 59 (pp. 140-141 PDF32000_2008).
func (_gdg *ContentCreator )Add_l (x ,y float64 )*ContentCreator {_ff :=ContentStreamOperation {};_ff .Operand ="\u006c";_ff .Params =_acfc ([]float64 {x ,y });_gdg ._fcb =append (_gdg ._fcb ,&_ff );return _gdg ;};func (_feeb *ContentStreamProcessor )handleCommand_scn (_gafg *ContentStreamOperation ,_ *_a .PdfPageResources )error {_becee :=_feeb ._fgfc .ColorspaceNonStroking ;
if !_afceb (_becee ){if len (_gafg .Params )!=_becee .GetNumComponents (){_ege .Log .Debug ("I\u006e\u0076\u0061\u006c\u0069\u0064 \u006e\u0075\u006d\u0062\u0065\u0072 \u006f\u0066\u0020\u0070\u0061\u0072\u0061m\u0065\u0074\u0065\u0072\u0073\u0020\u0066\u006f\u0072\u0020S\u0043");
_ege .Log .Debug ("\u004e\u0075mb\u0065\u0072\u0020%\u0064\u0020\u006e\u006ft m\u0061tc\u0068\u0069\u006e\u0067\u0020\u0063\u006flo\u0072\u0073\u0070\u0061\u0063\u0065\u0020%\u0054",len (_gafg .Params ),_becee );if !_feeb ._deff {return _d .New ("\u0069\u006e\u0076\u0061l\u0069\u0064\u0020\u006e\u0075\u006d\u0062\u0065\u0072\u0020o\u0066 \u0070\u0061\u0072\u0061\u006d\u0065\u0074e\u0072\u0073");
};_bbba ,_cceg :=_edbb (_gafg .Params );if _cceg !=nil {_ege .Log .Debug ("\u0045\u0052\u0052\u004f\u0052:\u0020\u0046\u0061\u0069\u006c\u0020\u0074\u006f\u0020\u0063\u006f\u006e\u0076e\u0072\u0074\u0020\u0063\u006f\u006c\u006f\u0072\u0020\u0074\u006f\u0020\u0067\u0072\u0061\u0079\u003a\u0020\u0025\u002b\u0076",_gafg .Params );
return _cceg ;};_gafg .Params =[]_dc .PdfObject {_bbba };};};_ddcf ,_cgeg :=_becee .ColorFromPdfObjects (_gafg .Params );if _cgeg !=nil {_ege .Log .Debug ("\u0045\u0052\u0052\u004f\u0052\u003a\u0020\u0046\u0061\u0069\u006c \u0074\u006f\u0020\u0067\u0065\u0074\u0020\u0063o\u006co\u0072\u0020\u0066\u0072\u006f\u006d\u0020\u0070\u0061\u0072\u0061\u006d\u0073\u003a\u0020\u0025\u002b\u0076 \u0028\u0043\u0053\u0020\u0069\u0073\u0020\u0025\u002b\u0076\u0029",_gafg .Params ,_becee );
return _cgeg ;};_feeb ._fgfc .ColorNonStroking =_ddcf ;return nil ;};
// SetRelaxedMode sets the relaxed mode for the content stream processor.
func (_afgc *ContentStreamProcessor )SetRelaxedMode (val bool ){_afgc ._deff =val };
// Add_i adds 'i' operand to the content stream: Set the flatness tolerance in the graphics state.
//
// See section 8.4.4 "Graphic State Operators" and Table 57 (pp. 135-136 PDF32000_2008).
func (_bcb *ContentCreator )Add_i (flatness float64 )*ContentCreator {_dafc :=ContentStreamOperation {};_dafc .Operand ="\u0069";_dafc .Params =_acfc ([]float64 {flatness });_bcb ._fcb =append (_bcb ._fcb ,&_dafc );return _bcb ;};
// Add_SC appends 'SC' operand to the content stream:
// Set color for stroking operations. Input: c1, ..., cn.
//
// See section 8.6.8 "Colour Operators" and Table 74 (p. 179-180 PDF32000_2008).
func (_gb *ContentCreator )Add_SC (c ...float64 )*ContentCreator {_gc :=ContentStreamOperation {};_gc .Operand ="\u0053\u0043";_gc .Params =_acfc (c );_gb ._fcb =append (_gb ._fcb ,&_gc );return _gb ;};func (_badc *ContentStreamProcessor )handleCommand_sc (_cfa *ContentStreamOperation ,_ *_a .PdfPageResources )error {_ababg :=_badc ._fgfc .ColorspaceNonStroking ;
if !_afceb (_ababg ){if len (_cfa .Params )!=_ababg .GetNumComponents (){_ege .Log .Debug ("I\u006e\u0076\u0061\u006c\u0069\u0064 \u006e\u0075\u006d\u0062\u0065\u0072 \u006f\u0066\u0020\u0070\u0061\u0072\u0061m\u0065\u0074\u0065\u0072\u0073\u0020\u0066\u006f\u0072\u0020S\u0043");
_ege .Log .Debug ("\u004e\u0075mb\u0065\u0072\u0020%\u0064\u0020\u006e\u006ft m\u0061tc\u0068\u0069\u006e\u0067\u0020\u0063\u006flo\u0072\u0073\u0070\u0061\u0063\u0065\u0020%\u0054",len (_cfa .Params ),_ababg );if !_badc ._deff {return _d .New ("\u0069\u006e\u0076\u0061l\u0069\u0064\u0020\u006e\u0075\u006d\u0062\u0065\u0072\u0020o\u0066 \u0070\u0061\u0072\u0061\u006d\u0065\u0074e\u0072\u0073");
};_agfg ,_edac :=_edbb (_cfa .Params );if _edac !=nil {_ege .Log .Debug ("\u0045\u0052\u0052\u004f\u0052:\u0020\u0046\u0061\u0069\u006c\u0020\u0074\u006f\u0020\u0063\u006f\u006e\u0076e\u0072\u0074\u0020\u0063\u006f\u006c\u006f\u0072\u0020\u0074\u006f\u0020\u0067\u0072\u0061\u0079\u003a\u0020\u0025\u002b\u0076",_cfa .Params );
return _edac ;};_cfa .Params =[]_dc .PdfObject {_agfg };};};_gfeb ,_ffa :=_ababg .ColorFromPdfObjects (_cfa .Params );if _ffa !=nil {return _ffa ;};_badc ._fgfc .ColorNonStroking =_gfeb ;return nil ;};
// Add_j adds 'j' operand to the content stream: Set the line join style (graphics state).
//
// See section 8.4.4 "Graphic State Operators" and Table 57 (pp. 135-136 PDF32000_2008).
func (_fdb *ContentCreator )Add_j (lineJoinStyle string )*ContentCreator {_cgb :=ContentStreamOperation {};_cgb .Operand ="\u006a";_cgb .Params =_bedg ([]_dc .PdfObjectName {_dc .PdfObjectName (lineJoinStyle )});_fdb ._fcb =append (_fdb ._fcb ,&_cgb );
return _fdb ;};const (HandlerConditionEnumOperand HandlerConditionEnum =iota ;HandlerConditionEnumAllOperands ;);func (_bebf *ContentStreamParser )parseName ()(_dc .PdfObjectName ,error ){_fgab :="";_bbfd :=false ;for {_ggde ,_efg :=_bebf ._aga .Peek (1);
if _efg ==_ebb .EOF {break ;};if _efg !=nil {return _dc .PdfObjectName (_fgab ),_efg ;};if !_bbfd {if _ggde [0]=='/'{_bbfd =true ;_bebf ._aga .ReadByte ();}else {_ege .Log .Error ("N\u0061\u006d\u0065\u0020\u0073\u0074a\u0072\u0074\u0069\u006e\u0067\u0020\u0077\u0069\u0074h\u0020\u0025\u0073 \u0028%\u0020\u0078\u0029",_ggde ,_ggde );
return _dc .PdfObjectName (_fgab ),_c .Errorf ("\u0069n\u0076a\u006c\u0069\u0064\u0020\u006ea\u006d\u0065:\u0020\u0028\u0025\u0063\u0029",_ggde [0]);};}else {if _dc .IsWhiteSpace (_ggde [0]){break ;}else if (_ggde [0]=='/')||(_ggde [0]=='[')||(_ggde [0]=='(')||(_ggde [0]==']')||(_ggde [0]=='<')||(_ggde [0]=='>'){break ;
}else if _ggde [0]=='#'{_dcc ,_cccf :=_bebf ._aga .Peek (3);if _cccf !=nil {return _dc .PdfObjectName (_fgab ),_cccf ;};_bebf ._aga .Discard (3);_eggc ,_cccf :=_eb .DecodeString (string (_dcc [1:3]));if _cccf !=nil {return _dc .PdfObjectName (_fgab ),_cccf ;
};_fgab +=string (_eggc );}else {_bdff ,_ :=_bebf ._aga .ReadByte ();_fgab +=string (_bdff );};};};return _dc .PdfObjectName (_fgab ),nil ;};
// Add_TD appends 'TD' operand to the content stream:
// Move to start of next line with offset (`tx`, `ty`).
//
// See section 9.4.2 "Text Positioning Operators" and
// Table 108 (pp. 257-258 PDF32000_2008).
func (_ffd *ContentCreator )Add_TD (tx ,ty float64 )*ContentCreator {_gbg :=ContentStreamOperation {};_gbg .Operand ="\u0054\u0044";_gbg .Params =_acfc ([]float64 {tx ,ty });_ffd ._fcb =append (_ffd ._fcb ,&_gbg );return _ffd ;};func (_efaf *ContentStreamParser )parseBool ()(_dc .PdfObjectBool ,error ){_ebea ,_abaf :=_efaf ._aga .Peek (4);
if _abaf !=nil {return _dc .PdfObjectBool (false ),_abaf ;};if (len (_ebea )>=4)&&(string (_ebea [:4])=="\u0074\u0072\u0075\u0065"){_efaf ._aga .Discard (4);return _dc .PdfObjectBool (true ),nil ;};_ebea ,_abaf =_efaf ._aga .Peek (5);if _abaf !=nil {return _dc .PdfObjectBool (false ),_abaf ;
};if (len (_ebea )>=5)&&(string (_ebea [:5])=="\u0066\u0061\u006cs\u0065"){_efaf ._aga .Discard (5);return _dc .PdfObjectBool (false ),nil ;};return _dc .PdfObjectBool (false ),_d .New ("\u0075n\u0065\u0078\u0070\u0065c\u0074\u0065\u0064\u0020\u0062o\u006fl\u0065a\u006e\u0020\u0073\u0074\u0072\u0069\u006eg");
};
// Add_y appends 'y' operand to the content stream: Append a Bezier curve to the current path from the
// current point to (x3,y3) with (x1, y1) and (x3,y3) as control points.
//
// See section 8.5.2 "Path Construction Operators" and Table 59 (pp. 140-141 PDF32000_2008).
func (_fb *ContentCreator )Add_y (x1 ,y1 ,x3 ,y3 float64 )*ContentCreator {_agc :=ContentStreamOperation {};_agc .Operand ="\u0079";_agc .Params =_acfc ([]float64 {x1 ,y1 ,x3 ,y3 });_fb ._fcb =append (_fb ._fcb ,&_agc );return _fb ;};
// Add_K appends 'K' operand to the content stream:
// Set the stroking colorspace to DeviceCMYK and sets the c,m,y,k color (0-1 each component).
//
// See section 8.6.8 "Colour Operators" and Table 74 (p. 179-180 PDF32000_2008).
func (_bcg *ContentCreator )Add_K (c ,m ,y ,k float64 )*ContentCreator {_bce :=ContentStreamOperation {};_bce .Operand ="\u004b";_bce .Params =_acfc ([]float64 {c ,m ,y ,k });_bcg ._fcb =append (_bcg ._fcb ,&_bce );return _bcg ;};func (_deba *ContentStreamProcessor )handleCommand_g (_edf *ContentStreamOperation ,_ *_a .PdfPageResources )error {_ggca :=_a .NewPdfColorspaceDeviceGray ();
if len (_edf .Params )!=_ggca .GetNumComponents (){_ege .Log .Debug ("\u0049\u006e\u0076al\u0069\u0064\u0020\u006e\u0075\u006d\u0062\u0065\u0072 \u006ff\u0020p\u0061r\u0061\u006d\u0065\u0074\u0065\u0072\u0073\u0020\u0066\u006f\u0072\u0020\u0067");_ege .Log .Debug ("\u004e\u0075mb\u0065\u0072\u0020%\u0064\u0020\u006e\u006ft m\u0061tc\u0068\u0069\u006e\u0067\u0020\u0063\u006flo\u0072\u0073\u0070\u0061\u0063\u0065\u0020%\u0054",len (_edf .Params ),_ggca );
if !_deba ._deff {return _d .New ("\u0069\u006e\u0076\u0061l\u0069\u0064\u0020\u006e\u0075\u006d\u0062\u0065\u0072\u0020o\u0066 \u0070\u0061\u0072\u0061\u006d\u0065\u0074e\u0072\u0073");};_fdea ,_gbga :=_edbb (_edf .Params );if _gbga !=nil {_ege .Log .Debug ("\u0045\u0052\u0052\u004f\u0052:\u0020\u0046\u0061\u0069\u006c\u0020\u0074\u006f\u0020\u0063\u006f\u006e\u0076e\u0072\u0074\u0020\u0063\u006f\u006c\u006f\u0072\u0020\u0074\u006f\u0020\u0067\u0072\u0061\u0079\u003a\u0020\u0025\u002b\u0076",_edf .Params );
return _gbga ;};_edf .Params =[]_dc .PdfObject {_fdea };};_cegff ,_fbad :=_ggca .ColorFromPdfObjects (_edf .Params );if _fbad !=nil {_ege .Log .Debug ("\u0045\u0052\u0052\u004fR\u003a\u0020\u0068\u0061\u006e\u0064\u006c\u0065\u0043o\u006d\u006d\u0061\u006e\u0064\u005f\u0067\u0020\u0049\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u0070\u0061r\u0061\u006d\u0073\u002e\u0020c\u0073\u003d\u0025\u0054\u0020\u006f\u0070\u003d\u0025\u0073\u0020\u0065\u0072\u0072\u003d\u0025\u0076",_ggca ,_edf ,_fbad );
return _fbad ;};_deba ._fgfc .ColorspaceNonStroking =_ggca ;_deba ._fgfc .ColorNonStroking =_cegff ;return nil ;};func (_fagd *ContentStreamParser )parseNumber ()(_dc .PdfObject ,error ){return _dc .ParseNumber (_fagd ._aga );};func (_edae *ContentStreamProcessor )getColorspace (_bddc string ,_dda *_a .PdfPageResources )(_a .PdfColorspace ,error ){switch _bddc {case "\u0044\u0065\u0076\u0069\u0063\u0065\u0047\u0072\u0061\u0079":return _a .NewPdfColorspaceDeviceGray (),nil ;
case "\u0044e\u0076\u0069\u0063\u0065\u0052\u0047B":return _a .NewPdfColorspaceDeviceRGB (),nil ;case "\u0044\u0065\u0076\u0069\u0063\u0065\u0043\u004d\u0059\u004b":return _a .NewPdfColorspaceDeviceCMYK (),nil ;case "\u0050a\u0074\u0074\u0065\u0072\u006e":return _a .NewPdfColorspaceSpecialPattern (),nil ;
};if _dda !=nil {_bced ,_efbc :=_dda .GetColorspaceByName (_dc .PdfObjectName (_bddc ));if _efbc {return _bced ,nil ;};};switch _bddc {case "\u0043a\u006c\u0047\u0072\u0061\u0079":return _a .NewPdfColorspaceCalGray (),nil ;case "\u0043\u0061\u006c\u0052\u0047\u0042":return _a .NewPdfColorspaceCalRGB (),nil ;
case "\u004c\u0061\u0062":return _a .NewPdfColorspaceLab (),nil ;};_ege .Log .Debug ("\u0055\u006e\u006b\u006e\u006f\u0077\u006e\u0020\u0063\u006f\u006c\u006f\u0072\u0073\u0070a\u0063e\u0020\u0072\u0065\u0071\u0075\u0065\u0073\u0074\u0065\u0064\u003a\u0020\u0025\u0073",_bddc );
return nil ,_c .Errorf ("\u0075\u006e\u0073\u0075\u0070\u0070\u006f\u0072\u0074\u0065\u0064 \u0063\u006f\u006c\u006f\u0072\u0073\u0070\u0061\u0063\u0065:\u0020\u0025\u0073",_bddc );};func (_ecdd *ContentStreamParser )skipComments ()error {if _ ,_baff :=_ecdd .skipSpaces ();
_baff !=nil {return _baff ;};_bdf :=true ;for {_adbg ,_gdcd :=_ecdd ._aga .Peek (1);if _gdcd !=nil {_ege .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0025\u0073",_gdcd .Error ());return _gdcd ;};if _bdf &&_adbg [0]!='%'{return nil ;};_bdf =false ;
if (_adbg [0]!='\r')&&(_adbg [0]!='\n'){_ecdd ._aga .ReadByte ();}else {break ;};};return _ecdd .skipComments ();};
// Add_M adds 'M' operand to the content stream: Set the miter limit (graphics state).
//
// See section 8.4.4 "Graphic State Operators" and Table 57 (pp. 135-136 PDF32000_2008).
func (_eece *ContentCreator )Add_M (miterlimit float64 )*ContentCreator {_gd :=ContentStreamOperation {};_gd .Operand ="\u004d";_gd .Params =_acfc ([]float64 {miterlimit });_eece ._fcb =append (_eece ._fcb ,&_gd );return _eece ;};
// Add_quote appends "'" operand to the content stream:
// Move to next line and show a string.
//
// See section 9.4.3 "Text Showing Operators" and
// Table 209 (pp. 258-259 PDF32000_2008).
func (_gbf *ContentCreator )Add_quote (textstr _dc .PdfObjectString )*ContentCreator {_ecba :=ContentStreamOperation {};_ecba .Operand ="\u0027";_ecba .Params =_dfda ([]_dc .PdfObjectString {textstr });_gbf ._fcb =append (_gbf ._fcb ,&_ecba );return _gbf ;
};
// Parse parses all commands in content stream, returning a list of operation data.
func (_bdba *ContentStreamParser )Parse ()(*ContentStreamOperations ,error ){_bcfd :=ContentStreamOperations {};for {_cfef :=ContentStreamOperation {};for {_aad ,_cegc ,_addf :=_bdba .parseObject ();if _addf !=nil {if _addf ==_ebb .EOF {return &_bcfd ,nil ;
};return &_bcfd ,_addf ;};if _cegc {_cfef .Operand ,_ =_dc .GetStringVal (_aad );_bcfd =append (_bcfd ,&_cfef );break ;}else {_cfef .Params =append (_cfef .Params ,_aad );};};if _cfef .Operand =="\u0042\u0049"{_ggc ,_gacg :=_bdba .ParseInlineImage ();if _gacg !=nil {return &_bcfd ,_gacg ;
};_cfef .Params =append (_cfef .Params ,_ggc );};};};
// Add_c adds 'c' operand to the content stream: Append a Bezier curve to the current path from
// the current point to (x3,y3) with (x1,x1) and (x2,y2) as control points.
//
// See section 8.5.2 "Path Construction Operators" and Table 59 (pp. 140-141 PDF32000_2008).
func (_gdb *ContentCreator )Add_c (x1 ,y1 ,x2 ,y2 ,x3 ,y3 float64 )*ContentCreator {_eaa :=ContentStreamOperation {};_eaa .Operand ="\u0063";_eaa .Params =_acfc ([]float64 {x1 ,y1 ,x2 ,y2 ,x3 ,y3 });_gdb ._fcb =append (_gdb ._fcb ,&_eaa );return _gdb ;
};func _ebbbc (_cgg _dc .PdfObject )(_a .PdfColorspace ,error ){_cbe ,_ddg :=_cgg .(*_dc .PdfObjectArray );if !_ddg {_ege .Log .Debug ("\u0045r\u0072\u006fr\u003a\u0020\u0049\u006ev\u0061\u006c\u0069d\u0020\u0069\u006e\u0064\u0065\u0078\u0065\u0064\u0020cs\u0020\u006e\u006ft\u0020\u0069n\u0020\u0061\u0072\u0072\u0061\u0079 \u0028\u0025#\u0076\u0029",_cgg );
return nil ,_d .New ("\u0074\u0079p\u0065\u0020\u0063h\u0065\u0063\u006b\u0020\u0065\u0072\u0072\u006f\u0072");};if _cbe .Len ()!=4{_ege .Log .Debug ("\u0045\u0072\u0072\u006f\u0072:\u0020\u0049\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u0063\u0073\u0020\u0061r\u0072\u0061\u0079\u002c\u0020\u006c\u0065\u006e\u0067\u0074\u0068\u0020\u0021\u003d\u0020\u0034\u0020\u0028\u0025\u0064\u0029",_cbe .Len ());
return nil ,_d .New ("\u0072\u0061\u006e\u0067\u0065\u0020\u0063\u0068\u0065\u0063\u006b\u0020e\u0072\u0072\u006f\u0072");};_aabe ,_ddg :=_cbe .Get (0).(*_dc .PdfObjectName );if !_ddg {_ege .Log .Debug ("E\u0072\u0072\u006f\u0072\u003a\u0020\u0049\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u0063\u0073\u0020\u0061\u0072\u0072\u0061\u0079\u0020\u0066\u0069\u0072s\u0074 \u0065\u006c\u0065\u006de\u006e\u0074 \u006e\u006f\u0074\u0020\u0061\u0020\u006e\u0061\u006d\u0065\u0020\u0028\u0061\u0072\u0072\u0061\u0079\u003a\u0020\u0025\u0023\u0076\u0029",*_cbe );
return nil ,_d .New ("\u0074\u0079p\u0065\u0020\u0063h\u0065\u0063\u006b\u0020\u0065\u0072\u0072\u006f\u0072");};if *_aabe !="\u0049"&&*_aabe !="\u0049n\u0064\u0065\u0078\u0065\u0064"{_ege .Log .Debug ("\u0045\u0072r\u006f\u0072\u003a\u0020\u0049n\u0076\u0061\u006c\u0069\u0064 \u0063\u0073\u0020\u0061\u0072\u0072\u0061\u0079\u0020\u0066\u0069\u0072\u0073\u0074\u0020\u0065\u006c\u0065\u006d\u0065\u006e\u0074\u0020\u0021\u003d\u0020\u0049\u0020\u0028\u0067\u006f\u0074\u003a\u0020\u0025\u0076\u0029",*_aabe );
return nil ,_d .New ("\u0072\u0061\u006e\u0067\u0065\u0020\u0063\u0068\u0065\u0063\u006b\u0020e\u0072\u0072\u006f\u0072");};_aabe ,_ddg =_cbe .Get (1).(*_dc .PdfObjectName );if !_ddg {_ege .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u003a\u0020\u0049\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u0063\u0073\u0020\u0061\u0072r\u0061\u0079\u0020\u0032\u006e\u0064\u0020\u0065\u006c\u0065\u006d\u0065\u006e\u0074\u0020\u006e\u006f\u0074\u0020\u0061\u0020\u006e\u0061\u006d\u0065\u0020\u0028\u0061\u0072\u0072a\u0079\u003a\u0020\u0025\u0023v\u0029",*_cbe );
return nil ,_d .New ("\u0074\u0079p\u0065\u0020\u0063h\u0065\u0063\u006b\u0020\u0065\u0072\u0072\u006f\u0072");};if *_aabe !="\u0047"&&*_aabe !="\u0052\u0047\u0042"&&*_aabe !="\u0043\u004d\u0059\u004b"&&*_aabe !="\u0044\u0065\u0076\u0069\u0063\u0065\u0047\u0072\u0061\u0079"&&*_aabe !="\u0044e\u0076\u0069\u0063\u0065\u0052\u0047B"&&*_aabe !="\u0044\u0065\u0076\u0069\u0063\u0065\u0043\u004d\u0059\u004b"{_ege .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u003a\u0020\u0049\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u0063\u0073\u0020\u0061\u0072r\u0061\u0079\u0020\u0032\u006e\u0064\u0020\u0065\u006c\u0065\u006d\u0065\u006e\u0074\u0020\u0021\u003d\u0020\u0047\u002f\u0052\u0047\u0042\u002f\u0043\u004d\u0059\u004b\u0020\u0028g\u006f\u0074\u003a\u0020\u0025v\u0029",*_aabe );
return nil ,_d .New ("\u0072\u0061\u006e\u0067\u0065\u0020\u0063\u0068\u0065\u0063\u006b\u0020e\u0072\u0072\u006f\u0072");};_beaa :="";switch *_aabe {case "\u0047","\u0044\u0065\u0076\u0069\u0063\u0065\u0047\u0072\u0061\u0079":_beaa ="\u0044\u0065\u0076\u0069\u0063\u0065\u0047\u0072\u0061\u0079";
case "\u0052\u0047\u0042","\u0044e\u0076\u0069\u0063\u0065\u0052\u0047B":_beaa ="\u0044e\u0076\u0069\u0063\u0065\u0052\u0047B";case "\u0043\u004d\u0059\u004b","\u0044\u0065\u0076\u0069\u0063\u0065\u0043\u004d\u0059\u004b":_beaa ="\u0044\u0065\u0076\u0069\u0063\u0065\u0043\u004d\u0059\u004b";
};_degd :=_dc .MakeArray (_dc .MakeName ("\u0049n\u0064\u0065\u0078\u0065\u0064"),_dc .MakeName (_beaa ),_cbe .Get (2),_cbe .Get (3));return _a .NewPdfColorspaceFromPdfObject (_degd );};
// Add_Do adds 'Do' operation to the content stream:
// Displays an XObject (image or form) specified by `name`.
//
// See section 8.8 "External Objects" and Table 87 (pp. 209-220 PDF32000_2008).
func (_cfg *ContentCreator )Add_Do (name _dc .PdfObjectName )*ContentCreator {_fdg :=ContentStreamOperation {};_fdg .Operand ="\u0044\u006f";_fdg .Params =_bedg ([]_dc .PdfObjectName {name });_cfg ._fcb =append (_cfg ._fcb ,&_fdg );return _cfg ;};func _gffd (_cff *ContentStreamInlineImage )(_dc .StreamEncoder ,error ){if _cff .Filter ==nil {return _dc .NewRawEncoder (),nil ;
};_gba ,_gbfe :=_cff .Filter .(*_dc .PdfObjectName );if !_gbfe {_ecc ,_dgcd :=_cff .Filter .(*_dc .PdfObjectArray );if !_dgcd {return nil ,_c .Errorf ("\u0066\u0069\u006c\u0074\u0065\u0072 \u006e\u006f\u0074\u0020\u0061\u0020\u004e\u0061\u006d\u0065\u0020\u006f\u0072 \u0041\u0072\u0072\u0061\u0079\u0020\u006fb\u006a\u0065\u0063\u0074");
};if _ecc .Len ()==0{return _dc .NewRawEncoder (),nil ;};if _ecc .Len ()!=1{_afg ,_cab :=_ceg (_cff );if _cab !=nil {_ege .Log .Error ("\u0046\u0061\u0069\u006c\u0065\u0064 \u0063\u0072\u0065\u0061\u0074\u0069\u006e\u0067\u0020\u006d\u0075\u006c\u0074i\u0020\u0065\u006e\u0063\u006f\u0064\u0065r\u003a\u0020\u0025\u0076",_cab );
return nil ,_cab ;};_ege .Log .Trace ("\u004d\u0075\u006c\u0074\u0069\u0020\u0065\u006e\u0063:\u0020\u0025\u0073\u000a",_afg );return _afg ,nil ;};_ded :=_ecc .Get (0);_gba ,_dgcd =_ded .(*_dc .PdfObjectName );if !_dgcd {return nil ,_c .Errorf ("\u0066\u0069l\u0074\u0065\u0072\u0020a\u0072\u0072a\u0079\u0020\u006d\u0065\u006d\u0062\u0065\u0072 \u006e\u006f\u0074\u0020\u0061\u0020\u004e\u0061\u006d\u0065\u0020\u006fb\u006a\u0065\u0063\u0074");
};};switch *_gba {case "\u0041\u0048\u0078","\u0041\u0053\u0043\u0049\u0049\u0048\u0065\u0078\u0044e\u0063\u006f\u0064\u0065":return _dc .NewASCIIHexEncoder (),nil ;case "\u0041\u0038\u0035","\u0041\u0053\u0043\u0049\u0049\u0038\u0035\u0044\u0065\u0063\u006f\u0064\u0065":return _dc .NewASCII85Encoder (),nil ;
case "\u0044\u0043\u0054","\u0044C\u0054\u0044\u0065\u0063\u006f\u0064e":return _cdgg (_cff );case "\u0046\u006c","F\u006c\u0061\u0074\u0065\u0044\u0065\u0063\u006f\u0064\u0065":return _gfdc (_cff ,nil );case "\u004c\u005a\u0057","\u004cZ\u0057\u0044\u0065\u0063\u006f\u0064e":return _eaaa (_cff ,nil );
case "\u0043\u0043\u0046","\u0043\u0043\u0049\u0054\u0054\u0046\u0061\u0078\u0044e\u0063\u006f\u0064\u0065":return _dc .NewCCITTFaxEncoder (),nil ;case "\u0052\u004c","\u0052u\u006eL\u0065\u006e\u0067\u0074\u0068\u0044\u0065\u0063\u006f\u0064\u0065":return _dc .NewRunLengthEncoder (),nil ;
default:_ege .Log .Debug ("\u0055\u006e\u0073\u0075\u0070\u0070\u006f\u0072\u0074\u0065\u0064\u0020\u0069\u006e\u006c\u0069\u006e\u0065 \u0069\u006d\u0061\u0067\u0065\u0020\u0065n\u0063\u006f\u0064\u0069\u006e\u0067\u0020\u0066\u0069\u006c\u0074e\u0072\u0020\u006e\u0061\u006d\u0065\u0020\u003a\u0020\u0025\u0073",*_gba );
return nil ,_d .New ("\u0075\u006e\u0073up\u0070\u006f\u0072\u0074\u0065\u0064\u0020\u0069\u006el\u0069n\u0065 \u0065n\u0063\u006f\u0064\u0069\u006e\u0067\u0020\u006d\u0065\u0074\u0068\u006f\u0064");};};
// Add_q adds 'q' operand to the content stream: Pushes the current graphics state on the stack.
//
// See section 8.4.4 "Graphic State Operators" and Table 57 (pp. 135-136 PDF32000_2008).
func (_dfde *ContentCreator )Add_q ()*ContentCreator {_ea :=ContentStreamOperation {};_ea .Operand ="\u0071";_dfde ._fcb =append (_dfde ._fcb ,&_ea );return _dfde ;};var _bece =_f .MustCompile ("\u005e\u002f\u007b\u0032\u002c\u007d");
// Add_BDC appends 'BDC' operand to the content stream:
// Begins a marked-content sequence with an associated property list terminated by a balancing EMC operator.
// `tag` shall be a name object indicating the role or significance of
// the sequence.
// `propertyList` shall be a dictionary containing the properties of the
//
// See section 14.6 "Marked Content" and Table 320 (p. 561 PDF32000_2008).
func (_ebfg *ContentCreator )Add_BDC (tag _dc .PdfObjectName ,propertyList map[string ]_dc .PdfObject )*ContentCreator {_dbf :=ContentStreamOperation {};_dbf .Operand ="\u0042\u0044\u0043";_dbf .Params =_bedg ([]_dc .PdfObjectName {tag });if len (propertyList )> 0{_dbf .Params =append (_dbf .Params ,_dc .MakeDictMap (propertyList ));
};_ebfg ._fcb =append (_ebfg ._fcb ,&_dbf );return _ebfg ;};
// Add_Tr appends 'Tr' operand to the content stream:
// Set text rendering mode.
//
// See section 9.3 "Text State Parameters and Operators" and
// Table 105 (pp. 251-252 PDF32000_2008).
func (_egcg *ContentCreator )Add_Tr (render int64 )*ContentCreator {_bcge :=ContentStreamOperation {};_bcge .Operand ="\u0054\u0072";_bcge .Params =_edgd ([]int64 {render });_egcg ._fcb =append (_egcg ._fcb ,&_bcge );return _egcg ;};
// String is same as Bytes() except returns as a string for convenience.
func (_cb *ContentCreator )String ()string {return string (_cb ._fcb .Bytes ())};
// ContentStreamOperations is a slice of ContentStreamOperations.
type ContentStreamOperations []*ContentStreamOperation ;
// SetStrokingColor sets the stroking `color` where color can be one of
// PdfColorDeviceGray, PdfColorDeviceRGB, or PdfColorDeviceCMYK.
func (_ccbe *ContentCreator )SetStrokingColor (color _a .PdfColor )*ContentCreator {switch _aaa :=color .(type ){case *_a .PdfColorDeviceGray :_ccbe .Add_G (_aaa .Val ());case *_a .PdfColorDeviceRGB :_ccbe .Add_RG (_aaa .R (),_aaa .G (),_aaa .B ());case *_a .PdfColorDeviceCMYK :_ccbe .Add_K (_aaa .C (),_aaa .M (),_aaa .Y (),_aaa .K ());
case *_a .PdfColorPatternType2 :_ccbe .Add_CS (*_dc .MakeName ("\u0050a\u0074\u0074\u0065\u0072\u006e"));_ccbe .Add_SCN_pattern (_aaa .PatternName );case *_a .PdfColorPatternType3 :_ccbe .Add_CS (*_dc .MakeName ("\u0050a\u0074\u0074\u0065\u0072\u006e"));
_ccbe .Add_SCN_pattern (_aaa .PatternName );default:_ege .Log .Debug ("\u0053\u0065\u0074\u0053\u0074\u0072\u006f\u006b\u0069\u006e\u0067\u0043\u006fl\u006f\u0072\u003a\u0020\u0075\u006es\u0075\u0070\u0070\u006f\u0072\u0074\u0065\u0064\u0020\u0063\u006f\u006c\u006fr\u003a\u0020\u0025\u0054",_aaa );
};return _ccbe ;};func (_dfef *ContentStreamParser )parseNull ()(_dc .PdfObjectNull ,error ){_ ,_ece :=_dfef ._aga .Discard (4);return _dc .PdfObjectNull {},_ece ;};
// Translate applies a simple x-y translation to the transformation matrix.
func (_eged *ContentCreator )Translate (tx ,ty float64 )*ContentCreator {return _eged .Add_cm (1,0,0,1,tx ,ty );};
// Add_Tz appends 'Tz' operand to the content stream:
// Set horizontal scaling.
//
// See section 9.3 "Text State Parameters and Operators" and
// Table 105 (pp. 251-252 PDF32000_2008).
func (_fdf *ContentCreator )Add_Tz (scale float64 )*ContentCreator {_fdbg :=ContentStreamOperation {};_fdbg .Operand ="\u0054\u007a";_fdbg .Params =_acfc ([]float64 {scale });_fdf ._fcb =append (_fdf ._fcb ,&_fdbg );return _fdf ;};
// Operations returns the list of operations.
func (_ec *ContentCreator )Operations ()*ContentStreamOperations {return &_ec ._fcb };
// Scale applies x-y scaling to the transformation matrix.
func (_ceb *ContentCreator )Scale (sx ,sy float64 )*ContentCreator {return _ceb .Add_cm (sx ,0,0,sy ,0,0);};
// Add_cm adds 'cm' operation to the content stream: Modifies the current transformation matrix (ctm)
// of the graphics state.
//
// See section 8.4.4 "Graphic State Operators" and Table 57 (pp. 135-136 PDF32000_2008).
func (_bde *ContentCreator )Add_cm (a ,b ,c ,d ,e ,f float64 )*ContentCreator {_bef :=ContentStreamOperation {};_bef .Operand ="\u0063\u006d";_bef .Params =_acfc ([]float64 {a ,b ,c ,d ,e ,f });_bde ._fcb =append (_bde ._fcb ,&_bef );return _bde ;};func (_df *ContentStreamOperations )isWrapped ()bool {if len (*_df )< 2{return false ;
};_ge :=0;for _ ,_bd :=range *_df {switch _bd .Operand {case "\u0071":_ge ++;case "\u0051":_ge --;default:if _ge < 1{return false ;};};};return _ge ==0;};
// Add_f_starred appends 'f*' operand to the content stream.
// f*: Fill the path using the even-odd rule to determine fill region.
//
// See section 8.5.3 "Path Painting Operators" and Table 60 (p. 143 PDF32000_2008).
func (_cag *ContentCreator )Add_f_starred ()*ContentCreator {_feg :=ContentStreamOperation {};_feg .Operand ="\u0066\u002a";_cag ._fcb =append (_cag ._fcb ,&_feg );return _cag ;};
|