unipdf/render/render.go
2021-12-14 01:08:28 +00:00

149 lines
39 KiB
Go

//
// 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 render ;import (_b "errors";_ca "fmt";_ac "github.com/adrg/sysfont";_d "github.com/unidoc/unipdf/v3/common";_bb "github.com/unidoc/unipdf/v3/contentstream";_eb "github.com/unidoc/unipdf/v3/contentstream/draw";_gd "github.com/unidoc/unipdf/v3/core";
_cb "github.com/unidoc/unipdf/v3/internal/license";_cc "github.com/unidoc/unipdf/v3/internal/transform";_ad "github.com/unidoc/unipdf/v3/model";_df "github.com/unidoc/unipdf/v3/render/internal/context";_ag "github.com/unidoc/unipdf/v3/render/internal/context/imagerender";
_fb "golang.org/x/image/draw";_ed "image";_cgc "image/color";_f "image/draw";_cg "image/jpeg";_fc "image/png";_ae "math";_c "os";_g "path/filepath";_a "strings";);func _bedbb (_ffcd _gd .PdfObject ,_aged _cgc .Color )(_ed .Image ,error ){_cbeb ,_febc :=_gd .GetStream (_ffcd );
if !_febc {return nil ,nil ;};_ebdc ,_agd :=_ad .NewXObjectImageFromStream (_cbeb );if _agd !=nil {return nil ,_agd ;};_ede ,_agd :=_ebdc .ToImage ();if _agd !=nil {return nil ,_agd ;};return _abaf (_ede ,_aged ),nil ;};var (_bbe =_b .New ("\u0074\u0079p\u0065\u0020\u0063h\u0065\u0063\u006b\u0020\u0065\u0072\u0072\u006f\u0072");
_ffa =_b .New ("\u0072\u0061\u006e\u0067\u0065\u0020\u0063\u0068\u0065\u0063\u006b\u0020e\u0072\u0072\u006f\u0072"););
// RenderToPath converts the specified PDF page into an image and saves the
// result at the specified location.
func (_ea *ImageDevice )RenderToPath (page *_ad .PdfPage ,outputPath string )error {_ebd ,_ge :=_ea .Render (page );if _ge !=nil {return _ge ;};_ga :=_a .ToLower (_g .Ext (outputPath ));if _ga ==""{return _b .New ("\u0063\u006ful\u0064\u0020\u006eo\u0074\u0020\u0072\u0065cog\u006eiz\u0065\u0020\u006f\u0075\u0074\u0070\u0075t \u0066\u0069\u006c\u0065\u0020\u0074\u0079p\u0065");
};switch _ga {case "\u002e\u0070\u006e\u0067":return _ccc (outputPath ,_ebd );case "\u002e\u006a\u0070\u0067","\u002e\u006a\u0070e\u0067":return _bgd (outputPath ,_ebd ,100);};return _ca .Errorf ("\u0075\u006e\u0072\u0065\u0063\u006fg\u006e\u0069\u007a\u0065\u0064\u0020\u006f\u0075\u0074\u0070\u0075\u0074\u0020f\u0069\u006c\u0065\u0020\u0074\u0079\u0070e\u003a\u0020\u0025\u0073",_ga );
};func _bgd (_dec string ,_edg _ed .Image ,_dce int )error {_bdc ,_fbe :=_c .Create (_dec );if _fbe !=nil {return _fbe ;};defer _bdc .Close ();return _cg .Encode (_bdc ,_edg ,&_cg .Options {Quality :_dce });};func _ccc (_age string ,_ffc _ed .Image )error {_fbc ,_cgea :=_c .Create (_age );
if _cgea !=nil {return _cgea ;};defer _fbc .Close ();return _fc .Encode (_fbc ,_ffc );};
// NewImageDevice returns a new image device.
func NewImageDevice ()*ImageDevice {const _dc ="r\u0065\u006e\u0064\u0065r.\u004ee\u0077\u0049\u006d\u0061\u0067e\u0044\u0065\u0076\u0069\u0063\u0065";_cb .TrackUse (_dc );return &ImageDevice {};};
// Render converts the specified PDF page into an image and returns the result.
func (_ce *ImageDevice )Render (page *_ad .PdfPage )(_ed .Image ,error ){_gdg ,_acc :=page .GetMediaBox ();if _acc !=nil {return nil ,_acc ;};_gdg .Normalize ();_af :=page .CropBox ;var _be ,_fa float64 ;if _af !=nil {_af .Normalize ();_be ,_fa =_af .Width (),_af .Height ();
};_cgb :=page .Rotate ;_acd ,_cee ,_ff ,_eda :=_gdg .Llx ,_gdg .Lly ,_gdg .Width (),_gdg .Height ();_ee :=_cc .IdentityMatrix ();if _cgb !=nil &&*_cgb %360!=0&&*_cgb %90==0{_dg :=-float64 (*_cgb );_gf :=_fcc (_ff ,_eda ,_dg );_ee =_ee .Translate ((_gf .Width -_ff )/2+_ff /2,(_gf .Height -_eda )/2+_eda /2).Rotate (_dg *_ae .Pi /180).Translate (-_ff /2,-_eda /2);
_ff ,_eda =_gf .Width ,_gf .Height ;if _af !=nil {_da :=_fcc (_be ,_fa ,_dg );_be ,_fa =_da .Width ,_da .Height ;};};if _acd !=0||_cee !=0{_ee =_ee .Translate (-_acd ,-_cee );};_ce ._bg =1.0;if _ce .OutputWidth !=0{_afg :=_ff ;if _af !=nil {_afg =_be ;
};_ce ._bg =float64 (_ce .OutputWidth )/_afg ;_ff ,_eda ,_be ,_fa =_ff *_ce ._bg ,_eda *_ce ._bg ,_be *_ce ._bg ,_fa *_ce ._bg ;_ee =_cc .ScaleMatrix (_ce ._bg ,_ce ._bg ).Mult (_ee );};_gc :=_ag .NewContext (int (_ff ),int (_eda ));if _cbg :=_ce .renderPage (_gc ,page ,_ee );
_cbg !=nil {return nil ,_cbg ;};_dab :=_gc .Image ();if _af !=nil {_dabd ,_dag :=(_af .Llx -_acd )*_ce ._bg ,(_af .Lly -_cee )*_ce ._bg ;_acf :=_ed .Rect (0,0,int (_be ),int (_fa ));_bd :=_ed .Pt (int (_dabd ),int (_eda -_dag -_fa ));_gfg :=_ed .NewRGBA (_acf );
_f .Draw (_gfg ,_acf ,_dab ,_bd ,_f .Src );_dab =_gfg ;};return _dab ,nil ;};func (_ebg renderer )renderContentStream (_edc _df .Context ,_gb string ,_eaa *_ad .PdfPageResources )error {_eg ,_dac :=_bb .NewContentStreamParser (_gb ).Parse ();if _dac !=nil {return _dac ;
};_db :=_edc .TextState ();_db .GlobalScale =_ebg ._bg ;_gag :=map[string ]*_df .TextFont {};_gad :=_ac .NewFinder (&_ac .FinderOpts {Extensions :[]string {"\u002e\u0074\u0074\u0066","\u002e\u0074\u0074\u0063"}});_aa :=_bb .NewContentStreamProcessor (*_eg );
_aa .AddHandler (_bb .HandlerConditionEnumAllOperands ,"",func (_acce *_bb .ContentStreamOperation ,_aad _bb .GraphicsState ,_cf *_ad .PdfPageResources )error {_d .Log .Debug ("\u0050\u0072\u006f\u0063\u0065\u0073\u0073\u0069\u006e\u0067\u0020\u0025\u0073",_acce .Operand );
switch _acce .Operand {case "\u0071":_edc .Push ();case "\u0051":_edc .Pop ();_db =_edc .TextState ();case "\u0063\u006d":if len (_acce .Params )!=6{return _ffa ;};_cce ,_ef :=_gd .GetNumbersAsFloat (_acce .Params );if _ef !=nil {return _ef ;};_gdd :=_cc .NewMatrix (_cce [0],_cce [1],_cce [2],_cce [3],_cce [4],_cce [5]);
_d .Log .Debug ("\u0047\u0072\u0061\u0070\u0068\u0069\u0063\u0073\u0020\u0073\u0074a\u0074\u0065\u0020\u006d\u0061\u0074\u0072\u0069\u0078\u003a \u0025\u002b\u0076",_gdd );_edc .SetMatrix (_edc .Matrix ().Mult (_gdd ));case "\u0077":if len (_acce .Params )!=1{return _ffa ;
};_bc ,_dbf :=_gd .GetNumbersAsFloat (_acce .Params );if _dbf !=nil {return _dbf ;};_edc .SetLineWidth (_bc [0]);case "\u004a":if len (_acce .Params )!=1{return _ffa ;};_edd ,_bf :=_gd .GetIntVal (_acce .Params [0]);if !_bf {return _bbe ;};switch _edd {case 0:_edc .SetLineCap (_df .LineCapButt );
case 1:_edc .SetLineCap (_df .LineCapRound );case 2:_edc .SetLineCap (_df .LineCapSquare );default:_d .Log .Debug ("\u0049\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u006c\u0069\u006ee\u0020\u0063\u0061\u0070\u0020\u0073\u0074\u0079\u006c\u0065:\u0020\u0025\u0064",_edd );
return _ffa ;};case "\u006a":if len (_acce .Params )!=1{return _ffa ;};_cga ,_eba :=_gd .GetIntVal (_acce .Params [0]);if !_eba {return _bbe ;};switch _cga {case 0:_edc .SetLineJoin (_df .LineJoinBevel );case 1:_edc .SetLineJoin (_df .LineJoinRound );case 2:_edc .SetLineJoin (_df .LineJoinBevel );
default:_d .Log .Debug ("I\u006e\u0076\u0061\u006c\u0069\u0064 \u006c\u0069\u006e\u0065\u0020\u006a\u006f\u0069\u006e \u0073\u0074\u0079l\u0065:\u0020\u0025\u0064",_cga );return _ffa ;};case "\u004d":if len (_acce .Params )!=1{return _ffa ;};_dcd ,_cd :=_gd .GetNumbersAsFloat (_acce .Params );
if _cd !=nil {return _cd ;};_ =_dcd ;_d .Log .Debug ("\u004di\u0074\u0065\u0072\u0020l\u0069\u006d\u0069\u0074\u0020n\u006ft\u0020s\u0075\u0070\u0070\u006f\u0072\u0074\u0065d");case "\u0064":if len (_acce .Params )!=2{return _ffa ;};_gbb ,_baf :=_gd .GetArray (_acce .Params [0]);
if !_baf {return _bbe ;};_bbg ,_baf :=_gd .GetIntVal (_acce .Params [1]);if !_baf {return _bbe ;};_ab ,_gaa :=_gd .GetNumbersAsFloat (_gbb .Elements ());if _gaa !=nil {return _gaa ;};_edc .SetDash (_ab ...);_ =_bbg ;_d .Log .Debug ("\u004c\u0069n\u0065\u0020\u0064\u0061\u0073\u0068\u0020\u0070\u0068\u0061\u0073\u0065\u0020\u006e\u006f\u0074\u0020\u0073\u0075\u0070\u0070\u006frt\u0065\u0064");
case "\u0072\u0069":_d .Log .Debug ("\u0052\u0065\u006e\u0064\u0065\u0072\u0069\u006e\u0067\u0020i\u006e\u0074\u0065\u006e\u0074\u0020\u006eo\u0074\u0020\u0073\u0075\u0070\u0070\u006f\u0072\u0074\u0065\u0064");case "\u0069":_d .Log .Debug ("\u0046\u006c\u0061\u0074\u006e\u0065\u0073\u0073\u0020\u0074\u006f\u006c\u0065\u0072\u0061n\u0063e\u0020\u006e\u006f\u0074\u0020\u0073\u0075\u0070\u0070\u006f\u0072\u0074\u0065\u0064");
case "\u0067\u0073":if len (_acce .Params )!=1{return _ffa ;};_ffb ,_ec :=_gd .GetName (_acce .Params [0]);if !_ec {return _bbe ;};if _ffb ==nil {return _ffa ;};_beg ,_ec :=_cf .GetExtGState (*_ffb );if !_ec {_d .Log .Debug ("\u0045\u0052\u0052OR\u003a\u0020\u0063\u006f\u0075\u006c\u0064\u0020\u006eo\u0074 \u0066i\u006ed\u0020\u0072\u0065\u0073\u006f\u0075\u0072\u0063\u0065\u003a\u0020\u0025\u0073",*_ffb );
return _b .New ("\u0072e\u0073o\u0075\u0072\u0063\u0065\u0020n\u006f\u0074 \u0066\u006f\u0075\u006e\u0064");};_aae ,_ec :=_gd .GetDict (_beg );if !_ec {_d .Log .Debug ("\u0045\u0052RO\u0052\u003a\u0020c\u006f\u0075\u006c\u0064 ge\u0074 g\u0072\u0061\u0070\u0068\u0069\u0063\u0073 s\u0074\u0061\u0074\u0065\u0020\u0064\u0069c\u0074");
return _bbe ;};_d .Log .Debug ("G\u0053\u0020\u0064\u0069\u0063\u0074\u003a\u0020\u0025\u0073",_aae .String ());case "\u006d":if len (_acce .Params )!=2{_d .Log .Debug ("\u0057\u0041\u0052\u004e\u003a\u0020\u0065\u0072\u0072o\u0072\u0020\u0077\u0068\u0069\u006c\u0065\u0020\u0070\u0072\u006f\u0063\u0065\u0073\u0073\u0069\u006e\u0067\u0020\u0060\u006d\u0060\u0020o\u0070\u0065r\u0061\u0074o\u0072\u003a\u0020\u0025\u0073\u002e\u0020\u004f\u0075\u0074\u0070\u0075\u0074 m\u0061\u0079\u0020\u0062\u0065\u0020\u0069\u006e\u0063o\u0072\u0072\u0065\u0063\u0074\u002e",_ffa );
return nil ;};_ace ,_fcdd :=_gd .GetNumbersAsFloat (_acce .Params );if _fcdd !=nil {return _fcdd ;};_d .Log .Debug ("M\u006f\u0076\u0065\u0020\u0074\u006f\u003a\u0020\u0025\u0076",_ace );_edc .NewSubPath ();_edc .MoveTo (_ace [0],_ace [1]);case "\u006c":if len (_acce .Params )!=2{_d .Log .Debug ("\u0057\u0041\u0052\u004e\u003a\u0020\u0065\u0072\u0072o\u0072\u0020\u0077\u0068\u0069\u006c\u0065\u0020\u0070\u0072\u006f\u0063\u0065\u0073\u0073\u0069\u006e\u0067\u0020\u0060\u006c\u0060\u0020o\u0070\u0065r\u0061\u0074o\u0072\u003a\u0020\u0025\u0073\u002e\u0020\u004f\u0075\u0074\u0070\u0075\u0074 m\u0061\u0079\u0020\u0062\u0065\u0020\u0069\u006e\u0063o\u0072\u0072\u0065\u0063\u0074\u002e",_ffa );
return nil ;};_beb ,_fae :=_gd .GetNumbersAsFloat (_acce .Params );if _fae !=nil {return _fae ;};_edc .LineTo (_beb [0],_beb [1]);case "\u0063":if len (_acce .Params )!=6{return _ffa ;};_bed ,_efc :=_gd .GetNumbersAsFloat (_acce .Params );if _efc !=nil {return _efc ;
};_d .Log .Debug ("\u0043u\u0062\u0069\u0063\u0020\u0062\u0065\u007a\u0069\u0065\u0072\u0020p\u0061\u0072\u0061\u006d\u0073\u003a\u0020\u0025\u002b\u0076",_bed );_edc .CubicTo (_bed [0],_bed [1],_bed [2],_bed [3],_bed [4],_bed [5]);case "\u0076","\u0079":if len (_acce .Params )!=4{return _ffa ;
};_ecf ,_gade :=_gd .GetNumbersAsFloat (_acce .Params );if _gade !=nil {return _gade ;};_d .Log .Debug ("\u0043u\u0062\u0069\u0063\u0020\u0062\u0065\u007a\u0069\u0065\u0072\u0020p\u0061\u0072\u0061\u006d\u0073\u003a\u0020\u0025\u002b\u0076",_ecf );_edc .QuadraticTo (_ecf [0],_ecf [1],_ecf [2],_ecf [3]);
case "\u0068":_edc .ClosePath ();_edc .NewSubPath ();case "\u0072\u0065":if len (_acce .Params )!=4{return _ffa ;};_ebb ,_eeg :=_gd .GetNumbersAsFloat (_acce .Params );if _eeg !=nil {return _eeg ;};_edc .DrawRectangle (_ebb [0],_ebb [1],_ebb [2],_ebb [3]);
_edc .NewSubPath ();case "\u0053":_de ,_ecg :=_aad .ColorspaceStroking .ColorToRGB (_aad .ColorStroking );if _ecg !=nil {_d .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_ecg );
return _ecg ;};_ffbe ,_agg :=_de .(*_ad .PdfColorDeviceRGB );if !_agg {_d .Log .Debug ("\u0045\u0072\u0072\u006fr \u0063\u006f\u006e\u0076\u0065\u0072\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006co\u0072");return _ecg ;};_edc .SetRGBA (_ffbe .R (),_ffbe .G (),_ffbe .B (),1);
_edc .Stroke ();case "\u0073":_cfd ,_cef :=_aad .ColorspaceStroking .ColorToRGB (_aad .ColorStroking );if _cef !=nil {_d .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_cef );
return _cef ;};_gbe ,_ccg :=_cfd .(*_ad .PdfColorDeviceRGB );if !_ccg {_d .Log .Debug ("\u0045\u0072\u0072\u006fr \u0063\u006f\u006e\u0076\u0065\u0072\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006co\u0072");return _cef ;};_edc .ClosePath ();_edc .NewSubPath ();
_edc .SetRGBA (_gbe .R (),_gbe .G (),_gbe .B (),1);_edc .Stroke ();case "\u0066","\u0046":_bef ,_fd :=_aad .ColorspaceNonStroking .ColorToRGB (_aad .ColorNonStroking );if _fd !=nil {_d .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_fd );
return _fd ;};_gde ,_fbb :=_bef .(*_ad .PdfColorDeviceRGB );if !_fbb {_d .Log .Debug ("\u0045\u0072\u0072\u006fr \u0063\u006f\u006e\u0076\u0065\u0072\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006co\u0072");return _fd ;};_edc .SetRGBA (_gde .R (),_gde .G (),_gde .B (),1);
_edc .SetFillRule (_df .FillRuleWinding );_edc .Fill ();case "\u0066\u002a":_gfd ,_geb :=_aad .ColorspaceNonStroking .ColorToRGB (_aad .ColorNonStroking );if _geb !=nil {_d .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_geb );
return _geb ;};_gdf ,_eec :=_gfd .(*_ad .PdfColorDeviceRGB );if !_eec {_d .Log .Debug ("\u0045\u0072\u0072\u006fr \u0063\u006f\u006e\u0076\u0065\u0072\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006co\u0072");return _geb ;};_edc .SetRGBA (_gdf .R (),_gdf .G (),_gdf .B (),1);
_edc .SetFillRule (_df .FillRuleEvenOdd );_edc .Fill ();case "\u0042":_eee ,_acef :=_aad .ColorspaceNonStroking .ColorToRGB (_aad .ColorNonStroking );if _acef !=nil {_d .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_acef );
return _acef ;};_edb :=_eee .(*_ad .PdfColorDeviceRGB );_edc .SetRGBA (_edb .R (),_edb .G (),_edb .B (),1);_edc .SetFillRule (_df .FillRuleWinding );_edc .FillPreserve ();_eee ,_acef =_aad .ColorspaceStroking .ColorToRGB (_aad .ColorStroking );if _acef !=nil {_d .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_acef );
return _acef ;};_edb =_eee .(*_ad .PdfColorDeviceRGB );_edc .SetRGBA (_edb .R (),_edb .G (),_edb .B (),1);_edc .Stroke ();case "\u0042\u002a":_bea ,_bgcd :=_aad .ColorspaceNonStroking .ColorToRGB (_aad .ColorNonStroking );if _bgcd !=nil {_d .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_bgcd );
return _bgcd ;};_eag :=_bea .(*_ad .PdfColorDeviceRGB );_edc .SetRGBA (_eag .R (),_eag .G (),_eag .B (),1);_edc .SetFillRule (_df .FillRuleEvenOdd );_edc .FillPreserve ();_bea ,_bgcd =_aad .ColorspaceStroking .ColorToRGB (_aad .ColorStroking );if _bgcd !=nil {_d .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_bgcd );
return _bgcd ;};_eag =_bea .(*_ad .PdfColorDeviceRGB );_edc .SetRGBA (_eag .R (),_eag .G (),_eag .B (),1);_edc .Stroke ();case "\u0062":_dee ,_gef :=_aad .ColorspaceNonStroking .ColorToRGB (_aad .ColorNonStroking );if _gef !=nil {_d .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_gef );
return _gef ;};_gagg :=_dee .(*_ad .PdfColorDeviceRGB );_edc .SetRGBA (_gagg .R (),_gagg .G (),_gagg .B (),1);_edc .ClosePath ();_edc .NewSubPath ();_edc .SetFillRule (_df .FillRuleWinding );_edc .FillPreserve ();_dee ,_gef =_aad .ColorspaceStroking .ColorToRGB (_aad .ColorStroking );
if _gef !=nil {_d .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_gef );return _gef ;};_gagg =_dee .(*_ad .PdfColorDeviceRGB );_edc .SetRGBA (_gagg .R (),_gagg .G (),_gagg .B (),1);
_edc .Stroke ();case "\u0062\u002a":_edc .ClosePath ();_aaa ,_dd :=_aad .ColorspaceNonStroking .ColorToRGB (_aad .ColorNonStroking );if _dd !=nil {_d .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_dd );
return _dd ;};_bbb :=_aaa .(*_ad .PdfColorDeviceRGB );_edc .SetRGBA (_bbb .R (),_bbb .G (),_bbb .B (),1);_edc .NewSubPath ();_edc .SetFillRule (_df .FillRuleEvenOdd );_edc .FillPreserve ();_aaa ,_dd =_aad .ColorspaceStroking .ColorToRGB (_aad .ColorStroking );
if _dd !=nil {_d .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_dd );return _dd ;};_bbb =_aaa .(*_ad .PdfColorDeviceRGB );_edc .SetRGBA (_bbb .R (),_bbb .G (),_bbb .B (),1);
_edc .Stroke ();case "\u006e":_edc .ClearPath ();case "\u0057":_edc .SetFillRule (_df .FillRuleWinding );_edc .ClipPreserve ();case "\u0057\u002a":_edc .SetFillRule (_df .FillRuleEvenOdd );_edc .ClipPreserve ();case "\u0072\u0067":_fcdb ,_cab :=_aad .ColorNonStroking .(*_ad .PdfColorDeviceRGB );
if !_cab {_d .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_aad .ColorNonStroking );return nil ;};_edc .SetFillRGBA (_fcdb .R (),_fcdb .G (),_fcdb .B (),1);
case "\u0052\u0047":_agb ,_bae :=_aad .ColorStroking .(*_ad .PdfColorDeviceRGB );if !_bae {_d .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_aad .ColorStroking );
return nil ;};_edc .SetStrokeRGBA (_agb .R (),_agb .G (),_agb .B (),1);case "\u006b":_abg ,_eab :=_aad .ColorNonStroking .(*_ad .PdfColorDeviceCMYK );if !_eab {_d .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_aad .ColorNonStroking );
return nil ;};_ece ,_fe :=_aad .ColorspaceNonStroking .ColorToRGB (_abg );if _fe !=nil {_d .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_aad .ColorNonStroking );
return nil ;};_ddf ,_eab :=_ece .(*_ad .PdfColorDeviceRGB );if !_eab {_d .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_ece );return nil ;
};_edc .SetFillRGBA (_ddf .R (),_ddf .G (),_ddf .B (),1);case "\u004b":_gdgf ,_bga :=_aad .ColorStroking .(*_ad .PdfColorDeviceCMYK );if !_bga {_d .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_aad .ColorStroking );
return nil ;};_ded ,_aea :=_aad .ColorspaceStroking .ColorToRGB (_gdgf );if _aea !=nil {_d .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_aad .ColorStroking );
return nil ;};_egb ,_bga :=_ded .(*_ad .PdfColorDeviceRGB );if !_bga {_d .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_ded );return nil ;
};_edc .SetStrokeRGBA (_egb .R (),_egb .G (),_egb .B (),1);case "\u0067":_cfg ,_ege :=_aad .ColorNonStroking .(*_ad .PdfColorDeviceGray );if !_ege {_d .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_aad .ColorNonStroking );
return nil ;};_bad ,_fg :=_aad .ColorspaceNonStroking .ColorToRGB (_cfg );if _fg !=nil {_d .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_aad .ColorNonStroking );
return nil ;};_ffe ,_ege :=_bad .(*_ad .PdfColorDeviceRGB );if !_ege {_d .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_bad );return nil ;
};_edc .SetFillRGBA (_ffe .R (),_ffe .G (),_ffe .B (),1);case "\u0047":_baeg ,_bdd :=_aad .ColorStroking .(*_ad .PdfColorDeviceGray );if !_bdd {_d .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_aad .ColorStroking );
return nil ;};_ecfe ,_bfd :=_aad .ColorspaceStroking .ColorToRGB (_baeg );if _bfd !=nil {_d .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_aad .ColorStroking );
return nil ;};_aac ,_bdd :=_ecfe .(*_ad .PdfColorDeviceRGB );if !_bdd {_d .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_ecfe );return nil ;
};_edc .SetStrokeRGBA (_aac .R (),_aac .G (),_aac .B (),1);case "\u0063\u0073","\u0073\u0063","\u0073\u0063\u006e":_cec ,_aga :=_aad .ColorspaceNonStroking .ColorToRGB (_aad .ColorNonStroking );if _aga !=nil {_d .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_aad .ColorNonStroking );
return nil ;};_dacb ,_agag :=_cec .(*_ad .PdfColorDeviceRGB );if !_agag {_d .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_cec );return nil ;
};_edc .SetFillRGBA (_dacb .R (),_dacb .G (),_dacb .B (),1);case "\u0043\u0053","\u0053\u0043","\u0053\u0043\u004e":_bdde ,_ebbd :=_aad .ColorspaceStroking .ColorToRGB (_aad .ColorStroking );if _ebbd !=nil {_d .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_aad .ColorStroking );
return nil ;};_dgf ,_cecg :=_bdde .(*_ad .PdfColorDeviceRGB );if !_cecg {_d .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_bdde );return nil ;
};_edc .SetStrokeRGBA (_dgf .R (),_dgf .G (),_dgf .B (),1);case "\u0044\u006f":if len (_acce .Params )!=1{return _ffa ;};_gcf ,_eeeg :=_gd .GetName (_acce .Params [0]);if !_eeeg {return _bbe ;};_ ,_bbd :=_cf .GetXObjectByName (*_gcf );switch _bbd {case _ad .XObjectTypeImage :_d .Log .Debug ("\u0058\u004f\u0062\u006a\u0065\u0063\u0074\u0020\u0069\u006d\u0061\u0067e\u003a\u0020\u0025\u0073",_gcf .String ());
_cefb ,_gg :=_cf .GetXObjectImageByName (*_gcf );if _gg !=nil {return _gg ;};_bde ,_gg :=_cefb .ToImage ();if _gg !=nil {return _gg ;};if _afgc :=_cefb .ColorSpace ;_afgc !=nil {var _eac bool ;switch _afgc .(type ){case *_ad .PdfColorspaceSpecialIndexed :_eac =true ;
};if _eac {if _def ,_aec :=_afgc .ImageToRGB (*_bde );_aec !=nil {_d .Log .Debug ("\u0057\u0041\u0052\u004e\u003a\u0020\u0063\u006f\u0075\u006c\u0064\u0020\u006e\u006f\u0074\u0020\u0063\u006fnv\u0065r\u0074\u0020\u0069\u006d\u0061\u0067\u0065\u0020\u0074\u006f\u0020\u0052G\u0042\u002e\u0020\u004f\u0075\u0074\u0070\u0075\u0074\u0020\u006d\u0061\u0079\u0020\u0062\u0065\u0020i\u006e\u0063\u006f\u0072\u0072\u0065\u0063\u0074\u002e");
}else {_bde =&_def ;};};};_ccb :=_edc .FillPattern ().ColorAt (0,0);var _fde _ed .Image ;if _cefb .Mask !=nil {if _fde ,_gg =_acea (_cefb .Mask ,_ccb );_gg !=nil {_d .Log .Debug ("\u0057\u0041\u0052\u004e\u003a \u0063\u006f\u0075\u006c\u0064 \u006eo\u0074\u0020\u0067\u0065\u0074\u0020\u0065\u0078\u0070\u006c\u0069\u0063\u0069\u0074\u0020\u0069\u006d\u0061\u0067e\u0020\u006d\u0061\u0073\u006b\u002e\u0020\u004f\u0075\u0074\u0070\u0075\u0074\u0020\u006d\u0061\u0079\u0020\u0062\u0065\u0020\u0069\u006e\u0063o\u0072\u0072\u0065\u0063\u0074\u002e");
};}else if _cefb .SMask !=nil {if _fde ,_gg =_bedbb (_cefb .SMask ,_ccb );_gg !=nil {_d .Log .Debug ("W\u0041\u0052\u004e\u003a\u0020\u0063\u006f\u0075\u006c\u0064\u0020\u006e\u006f\u0074\u0020\u0067\u0065\u0074\u0020\u0073\u006f\u0066\u0074\u0020\u0069\u006da\u0067e\u0020\u006d\u0061\u0073k\u002e\u0020O\u0075\u0074\u0070\u0075\u0074\u0020\u006d\u0061\u0079\u0020\u0062\u0065\u0020\u0069\u006e\u0063\u006f\u0072\u0072\u0065\u0063\u0074\u002e");
};};var _badf _ed .Image ;if _acg ,_ :=_gd .GetBoolVal (_cefb .ImageMask );_acg {_badf =_bbbg (_bde ,_ccb );}else {_badf ,_gg =_bde .ToGoImage ();if _gg !=nil {return _gg ;};};if _fde !=nil {_badf =_cca (_badf ,_fde );};_acdc :=_badf .Bounds ();_edc .Push ();
_edc .Scale (1.0/float64 (_acdc .Dx ()),-1.0/float64 (_acdc .Dy ()));_edc .DrawImageAnchored (_badf ,0,0,0,1);_edc .Pop ();case _ad .XObjectTypeForm :_d .Log .Debug ("\u0058\u004fb\u006a\u0065\u0063t\u0020\u0066\u006f\u0072\u006d\u003a\u0020\u0025\u0073",_gcf .String ());
_fed ,_efd :=_cf .GetXObjectFormByName (*_gcf );if _efd !=nil {return _efd ;};_gfa ,_efd :=_fed .GetContentStream ();if _efd !=nil {return _efd ;};_gcd :=_fed .Resources ;if _gcd ==nil {_gcd =_cf ;};_edc .Push ();if _fed .Matrix !=nil {_cefa ,_dbc :=_gd .GetArray (_fed .Matrix );
if !_dbc {return _bbe ;};_egc ,_cafd :=_gd .GetNumbersAsFloat (_cefa .Elements ());if _cafd !=nil {return _cafd ;};if len (_egc )!=6{return _ffa ;};_acgf :=_cc .NewMatrix (_egc [0],_egc [1],_egc [2],_egc [3],_egc [4],_egc [5]);_edc .SetMatrix (_edc .Matrix ().Mult (_acgf ));
};if _fed .BBox !=nil {_fge ,_bedb :=_gd .GetArray (_fed .BBox );if !_bedb {return _bbe ;};_baege ,_bbbb :=_gd .GetNumbersAsFloat (_fge .Elements ());if _bbbb !=nil {return _bbbb ;};if len (_baege )!=4{_d .Log .Debug ("\u004c\u0065\u006e\u0020\u003d\u0020\u0025\u0064",len (_baege ));
return _ffa ;};_edc .DrawRectangle (_baege [0],_baege [1],_baege [2]-_baege [0],_baege [3]-_baege [1]);_edc .SetRGBA (1,0,0,1);_edc .Clip ();}else {_d .Log .Debug ("\u0045R\u0052\u004fR\u003a\u0020\u0052\u0065q\u0075\u0069\u0072e\u0064\u0020\u0042\u0042\u006f\u0078\u0020\u006d\u0069ss\u0069\u006e\u0067 \u006f\u006e \u0058\u004f\u0062\u006a\u0065\u0063t\u0020\u0046o\u0072\u006d");
};_efd =_ebg .renderContentStream (_edc ,string (_gfa ),_gcd );if _efd !=nil {return _efd ;};_edc .Pop ();};case "\u0042\u0049":if len (_acce .Params )!=1{return _ffa ;};_gebd ,_ffae :=_acce .Params [0].(*_bb .ContentStreamInlineImage );if !_ffae {return nil ;
};_gefb ,_dbg :=_gebd .ToImage (_cf );if _dbg !=nil {return _dbg ;};_afge ,_dbg :=_gefb .ToGoImage ();if _dbg !=nil {return _dbg ;};_dbcc :=_afge .Bounds ();_edc .Push ();_edc .Scale (1.0/float64 (_dbcc .Dx ()),-1.0/float64 (_dbcc .Dy ()));_edc .DrawImageAnchored (_afge ,0,0,0,1);
_edc .Pop ();case "\u0042\u0054":_db .Reset ();case "\u0045\u0054":_db .Reset ();case "\u0054\u0072":if len (_acce .Params )!=1{return _ffa ;};_agc ,_gfc :=_gd .GetNumberAsFloat (_acce .Params [0]);if _gfc !=nil {return _gfc ;};_db .Tr =_df .TextRenderingMode (_agc );
case "\u0054\u004c":if len (_acce .Params )!=1{return _ffa ;};_cacb ,_ecga :=_gd .GetNumberAsFloat (_acce .Params [0]);if _ecga !=nil {return _ecga ;};_db .Tl =_cacb ;case "\u0054\u0063":if len (_acce .Params )!=1{return _ffa ;};_bgea ,_gfdc :=_gd .GetNumberAsFloat (_acce .Params [0]);
if _gfdc !=nil {return _gfdc ;};_d .Log .Debug ("\u0054\u0063\u003a\u0020\u0025\u0076",_bgea );_db .Tc =_bgea ;case "\u0054\u0077":if len (_acce .Params )!=1{return _ffa ;};_bdb ,_gcc :=_gd .GetNumberAsFloat (_acce .Params [0]);if _gcc !=nil {return _gcc ;
};_d .Log .Debug ("\u0054\u0077\u003a\u0020\u0025\u0076",_bdb );_db .Tw =_bdb ;case "\u0054\u007a":if len (_acce .Params )!=1{return _ffa ;};_acgc ,_bce :=_gd .GetNumberAsFloat (_acce .Params [0]);if _bce !=nil {return _bce ;};_db .Th =_acgc ;case "\u0054\u0073":if len (_acce .Params )!=1{return _ffa ;
};_ccga ,_gda :=_gd .GetNumberAsFloat (_acce .Params [0]);if _gda !=nil {return _gda ;};_db .Ts =_ccga ;case "\u0054\u0064":if len (_acce .Params )!=2{return _ffa ;};_deb ,_aba :=_gd .GetNumbersAsFloat (_acce .Params );if _aba !=nil {return _aba ;};_d .Log .Debug ("\u0054\u0064\u003a\u0020\u0025\u0076",_deb );
_db .ProcTd (_deb [0],_deb [1]);case "\u0054\u0044":if len (_acce .Params )!=2{return _ffa ;};_afa ,_gbbc :=_gd .GetNumbersAsFloat (_acce .Params );if _gbbc !=nil {return _gbbc ;};_d .Log .Debug ("\u0054\u0044\u003a\u0020\u0025\u0076",_afa );_db .ProcTD (_afa [0],_afa [1]);
case "\u0054\u002a":_db .ProcTStar ();case "\u0054\u006d":if len (_acce .Params )!=6{return _ffa ;};_cfgf ,_fca :=_gd .GetNumbersAsFloat (_acce .Params );if _fca !=nil {return _fca ;};_d .Log .Debug ("\u0054\u0065x\u0074\u0020\u006da\u0074\u0072\u0069\u0078\u003a\u0020\u0025\u002b\u0076",_cfgf );
_db .ProcTm (_cfgf [0],_cfgf [1],_cfgf [2],_cfgf [3],_cfgf [4],_cfgf [5]);case "\u0027":if len (_acce .Params )!=1{return _ffa ;};_bcg ,_dbgf :=_gd .GetStringBytes (_acce .Params [0]);if !_dbgf {return _bbe ;};_d .Log .Debug ("\u0027\u0020\u0073t\u0072\u0069\u006e\u0067\u003a\u0020\u0025\u0073",string (_bcg ));
_db .ProcQ (_bcg ,_edc );case "\u0022":if len (_acce .Params )!=3{return _ffa ;};_gab ,_eeca :=_gd .GetNumberAsFloat (_acce .Params [0]);if _eeca !=nil {return _eeca ;};_gfb ,_eeca :=_gd .GetNumberAsFloat (_acce .Params [1]);if _eeca !=nil {return _eeca ;
};_gabb ,_ccd :=_gd .GetStringBytes (_acce .Params [2]);if !_ccd {return _bbe ;};_db .ProcDQ (_gabb ,_gab ,_gfb ,_edc );case "\u0054\u006a":if len (_acce .Params )!=1{return _ffa ;};_cefc ,_cbf :=_gd .GetStringBytes (_acce .Params [0]);if !_cbf {return _bbe ;
};_d .Log .Debug ("\u0054j\u0020s\u0074\u0072\u0069\u006e\u0067\u003a\u0020\u0060\u0025\u0073\u0060",string (_cefc ));_db .ProcTj (_cefc ,_edc );case "\u0054\u004a":if len (_acce .Params )!=1{return _ffa ;};_gfba ,_badd :=_gd .GetArray (_acce .Params [0]);
if !_badd {_d .Log .Debug ("\u0054\u0079\u0070\u0065\u003a\u0020\u0025\u0054",_gfba );return _bbe ;};_d .Log .Debug ("\u0054\u004a\u0020\u0061\u0072\u0072\u0061\u0079\u003a\u0020\u0025\u002b\u0076",_gfba );for _ ,_fef :=range _gfba .Elements (){switch _cdg :=_fef .(type ){case *_gd .PdfObjectString :if _cdg !=nil {_db .ProcTj (_cdg .Bytes (),_edc );
};case *_gd .PdfObjectFloat ,*_gd .PdfObjectInteger :_cea ,_cgg :=_gd .GetNumberAsFloat (_cdg );if _cgg ==nil {_db .Translate (-_cea *0.001*_db .Tf .Size *_db .Th /100.0,0);};};};case "\u0054\u0066":if len (_acce .Params )!=2{return _ffa ;};_d .Log .Debug ("\u0025\u0023\u0076",_acce .Params );
_fgd ,_edba :=_gd .GetName (_acce .Params [0]);if !_edba ||_fgd ==nil {_d .Log .Debug ("\u0069\u006e\u0076\u0061l\u0069\u0064\u0020\u0066\u006f\u006e\u0074\u0020\u006e\u0061m\u0065 \u006f\u0062\u006a\u0065\u0063\u0074\u003a \u0025\u0076",_acce .Params [0]);
return _bbe ;};_d .Log .Debug ("\u0046\u006f\u006e\u0074\u0020\u006e\u0061\u006d\u0065\u003a\u0020\u0025\u0073",_fgd .String ());_cge ,_bbf :=_gd .GetNumberAsFloat (_acce .Params [1]);if _bbf !=nil {_d .Log .Debug ("\u0069\u006e\u0076\u0061l\u0069\u0064\u0020\u0066\u006f\u006e\u0074\u0020\u0073\u0069z\u0065 \u006f\u0062\u006a\u0065\u0063\u0074\u003a \u0025\u0076",_acce .Params [1]);
return _bbe ;};_d .Log .Debug ("\u0046\u006f\u006e\u0074\u0020\u0073\u0069\u007a\u0065\u003a\u0020\u0025\u0076",_cge );_gea ,_ebe :=_cf .GetFontByName (*_fgd );if !_ebe {_d .Log .Debug ("\u0045R\u0052\u004f\u0052\u003a\u0020\u0046\u006f\u006e\u0074\u0020\u0025s\u0020\u006e\u006f\u0074\u0020\u0066\u006f\u0075\u006e\u0064",_fgd .String ());
return _b .New ("\u0066\u006f\u006e\u0074\u0020\u006e\u006f\u0074\u0020f\u006f\u0075\u006e\u0064");};_d .Log .Debug ("\u0046\u006f\u006e\u0074\u003a\u0020\u0025\u0054",_gea );_cbe ,_edba :=_gd .GetDict (_gea );if !_edba {_d .Log .Debug ("\u0045\u0052\u0052\u004f\u0052\u003a\u0020\u0063\u006f\u0075l\u0064\u0020\u006e\u006f\u0074\u0020\u0067e\u0074\u0020\u0066\u006f\u006e\u0074\u0020\u0064\u0069\u0063\u0074");
return _bbe ;};_cdc ,_bbf :=_ad .NewPdfFontFromPdfObject (_cbe );if _bbf !=nil {_d .Log .Debug ("\u0045\u0052\u0052\u004f\u0052\u003a\u0020\u0063\u006f\u0075\u006c\u0064\u0020\u006e\u006f\u0074\u0020\u006c\u006f\u0061\u0064\u0020\u0066\u006fn\u0074\u0020\u0066\u0072\u006fm\u0020\u006fb\u006a\u0065\u0063\u0074");
return _bbf ;};_feb :=_cdc .BaseFont ();if _feb ==""{_feb =_fgd .String ();};_cfbf ,_edba :=_gag [_feb ];if !_edba {_cfbf ,_bbf =_df .NewTextFont (_cdc ,_cge );if _bbf !=nil {_d .Log .Debug ("\u0045R\u0052\u004f\u0052\u003a\u0020\u0025v",_bbf );};};if _cfbf ==nil {if len (_feb )> 7&&_feb [6]=='+'{_feb =_feb [7:];
};_adb :=[]string {_feb ,"\u0054i\u006de\u0073\u0020\u004e\u0065\u0077\u0020\u0052\u006f\u006d\u0061\u006e","\u0041\u0072\u0069a\u006c","D\u0065\u006a\u0061\u0056\u0075\u0020\u0053\u0061\u006e\u0073"};for _ ,_fcf :=range _adb {_d .Log .Debug ("\u0044\u0045\u0042\u0055\u0047\u003a \u0073\u0065\u0061\u0072\u0063\u0068\u0069\u006e\u0067\u0020\u0073\u0079\u0073t\u0065\u006d\u0020\u0066\u006f\u006e\u0074 \u0060\u0025\u0073\u0060",_fcf );
if _cfbf ,_edba =_gag [_fcf ];_edba {break ;};_gfdg :=_gad .Match (_fcf );if _gfdg ==nil {_d .Log .Debug ("c\u006f\u0075\u006c\u0064\u0020\u006eo\u0074\u0020\u0066\u0069\u006e\u0064\u0020\u0066\u006fn\u0074\u0020\u0066i\u006ce\u0020\u0025\u0073",_fcf );
continue ;};_cfbf ,_bbf =_df .NewTextFontFromPath (_gfdg .Filename ,_cge );if _bbf !=nil {_d .Log .Debug ("c\u006f\u0075\u006c\u0064\u0020\u006eo\u0074\u0020\u006c\u006f\u0061\u0064\u0020\u0066\u006fn\u0074\u0020\u0066i\u006ce\u0020\u0025\u0073",_gfdg .Filename );
continue ;};_d .Log .Debug ("\u0053\u0075\u0062\u0073\u0074\u0069t\u0075\u0074\u0069\u006e\u0067\u0020\u0066\u006f\u006e\u0074\u0020\u0025\u0073 \u0077\u0069\u0074\u0068\u0020\u0025\u0073 \u0028\u0025\u0073\u0029",_feb ,_gfdg .Name ,_gfdg .Filename );_gag [_fcf ]=_cfbf ;
break ;};};if _cfbf ==nil {_d .Log .Debug ("\u0045\u0052\u0052\u004f\u0052\u003a\u0020\u0063\u006f\u0075\u006c\u0064\u0020n\u006f\u0074\u0020\u0066\u0069\u006ed\u0020\u0061\u006e\u0079\u0020\u0073\u0075\u0069\u0074\u0061\u0062\u006c\u0065 \u0066\u006f\u006e\u0074");
return _b .New ("\u0063\u006f\u0075\u006c\u0064\u0020\u006e\u006f\u0074\u0020\u0066\u0069\u006e\u0064\u0020a\u006ey\u0020\u0073\u0075\u0069\u0074\u0061\u0062\u006c\u0065\u0020\u0066\u006f\u006e\u0074");};_db .ProcTf (_cfbf .WithSize (_cge ,_cdc ));case "\u0042\u004d\u0043","\u0042\u0044\u0043":case "\u0045\u004d\u0043":default:_d .Log .Debug ("\u0045\u0052\u0052\u004f\u0052\u003a\u0020\u0075\u006e\u0073u\u0070\u0070\u006f\u0072\u0074\u0065\u0064 \u006f\u0070\u0065\u0072\u0061\u006e\u0064\u003a\u0020\u0025\u0073",_acce .Operand );
};return nil ;});_dac =_aa .Process (_eaa );if _dac !=nil {return _dac ;};return nil ;};func (_gca renderer )renderPage (_dfe _df .Context ,_gaf *_ad .PdfPage ,_ba _cc .Matrix )error {_fcd ,_caf :=_gaf .GetAllContentStreams ();if _caf !=nil {return _caf ;
};if _bge :=_ba ;!_bge .Identity (){_fcd =_ca .Sprintf ("%\u002e\u0032\u0066\u0020\u0025\u002e2\u0066\u0020\u0025\u002e\u0032\u0066 \u0025\u002e\u0032\u0066\u0020\u0025\u002e2\u0066\u0020\u0025\u002e\u0032\u0066\u0020\u0063\u006d\u0020%\u0073",_bge [0],_bge [1],_bge [3],_bge [4],_bge [6],_bge [7],_fcd );
};_dfe .Translate (0,float64 (_dfe .Height ()));_dfe .Scale (1,-1);_dfe .Push ();_dfe .SetRGBA (1,1,1,1);_dfe .DrawRectangle (0,0,float64 (_dfe .Width ()),float64 (_dfe .Height ()));_dfe .Fill ();_dfe .Pop ();_dfe .SetLineWidth (1.0);_dfe .SetRGBA (0,0,0,1);
return _gca .renderContentStream (_dfe ,_fcd ,_gaf .Resources );};func _abaf (_egcg *_ad .Image ,_cgee _cgc .Color )_ed .Image {_efca ,_fac :=int (_egcg .Width ),int (_egcg .Height );_gdda :=_ed .NewRGBA (_ed .Rect (0,0,_efca ,_fac ));for _dbcd :=0;_dbcd < _fac ;
_dbcd ++{for _fcg :=0;_fcg < _efca ;_fcg ++{_gbd ,_dfb :=_egcg .ColorAt (_fcg ,_dbcd );if _dfb !=nil {_d .Log .Debug ("\u0057\u0041\u0052\u004e\u003a\u0020\u0063o\u0075\u006c\u0064\u0020\u006e\u006f\u0074\u0020\u0072\u0065\u0074\u0072\u0069\u0065v\u0065 \u0069\u006d\u0061\u0067\u0065\u0020m\u0061\u0073\u006b\u0020\u0076\u0061\u006cu\u0065\u0020\u0061\u0074\u0020\u0028\u0025\u0064\u002c\u0020\u0025\u0064\u0029\u002e\u0020\u004f\u0075\u0074\u0070\u0075\u0074\u0020\u006da\u0079\u0020\u0062\u0065\u0020\u0069\u006e\u0063\u006f\u0072\u0072\u0065\u0063t\u002e",_fcg ,_dbcd );
continue ;};_efda ,_ceab ,_bgag ,_ :=_gbd .RGBA ();var _gabg _cgc .Color ;if _efda +_ceab +_bgag ==0{_gabg =_cgc .Transparent ;}else {_gabg =_cgee ;};_gdda .Set (_fcg ,_dbcd ,_gabg );};};return _gdda ;};func _bbbg (_fda *_ad .Image ,_fedb _cgc .Color )_ed .Image {_ccba ,_fgc :=int (_fda .Width ),int (_fda .Height );
_gba :=_ed .NewRGBA (_ed .Rect (0,0,_ccba ,_fgc ));for _egf :=0;_egf < _fgc ;_egf ++{for _fgb :=0;_fgb < _ccba ;_fgb ++{_ccbc ,_fbg :=_fda .ColorAt (_fgb ,_egf );if _fbg !=nil {_d .Log .Debug ("\u0057\u0041\u0052\u004e\u003a\u0020\u0063o\u0075\u006c\u0064\u0020\u006e\u006f\u0074\u0020\u0072\u0065\u0074\u0072\u0069\u0065v\u0065 \u0069\u006d\u0061\u0067\u0065\u0020m\u0061\u0073\u006b\u0020\u0076\u0061\u006cu\u0065\u0020\u0061\u0074\u0020\u0028\u0025\u0064\u002c\u0020\u0025\u0064\u0029\u002e\u0020\u004f\u0075\u0074\u0070\u0075\u0074\u0020\u006da\u0079\u0020\u0062\u0065\u0020\u0069\u006e\u0063\u006f\u0072\u0072\u0065\u0063t\u002e",_fgb ,_egf );
continue ;};_ddc ,_dfc ,_fgde ,_ :=_ccbc .RGBA ();var _gefd _cgc .Color ;if _ddc +_dfc +_fgde ==0{_gefd =_fedb ;}else {_gefd =_cgc .Transparent ;};_gba .Set (_fgb ,_egf ,_gefd );};};return _gba ;};type renderer struct{_bg float64 };func _cca (_aadf ,_ecb _ed .Image )_ed .Image {_eef ,_eecc :=_ecb .Bounds ().Size (),_aadf .Bounds ().Size ();
_badfb ,_dea :=_eef .X ,_eef .Y ;if _eecc .X > _badfb {_badfb =_eecc .X ;};if _eecc .Y > _dea {_dea =_eecc .Y ;};_gaaa :=_ed .Rect (0,0,_badfb ,_dea );if _eef .X !=_badfb ||_eef .Y !=_dea {_cad :=_ed .NewRGBA (_gaaa );_fb .BiLinear .Scale (_cad ,_gaaa ,_aadf ,_ecb .Bounds (),_fb .Over ,nil );
_ecb =_cad ;};if _eecc .X !=_badfb ||_eecc .Y !=_dea {_cefbe :=_ed .NewRGBA (_gaaa );_fb .BiLinear .Scale (_cefbe ,_gaaa ,_aadf ,_aadf .Bounds (),_fb .Over ,nil );_aadf =_cefbe ;};_eefd :=_ed .NewRGBA (_gaaa );_fb .DrawMask (_eefd ,_gaaa ,_aadf ,_ed .Point {},_ecb ,_ed .Point {},_fb .Over );
return _eefd ;};func _acea (_bded _gd .PdfObject ,_bgg _cgc .Color )(_ed .Image ,error ){_ggc ,_dgc :=_gd .GetStream (_bded );if !_dgc {return nil ,nil ;};_ceef ,_aace :=_ad .NewXObjectImageFromStream (_ggc );if _aace !=nil {return nil ,_aace ;};_egfc ,_aace :=_ceef .ToImage ();
if _aace !=nil {return nil ,_aace ;};return _bbbg (_egfc ,_bgg ),nil ;};func _fcc (_fbca ,_fab ,_faf float64 )_eb .BoundingBox {return _eb .Path {Points :[]_eb .Point {_eb .NewPoint (0,0).Rotate (_faf ),_eb .NewPoint (_fbca ,0).Rotate (_faf ),_eb .NewPoint (0,_fab ).Rotate (_faf ),_eb .NewPoint (_fbca ,_fab ).Rotate (_faf )}}.GetBoundingBox ();
};
// ImageDevice is used to render PDF pages to image targets.
type ImageDevice struct{renderer ;
// OutputWidth represents the width of the rendered images in pixels.
// The heights of the output images are calculated based on the selected
// width and the original height of each rendered page.
OutputWidth int ;};