// // 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 (_a "bufio";_e "bytes";_fc "encoding/hex";_f "errors";_gb "fmt";_dd "github.com/unidoc/unipdf/v3/common";_ed "github.com/unidoc/unipdf/v3/core";_ge "github.com/unidoc/unipdf/v3/internal/imageutil";_gbe "github.com/unidoc/unipdf/v3/internal/transform";_ab "github.com/unidoc/unipdf/v3/model";_d "image/color";_df "image/jpeg";_g "io";_ag "math";_ff "strconv";); // 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 (_ee *ContentStreamParser )ExtractText ()(string ,error ){_ffaa ,_be :=_ee .Parse ();if _be !=nil {return "",_be ;};_gg :=false ;_db ,_agg :=float64 (-1),float64 (-1);_fcf :="";for _ ,_ca :=range *_ffaa {if _ca .Operand =="\u0042\u0054"{_gg =true ;}else if _ca .Operand =="\u0045\u0054"{_gg =false ;};if _ca .Operand =="\u0054\u0064"||_ca .Operand =="\u0054\u0044"||_ca .Operand =="\u0054\u002a"{_fcf +="\u000a";};if _ca .Operand =="\u0054\u006d"{if len (_ca .Params )!=6{continue ;};_eeb ,_gbf :=_ca .Params [4].(*_ed .PdfObjectFloat );if !_gbf {_fag ,_cg :=_ca .Params [4].(*_ed .PdfObjectInteger );if !_cg {continue ;};_eeb =_ed .MakeFloat (float64 (*_fag ));};_cea ,_gbf :=_ca .Params [5].(*_ed .PdfObjectFloat );if !_gbf {_de ,_cd :=_ca .Params [5].(*_ed .PdfObjectInteger );if !_cd {continue ;};_cea =_ed .MakeFloat (float64 (*_de ));};if _agg ==-1{_agg =float64 (*_cea );}else if _agg > float64 (*_cea ){_fcf +="\u000a";_db =float64 (*_eeb );_agg =float64 (*_cea );continue ;};if _db ==-1{_db =float64 (*_eeb );}else if _db < float64 (*_eeb ){_fcf +="\u0009";_db =float64 (*_eeb );};};if _gg &&_ca .Operand =="\u0054\u004a"{if len (_ca .Params )< 1{continue ;};_ffg ,_caf :=_ca .Params [0].(*_ed .PdfObjectArray );if !_caf {return "",_gb .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",_ca .Params [0]);};for _ ,_bge :=range _ffg .Elements (){switch _gbfa :=_bge .(type ){case *_ed .PdfObjectString :_fcf +=_gbfa .Str ();case *_ed .PdfObjectFloat :if *_gbfa < -100{_fcf +="\u0020";};case *_ed .PdfObjectInteger :if *_gbfa < -100{_fcf +="\u0020";};};};}else if _gg &&_ca .Operand =="\u0054\u006a"{if len (_ca .Params )< 1{continue ;};_eb ,_ea :=_ca .Params [0].(*_ed .PdfObjectString );if !_ea {return "",_gb .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",_ca .Params [0]);};_fcf +=_eb .Str ();};};return _fcf ,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 (_ggb *ContentCreator )Add_S ()*ContentCreator {_bdf :=ContentStreamOperation {};_bdf .Operand ="\u0053";_ggb ._ged =append (_ggb ._ged ,&_bdf );return _ggb ;}; // 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 (_dfa *ContentCreator )Add_d (dashArray []int64 ,dashPhase int64 )*ContentCreator {_ba :=ContentStreamOperation {};_ba .Operand ="\u0064";_ba .Params =[]_ed .PdfObject {};_ba .Params =append (_ba .Params ,_ed .MakeArrayFromIntegers64 (dashArray ));_ba .Params =append (_ba .Params ,_ed .MakeInteger (dashPhase ));_dfa ._ged =append (_dfa ._ged ,&_ba );return _dfa ;}; // 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 (_eee *ContentCreator )Add_k (c ,m ,y ,k float64 )*ContentCreator {_ebe :=ContentStreamOperation {};_ebe .Operand ="\u006b";_ebe .Params =_adcb ([]float64 {c ,m ,y ,k });_eee ._ged =append (_eee ._ged ,&_ebe );return _eee ;}; // 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 (_ceae *ContentCreator )Add_m (x ,y float64 )*ContentCreator {_cgc :=ContentStreamOperation {};_cgc .Operand ="\u006d";_cgc .Params =_adcb ([]float64 {x ,y });_ceae ._ged =append (_ceae ._ged ,&_cgc );return _ceae ;}; // 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 (_cdb *ContentStreamParser )ParseInlineImage ()(*ContentStreamInlineImage ,error ){_bbe :=ContentStreamInlineImage {};for {_cdb .skipSpaces ();_ceeg ,_edb ,_cbgb :=_cdb .parseObject ();if _cbgb !=nil {return nil ,_cbgb ;};if !_edb {_dceb ,_dfdb :=_ed .GetName (_ceeg );if !_dfdb {_dd .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",_ceeg );return nil ,_gb .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",_ceeg );};_aed ,_efg ,_fcfa :=_cdb .parseObject ();if _fcfa !=nil {return nil ,_fcfa ;};if _efg {return nil ,_gb .Errorf ("\u006eo\u0074\u0020\u0065\u0078\u0070\u0065\u0063\u0074\u0069\u006e\u0067 \u0061\u006e\u0020\u006f\u0070\u0065\u0072\u0061\u006e\u0064");};switch *_dceb {case "\u0042\u0050\u0043","\u0042\u0069t\u0073\u0050\u0065r\u0043\u006f\u006d\u0070\u006f\u006e\u0065\u006e\u0074":_bbe .BitsPerComponent =_aed ;case "\u0043\u0053","\u0043\u006f\u006c\u006f\u0072\u0053\u0070\u0061\u0063\u0065":_bbe .ColorSpace =_aed ;case "\u0044","\u0044\u0065\u0063\u006f\u0064\u0065":_bbe .Decode =_aed ;case "\u0044\u0050","D\u0065\u0063\u006f\u0064\u0065\u0050\u0061\u0072\u006d\u0073":_bbe .DecodeParms =_aed ;case "\u0046","\u0046\u0069\u006c\u0074\u0065\u0072":_bbe .Filter =_aed ;case "\u0048","\u0048\u0065\u0069\u0067\u0068\u0074":_bbe .Height =_aed ;case "\u0049\u004d","\u0049m\u0061\u0067\u0065\u004d\u0061\u0073k":_bbe .ImageMask =_aed ;case "\u0049\u006e\u0074\u0065\u006e\u0074":_bbe .Intent =_aed ;case "\u0049","I\u006e\u0074\u0065\u0072\u0070\u006f\u006c\u0061\u0074\u0065":_bbe .Interpolate =_aed ;case "\u0057","\u0057\u0069\u0064t\u0068":_bbe .Width =_aed ;case "\u004c\u0065\u006e\u0067\u0074\u0068","\u0053u\u0062\u0074\u0079\u0070\u0065","\u0054\u0079\u0070\u0065":_dd .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",*_dceb );default:return nil ,_gb .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",*_dceb );};};if _edb {_abbbg ,_ebee :=_ceeg .(*_ed .PdfObjectString );if !_ebee {return nil ,_gb .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 _abbbg .Str ()=="\u0045\u0049"{_dd .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 &_bbe ,nil ;}else if _abbbg .Str ()=="\u0049\u0044"{_dd .Log .Trace ("\u0049\u0044\u0020\u0073\u0074\u0061\u0072\u0074");_fbe ,_fgag :=_cdb ._bfde .Peek (1);if _fgag !=nil {return nil ,_fgag ;};if _ed .IsWhiteSpace (_fbe [0]){_cdb ._bfde .Discard (1);};_bbe ._dfae =[]byte {};_geg :=0;var _gaf []byte ;for {_fgcd ,_adc :=_cdb ._bfde .ReadByte ();if _adc !=nil {_dd .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 ,_adc ;};if _geg ==0{if _ed .IsWhiteSpace (_fgcd ){_gaf =[]byte {};_gaf =append (_gaf ,_fgcd );_geg =1;}else if _fgcd =='E'{_gaf =append (_gaf ,_fgcd );_geg =2;}else {_bbe ._dfae =append (_bbe ._dfae ,_fgcd );};}else if _geg ==1{_gaf =append (_gaf ,_fgcd );if _fgcd =='E'{_geg =2;}else {_bbe ._dfae =append (_bbe ._dfae ,_gaf ...);_gaf =[]byte {};if _ed .IsWhiteSpace (_fgcd ){_geg =1;}else {_geg =0;};};}else if _geg ==2{_gaf =append (_gaf ,_fgcd );if _fgcd =='I'{_geg =3;}else {_bbe ._dfae =append (_bbe ._dfae ,_gaf ...);_gaf =[]byte {};_geg =0;};}else if _geg ==3{_gaf =append (_gaf ,_fgcd );if _ed .IsWhiteSpace (_fgcd ){_cagc ,_age :=_cdb ._bfde .Peek (20);if _age !=nil &&_age !=_g .EOF {return nil ,_age ;};_fbb :=NewContentStreamParser (string (_cagc ));_gcdg :=true ;for _gdfc :=0;_gdfc < 3;_gdfc ++{_dbae ,_ebeb ,_gecd :=_fbb .parseObject ();if _gecd !=nil {if _gecd ==_g .EOF {break ;};continue ;};if _ebeb &&!_aga (_dbae .String ()){_gcdg =false ;break ;};};if _gcdg {if len (_bbe ._dfae )> 100{_dd .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 (_bbe ._dfae ),_bbe ._dfae [:100]);}else {_dd .Log .Trace ("\u0049\u006d\u0061\u0067e \u0073\u0074\u0072\u0065\u0061\u006d\u0020\u0028\u0025\u0064\u0029\u003a\u0020\u0025 \u0078",len (_bbe ._dfae ),_bbe ._dfae );};return &_bbe ,nil ;};};_bbe ._dfae =append (_bbe ._dfae ,_gaf ...);_gaf =[]byte {};_geg =0;};};};};};};func (_dbbd *ContentStreamParser )parseDict ()(*_ed .PdfObjectDictionary ,error ){_dd .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");_feg :=_ed .MakeDict ();_dbcb ,_ :=_dbbd ._bfde .ReadByte ();if _dbcb !='<'{return nil ,_f .New ("\u0069\u006e\u0076a\u006c\u0069\u0064\u0020\u0064\u0069\u0063\u0074");};_dbcb ,_ =_dbbd ._bfde .ReadByte ();if _dbcb !='<'{return nil ,_f .New ("\u0069\u006e\u0076a\u006c\u0069\u0064\u0020\u0064\u0069\u0063\u0074");};for {_dbbd .skipSpaces ();_acb ,_bcg :=_dbbd ._bfde .Peek (2);if _bcg !=nil {return nil ,_bcg ;};_dd .Log .Trace ("D\u0069c\u0074\u0020\u0070\u0065\u0065\u006b\u003a\u0020%\u0073\u0020\u0028\u0025 x\u0029\u0021",string (_acb ),string (_acb ));if (_acb [0]=='>')&&(_acb [1]=='>'){_dd .Log .Trace ("\u0045\u004f\u0046\u0020\u0064\u0069\u0063\u0074\u0069o\u006e\u0061\u0072\u0079");_dbbd ._bfde .ReadByte ();_dbbd ._bfde .ReadByte ();break ;};_dd .Log .Trace ("\u0050a\u0072s\u0065\u0020\u0074\u0068\u0065\u0020\u006e\u0061\u006d\u0065\u0021");_dgd ,_bcg :=_dbbd .parseName ();_dd .Log .Trace ("\u004be\u0079\u003a\u0020\u0025\u0073",_dgd );if _bcg !=nil {_dd .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",_bcg );return nil ,_bcg ;};if len (_dgd )> 4&&_dgd [len (_dgd )-4:]=="\u006e\u0075\u006c\u006c"{_ffbg :=_dgd [0:len (_dgd )-4];_dd .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",_dgd );_dd .Log .Trace ("\u004e\u0065\u0077\u0020ke\u0079\u0020\u0022\u0025\u0073\u0022\u0020\u003d\u0020\u006e\u0075\u006c\u006c",_ffbg );_dbbd .skipSpaces ();_abe ,_ :=_dbbd ._bfde .Peek (1);if _abe [0]=='/'{_feg .Set (_ffbg ,_ed .MakeNull ());continue ;};};_dbbd .skipSpaces ();_gge ,_ ,_bcg :=_dbbd .parseObject ();if _bcg !=nil {return nil ,_bcg ;};_feg .Set (_dgd ,_gge );_dd .Log .Trace ("\u0064\u0069\u0063\u0074\u005b\u0025\u0073\u005d\u0020\u003d\u0020\u0025\u0073",_dgd ,_gge .String ());};return _feg ,nil ;}; // 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 (_ceaf *ContentCreator )Add_TL (leading float64 )*ContentCreator {_def :=ContentStreamOperation {};_def .Operand ="\u0054\u004c";_def .Params =_adcb ([]float64 {leading });_ceaf ._ged =append (_ceaf ._ged ,&_def );return _ceaf ;}; // 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 (_afd *ContentCreator )Add_Tm (a ,b ,c ,d ,e ,f float64 )*ContentCreator {_ecf :=ContentStreamOperation {};_ecf .Operand ="\u0054\u006d";_ecf .Params =_adcb ([]float64 {a ,b ,c ,d ,e ,f });_afd ._ged =append (_afd ._ged ,&_ecf );return _afd ;}; // NewContentStreamProcessor returns a new ContentStreamProcessor for operations `ops`. func NewContentStreamProcessor (ops []*ContentStreamOperation )*ContentStreamProcessor {_caa :=ContentStreamProcessor {};_caa ._bcbd =GraphicStateStack {};_afdb :=GraphicsState {};_caa ._bec =_afdb ;_caa ._aac =[]handlerEntry {};_caa ._gcb =0;_caa ._badg =ops ;return &_caa ;}; // 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 (_gc *ContentCreator )Add_i (flatness float64 )*ContentCreator {_bd :=ContentStreamOperation {};_bd .Operand ="\u0069";_bd .Params =_adcb ([]float64 {flatness });_gc ._ged =append (_gc ._ged ,&_bd );return _gc ;}; // 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 (_aef *ContentCreator )Add_scn_pattern (name _ed .PdfObjectName ,c ...float64 )*ContentCreator {_deeg :=ContentStreamOperation {};_deeg .Operand ="\u0073\u0063\u006e";_deeg .Params =_adcb (c );_deeg .Params =append (_deeg .Params ,_ed .MakeName (string (name )));_aef ._ged =append (_aef ._ged ,&_deeg );return _aef ;};func (_cffa *ContentStreamParser )parseNull ()(_ed .PdfObjectNull ,error ){_ ,_cebb :=_cffa ._bfde .Discard (4);return _ed .PdfObjectNull {},_cebb ;}; // 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 (_dga *ContentCreator )Add_BMC (tag _ed .PdfObjectName )*ContentCreator {_bab :=ContentStreamOperation {};_bab .Operand ="\u0042\u004d\u0043";_bab .Params =_begg ([]_ed .PdfObjectName {tag });_dga ._ged =append (_dga ._ged ,&_bab );return _dga ;};func (_edc *ContentStreamInlineImage )toImageBase (_bfd *_ab .PdfPageResources )(*_ge .ImageBase ,error ){if _edc ._fdf !=nil {return _edc ._fdf ,nil ;};_eab :=_ge .ImageBase {};if _edc .Height ==nil {return nil ,_f .New ("\u0068e\u0069\u0067\u0068\u0074\u0020\u0061\u0074\u0074\u0072\u0069\u0062u\u0074\u0065\u0020\u006d\u0069\u0073\u0073\u0069\u006e\u0067");};_fge ,_gfe :=_edc .Height .(*_ed .PdfObjectInteger );if !_gfe {return nil ,_f .New ("\u0069\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u0068e\u0069\u0067\u0068\u0074");};_eab .Height =int (*_fge );if _edc .Width ==nil {return nil ,_f .New ("\u0077\u0069\u0064th\u0020\u0061\u0074\u0074\u0072\u0069\u0062\u0075\u0074\u0065\u0020\u006d\u0069\u0073\u0073\u0069\u006e\u0067");};_gba ,_gfe :=_edc .Width .(*_ed .PdfObjectInteger );if !_gfe {return nil ,_f .New ("\u0069\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u0077\u0069\u0064\u0074\u0068");};_eab .Width =int (*_gba );_afe ,_gdfd :=_edc .IsMask ();if _gdfd !=nil {return nil ,_gdfd ;};if _afe {_eab .BitsPerComponent =1;_eab .ColorComponents =1;}else {if _edc .BitsPerComponent ==nil {_dd .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");_eab .BitsPerComponent =8;}else {_bfaa ,_dfff :=_edc .BitsPerComponent .(*_ed .PdfObjectInteger );if !_dfff {_dd .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",_edc .BitsPerComponent );return nil ,_f .New ("\u0042\u0050\u0043\u0020\u0054\u0079\u0070\u0065\u0020e\u0072\u0072\u006f\u0072");};_eab .BitsPerComponent =int (*_bfaa );};if _edc .ColorSpace !=nil {_ddge ,_geef :=_edc .GetColorSpace (_bfd );if _geef !=nil {return nil ,_geef ;};_eab .ColorComponents =_ddge .GetNumComponents ();}else {_dd .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");_eab .ColorComponents =1;};};if _daafb ,_dege :=_ed .GetArray (_edc .Decode );_dege {_eab .Decode ,_gdfd =_daafb .ToFloat64Array ();if _gdfd !=nil {return nil ,_gdfd ;};};_edc ._fdf =&_eab ;return _edc ._fdf ,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 (_cbf *ContentCreator )Add_SCN_pattern (name _ed .PdfObjectName ,c ...float64 )*ContentCreator {_edab :=ContentStreamOperation {};_edab .Operand ="\u0053\u0043\u004e";_edab .Params =_adcb (c );_edab .Params =append (_edab .Params ,_ed .MakeName (string (name )));_cbf ._ged =append (_cbf ._ged ,&_edab );return _cbf ;}; // 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 (_daad *ContentCreator )Add_TD (tx ,ty float64 )*ContentCreator {_dad :=ContentStreamOperation {};_dad .Operand ="\u0054\u0044";_dad .Params =_adcb ([]float64 {tx ,ty });_daad ._ged =append (_daad ._ged ,&_dad );return _daad ;}; // 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 (_baf *ContentCreator )Add_Tstar ()*ContentCreator {_fcff :=ContentStreamOperation {};_fcff .Operand ="\u0054\u002a";_baf ._ged =append (_baf ._ged ,&_fcff );return _baf ;};type handlerEntry struct{Condition HandlerConditionEnum ;Operand string ;Handler HandlerFunc ;}; // 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 (_dbg *ContentCreator )Add_b_starred ()*ContentCreator {_cee :=ContentStreamOperation {};_cee .Operand ="\u0062\u002a";_dbg ._ged =append (_dbg ._ged ,&_cee );return _dbg ;}; // 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 (_gbc *ContentCreator )Add_quotes (textstr _ed .PdfObjectString ,aw ,ac float64 )*ContentCreator {_accf :=ContentStreamOperation {};_accf .Operand ="\u0022";_accf .Params =_adcb ([]float64 {aw ,ac });_accf .Params =append (_accf .Params ,_agff ([]_ed .PdfObjectString {textstr })...);_gbc ._ged =append (_gbc ._ged ,&_accf );return _gbc ;};func (_fgee *ContentStreamProcessor )getColorspace (_aggag string ,_fff *_ab .PdfPageResources )(_ab .PdfColorspace ,error ){switch _aggag {case "\u0044\u0065\u0076\u0069\u0063\u0065\u0047\u0072\u0061\u0079":return _ab .NewPdfColorspaceDeviceGray (),nil ;case "\u0044e\u0076\u0069\u0063\u0065\u0052\u0047B":return _ab .NewPdfColorspaceDeviceRGB (),nil ;case "\u0044\u0065\u0076\u0069\u0063\u0065\u0043\u004d\u0059\u004b":return _ab .NewPdfColorspaceDeviceCMYK (),nil ;case "\u0050a\u0074\u0074\u0065\u0072\u006e":return _ab .NewPdfColorspaceSpecialPattern (),nil ;};_ecb ,_bdff :=_fff .GetColorspaceByName (_ed .PdfObjectName (_aggag ));if _bdff {return _ecb ,nil ;};switch _aggag {case "\u0043a\u006c\u0047\u0072\u0061\u0079":return _ab .NewPdfColorspaceCalGray (),nil ;case "\u0043\u0061\u006c\u0052\u0047\u0042":return _ab .NewPdfColorspaceCalRGB (),nil ;case "\u004c\u0061\u0062":return _ab .NewPdfColorspaceLab (),nil ;};_dd .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",_aggag );return nil ,_gb .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",_aggag );};func (_aae *ContentStreamParser )parseBool ()(_ed .PdfObjectBool ,error ){_gfdd ,_agea :=_aae ._bfde .Peek (4);if _agea !=nil {return _ed .PdfObjectBool (false ),_agea ;};if (len (_gfdd )>=4)&&(string (_gfdd [:4])=="\u0074\u0072\u0075\u0065"){_aae ._bfde .Discard (4);return _ed .PdfObjectBool (true ),nil ;};_gfdd ,_agea =_aae ._bfde .Peek (5);if _agea !=nil {return _ed .PdfObjectBool (false ),_agea ;};if (len (_gfdd )>=5)&&(string (_gfdd [:5])=="\u0066\u0061\u006cs\u0065"){_aae ._bfde .Discard (5);return _ed .PdfObjectBool (false ),nil ;};return _ed .PdfObjectBool (false ),_f .New ("\u0075n\u0065\u0078\u0070\u0065c\u0074\u0065\u0064\u0020\u0062o\u006fl\u0065a\u006e\u0020\u0073\u0074\u0072\u0069\u006eg");}; // 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 (_eeg *ContentCreator )Add_W ()*ContentCreator {_fada :=ContentStreamOperation {};_fada .Operand ="\u0057";_eeg ._ged =append (_eeg ._ged ,&_fada );return _eeg ;}; // HandlerFunc is the function syntax that the ContentStreamProcessor handler must implement. type HandlerFunc func (_gea *ContentStreamOperation ,_fec GraphicsState ,_cecc *_ab .PdfPageResources )error ;func (_cdf *ContentStreamProcessor )handleCommand_G (_dgdf *ContentStreamOperation ,_aec *_ab .PdfPageResources )error {_fgf :=_ab .NewPdfColorspaceDeviceGray ();if len (_dgdf .Params )!=_fgf .GetNumComponents (){_dd .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");_dd .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 (_dgdf .Params ),_fgf );return _f .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");};_caeb ,_bgbd :=_fgf .ColorFromPdfObjects (_dgdf .Params );if _bgbd !=nil {return _bgbd ;};_cdf ._bec .ColorspaceStroking =_fgf ;_cdf ._bec .ColorStroking =_caeb ;return nil ;};func (_ebed *ContentStreamParser )parseObject ()(_ggc _ed .PdfObject ,_dafc bool ,_cgcb error ){_ebed .skipSpaces ();for {_bafg ,_dag :=_ebed ._bfde .Peek (2);if _dag !=nil {return nil ,false ,_dag ;};_dd .Log .Trace ("\u0050e\u0065k\u0020\u0073\u0074\u0072\u0069\u006e\u0067\u003a\u0020\u0025\u0073",string (_bafg ));if _bafg [0]=='%'{_ebed .skipComments ();continue ;}else if _bafg [0]=='/'{_fage ,_ggbbd :=_ebed .parseName ();_dd .Log .Trace ("\u002d\u003e\u004ea\u006d\u0065\u003a\u0020\u0027\u0025\u0073\u0027",_fage );return &_fage ,false ,_ggbbd ;}else if _bafg [0]=='('{_dd .Log .Trace ("\u002d>\u0053\u0074\u0072\u0069\u006e\u0067!");_gdfa ,_dbcbc :=_ebed .parseString ();return _gdfa ,false ,_dbcbc ;}else if _bafg [0]=='<'&&_bafg [1]!='<'{_dd .Log .Trace ("\u002d\u003e\u0048\u0065\u0078\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0021");_edcgd ,_dacg :=_ebed .parseHexString ();return _edcgd ,false ,_dacg ;}else if _bafg [0]=='['{_dd .Log .Trace ("\u002d\u003e\u0041\u0072\u0072\u0061\u0079\u0021");_eeda ,_dbcc :=_ebed .parseArray ();return _eeda ,false ,_dbcc ;}else if _ed .IsFloatDigit (_bafg [0])||(_bafg [0]=='-'&&_ed .IsFloatDigit (_bafg [1])){_dd .Log .Trace ("\u002d>\u004e\u0075\u006d\u0062\u0065\u0072!");_aedb ,_dacd :=_ebed .parseNumber ();return _aedb ,false ,_dacd ;}else if _bafg [0]=='<'&&_bafg [1]=='<'{_accgg ,_bcbf :=_ebed .parseDict ();return _accgg ,false ,_bcbf ;}else {_dd .Log .Trace ("\u002d>\u004fp\u0065\u0072\u0061\u006e\u0064 \u006f\u0072 \u0062\u006f\u006f\u006c\u003f");_bafg ,_ =_ebed ._bfde .Peek (5);_ggbg :=string (_bafg );_dd .Log .Trace ("\u0063\u006f\u006e\u0074\u0020\u0050\u0065\u0065\u006b\u0020\u0073\u0074r\u003a\u0020\u0025\u0073",_ggbg );if (len (_ggbg )> 3)&&(_ggbg [:4]=="\u006e\u0075\u006c\u006c"){_ffba ,_ffd :=_ebed .parseNull ();return &_ffba ,false ,_ffd ;}else if (len (_ggbg )> 4)&&(_ggbg [:5]=="\u0066\u0061\u006cs\u0065"){_edcgf ,_gbd :=_ebed .parseBool ();return &_edcgf ,false ,_gbd ;}else if (len (_ggbg )> 3)&&(_ggbg [:4]=="\u0074\u0072\u0075\u0065"){_fca ,_bbc :=_ebed .parseBool ();return &_fca ,false ,_bbc ;};_bbea ,_cbgg :=_ebed .parseOperand ();if _cbgg !=nil {return _bbea ,false ,_cbgg ;};if len (_bbea .String ())< 1{return _bbea ,false ,ErrInvalidOperand ;};return _bbea ,true ,nil ;};};}; // AddHandler adds a new ContentStreamProcessor `handler` of type `condition` for `operand`. func (_acbf *ContentStreamProcessor )AddHandler (condition HandlerConditionEnum ,operand string ,handler HandlerFunc ){_fbgg :=handlerEntry {};_fbgg .Condition =condition ;_fbgg .Operand =operand ;_fbgg .Handler =handler ;_acbf ._aac =append (_acbf ._aac ,_fbgg );}; // ContentStreamParser represents a content stream parser for parsing content streams in PDFs. type ContentStreamParser struct{_bfde *_a .Reader };func (_faca *ContentStreamParser )skipSpaces ()(int ,error ){_edbd :=0;for {_eabc ,_bga :=_faca ._bfde .Peek (1);if _bga !=nil {return 0,_bga ;};if _ed .IsWhiteSpace (_eabc [0]){_faca ._bfde .ReadByte ();_edbd ++;}else {break ;};};return _edbd ,nil ;}; // 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 (_gefd *ContentCreator )Add_Tc (charSpace float64 )*ContentCreator {_ggbc :=ContentStreamOperation {};_ggbc .Operand ="\u0054\u0063";_ggbc .Params =_adcb ([]float64 {charSpace });_gefd ._ged =append (_gefd ._ged ,&_ggbc );return _gefd ;};func (_cab *ContentStreamInlineImage )String ()string {_dgc :=_gb .Sprintf ("I\u006el\u0069\u006e\u0065\u0049\u006d\u0061\u0067\u0065(\u006c\u0065\u006e\u003d%d\u0029\u000a",len (_cab ._dfae ));if _cab .BitsPerComponent !=nil {_dgc +="\u002d\u0020\u0042\u0050\u0043\u0020"+_cab .BitsPerComponent .WriteString ()+"\u000a";};if _cab .ColorSpace !=nil {_dgc +="\u002d\u0020\u0043S\u0020"+_cab .ColorSpace .WriteString ()+"\u000a";};if _cab .Decode !=nil {_dgc +="\u002d\u0020\u0044\u0020"+_cab .Decode .WriteString ()+"\u000a";};if _cab .DecodeParms !=nil {_dgc +="\u002d\u0020\u0044P\u0020"+_cab .DecodeParms .WriteString ()+"\u000a";};if _cab .Filter !=nil {_dgc +="\u002d\u0020\u0046\u0020"+_cab .Filter .WriteString ()+"\u000a";};if _cab .Height !=nil {_dgc +="\u002d\u0020\u0048\u0020"+_cab .Height .WriteString ()+"\u000a";};if _cab .ImageMask !=nil {_dgc +="\u002d\u0020\u0049M\u0020"+_cab .ImageMask .WriteString ()+"\u000a";};if _cab .Intent !=nil {_dgc +="\u002d \u0049\u006e\u0074\u0065\u006e\u0074 "+_cab .Intent .WriteString ()+"\u000a";};if _cab .Interpolate !=nil {_dgc +="\u002d\u0020\u0049\u0020"+_cab .Interpolate .WriteString ()+"\u000a";};if _cab .Width !=nil {_dgc +="\u002d\u0020\u0057\u0020"+_cab .Width .WriteString ()+"\u000a";};return _dgc ;}; // Push pushes `gs` on the `gsStack`. func (_dafce *GraphicStateStack )Push (gs GraphicsState ){*_dafce =append (*_dafce ,gs )};func (_adcfb *ContentStreamProcessor )handleCommand_sc (_ddc *ContentStreamOperation ,_cadg *_ab .PdfPageResources )error {_abde :=_adcfb ._bec .ColorspaceNonStroking ;if !_fbfa (_abde ){if len (_ddc .Params )!=_abde .GetNumComponents (){_dd .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");_dd .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 (_ddc .Params ),_abde );return _f .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");};};_dfde ,_bacc :=_abde .ColorFromPdfObjects (_ddc .Params );if _bacc !=nil {return _bacc ;};_adcfb ._bec .ColorNonStroking =_dfde ;return nil ;}; // ContentStreamOperations is a slice of ContentStreamOperations. type ContentStreamOperations []*ContentStreamOperation ; // 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 (_agf *ContentCreator )Add_M (miterlimit float64 )*ContentCreator {_ffga :=ContentStreamOperation {};_ffga .Operand ="\u004d";_ffga .Params =_adcb ([]float64 {miterlimit });_agf ._ged =append (_agf ._ged ,&_ffga );return _agf ;}; // 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 (_bbf *ContentCreator )Add_q ()*ContentCreator {_gbg :=ContentStreamOperation {};_gbg .Operand ="\u0071";_bbf ._ged =append (_bbf ._ged ,&_gbg );return _bbf ;};func (_ccfe *ContentStreamParser )parseHexString ()(*_ed .PdfObjectString ,error ){_ccfe ._bfde .ReadByte ();_bfdf :=[]byte ("\u0030\u0031\u0032\u003345\u0036\u0037\u0038\u0039\u0061\u0062\u0063\u0064\u0065\u0066\u0041\u0042\u0043\u0044E\u0046");var _aggd []byte ;for {_ccfe .skipSpaces ();_gab ,_dceba :=_ccfe ._bfde .Peek (1);if _dceba !=nil {return _ed .MakeString (""),_dceba ;};if _gab [0]=='>'{_ccfe ._bfde .ReadByte ();break ;};_deff ,_ :=_ccfe ._bfde .ReadByte ();if _e .IndexByte (_bfdf ,_deff )>=0{_aggd =append (_aggd ,_deff );};};if len (_aggd )%2==1{_aggd =append (_aggd ,'0');};_adba ,_ :=_fc .DecodeString (string (_aggd ));return _ed .MakeHexString (string (_adba )),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 (_gcf *ContentCreator )Add_W_starred ()*ContentCreator {_gee :=ContentStreamOperation {};_gee .Operand ="\u0057\u002a";_gcf ._ged =append (_gcf ._ged ,&_gee );return _gcf ;};func _aga (_ddgb string )bool {_ ,_gfg :=_ddga [_ddgb ];return _gfg }; // 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 (_cde *ContentCreator )Add_scn (c ...float64 )*ContentCreator {_ae :=ContentStreamOperation {};_ae .Operand ="\u0073\u0063\u006e";_ae .Params =_adcb (c );_cde ._ged =append (_cde ._ged ,&_ae );return _cde ;}; // 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 (_acc *ContentCreator )Add_v (x2 ,y2 ,x3 ,y3 float64 )*ContentCreator {_gef :=ContentStreamOperation {};_gef .Operand ="\u0076";_gef .Params =_adcb ([]float64 {x2 ,y2 ,x3 ,y3 });_acc ._ged =append (_acc ._ged ,&_gef );return _acc ;}; // 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 (_fbd *ContentCreator )Add_gs (dictName _ed .PdfObjectName )*ContentCreator {_ced :=ContentStreamOperation {};_ced .Operand ="\u0067\u0073";_ced .Params =_begg ([]_ed .PdfObjectName {dictName });_fbd ._ged =append (_fbd ._ged ,&_ced );return _fbd ;}; // GraphicStateStack represents a stack of GraphicsState. type GraphicStateStack []GraphicsState ; // 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 (_gce *ContentCreator )Add_f_starred ()*ContentCreator {_bae :=ContentStreamOperation {};_bae .Operand ="\u0066\u002a";_gce ._ged =append (_gce ._ged ,&_bae );return _gce ;}; // 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 (_baba *ContentCreator )Add_EMC ()*ContentCreator {_eebf :=ContentStreamOperation {};_eebf .Operand ="\u0045\u004d\u0043";_baba ._ged =append (_baba ._ged ,&_eebf );return _baba ;}; // RotateDeg applies a rotation to the transformation matrix. func (_gbee *ContentCreator )RotateDeg (angle float64 )*ContentCreator {_cf :=_ag .Cos (angle *_ag .Pi /180.0);_ddg :=_ag .Sin (angle *_ag .Pi /180.0);_ebge :=-_ag .Sin (angle *_ag .Pi /180.0);_abg :=_ag .Cos (angle *_ag .Pi /180.0);return _gbee .Add_cm (_cf ,_ddg ,_ebge ,_abg ,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 (_agfb *ContentCreator )Add_Tf (fontName _ed .PdfObjectName ,fontSize float64 )*ContentCreator {_bag :=ContentStreamOperation {};_bag .Operand ="\u0054\u0066";_bag .Params =_begg ([]_ed .PdfObjectName {fontName });_bag .Params =append (_bag .Params ,_adcb ([]float64 {fontSize })...);_agfb ._ged =append (_agfb ._ged ,&_bag );return _agfb ;}; // 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 (_ebg *ContentCreator )Add_cm (a ,b ,c ,d ,e ,f float64 )*ContentCreator {_agc :=ContentStreamOperation {};_agc .Operand ="\u0063\u006d";_agc .Params =_adcb ([]float64 {a ,b ,c ,d ,e ,f });_ebg ._ged =append (_ebg ._ged ,&_agc );return _ebg ;}; // 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 (_bda *ContentCreator )Add_Td (tx ,ty float64 )*ContentCreator {_dba :=ContentStreamOperation {};_dba .Operand ="\u0054\u0064";_dba .Params =_adcb ([]float64 {tx ,ty });_bda ._ged =append (_bda ._ged ,&_dba );return _bda ;}; // Scale applies x-y scaling to the transformation matrix. func (_fg *ContentCreator )Scale (sx ,sy float64 )*ContentCreator {return _fg .Add_cm (sx ,0,0,sy ,0,0);}; // 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 (_cac *ContentCreator )Add_RG (r ,g ,b float64 )*ContentCreator {_cgca :=ContentStreamOperation {};_cgca .Operand ="\u0052\u0047";_cgca .Params =_adcb ([]float64 {r ,g ,b });_cac ._ged =append (_cac ._ged ,&_cgca );return _cac ;}; // 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 (_ecdg *ContentCreator )Add_ET ()*ContentCreator {_adb :=ContentStreamOperation {};_adb .Operand ="\u0045\u0054";_ecdg ._ged =append (_ecdg ._ged ,&_adb );return _ecdg ;}; // Operand returns true if `hce` is equivalent to HandlerConditionEnumOperand. func (_cfce HandlerConditionEnum )Operand ()bool {return _cfce ==HandlerConditionEnumOperand }; // 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 (_ggd *ContentCreator )Add_ri (intent _ed .PdfObjectName )*ContentCreator {_eg :=ContentStreamOperation {};_eg .Operand ="\u0072\u0069";_eg .Params =_begg ([]_ed .PdfObjectName {intent });_ggd ._ged =append (_ggd ._ged ,&_eg );return _ggd ;}; // 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 (_cgf *ContentCreator )Add_Ts (rise float64 )*ContentCreator {_ace :=ContentStreamOperation {};_ace .Operand ="\u0054\u0073";_ace .Params =_adcb ([]float64 {rise });_cgf ._ged =append (_cgf ._ged ,&_ace );return _cgf ;};func (_abfa *ContentStreamProcessor )handleCommand_K (_egdg *ContentStreamOperation ,_ggcd *_ab .PdfPageResources )error {_gbcg :=_ab .NewPdfColorspaceDeviceCMYK ();if len (_egdg .Params )!=_gbcg .GetNumComponents (){_dd .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");_dd .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 (_egdg .Params ),_gbcg );return _f .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");};_dae ,_fgg :=_gbcg .ColorFromPdfObjects (_egdg .Params );if _fgg !=nil {return _fgg ;};_abfa ._bec .ColorspaceStroking =_gbcg ;_abfa ._bec .ColorStroking =_dae ;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 (_bbd *ContentCreator )Add_TJ (vals ..._ed .PdfObject )*ContentCreator {_agfd :=ContentStreamOperation {};_agfd .Operand ="\u0054\u004a";_agfd .Params =[]_ed .PdfObject {_ed .MakeArray (vals ...)};_bbd ._ged =append (_bbd ._ged ,&_agfd );return _bbd ;}; // String returns `ops.Bytes()` as a string. func (_da *ContentStreamOperations )String ()string {return string (_da .Bytes ())}; // SetNonStrokingColor sets the non-stroking `color` where color can be one of // PdfColorDeviceGray, PdfColorDeviceRGB, or PdfColorDeviceCMYK. func (_bdb *ContentCreator )SetNonStrokingColor (color _ab .PdfColor )*ContentCreator {switch _gccb :=color .(type ){case *_ab .PdfColorDeviceGray :_bdb .Add_g (_gccb .Val ());case *_ab .PdfColorDeviceRGB :_bdb .Add_rg (_gccb .R (),_gccb .G (),_gccb .B ());case *_ab .PdfColorDeviceCMYK :_bdb .Add_k (_gccb .C (),_gccb .M (),_gccb .Y (),_gccb .K ());default:_dd .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",_gccb );};return _bdb ;}; // ContentCreator is a builder for PDF content streams. type ContentCreator struct{_ged ContentStreamOperations }; // 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 (_bgb *ContentCreator )Add_rg (r ,g ,b float64 )*ContentCreator {_ceb :=ContentStreamOperation {};_ceb .Operand ="\u0072\u0067";_ceb .Params =_adcb ([]float64 {r ,g ,b });_bgb ._ged =append (_bgb ._ged ,&_ceb );return _bgb ;};var (ErrInvalidOperand =_f .New ("\u0069n\u0076a\u006c\u0069\u0064\u0020\u006f\u0070\u0065\u0072\u0061\u006e\u0064"););func _baec (_cec *ContentStreamInlineImage ,_bee *_ed .PdfObjectDictionary )(*_ed .FlateEncoder ,error ){_dbb :=_ed .NewFlateEncoder ();if _cec ._fdf !=nil {_dbb .SetImage (_cec ._fdf );};if _bee ==nil {_eef :=_cec .DecodeParms ;if _eef !=nil {_cgb ,_eed :=_ed .GetDict (_eef );if !_eed {_dd .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",_eef );return nil ,_gb .Errorf ("\u0069\u006e\u0076\u0061li\u0064\u0020\u0044\u0065\u0063\u006f\u0064\u0065\u0050\u0061\u0072\u006d\u0073");};_bee =_cgb ;};};if _bee ==nil {return _dbb ,nil ;};_dd .Log .Trace ("\u0064\u0065\u0063\u006f\u0064\u0065\u0020\u0070\u0061\u0072\u0061\u006ds\u003a\u0020\u0025\u0073",_bee .String ());_acf :=_bee .Get ("\u0050r\u0065\u0064\u0069\u0063\u0074\u006fr");if _acf ==nil {_dd .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 {_bef ,_ggg :=_acf .(*_ed .PdfObjectInteger );if !_ggg {_dd .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",_acf );return nil ,_gb .Errorf ("\u0069\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u0050\u0072\u0065\u0064i\u0063\u0074\u006f\u0072");};_dbb .Predictor =int (*_bef );};_acf =_bee .Get ("\u0042\u0069t\u0073\u0050\u0065r\u0043\u006f\u006d\u0070\u006f\u006e\u0065\u006e\u0074");if _acf !=nil {_edd ,_fd :=_acf .(*_ed .PdfObjectInteger );if !_fd {_dd .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 ,_gb .Errorf ("\u0069n\u0076\u0061\u006c\u0069\u0064\u0020\u0042\u0069\u0074\u0073\u0050e\u0072\u0043\u006f\u006d\u0070\u006f\u006e\u0065\u006e\u0074");};_dbb .BitsPerComponent =int (*_edd );};if _dbb .Predictor > 1{_dbb .Columns =1;_acf =_bee .Get ("\u0043o\u006c\u0075\u006d\u006e\u0073");if _acf !=nil {_gedd ,_daab :=_acf .(*_ed .PdfObjectInteger );if !_daab {return nil ,_gb .Errorf ("\u0070r\u0065\u0064\u0069\u0063\u0074\u006f\u0072\u0020\u0063\u006f\u006cu\u006d\u006e\u0020\u0069\u006e\u0076\u0061\u006c\u0069\u0064");};_dbb .Columns =int (*_gedd );};_dbb .Colors =1;_bad :=_bee .Get ("\u0043\u006f\u006c\u006f\u0072\u0073");if _bad !=nil {_gdaf ,_adbe :=_bad .(*_ed .PdfObjectInteger );if !_adbe {return nil ,_gb .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");};_dbb .Colors =int (*_gdaf );};};return _dbb ,nil ;}; // ToImage exports the inline image to Image which can be transformed or exported easily. // Page resources are needed to look up colorspace information. func (_agga *ContentStreamInlineImage )ToImage (resources *_ab .PdfPageResources )(*_ab .Image ,error ){_ece ,_edcg :=_agga .toImageBase (resources );if _edcg !=nil {return nil ,_edcg ;};_acfc ,_edcg :=_eac (_agga );if _edcg !=nil {return nil ,_edcg ;};_dd .Log .Trace ("\u0065n\u0063o\u0064\u0065\u0072\u003a\u0020\u0025\u002b\u0076\u0020\u0025\u0054",_acfc ,_acfc );_dd .Log .Trace ("\u0069\u006e\u006c\u0069\u006e\u0065\u0020\u0069\u006d\u0061\u0067\u0065:\u0020\u0025\u002b\u0076",_agga );_cbc ,_edcg :=_acfc .DecodeBytes (_agga ._dfae );if _edcg !=nil {return nil ,_edcg ;};_dec :=&_ab .Image {Width :int64 (_ece .Width ),Height :int64 (_ece .Height ),BitsPerComponent :int64 (_ece .BitsPerComponent ),ColorComponents :_ece .ColorComponents ,Data :_cbc };if len (_ece .Decode )> 0{for _cecf :=0;_cecf < len (_ece .Decode );_cecf ++{_ece .Decode [_cecf ]*=float64 ((int (1)< 0{*_ef =append (*_ef ,&ContentStreamOperation {Operand :"\u0051"});_ad --;};return _ef ;}; // 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 (_agfe *ContentCreator )Add_h ()*ContentCreator {_dbc :=ContentStreamOperation {};_dbc .Operand ="\u0068";_agfe ._ged =append (_agfe ._ged ,&_dbc );return _agfe ;};func (_dca *ContentStreamParser )parseOperand ()(*_ed .PdfObjectString ,error ){var _edf []byte ;for {_cefd ,_fade :=_dca ._bfde .Peek (1);if _fade !=nil {return _ed .MakeString (string (_edf )),_fade ;};if _ed .IsDelimiter (_cefd [0]){break ;};if _ed .IsWhiteSpace (_cefd [0]){break ;};_beg ,_ :=_dca ._bfde .ReadByte ();_edf =append (_edf ,_beg );};return _ed .MakeString (string (_edf )),nil ;}; // 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 (_dac *ContentCreator )Add_G (gray float64 )*ContentCreator {_fgb :=ContentStreamOperation {};_fgb .Operand ="\u0047";_fgb .Params =_adcb ([]float64 {gray });_dac ._ged =append (_dac ._ged ,&_fgb );return _dac ;}; // All returns true if `hce` is equivalent to HandlerConditionEnumAllOperands. func (_febbg HandlerConditionEnum )All ()bool {return _febbg ==HandlerConditionEnumAllOperands }; // WriteString outputs the object as it is to be written to file. func (_eebc *ContentStreamInlineImage )WriteString ()string {var _dbda _e .Buffer ;_abbb :="";if _eebc .BitsPerComponent !=nil {_abbb +="\u002f\u0042\u0050C\u0020"+_eebc .BitsPerComponent .WriteString ()+"\u000a";};if _eebc .ColorSpace !=nil {_abbb +="\u002f\u0043\u0053\u0020"+_eebc .ColorSpace .WriteString ()+"\u000a";};if _eebc .Decode !=nil {_abbb +="\u002f\u0044\u0020"+_eebc .Decode .WriteString ()+"\u000a";};if _eebc .DecodeParms !=nil {_abbb +="\u002f\u0044\u0050\u0020"+_eebc .DecodeParms .WriteString ()+"\u000a";};if _eebc .Filter !=nil {_abbb +="\u002f\u0046\u0020"+_eebc .Filter .WriteString ()+"\u000a";};if _eebc .Height !=nil {_abbb +="\u002f\u0048\u0020"+_eebc .Height .WriteString ()+"\u000a";};if _eebc .ImageMask !=nil {_abbb +="\u002f\u0049\u004d\u0020"+_eebc .ImageMask .WriteString ()+"\u000a";};if _eebc .Intent !=nil {_abbb +="\u002f\u0049\u006e\u0074\u0065\u006e\u0074\u0020"+_eebc .Intent .WriteString ()+"\u000a";};if _eebc .Interpolate !=nil {_abbb +="\u002f\u0049\u0020"+_eebc .Interpolate .WriteString ()+"\u000a";};if _eebc .Width !=nil {_abbb +="\u002f\u0057\u0020"+_eebc .Width .WriteString ()+"\u000a";};_dbda .WriteString (_abbb );_dbda .WriteString ("\u0049\u0044\u0020");_dbda .Write (_eebc ._dfae );_dbda .WriteString ("\u000a\u0045\u0049\u000a");return _dbda .String ();}; // 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 (_fbdgd *ContentCreator )Add_n ()*ContentCreator {_cbd :=ContentStreamOperation {};_cbd .Operand ="\u006e";_fbdgd ._ged =append (_fbdgd ._ged ,&_cbd );return _fbdgd ;}; // 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 (_eae *ContentCreator )Add_B ()*ContentCreator {_cfe :=ContentStreamOperation {};_cfe .Operand ="\u0042";_eae ._ged =append (_eae ._ged ,&_cfe );return _eae ;}; // Wrap ensures that the contentstream is wrapped within a balanced q ... Q expression. func (_gf *ContentCreator )Wrap (){_gf ._ged .WrapIfNeeded ()};func (_eegb *ContentStreamProcessor )getInitialColor (_gafa _ab .PdfColorspace )(_ab .PdfColor ,error ){switch _fgea :=_gafa .(type ){case *_ab .PdfColorspaceDeviceGray :return _ab .NewPdfColorDeviceGray (0.0),nil ;case *_ab .PdfColorspaceDeviceRGB :return _ab .NewPdfColorDeviceRGB (0.0,0.0,0.0),nil ;case *_ab .PdfColorspaceDeviceCMYK :return _ab .NewPdfColorDeviceCMYK (0.0,0.0,0.0,1.0),nil ;case *_ab .PdfColorspaceCalGray :return _ab .NewPdfColorCalGray (0.0),nil ;case *_ab .PdfColorspaceCalRGB :return _ab .NewPdfColorCalRGB (0.0,0.0,0.0),nil ;case *_ab .PdfColorspaceLab :_dcfg :=0.0;_agd :=0.0;_bba :=0.0;if _fgea .Range [0]> 0{_dcfg =_fgea .Range [0];};if _fgea .Range [2]> 0{_agd =_fgea .Range [2];};return _ab .NewPdfColorLab (_dcfg ,_agd ,_bba ),nil ;case *_ab .PdfColorspaceICCBased :if _fgea .Alternate ==nil {_dd .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",_fgea .N );if _fgea .N ==1{_dd .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 _eegb .getInitialColor (_ab .NewPdfColorspaceDeviceGray ());}else if _fgea .N ==3{_dd .Log .Trace ("\u0046a\u006c\u006c\u0069\u006eg\u0020\u0062\u0061\u0063\u006b \u0074o\u0020D\u0065\u0076\u0069\u0063\u0065\u0052\u0047B");return _eegb .getInitialColor (_ab .NewPdfColorspaceDeviceRGB ());}else if _fgea .N ==4{_dd .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 _eegb .getInitialColor (_ab .NewPdfColorspaceDeviceCMYK ());}else {return nil ,_f .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 _eegb .getInitialColor (_fgea .Alternate );case *_ab .PdfColorspaceSpecialIndexed :if _fgea .Base ==nil {return nil ,_f .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 _eegb .getInitialColor (_fgea .Base );case *_ab .PdfColorspaceSpecialSeparation :if _fgea .AlternateSpace ==nil {return nil ,_f .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 _eegb .getInitialColor (_fgea .AlternateSpace );case *_ab .PdfColorspaceDeviceN :if _fgea .AlternateSpace ==nil {return nil ,_f .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 _eegb .getInitialColor (_fgea .AlternateSpace );case *_ab .PdfColorspaceSpecialPattern :return nil ,nil ;};_dd .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",_gafa );return nil ,_f .New ("\u0075\u006e\u0073\u0075pp\u006f\u0072\u0074\u0065\u0064\u0020\u0063\u006f\u006c\u006f\u0072\u0073\u0070\u0061c\u0065");}; // GetEncoder returns the encoder of the inline image. func (_ecdf *ContentStreamInlineImage )GetEncoder ()(_ed .StreamEncoder ,error ){return _eac (_ecdf )};func (_bcd *ContentStreamParser )parseArray ()(*_ed .PdfObjectArray ,error ){_afee :=_ed .MakeArray ();_bcd ._bfde .ReadByte ();for {_bcd .skipSpaces ();_aefe ,_fbfg :=_bcd ._bfde .Peek (1);if _fbfg !=nil {return _afee ,_fbfg ;};if _aefe [0]==']'{_bcd ._bfde .ReadByte ();break ;};_gbfe ,_ ,_fbfg :=_bcd .parseObject ();if _fbfg !=nil {return _afee ,_fbfg ;};_afee .Append (_gbfe );};return _afee ,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 _ed .PdfObject ;ColorSpace _ed .PdfObject ;Decode _ed .PdfObject ;DecodeParms _ed .PdfObject ;Filter _ed .PdfObject ;Height _ed .PdfObject ;ImageMask _ed .PdfObject ;Intent _ed .PdfObject ;Interpolate _ed .PdfObject ;Width _ed .PdfObject ;_dfae []byte ;_fdf *_ge .ImageBase ;}; // Operations returns the list of operations. func (_efc *ContentCreator )Operations ()*ContentStreamOperations {return &_efc ._ged };func (_aaf *ContentStreamParser )parseNumber ()(_ed .PdfObject ,error ){return _ed .ParseNumber (_aaf ._bfde );};func (_b *ContentStreamOperations )isWrapped ()bool {if len (*_b )< 2{return false ;};_ffa :=0;for _ ,_gd :=range *_b {if _gd .Operand =="\u0071"{_ffa ++;}else if _gd .Operand =="\u0051"{_ffa --;}else {if _ffa < 1{return false ;};};};return _ffa ==0;};func _adf (_fda *ContentStreamInlineImage )(*_ed .MultiEncoder ,error ){_bed :=_ed .NewMultiEncoder ();var _gbb *_ed .PdfObjectDictionary ;var _abb []_ed .PdfObject ;if _eff :=_fda .DecodeParms ;_eff !=nil {_cda ,_ddgg :=_eff .(*_ed .PdfObjectDictionary );if _ddgg {_gbb =_cda ;};_deg ,_effd :=_eff .(*_ed .PdfObjectArray );if _effd {for _ ,_fde :=range _deg .Elements (){if _gddf ,_ffb :=_fde .(*_ed .PdfObjectDictionary );_ffb {_abb =append (_abb ,_gddf );}else {_abb =append (_abb ,nil );};};};};_feb :=_fda .Filter ;if _feb ==nil {return nil ,_gb .Errorf ("\u0066\u0069\u006c\u0074\u0065\u0072\u0020\u006d\u0069s\u0073\u0069\u006e\u0067");};_cdea ,_dce :=_feb .(*_ed .PdfObjectArray );if !_dce {return nil ,_gb .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 _edg ,_gec :=range _cdea .Elements (){_caff ,_cdd :=_gec .(*_ed .PdfObjectName );if !_cdd {return nil ,_gb .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 _baecg _ed .PdfObject ;if _gbb !=nil {_baecg =_gbb ;}else {if len (_abb )> 0{if _edg >=len (_abb ){return nil ,_gb .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");};_baecg =_abb [_edg ];};};var _dfaac *_ed .PdfObjectDictionary ;if _afg ,_deegf :=_baecg .(*_ed .PdfObjectDictionary );_deegf {_dfaac =_afg ;};if *_caff ==_ed .StreamEncodingFilterNameFlate ||*_caff =="\u0046\u006c"{_dgbf ,_gcd :=_baec (_fda ,_dfaac );if _gcd !=nil {return nil ,_gcd ;};_bed .AddEncoder (_dgbf );}else if *_caff ==_ed .StreamEncodingFilterNameLZW {_fed ,_dfg :=_cef (_fda ,_dfaac );if _dfg !=nil {return nil ,_dfg ;};_bed .AddEncoder (_fed );}else if *_caff ==_ed .StreamEncodingFilterNameASCIIHex {_bgd :=_ed .NewASCIIHexEncoder ();_bed .AddEncoder (_bgd );}else if *_caff ==_ed .StreamEncodingFilterNameASCII85 ||*_caff =="\u0041\u0038\u0035"{_aeb :=_ed .NewASCII85Encoder ();_bed .AddEncoder (_aeb );}else {_dd .Log .Error ("U\u006e\u0073\u0075\u0070po\u0072t\u0065\u0064\u0020\u0066\u0069l\u0074\u0065\u0072\u0020\u0025\u0073",*_caff );return nil ,_gb .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 _bed ,nil ;};func _agff (_ccff []_ed .PdfObjectString )[]_ed .PdfObject {var _eecae []_ed .PdfObject ;for _ ,_cce :=range _ccff {_eecae =append (_eecae ,_ed .MakeString (_cce .Str ()));};return _eecae ;}; // 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 (_ccb *ContentCreator )Add_SCN (c ...float64 )*ContentCreator {_dffb :=ContentStreamOperation {};_dffb .Operand ="\u0053\u0043\u004e";_dffb .Params =_adcb (c );_ccb ._ged =append (_ccb ._ged ,&_dffb );return _ccb ;};func (_bggge *ContentStreamParser )parseString ()(*_ed .PdfObjectString ,error ){_bggge ._bfde .ReadByte ();var _aba []byte ;_abdf :=1;for {_eec ,_dddf :=_bggge ._bfde .Peek (1);if _dddf !=nil {return _ed .MakeString (string (_aba )),_dddf ;};if _eec [0]=='\\'{_bggge ._bfde .ReadByte ();_cdeb ,_cgfg :=_bggge ._bfde .ReadByte ();if _cgfg !=nil {return _ed .MakeString (string (_aba )),_cgfg ;};if _ed .IsOctalDigit (_cdeb ){_ggbb ,_ecfff :=_bggge ._bfde .Peek (2);if _ecfff !=nil {return _ed .MakeString (string (_aba )),_ecfff ;};var _bdd []byte ;_bdd =append (_bdd ,_cdeb );for _ ,_bgc :=range _ggbb {if _ed .IsOctalDigit (_bgc ){_bdd =append (_bdd ,_bgc );}else {break ;};};_bggge ._bfde .Discard (len (_bdd )-1);_dd .Log .Trace ("\u004e\u0075\u006d\u0065ri\u0063\u0020\u0073\u0074\u0072\u0069\u006e\u0067\u0020\u0022\u0025\u0073\u0022",_bdd );_gbgd ,_ecfff :=_ff .ParseUint (string (_bdd ),8,32);if _ecfff !=nil {return _ed .MakeString (string (_aba )),_ecfff ;};_aba =append (_aba ,byte (_gbgd ));continue ;};switch _cdeb {case 'n':_aba =append (_aba ,'\n');case 'r':_aba =append (_aba ,'\r');case 't':_aba =append (_aba ,'\t');case 'b':_aba =append (_aba ,'\b');case 'f':_aba =append (_aba ,'\f');case '(':_aba =append (_aba ,'(');case ')':_aba =append (_aba ,')');case '\\':_aba =append (_aba ,'\\');};continue ;}else if _eec [0]=='('{_abdf ++;}else if _eec [0]==')'{_abdf --;if _abdf ==0{_bggge ._bfde .ReadByte ();break ;};};_cfc ,_ :=_bggge ._bfde .ReadByte ();_aba =append (_aba ,_cfc );};return _ed .MakeString (string (_aba )),nil ;}; // NewContentStreamParser creates a new instance of the content stream parser from an input content // stream string. func NewContentStreamParser (contentStr string )*ContentStreamParser {_febb :=ContentStreamParser {};_aebe :=_e .NewBufferString (contentStr +"\u000a");_febb ._bfde =_a .NewReader (_aebe );return &_febb ;}; // 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{_bcbd GraphicStateStack ;_badg []*ContentStreamOperation ;_bec GraphicsState ;_aac []handlerEntry ;_gcb int ;}; // Pop pops and returns the topmost GraphicsState off the `gsStack`. func (_acd *GraphicStateStack )Pop ()GraphicsState {_edda :=(*_acd )[len (*_acd )-1];*_acd =(*_acd )[:len (*_acd )-1];return _edda ;};func (_gedc *ContentStreamProcessor )handleCommand_CS (_abbe *ContentStreamOperation ,_egd *_ab .PdfPageResources )error {if len (_abbe .Params )< 1{_dd .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 _f .New ("\u0074o\u006f \u0066\u0065\u0077\u0020\u0070a\u0072\u0061m\u0065\u0074\u0065\u0072\u0073");};if len (_abbe .Params )> 1{_dd .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 _f .New ("\u0074\u006f\u006f\u0020ma\u006e\u0079\u0020\u0070\u0061\u0072\u0061\u006d\u0065\u0074\u0065\u0072\u0073");};_cadc ,_fecf :=_abbe .Params [0].(*_ed .PdfObjectName );if !_fecf {_dd .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 _f .New ("\u0074\u0079p\u0065\u0020\u0063h\u0065\u0063\u006b\u0020\u0065\u0072\u0072\u006f\u0072");};_facg ,_geec :=_gedc .getColorspace (string (*_cadc ),_egd );if _geec !=nil {return _geec ;};_gedc ._bec .ColorspaceStroking =_facg ;_bace ,_geec :=_gedc .getInitialColor (_facg );if _geec !=nil {return _geec ;};_gedc ._bec .ColorStroking =_bace ;return nil ;}; // 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 (_adg *ContentCreator )Add_Tj (textstr _ed .PdfObjectString )*ContentCreator {_gff :=ContentStreamOperation {};_gff .Operand ="\u0054\u006a";_gff .Params =_agff ([]_ed .PdfObjectString {textstr });_adg ._ged =append (_adg ._ged ,&_gff );return _adg ;}; // 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 (_dacb *ContentStreamInlineImage )IsMask ()(bool ,error ){if _dacb .ImageMask !=nil {_ceac ,_gbef :=_dacb .ImageMask .(*_ed .PdfObjectBool );if !_gbef {_dd .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 ,_f .New ("\u0069\u006e\u0076\u0061li\u0064\u0020\u006f\u0062\u006a\u0065\u0063\u0074\u0020\u0074\u0079\u0070\u0065");};return bool (*_ceac ),nil ;};return false ,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 (_bce *ContentCreator )Add_j (lineJoinStyle string )*ContentCreator {_daa :=ContentStreamOperation {};_daa .Operand ="\u006a";_daa .Params =_begg ([]_ed .PdfObjectName {_ed .PdfObjectName (lineJoinStyle )});_bce ._ged =append (_bce ._ged ,&_daa );return _bce ;};func (_ebff *ContentStreamParser )parseName ()(_ed .PdfObjectName ,error ){_bfea :="";_aab :=false ;for {_bdad ,_aeg :=_ebff ._bfde .Peek (1);if _aeg ==_g .EOF {break ;};if _aeg !=nil {return _ed .PdfObjectName (_bfea ),_aeg ;};if !_aab {if _bdad [0]=='/'{_aab =true ;_ebff ._bfde .ReadByte ();}else {_dd .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",_bdad ,_bdad );return _ed .PdfObjectName (_bfea ),_gb .Errorf ("\u0069n\u0076a\u006c\u0069\u0064\u0020\u006ea\u006d\u0065:\u0020\u0028\u0025\u0063\u0029",_bdad [0]);};}else {if _ed .IsWhiteSpace (_bdad [0]){break ;}else if (_bdad [0]=='/')||(_bdad [0]=='[')||(_bdad [0]=='(')||(_bdad [0]==']')||(_bdad [0]=='<')||(_bdad [0]=='>'){break ;}else if _bdad [0]=='#'{_fgcg ,_dfdg :=_ebff ._bfde .Peek (3);if _dfdg !=nil {return _ed .PdfObjectName (_bfea ),_dfdg ;};_ebff ._bfde .Discard (3);_adcf ,_dfdg :=_fc .DecodeString (string (_fgcg [1:3]));if _dfdg !=nil {return _ed .PdfObjectName (_bfea ),_dfdg ;};_bfea +=string (_adcf );}else {_ffc ,_ :=_ebff ._bfde .ReadByte ();_bfea +=string (_ffc );};};};return _ed .PdfObjectName (_bfea ),nil ;}; // Transform returns coordinates x, y transformed by the CTM. func (_dede *GraphicsState )Transform (x ,y float64 )(float64 ,float64 ){return _dede .CTM .Transform (x ,y );};func (_gdbe *ContentStreamProcessor )handleCommand_cs (_cdae *ContentStreamOperation ,_cdgg *_ab .PdfPageResources )error {if len (_cdae .Params )< 1{_dd .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 _f .New ("\u0074o\u006f \u0066\u0065\u0077\u0020\u0070a\u0072\u0061m\u0065\u0074\u0065\u0072\u0073");};if len (_cdae .Params )> 1{_dd .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 _f .New ("\u0074\u006f\u006f\u0020ma\u006e\u0079\u0020\u0070\u0061\u0072\u0061\u006d\u0065\u0074\u0065\u0072\u0073");};_ceacc ,_aaab :=_cdae .Params [0].(*_ed .PdfObjectName );if !_aaab {_dd .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 _f .New ("\u0074\u0079p\u0065\u0020\u0063h\u0065\u0063\u006b\u0020\u0065\u0072\u0072\u006f\u0072");};_cca ,_dcg :=_gdbe .getColorspace (string (*_ceacc ),_cdgg );if _dcg !=nil {return _dcg ;};_gdbe ._bec .ColorspaceNonStroking =_cca ;_adde ,_dcg :=_gdbe .getInitialColor (_cca );if _dcg !=nil {return _dcg ;};_gdbe ._bec .ColorNonStroking =_adde ;return nil ;}; // SetStrokingColor sets the stroking `color` where color can be one of // PdfColorDeviceGray, PdfColorDeviceRGB, or PdfColorDeviceCMYK. func (_dffe *ContentCreator )SetStrokingColor (color _ab .PdfColor )*ContentCreator {switch _fcc :=color .(type ){case *_ab .PdfColorDeviceGray :_dffe .Add_G (_fcc .Val ());case *_ab .PdfColorDeviceRGB :_dffe .Add_RG (_fcc .R (),_fcc .G (),_fcc .B ());case *_ab .PdfColorDeviceCMYK :_dffe .Add_K (_fcc .C (),_fcc .M (),_fcc .Y (),_fcc .K ());default:_dd .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",_fcc );};return _dffe ;};func (_dcc *ContentStreamParser )skipComments ()error {if _ ,_dgfd :=_dcc .skipSpaces ();_dgfd !=nil {return _dgfd ;};_ccc :=true ;for {_cccg ,_caea :=_dcc ._bfde .Peek (1);if _caea !=nil {_dd .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0025\u0073",_caea .Error ());return _caea ;};if _ccc &&_cccg [0]!='%'{return nil ;};_ccc =false ;if (_cccg [0]!='\r')&&(_cccg [0]!='\n'){_dcc ._bfde .ReadByte ();}else {break ;};};return _dcc .skipComments ();}; // 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 (_cdg *ContentCreator )Bytes ()[]byte {return _cdg ._ged .Bytes ()};func (_aad *ContentStreamProcessor )handleCommand_g (_fcg *ContentStreamOperation ,_fcb *_ab .PdfPageResources )error {_fbdb :=_ab .NewPdfColorspaceDeviceGray ();if len (_fcg .Params )!=_fbdb .GetNumComponents (){_dd .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");_dd .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 (_fcg .Params ),_fbdb );return _f .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");};_fccf ,_efd :=_fbdb .ColorFromPdfObjects (_fcg .Params );if _efd !=nil {_dd .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",_fbdb ,_fcg ,_efd );return _efd ;};_aad ._bec .ColorspaceNonStroking =_fbdb ;_aad ._bec .ColorNonStroking =_fccf ;return nil ;};func _aace (_gecdd []int64 )[]_ed .PdfObject {var _cdfa []_ed .PdfObject ;for _ ,_gbad :=range _gecdd {_cdfa =append (_cdfa ,_ed .MakeInteger (_gbad ));};return _cdfa ;};func (_afb *ContentStreamProcessor )handleCommand_SC (_geddd *ContentStreamOperation ,_gedg *_ab .PdfPageResources )error {_cgd :=_afb ._bec .ColorspaceStroking ;if len (_geddd .Params )!=_cgd .GetNumComponents (){_dd .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");_dd .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 (_geddd .Params ),_cgd );return _f .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");};_abf ,_bgde :=_cgd .ColorFromPdfObjects (_geddd .Params );if _bgde !=nil {return _bgde ;};_afb ._bec .ColorStroking =_abf ;return nil ;};func _fbfa (_gdbeb _ab .PdfColorspace )bool {_ ,_cfcgc :=_gdbeb .(*_ab .PdfColorspaceSpecialPattern );return _cfcgc ;}; // 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 (_dgge *ContentCreator )Add_SC (c ...float64 )*ContentCreator {_fe :=ContentStreamOperation {};_fe .Operand ="\u0053\u0043";_fe .Params =_adcb (c );_dgge ._ged =append (_dgge ._ged ,&_fe );return _dgge ;};func (_bfg *ContentStreamProcessor )handleCommand_scn (_cga *ContentStreamOperation ,_acbg *_ab .PdfPageResources )error {_ffad :=_bfg ._bec .ColorspaceNonStroking ;if !_fbfa (_ffad ){if len (_cga .Params )!=_ffad .GetNumComponents (){_dd .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");_dd .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 (_cga .Params ),_ffad );return _f .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");};};_cccge ,_gbba :=_ffad .ColorFromPdfObjects (_cga .Params );if _gbba !=nil {_dd .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",_cga .Params ,_ffad );return _gbba ;};_bfg ._bec .ColorNonStroking =_cccge ;return nil ;}; // 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 (_dff *ContentCreator )Add_f ()*ContentCreator {_bcb :=ContentStreamOperation {};_bcb .Operand ="\u0066";_dff ._ged =append (_dff ._ged ,&_bcb );return _dff ;};func _adcb (_eedg []float64 )[]_ed .PdfObject {var _fcca []_ed .PdfObject ;for _ ,_eea :=range _eedg {_fcca =append (_fcca ,_ed .MakeFloat (_eea ));};return _fcca ;};func (_aaaf *ContentStreamProcessor )handleCommand_rg (_aaca *ContentStreamOperation ,_cgcaa *_ab .PdfPageResources )error {_cfca :=_ab .NewPdfColorspaceDeviceRGB ();if len (_aaca .Params )!=_cfca .GetNumComponents (){_dd .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");_dd .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 (_aaca .Params ),_cfca );return _f .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");};_cbcg ,_cedb :=_cfca .ColorFromPdfObjects (_aaca .Params );if _cedb !=nil {return _cedb ;};_aaaf ._bec .ColorspaceNonStroking =_cfca ;_aaaf ._bec .ColorNonStroking =_cbcg ;return nil ;};var _ddga =map[string ]struct{}{"\u0062":struct{}{},"\u0042":struct{}{},"\u0062\u002a":struct{}{},"\u0042\u002a":struct{}{},"\u0042\u0044\u0043":struct{}{},"\u0042\u0049":struct{}{},"\u0042\u004d\u0043":struct{}{},"\u0042\u0054":struct{}{},"\u0042\u0058":struct{}{},"\u0063":struct{}{},"\u0063\u006d":struct{}{},"\u0043\u0053":struct{}{},"\u0063\u0073":struct{}{},"\u0064":struct{}{},"\u0064\u0030":struct{}{},"\u0064\u0031":struct{}{},"\u0044\u006f":struct{}{},"\u0044\u0050":struct{}{},"\u0045\u0049":struct{}{},"\u0045\u004d\u0043":struct{}{},"\u0045\u0054":struct{}{},"\u0045\u0058":struct{}{},"\u0066":struct{}{},"\u0046":struct{}{},"\u0066\u002a":struct{}{},"\u0047":struct{}{},"\u0067":struct{}{},"\u0067\u0073":struct{}{},"\u0068":struct{}{},"\u0069":struct{}{},"\u0049\u0044":struct{}{},"\u006a":struct{}{},"\u004a":struct{}{},"\u004b":struct{}{},"\u006b":struct{}{},"\u006c":struct{}{},"\u006d":struct{}{},"\u004d":struct{}{},"\u004d\u0050":struct{}{},"\u006e":struct{}{},"\u0071":struct{}{},"\u0051":struct{}{},"\u0072\u0065":struct{}{},"\u0052\u0047":struct{}{},"\u0072\u0067":struct{}{},"\u0072\u0069":struct{}{},"\u0073":struct{}{},"\u0053":struct{}{},"\u0053\u0043":struct{}{},"\u0073\u0063":struct{}{},"\u0053\u0043\u004e":struct{}{},"\u0073\u0063\u006e":struct{}{},"\u0073\u0068":struct{}{},"\u0054\u002a":struct{}{},"\u0054\u0063":struct{}{},"\u0054\u0064":struct{}{},"\u0054\u0044":struct{}{},"\u0054\u0066":struct{}{},"\u0054\u006a":struct{}{},"\u0054\u004a":struct{}{},"\u0054\u004c":struct{}{},"\u0054\u006d":struct{}{},"\u0054\u0072":struct{}{},"\u0054\u0073":struct{}{},"\u0054\u0077":struct{}{},"\u0054\u007a":struct{}{},"\u0076":struct{}{},"\u0077":struct{}{},"\u0057":struct{}{},"\u0057\u002a":struct{}{},"\u0079":struct{}{},"\u0027":struct{}{},"\u0022":struct{}{}}; // 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 (_gcc *ContentCreator )Add_K (c ,m ,y ,k float64 )*ContentCreator {_bfe :=ContentStreamOperation {};_bfe .Operand ="\u004b";_bfe .Params =_adcb ([]float64 {c ,m ,y ,k });_gcc ._ged =append (_gcc ._ged ,&_bfe );return _gcc ;}; // 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 (_gdd *ContentCreator )Add_J (lineCapStyle string )*ContentCreator {_cba :=ContentStreamOperation {};_cba .Operand ="\u004a";_cba .Params =_begg ([]_ed .PdfObjectName {_ed .PdfObjectName (lineCapStyle )});_gdd ._ged =append (_gdd ._ged ,&_cba );return _gdd ;};func (_eeca *ContentStreamProcessor )handleCommand_k (_dfb *ContentStreamOperation ,_bdaa *_ab .PdfPageResources )error {_dab :=_ab .NewPdfColorspaceDeviceCMYK ();if len (_dfb .Params )!=_dab .GetNumComponents (){_dd .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");_dd .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 (_dfb .Params ),_dab );return _f .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");};_eged ,_aedc :=_dab .ColorFromPdfObjects (_dfb .Params );if _aedc !=nil {return _aedc ;};_eeca ._bec .ColorspaceNonStroking =_dab ;_eeca ._bec .ColorNonStroking =_eged ;return nil ;};func _begg (_bdc []_ed .PdfObjectName )[]_ed .PdfObject {var _cbec []_ed .PdfObject ;for _ ,_gcbc :=range _bdc {_cbec =append (_cbec ,_ed .MakeName (string (_gcbc )));};return _cbec ;}; // 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 (_daaa *ContentCreator )Add_B_starred ()*ContentCreator {_cfb :=ContentStreamOperation {};_cfb .Operand ="\u0042\u002a";_daaa ._ged =append (_daaa ._ged ,&_cfb );return _daaa ;}; // 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 (_dfaa *ContentCreator )Add_Tw (wordSpace float64 )*ContentCreator {_bff :=ContentStreamOperation {};_bff .Operand ="\u0054\u0077";_bff .Params =_adcb ([]float64 {wordSpace });_dfaa ._ged =append (_dfaa ._ged ,&_bff );return _dfaa ;}; // 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 (_cc *ContentCreator )Add_Do (name _ed .PdfObjectName )*ContentCreator {_ccf :=ContentStreamOperation {};_ccf .Operand ="\u0044\u006f";_ccf .Params =_begg ([]_ed .PdfObjectName {name });_cc ._ged =append (_cc ._ged ,&_ccf );return _cc ;}; // 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 (_af *ContentStreamOperations )Bytes ()[]byte {var _aa _e .Buffer ;for _ ,_fb :=range *_af {if _fb ==nil {continue ;};if _fb .Operand =="\u0042\u0049"{_aa .WriteString (_fb .Operand +"\u000a");_aa .WriteString (_fb .Params [0].WriteString ());}else {for _ ,_fa :=range _fb .Params {_aa .WriteString (_fa .WriteString ());_aa .WriteString ("\u0020");};_aa .WriteString (_fb .Operand +"\u000a");};};return _aa .Bytes ();}; // 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 (_daaf *ContentCreator )Add_Tr (render int64 )*ContentCreator {_bea :=ContentStreamOperation {};_bea .Operand ="\u0054\u0072";_bea .Params =_aace ([]int64 {render });_daaf ._ged =append (_daaf ._ged ,&_bea );return _daaf ;}; // 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 (_dg *ContentCreator )Add_w (lineWidth float64 )*ContentCreator {_bf :=ContentStreamOperation {};_bf .Operand ="\u0077";_bf .Params =_adcb ([]float64 {lineWidth });_dg ._ged =append (_dg ._ged ,&_bf );return _dg ;};func _aea (_dgf *ContentStreamInlineImage )(*_ed .DCTEncoder ,error ){_daf :=_ed .NewDCTEncoder ();_cgbc :=_e .NewReader (_dgf ._dfae );_fgc ,_cbdf :=_df .DecodeConfig (_cgbc );if _cbdf !=nil {_dd .Log .Debug ("\u0045\u0072\u0072or\u0020\u0064\u0065\u0063\u006f\u0064\u0069\u006e\u0067\u0020\u0066\u0069\u006c\u0065\u003a\u0020\u0025\u0073",_cbdf );return nil ,_cbdf ;};switch _fgc .ColorModel {case _d .RGBAModel :_daf .BitsPerComponent =8;_daf .ColorComponents =3;case _d .RGBA64Model :_daf .BitsPerComponent =16;_daf .ColorComponents =3;case _d .GrayModel :_daf .BitsPerComponent =8;_daf .ColorComponents =1;case _d .Gray16Model :_daf .BitsPerComponent =16;_daf .ColorComponents =1;case _d .CMYKModel :_daf .BitsPerComponent =8;_daf .ColorComponents =4;case _d .YCbCrModel :_daf .BitsPerComponent =8;_daf .ColorComponents =3;default:return nil ,_f .New ("\u0075\u006e\u0073up\u0070\u006f\u0072\u0074\u0065\u0064\u0020\u0063\u006f\u006c\u006f\u0072\u0020\u006d\u006f\u0064\u0065\u006c");};_daf .Width =_fgc .Width ;_daf .Height =_fgc .Height ;_dd .Log .Trace ("\u0044\u0043T\u0020\u0045\u006ec\u006f\u0064\u0065\u0072\u003a\u0020\u0025\u002b\u0076",_daf );return _daf ,nil ;}; // 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 (_faf *ContentCreator )Add_cs (name _ed .PdfObjectName )*ContentCreator {_cae :=ContentStreamOperation {};_cae .Operand ="\u0063\u0073";_cae .Params =_begg ([]_ed .PdfObjectName {name });_faf ._ged =append (_faf ._ged ,&_cae );return _faf ;}; // 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 _ab .PdfColorspace ;ColorspaceNonStroking _ab .PdfColorspace ;ColorStroking _ab .PdfColor ;ColorNonStroking _ab .PdfColor ;CTM _gbe .Matrix ;}; // Parse parses all commands in content stream, returning a list of operation data. func (_bbff *ContentStreamParser )Parse ()(*ContentStreamOperations ,error ){_dbdc :=ContentStreamOperations {};for {_dbf :=ContentStreamOperation {};for {_fdg ,_gfd ,_bac :=_bbff .parseObject ();if _bac !=nil {if _bac ==_g .EOF {return &_dbdc ,nil ;};return &_dbdc ,_bac ;};if _gfd {_dbf .Operand ,_ =_ed .GetStringVal (_fdg );_dbdc =append (_dbdc ,&_dbf );break ;}else {_dbf .Params =append (_dbf .Params ,_fdg );};};if _dbf .Operand =="\u0042\u0049"{_bafe ,_aaa :=_bbff .ParseInlineImage ();if _aaa !=nil {return &_dbdc ,_aaa ;};_dbf .Params =append (_dbf .Params ,_bafe );};};};func (_gbdc *ContentStreamProcessor )handleCommand_RG (_bgec *ContentStreamOperation ,_deege *_ab .PdfPageResources )error {_gabf :=_ab .NewPdfColorspaceDeviceRGB ();if len (_bgec .Params )!=_gabf .GetNumComponents (){_dd .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");_dd .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 (_bgec .Params ),_gabf );return _f .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");};_cagf ,_fgfa :=_gabf .ColorFromPdfObjects (_bgec .Params );if _fgfa !=nil {return _fgfa ;};_gbdc ._bec .ColorspaceStroking =_gabf ;_gbdc ._bec .ColorStroking =_cagf ;return nil ;}; // GetColorSpace returns the colorspace of the inline image. func (_ebfa *ContentStreamInlineImage )GetColorSpace (resources *_ab .PdfPageResources )(_ab .PdfColorspace ,error ){if _ebfa .ColorSpace ==nil {_dd .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 _ab .NewPdfColorspaceDeviceGray (),nil ;};if _gcdc ,_gac :=_ebfa .ColorSpace .(*_ed .PdfObjectArray );_gac {return _eddc (_gcdc );};_cefc ,_bfff :=_ebfa .ColorSpace .(*_ed .PdfObjectName );if !_bfff {_dd .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",_ebfa .ColorSpace ,_ebfa .ColorSpace );return nil ,_f .New ("\u0074\u0079p\u0065\u0020\u0063h\u0065\u0063\u006b\u0020\u0065\u0072\u0072\u006f\u0072");};if *_cefc =="\u0047"||*_cefc =="\u0044\u0065\u0076\u0069\u0063\u0065\u0047\u0072\u0061\u0079"{return _ab .NewPdfColorspaceDeviceGray (),nil ;}else if *_cefc =="\u0052\u0047\u0042"||*_cefc =="\u0044e\u0076\u0069\u0063\u0065\u0052\u0047B"{return _ab .NewPdfColorspaceDeviceRGB (),nil ;}else if *_cefc =="\u0043\u004d\u0059\u004b"||*_cefc =="\u0044\u0065\u0076\u0069\u0063\u0065\u0043\u004d\u0059\u004b"{return _ab .NewPdfColorspaceDeviceCMYK (),nil ;}else if *_cefc =="\u0049"||*_cefc =="\u0049n\u0064\u0065\u0078\u0065\u0064"{return nil ,_f .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");}else {if resources .ColorSpace ==nil {_dd .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",*_cefc );return nil ,_f .New ("\u0075n\u006bn\u006f\u0077\u006e\u0020\u0063o\u006c\u006fr\u0073\u0070\u0061\u0063\u0065");};_effg ,_dcd :=resources .GetColorspaceByName (*_cefc );if !_dcd {_dd .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",*_cefc );return nil ,_f .New ("\u0075n\u006bn\u006f\u0077\u006e\u0020\u0063o\u006c\u006fr\u0073\u0070\u0061\u0063\u0065");};return _effg ,nil ;};}; // 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 (_fbf *ContentCreator )Add_BT ()*ContentCreator {_bgf :=ContentStreamOperation {};_bgf .Operand ="\u0042\u0054";_fbf ._ged =append (_fbf ._ged ,&_bgf );return _fbf ;}; // 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 (_dfc *ContentCreator )Add_quote (textstr _ed .PdfObjectString )*ContentCreator {_cff :=ContentStreamOperation {};_cff .Operand ="\u0027";_cff .Params =_agff ([]_ed .PdfObjectString {textstr });_dfc ._ged =append (_dfc ._ged ,&_cff );return _dfc ;};func (_eeef *ContentStreamProcessor )handleCommand_cm (_cbag *ContentStreamOperation ,_caffc *_ab .PdfPageResources )error {if len (_cbag .Params )!=6{_dd .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 (_cbag .Params ));return _f .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");};_egf ,_acdg :=_ed .GetNumbersAsFloat (_cbag .Params );if _acdg !=nil {return _acdg ;};_baeca :=_gbe .NewMatrix (_egf [0],_egf [1],_egf [2],_egf [3],_egf [4],_egf [5]);_eeef ._bec .CTM .Concat (_baeca );return nil ;};func _eddc (_bfbf _ed .PdfObject )(_ab .PdfColorspace ,error ){_efb ,_bfgb :=_bfbf .(*_ed .PdfObjectArray );if !_bfgb {_dd .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",_bfbf );return nil ,_f .New ("\u0074\u0079p\u0065\u0020\u0063h\u0065\u0063\u006b\u0020\u0065\u0072\u0072\u006f\u0072");};if _efb .Len ()!=4{_dd .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",_efb .Len ());return nil ,_f .New ("\u0072\u0061\u006e\u0067\u0065\u0020\u0063\u0068\u0065\u0063\u006b\u0020e\u0072\u0072\u006f\u0072");};_dda ,_bfgb :=_efb .Get (0).(*_ed .PdfObjectName );if !_bfgb {_dd .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",*_efb );return nil ,_f .New ("\u0074\u0079p\u0065\u0020\u0063h\u0065\u0063\u006b\u0020\u0065\u0072\u0072\u006f\u0072");};if *_dda !="\u0049"&&*_dda !="\u0049n\u0064\u0065\u0078\u0065\u0064"{_dd .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",*_dda );return nil ,_f .New ("\u0072\u0061\u006e\u0067\u0065\u0020\u0063\u0068\u0065\u0063\u006b\u0020e\u0072\u0072\u006f\u0072");};_dda ,_bfgb =_efb .Get (1).(*_ed .PdfObjectName );if !_bfgb {_dd .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",*_efb );return nil ,_f .New ("\u0074\u0079p\u0065\u0020\u0063h\u0065\u0063\u006b\u0020\u0065\u0072\u0072\u006f\u0072");};if *_dda !="\u0047"&&*_dda !="\u0052\u0047\u0042"&&*_dda !="\u0043\u004d\u0059\u004b"&&*_dda !="\u0044\u0065\u0076\u0069\u0063\u0065\u0047\u0072\u0061\u0079"&&*_dda !="\u0044e\u0076\u0069\u0063\u0065\u0052\u0047B"&&*_dda !="\u0044\u0065\u0076\u0069\u0063\u0065\u0043\u004d\u0059\u004b"{_dd .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",*_dda );return nil ,_f .New ("\u0072\u0061\u006e\u0067\u0065\u0020\u0063\u0068\u0065\u0063\u006b\u0020e\u0072\u0072\u006f\u0072");};_cfg :="";switch *_dda {case "\u0047","\u0044\u0065\u0076\u0069\u0063\u0065\u0047\u0072\u0061\u0079":_cfg ="\u0044\u0065\u0076\u0069\u0063\u0065\u0047\u0072\u0061\u0079";case "\u0052\u0047\u0042","\u0044e\u0076\u0069\u0063\u0065\u0052\u0047B":_cfg ="\u0044e\u0076\u0069\u0063\u0065\u0052\u0047B";case "\u0043\u004d\u0059\u004b","\u0044\u0065\u0076\u0069\u0063\u0065\u0043\u004d\u0059\u004b":_cfg ="\u0044\u0065\u0076\u0069\u0063\u0065\u0043\u004d\u0059\u004b";};_ccae :=_ed .MakeArray (_ed .MakeName ("\u0049n\u0064\u0065\u0078\u0065\u0064"),_ed .MakeName (_cfg ),_efb .Get (2),_efb .Get (3));return _ab .NewPdfColorspaceFromPdfObject (_ccae );}; // 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 (_ac *ContentCreator )Add_Q ()*ContentCreator {_gfc :=ContentStreamOperation {};_gfc .Operand ="\u0051";_ac ._ged =append (_ac ._ged ,&_gfc );return _ac ;}; // 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 (_gdb *ContentCreator )Add_b ()*ContentCreator {_cbe :=ContentStreamOperation {};_cbe .Operand ="\u0062";_gdb ._ged =append (_gdb ._ged ,&_cbe );return _gdb ;};func (_bdab *ContentStreamProcessor )handleCommand_SCN (_abcf *ContentStreamOperation ,_fbggd *_ab .PdfPageResources )error {_febe :=_bdab ._bec .ColorspaceStroking ;if !_fbfa (_febe ){if len (_abcf .Params )!=_febe .GetNumComponents (){_dd .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");_dd .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 (_abcf .Params ),_febe );return _f .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");};};_fdb ,_faec :=_febe .ColorFromPdfObjects (_abcf .Params );if _faec !=nil {return _faec ;};_bdab ._bec .ColorStroking =_fdb ;return nil ;}; // 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 (_ege *ContentCreator )Add_sh (name _ed .PdfObjectName )*ContentCreator {_deb :=ContentStreamOperation {};_deb .Operand ="\u0073\u0068";_deb .Params =_begg ([]_ed .PdfObjectName {name });_ege ._ged =append (_ege ._ged ,&_deb );return _ege ;}; // 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 (_eda *ContentCreator )Add_c (x1 ,y1 ,x2 ,y2 ,x3 ,y3 float64 )*ContentCreator {_cag :=ContentStreamOperation {};_cag .Operand ="\u0063";_cag .Params =_adcb ([]float64 {x1 ,y1 ,x2 ,y2 ,x3 ,y3 });_eda ._ged =append (_eda ._ged ,&_cag );return _eda ;}; // 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 (_fad *ContentCreator )Add_s ()*ContentCreator {_dee :=ContentStreamOperation {};_dee .Operand ="\u0073";_fad ._ged =append (_fad ._ged ,&_dee );return _fad ;}; // 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 ; // String is same as Bytes() except returns as a string for convenience. func (_add *ContentCreator )String ()string {return string (_add ._ged .Bytes ())};const (HandlerConditionEnumOperand HandlerConditionEnum =iota ;HandlerConditionEnumAllOperands ;); // 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 (_gfcd *ContentCreator )Add_g (gray float64 )*ContentCreator {_bfa :=ContentStreamOperation {};_bfa .Operand ="\u0067";_bfa .Params =_adcb ([]float64 {gray });_gfcd ._ged =append (_gfcd ._ged ,&_bfa );return _gfcd ;}; // NewInlineImageFromImage makes a new content stream inline image object from an image. func NewInlineImageFromImage (img _ab .Image ,encoder _ed .StreamEncoder )(*ContentStreamInlineImage ,error ){if encoder ==nil {encoder =_ed .NewRawEncoder ();};encoder .UpdateParams (img .GetParamsDict ());_cbg :=ContentStreamInlineImage {};if img .ColorComponents ==1{_cbg .ColorSpace =_ed .MakeName ("\u0047");}else if img .ColorComponents ==3{_cbg .ColorSpace =_ed .MakeName ("\u0052\u0047\u0042");}else if img .ColorComponents ==4{_cbg .ColorSpace =_ed .MakeName ("\u0043\u004d\u0059\u004b");}else {_dd .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 ,_f .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");};_cbg .BitsPerComponent =_ed .MakeInteger (img .BitsPerComponent );_cbg .Width =_ed .MakeInteger (img .Width );_cbg .Height =_ed .MakeInteger (img .Height );_cad ,_ecff :=encoder .EncodeBytes (img .Data );if _ecff !=nil {return nil ,_ecff ;};_cbg ._dfae =_cad ;_bfc :=encoder .GetFilterName ();if _bfc !=_ed .StreamEncodingFilterNameRaw {_cbg .Filter =_ed .MakeName (_bfc );};return &_cbg ,nil ;}; // 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 (_bgg *ContentCreator )Add_re (x ,y ,width ,height float64 )*ContentCreator {_dcf :=ContentStreamOperation {};_dcf .Operand ="\u0072\u0065";_dcf .Params =_adcb ([]float64 {x ,y ,width ,height });_bgg ._ged =append (_bgg ._ged ,&_dcf );return _bgg ;};func _cef (_ga *ContentStreamInlineImage ,_gdg *_ed .PdfObjectDictionary )(*_ed .LZWEncoder ,error ){_baa :=_ed .NewLZWEncoder ();if _gdg ==nil {if _ga .DecodeParms !=nil {_gdf ,_eddd :=_ed .GetDict (_ga .DecodeParms );if !_eddd {_dd .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",_ga .DecodeParms );return nil ,_gb .Errorf ("\u0069\u006e\u0076\u0061li\u0064\u0020\u0044\u0065\u0063\u006f\u0064\u0065\u0050\u0061\u0072\u006d\u0073");};_gdg =_gdf ;};};if _gdg ==nil {return _baa ,nil ;};_bde :=_gdg .Get ("E\u0061\u0072\u006c\u0079\u0043\u0068\u0061\u006e\u0067\u0065");if _bde !=nil {_fac ,_dggb :=_bde .(*_ed .PdfObjectInteger );if !_dggb {_dd .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",_bde );return nil ,_gb .Errorf ("\u0069\u006e\u0076\u0061li\u0064\u0020\u0045\u0061\u0072\u006c\u0079\u0043\u0068\u0061\u006e\u0067\u0065");};if *_fac !=0&&*_fac !=1{return nil ,_gb .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");};_baa .EarlyChange =int (*_fac );}else {_baa .EarlyChange =1;};_bde =_gdg .Get ("\u0050r\u0065\u0064\u0069\u0063\u0074\u006fr");if _bde !=nil {_cefe ,_ebf :=_bde .(*_ed .PdfObjectInteger );if !_ebf {_dd .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",_bde );return nil ,_gb .Errorf ("\u0069\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u0050\u0072\u0065\u0064i\u0063\u0074\u006f\u0072");};_baa .Predictor =int (*_cefe );};_bde =_gdg .Get ("\u0042\u0069t\u0073\u0050\u0065r\u0043\u006f\u006d\u0070\u006f\u006e\u0065\u006e\u0074");if _bde !=nil {_bced ,_dfd :=_bde .(*_ed .PdfObjectInteger );if !_dfd {_dd .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 ,_gb .Errorf ("\u0069n\u0076\u0061\u006c\u0069\u0064\u0020\u0042\u0069\u0074\u0073\u0050e\u0072\u0043\u006f\u006d\u0070\u006f\u006e\u0065\u006e\u0074");};_baa .BitsPerComponent =int (*_bced );};if _baa .Predictor > 1{_baa .Columns =1;_bde =_gdg .Get ("\u0043o\u006c\u0075\u006d\u006e\u0073");if _bde !=nil {_bfb ,_eagb :=_bde .(*_ed .PdfObjectInteger );if !_eagb {return nil ,_gb .Errorf ("\u0070r\u0065\u0064\u0069\u0063\u0074\u006f\u0072\u0020\u0063\u006f\u006cu\u006d\u006e\u0020\u0069\u006e\u0076\u0061\u006c\u0069\u0064");};_baa .Columns =int (*_bfb );};_baa .Colors =1;_bde =_gdg .Get ("\u0043\u006f\u006c\u006f\u0072\u0073");if _bde !=nil {_ebc ,_dgb :=_bde .(*_ed .PdfObjectInteger );if !_dgb {return nil ,_gb .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");};_baa .Colors =int (*_ebc );};};_dd .Log .Trace ("\u0064\u0065\u0063\u006f\u0064\u0065\u0020\u0070\u0061\u0072\u0061\u006ds\u003a\u0020\u0025\u0073",_gdg .String ());return _baa ,nil ;};func _eac (_beab *ContentStreamInlineImage )(_ed .StreamEncoder ,error ){if _beab .Filter ==nil {return _ed .NewRawEncoder (),nil ;};_abd ,_eag :=_beab .Filter .(*_ed .PdfObjectName );if !_eag {_fae ,_fga :=_beab .Filter .(*_ed .PdfObjectArray );if !_fga {return nil ,_gb .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 _fae .Len ()==0{return _ed .NewRawEncoder (),nil ;};if _fae .Len ()!=1{_ada ,_dbd :=_adf (_beab );if _dbd !=nil {_dd .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",_dbd );return nil ,_dbd ;};_dd .Log .Trace ("\u004d\u0075\u006c\u0074\u0069\u0020\u0065\u006e\u0063:\u0020\u0025\u0073\u000a",_ada );return _ada ,nil ;};_gda :=_fae .Get (0);_abd ,_fga =_gda .(*_ed .PdfObjectName );if !_fga {return nil ,_gb .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 *_abd {case "\u0041\u0048\u0078","\u0041\u0053\u0043\u0049\u0049\u0048\u0065\u0078\u0044e\u0063\u006f\u0064\u0065":return _ed .NewASCIIHexEncoder (),nil ;case "\u0041\u0038\u0035","\u0041\u0053\u0043\u0049\u0049\u0038\u0035\u0044\u0065\u0063\u006f\u0064\u0065":return _ed .NewASCII85Encoder (),nil ;case "\u0044\u0043\u0054","\u0044C\u0054\u0044\u0065\u0063\u006f\u0064e":return _aea (_beab );case "\u0046\u006c","F\u006c\u0061\u0074\u0065\u0044\u0065\u0063\u006f\u0064\u0065":return _baec (_beab ,nil );case "\u004c\u005a\u0057","\u004cZ\u0057\u0044\u0065\u0063\u006f\u0064e":return _cef (_beab ,nil );case "\u0043\u0043\u0046","\u0043\u0043\u0049\u0054\u0054\u0046\u0061\u0078\u0044e\u0063\u006f\u0064\u0065":return _ed .NewCCITTFaxEncoder (),nil ;case "\u0052\u004c","\u0052u\u006eL\u0065\u006e\u0067\u0074\u0068\u0044\u0065\u0063\u006f\u0064\u0065":return _ed .NewRunLengthEncoder (),nil ;default:_dd .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",*_abd );return nil ,_f .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");};}; // AddOperand adds a specified operand. func (_cb *ContentCreator )AddOperand (op ContentStreamOperation )*ContentCreator {_cb ._ged =append (_cb ._ged ,&op );return _cb ;}; // NewContentCreator returns a new initialized ContentCreator. func NewContentCreator ()*ContentCreator {_bc :=&ContentCreator {};_bc ._ged =ContentStreamOperations {};return _bc ;}; // 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 (_bggg *ContentCreator )Add_CS (name _ed .PdfObjectName )*ContentCreator {_eegf :=ContentStreamOperation {};_eegf .Operand ="\u0043\u0053";_eegf .Params =_begg ([]_ed .PdfObjectName {name });_bggg ._ged =append (_bggg ._ged ,&_eegf );return _bggg ;}; // Translate applies a simple x-y translation to the transformation matrix. func (_dc *ContentCreator )Translate (tx ,ty float64 )*ContentCreator {return _dc .Add_cm (1,0,0,1,tx ,ty );}; // 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 (_ecd *ContentCreator )Add_l (x ,y float64 )*ContentCreator {_fbdg :=ContentStreamOperation {};_fbdg .Operand ="\u006c";_fbdg .Params =_adcb ([]float64 {x ,y });_ecd ._ged =append (_ecd ._ged ,&_fbdg );return _ecd ;}; // 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 (_dggc *ContentStreamProcessor )Process (resources *_ab .PdfPageResources )error {_dggc ._bec .ColorspaceStroking =_ab .NewPdfColorspaceDeviceGray ();_dggc ._bec .ColorspaceNonStroking =_ab .NewPdfColorspaceDeviceGray ();_dggc ._bec .ColorStroking =_ab .NewPdfColorDeviceGray (0);_dggc ._bec .ColorNonStroking =_ab .NewPdfColorDeviceGray (0);_dggc ._bec .CTM =_gbe .IdentityMatrix ();for _ ,_agfbd :=range _dggc ._badg {var _gcec error ;switch _agfbd .Operand {case "\u0071":_dggc ._bcbd .Push (_dggc ._bec );case "\u0051":if len (_dggc ._bcbd )==0{_dd .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 ;};_dggc ._bec =_dggc ._bcbd .Pop ();case "\u0043\u0053":_gcec =_dggc .handleCommand_CS (_agfbd ,resources );case "\u0063\u0073":_gcec =_dggc .handleCommand_cs (_agfbd ,resources );case "\u0053\u0043":_gcec =_dggc .handleCommand_SC (_agfbd ,resources );case "\u0053\u0043\u004e":_gcec =_dggc .handleCommand_SCN (_agfbd ,resources );case "\u0073\u0063":_gcec =_dggc .handleCommand_sc (_agfbd ,resources );case "\u0073\u0063\u006e":_gcec =_dggc .handleCommand_scn (_agfbd ,resources );case "\u0047":_gcec =_dggc .handleCommand_G (_agfbd ,resources );case "\u0067":_gcec =_dggc .handleCommand_g (_agfbd ,resources );case "\u0052\u0047":_gcec =_dggc .handleCommand_RG (_agfbd ,resources );case "\u0072\u0067":_gcec =_dggc .handleCommand_rg (_agfbd ,resources );case "\u004b":_gcec =_dggc .handleCommand_K (_agfbd ,resources );case "\u006b":_gcec =_dggc .handleCommand_k (_agfbd ,resources );case "\u0063\u006d":_gcec =_dggc .handleCommand_cm (_agfbd ,resources );};if _gcec !=nil {_dd .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",_agfbd .Operand ,_gcec );_dd .Log .Debug ("\u004f\u0070\u0065r\u0061\u006e\u0064\u003a\u0020\u0025\u0023\u0076",_agfbd .Operand );return _gcec ;};for _ ,_abc :=range _dggc ._aac {var _ecffg error ;if _abc .Condition .All (){_ecffg =_abc .Handler (_agfbd ,_dggc ._bec ,resources );}else if _abc .Condition .Operand ()&&_agfbd .Operand ==_abc .Operand {_ecffg =_abc .Handler (_agfbd ,_dggc ._bec ,resources );};if _ecffg !=nil {_dd .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",_ecffg );return _ecffg ;};};};return nil ;};