unipdf/render/render.go
2020-11-11 18:48:37 +00:00

25 lines
31 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 (_a "errors";_g "fmt";_dg "github.com/adrg/sysfont";_e "github.com/unidoc/unipdf/v3/common";_ac "github.com/unidoc/unipdf/v3/contentstream";_be "github.com/unidoc/unipdf/v3/core";_cc "github.com/unidoc/unipdf/v3/internal/transform";_bb "github.com/unidoc/unipdf/v3/model";_fg "github.com/unidoc/unipdf/v3/render/internal/context";_aec "github.com/unidoc/unipdf/v3/render/internal/context/imagerender";_ca "image";_d "image/draw";_fe "image/jpeg";_cf "image/png";_ae "os";_c "path/filepath";_f "strings";);var (_dfa =_a .New ("\u0074\u0079p\u0065\u0020\u0063h\u0065\u0063\u006b\u0020\u0065\u0072\u0072\u006f\u0072");_ag =_a .New ("\u0072\u0061\u006e\u0067\u0065\u0020\u0063\u0068\u0065\u0063\u006b\u0020e\u0072\u0072\u006f\u0072"););func (_gc renderer )renderPage (_efg _fg .Context ,_acd *_bb .PdfPage )error {_gg ,_beb :=_acd .GetAllContentStreams ();if _beb !=nil {return _beb ;};_efg .Translate (0,float64 (_efg .Height ()));_efg .Scale (1,-1);_efg .Push ();_efg .SetRGBA (1,1,1,1);_efg .DrawRectangle (0,0,float64 (_efg .Width ()),float64 (_efg .Height ()));_efg .Fill ();_efg .Pop ();_efg .SetLineWidth (1.0);_efg .SetRGBA (0,0,0,1);return _gc .renderContentStream (_efg ,_gg ,_acd .Resources );};
// Render converts the specified PDF page into an image and returns the result.
func (_bbf *ImageDevice )Render (page *_bb .PdfPage )(_ca .Image ,error ){_cg ,_ga :=page .GetMediaBox ();if _ga !=nil {return nil ,_ga ;};_aeg ,_dgg :=_cg .Llx +_cg .Width (),_cg .Lly +_cg .Height ();_acg :=_aec .NewContext (int (_aeg ),int (_dgg ));if _ge :=_bbf .renderPage (_acg ,page );_ge !=nil {return nil ,_ge ;};_ee :=_acg .Image ();if _bd :=page .CropBox ;_bd !=nil {_cfg :=_ca .Rect (0,0,int (_bd .Width ()),int (_bd .Height ()));_ad :=_ca .Pt (int (_bd .Llx ),int (_dgg -_bd .Ury ));_db :=_ca .NewRGBA (_cfg );_d .Draw (_db ,_cfg ,_ee ,_ad ,_d .Src );_ee =_db ;};return _ee ,nil ;};func (_caa renderer )renderContentStream (_aaa _fg .Context ,_cce string ,_cb *_bb .PdfPageResources )error {_fge ,_efgg :=_ac .NewContentStreamParser (_cce ).Parse ();if _efgg !=nil {return _efgg ;};_gb :=_aaa .TextState ();_gca :=map[string ]*_fg .TextFont {};_eb :=_dg .NewFinder (&_dg .FinderOpts {Extensions :[]string {"\u002e\u0074\u0074\u0066","\u002e\u0074\u0074\u0063"}});_fc :=_ac .NewContentStreamProcessor (*_fge );_fc .AddHandler (_ac .HandlerConditionEnumAllOperands ,"",func (_dd *_ac .ContentStreamOperation ,_bbg _ac .GraphicsState ,_bbb *_bb .PdfPageResources )error {_e .Log .Debug ("\u0050\u0072\u006f\u0063\u0065\u0073\u0073\u0069\u006e\u0067\u0020\u0025\u0073",_dd .Operand );switch _dd .Operand {case "\u0071":_aaa .Push ();case "\u0051":_aaa .Pop ();case "\u0063\u006d":if len (_dd .Params )!=6{return _ag ;};_da ,_bcf :=_be .GetNumbersAsFloat (_dd .Params );if _bcf !=nil {return _bcf ;};_ed :=_cc .NewMatrix (_da [0],_da [1],_da [2],_da [3],_da [4],_da [5]);_e .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",_ed );_aaa .SetMatrix (_aaa .Matrix ().Mult (_ed ));_aaag :=(_bbg .CTM .ScalingFactorX ()+_bbg .CTM .ScalingFactorY ())/2.0;_aaa .SetLineWidth (_aaag *_aaa .LineWidth ());case "\u0077":if len (_dd .Params )!=1{return _ag ;};_bfe ,_bcg :=_be .GetNumbersAsFloat (_dd .Params );if _bcg !=nil {return _bcg ;};_bfc :=(_bbg .CTM .ScalingFactorX ()+_bbg .CTM .ScalingFactorY ())/2.0;_aaa .SetLineWidth (_bfc *_bfe [0]);case "\u004a":if len (_dd .Params )!=1{return _ag ;};_edg ,_dc :=_be .GetIntVal (_dd .Params [0]);if !_dc {return _dfa ;};switch _edg {case 0:_aaa .SetLineCap (_fg .LineCapButt );case 1:_aaa .SetLineCap (_fg .LineCapRound );case 2:_aaa .SetLineCap (_fg .LineCapSquare );default:_e .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",_edg );return _ag ;};case "\u006a":if len (_dd .Params )!=1{return _ag ;};_ce ,_fgc :=_be .GetIntVal (_dd .Params [0]);if !_fgc {return _dfa ;};switch _ce {case 0:_aaa .SetLineJoin (_fg .LineJoinBevel );case 1:_aaa .SetLineJoin (_fg .LineJoinRound );case 2:_aaa .SetLineJoin (_fg .LineJoinBevel );default:_e .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",_ce );return _ag ;};case "\u004d":if len (_dd .Params )!=1{return _ag ;};_efa ,_ff :=_be .GetNumbersAsFloat (_dd .Params );if _ff !=nil {return _ff ;};_ =_efa ;_e .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 (_dd .Params )!=2{return _ag ;};_cad ,_eeb :=_be .GetArray (_dd .Params [0]);if !_eeb {return _dfa ;};_ccf ,_eeb :=_be .GetIntVal (_dd .Params [1]);if !_eeb {return _dfa ;};_fgb ,_dga :=_be .GetNumbersAsFloat (_cad .Elements ());if _dga !=nil {return _dga ;};_aaa .SetDash (_fgb ...);_ =_ccf ;_e .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":_e .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":_e .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 (_dd .Params )!=1{return _ag ;};_bbfd ,_de :=_be .GetName (_dd .Params [0]);if !_de {return _dfa ;};if _bbfd ==nil {return _ag ;};_abd ,_de :=_bbb .GetExtGState (*_bbfd );if !_de {_e .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",*_bbfd );return _a .New ("\u0072e\u0073o\u0075\u0072\u0063\u0065\u0020n\u006f\u0074 \u0066\u006f\u0075\u006e\u0064");};_deg ,_de :=_be .GetDict (_abd );if !_de {_e .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 _dfa ;};_e .Log .Debug ("G\u0053\u0020\u0064\u0069\u0063\u0074\u003a\u0020\u0025\u0073",_deg .String ());case "\u006d":if len (_dd .Params )!=2{_e .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",_ag );return nil ;};_bff ,_cfced :=_be .GetNumbersAsFloat (_dd .Params );if _cfced !=nil {return _cfced ;};_e .Log .Debug ("M\u006f\u0076\u0065\u0020\u0074\u006f\u003a\u0020\u0025\u0076",_bff );_aaa .NewSubPath ();_aaa .MoveTo (_bff [0],_bff [1]);case "\u006c":if len (_dd .Params )!=2{_e .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",_ag );return nil ;};_eg ,_abg :=_be .GetNumbersAsFloat (_dd .Params );if _abg !=nil {return _abg ;};_aaa .LineTo (_eg [0],_eg [1]);case "\u0063":if len (_dd .Params )!=6{return _ag ;};_aba ,_baa :=_be .GetNumbersAsFloat (_dd .Params );if _baa !=nil {return _baa ;};_e .Log .Debug ("\u0043u\u0062\u0069\u0063\u0020\u0062\u0065\u007a\u0069\u0065\u0072\u0020p\u0061\u0072\u0061\u006d\u0073\u003a\u0020\u0025\u002b\u0076",_aba );_aaa .CubicTo (_aba [0],_aba [1],_aba [2],_aba [3],_aba [4],_aba [5]);case "\u0076","\u0079":if len (_dd .Params )!=4{return _ag ;};_eebe ,_cgc :=_be .GetNumbersAsFloat (_dd .Params );if _cgc !=nil {return _cgc ;};_e .Log .Debug ("\u0043u\u0062\u0069\u0063\u0020\u0062\u0065\u007a\u0069\u0065\u0072\u0020p\u0061\u0072\u0061\u006d\u0073\u003a\u0020\u0025\u002b\u0076",_eebe );_aaa .QuadraticTo (_eebe [0],_eebe [1],_eebe [2],_eebe [3]);case "\u0068":_aaa .ClosePath ();_aaa .NewSubPath ();case "\u0072\u0065":if len (_dd .Params )!=4{return _ag ;};_ebg ,_bea :=_be .GetNumbersAsFloat (_dd .Params );if _bea !=nil {return _bea ;};_aaa .DrawRectangle (_ebg [0],_ebg [1],_ebg [2],_ebg [3]);_aaa .NewSubPath ();case "\u0053":_gcg ,_bcgf :=_bbg .ColorspaceStroking .ColorToRGB (_bbg .ColorStroking );if _bcgf !=nil {_e .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",_bcgf );return _bcgf ;};_ffb ,_dbb :=_gcg .(*_bb .PdfColorDeviceRGB );if !_dbb {_e .Log .Debug ("\u0045\u0072\u0072\u006fr \u0063\u006f\u006e\u0076\u0065\u0072\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006co\u0072");return _bcgf ;};_aaa .SetRGBA (_ffb .R (),_ffb .G (),_ffb .B (),1);_aaa .Stroke ();case "\u0073":_dfe ,_ffd :=_bbg .ColorspaceStroking .ColorToRGB (_bbg .ColorStroking );if _ffd !=nil {_e .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",_ffd );return _ffd ;};_ccb ,_ea :=_dfe .(*_bb .PdfColorDeviceRGB );if !_ea {_e .Log .Debug ("\u0045\u0072\u0072\u006fr \u0063\u006f\u006e\u0076\u0065\u0072\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006co\u0072");return _ffd ;};_aaa .ClosePath ();_aaa .NewSubPath ();_aaa .SetRGBA (_ccb .R (),_ccb .G (),_ccb .B (),1);_aaa .Stroke ();case "\u0066","\u0046":_fcf ,_ccg :=_bbg .ColorspaceNonStroking .ColorToRGB (_bbg .ColorNonStroking );if _ccg !=nil {_e .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",_ccg );return _ccg ;};_fce ,_bac :=_fcf .(*_bb .PdfColorDeviceRGB );if !_bac {_e .Log .Debug ("\u0045\u0072\u0072\u006fr \u0063\u006f\u006e\u0076\u0065\u0072\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006co\u0072");return _ccg ;};_aaa .SetRGBA (_fce .R (),_fce .G (),_fce .B (),1);_aaa .SetFillRule (_fg .FillRuleWinding );_aaa .Fill ();case "\u0066\u002a":_aab ,_faf :=_bbg .ColorspaceNonStroking .ColorToRGB (_bbg .ColorNonStroking );if _faf !=nil {_e .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",_faf );return _faf ;};_gcd ,_ged :=_aab .(*_bb .PdfColorDeviceRGB );if !_ged {_e .Log .Debug ("\u0045\u0072\u0072\u006fr \u0063\u006f\u006e\u0076\u0065\u0072\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006co\u0072");return _faf ;};_aaa .SetRGBA (_gcd .R (),_gcd .G (),_gcd .B (),1);_aaa .SetFillRule (_fg .FillRuleEvenOdd );_aaa .Fill ();case "\u0042":_acdd ,_caac :=_bbg .ColorspaceNonStroking .ColorToRGB (_bbg .ColorNonStroking );if _caac !=nil {_e .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",_caac );return _caac ;};_ceb :=_acdd .(*_bb .PdfColorDeviceRGB );_aaa .SetRGBA (_ceb .R (),_ceb .G (),_ceb .B (),1);_aaa .SetFillRule (_fg .FillRuleWinding );_aaa .FillPreserve ();_acdd ,_caac =_bbg .ColorspaceStroking .ColorToRGB (_bbg .ColorStroking );if _caac !=nil {_e .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",_caac );return _caac ;};_ceb =_acdd .(*_bb .PdfColorDeviceRGB );_aaa .SetRGBA (_ceb .R (),_ceb .G (),_ceb .B (),1);_aaa .Stroke ();case "\u0042\u002a":_bee ,_edf :=_bbg .ColorspaceNonStroking .ColorToRGB (_bbg .ColorNonStroking );if _edf !=nil {_e .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",_edf );return _edf ;};_aegd :=_bee .(*_bb .PdfColorDeviceRGB );_aaa .SetRGBA (_aegd .R (),_aegd .G (),_aegd .B (),1);_aaa .SetFillRule (_fg .FillRuleEvenOdd );_aaa .FillPreserve ();_bee ,_edf =_bbg .ColorspaceStroking .ColorToRGB (_bbg .ColorStroking );if _edf !=nil {_e .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",_edf );return _edf ;};_aegd =_bee .(*_bb .PdfColorDeviceRGB );_aaa .SetRGBA (_aegd .R (),_aegd .G (),_aegd .B (),1);_aaa .Stroke ();case "\u0062":_dgc ,_cd :=_bbg .ColorspaceNonStroking .ColorToRGB (_bbg .ColorNonStroking );if _cd !=nil {_e .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",_cd );return _cd ;};_fd :=_dgc .(*_bb .PdfColorDeviceRGB );_aaa .SetRGBA (_fd .R (),_fd .G (),_fd .B (),1);_aaa .ClosePath ();_aaa .NewSubPath ();_aaa .SetFillRule (_fg .FillRuleWinding );_aaa .FillPreserve ();_dgc ,_cd =_bbg .ColorspaceStroking .ColorToRGB (_bbg .ColorStroking );if _cd !=nil {_e .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",_cd );return _cd ;};_fd =_dgc .(*_bb .PdfColorDeviceRGB );_aaa .SetRGBA (_fd .R (),_fd .G (),_fd .B (),1);_aaa .Stroke ();case "\u0062\u002a":_aaa .ClosePath ();_cee ,_ddb :=_bbg .ColorspaceNonStroking .ColorToRGB (_bbg .ColorNonStroking );if _ddb !=nil {_e .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",_ddb );return _ddb ;};_acdg :=_cee .(*_bb .PdfColorDeviceRGB );_aaa .SetRGBA (_acdg .R (),_acdg .G (),_acdg .B (),1);_aaa .NewSubPath ();_aaa .SetFillRule (_fg .FillRuleEvenOdd );_aaa .FillPreserve ();_cee ,_ddb =_bbg .ColorspaceStroking .ColorToRGB (_bbg .ColorStroking );if _ddb !=nil {_e .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",_ddb );return _ddb ;};_acdg =_cee .(*_bb .PdfColorDeviceRGB );_aaa .SetRGBA (_acdg .R (),_acdg .G (),_acdg .B (),1);_aaa .Stroke ();case "\u006e":_aaa .ClearPath ();case "\u0057":_aaa .SetFillRule (_fg .FillRuleWinding );_aaa .ClipPreserve ();case "\u0057\u002a":_aaa .SetFillRule (_fg .FillRuleEvenOdd );_aaa .ClipPreserve ();case "\u0072\u0067":_aag ,_gf :=_bbg .ColorNonStroking .(*_bb .PdfColorDeviceRGB );if !_gf {_e .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",_bbg .ColorNonStroking );return nil ;};_aaa .SetFillRGBA (_aag .R (),_aag .G (),_aag .B (),1);case "\u0052\u0047":_ggf ,_ced :=_bbg .ColorStroking .(*_bb .PdfColorDeviceRGB );if !_ced {_e .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",_bbg .ColorStroking );return nil ;};_aaa .SetStrokeRGBA (_ggf .R (),_ggf .G (),_ggf .B (),1);case "\u006b":_bbgg ,_aagg :=_bbg .ColorNonStroking .(*_bb .PdfColorDeviceCMYK );if !_aagg {_e .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",_bbg .ColorNonStroking );return nil ;};_ebc ,_gaf :=_bbg .ColorspaceNonStroking .ColorToRGB (_bbgg );if _gaf !=nil {_e .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",_bbg .ColorNonStroking );return nil ;};_cbf ,_aagg :=_ebc .(*_bb .PdfColorDeviceRGB );if !_aagg {_e .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",_ebc );return nil ;};_aaa .SetFillRGBA (_cbf .R (),_cbf .G (),_cbf .B (),1);case "\u004b":_gadc ,_cfef :=_bbg .ColorStroking .(*_bb .PdfColorDeviceCMYK );if !_cfef {_e .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",_bbg .ColorStroking );return nil ;};_gd ,_acf :=_bbg .ColorspaceStroking .ColorToRGB (_gadc );if _acf !=nil {_e .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",_bbg .ColorStroking );return nil ;};_feb ,_cfef :=_gd .(*_bb .PdfColorDeviceRGB );if !_cfef {_e .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",_gd );return nil ;};_aaa .SetStrokeRGBA (_feb .R (),_feb .G (),_feb .B (),1);case "\u0067":_beec ,_acdge :=_bbg .ColorNonStroking .(*_bb .PdfColorDeviceGray );if !_acdge {_e .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",_bbg .ColorNonStroking );return nil ;};_eca ,_gef :=_bbg .ColorspaceNonStroking .ColorToRGB (_beec );if _gef !=nil {_e .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",_bbg .ColorNonStroking );return nil ;};_agf ,_acdge :=_eca .(*_bb .PdfColorDeviceRGB );if !_acdge {_e .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",_eca );return nil ;};_aaa .SetFillRGBA (_agf .R (),_agf .G (),_agf .B (),1);case "\u0047":_fda ,_geg :=_bbg .ColorStroking .(*_bb .PdfColorDeviceGray );if !_geg {_e .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",_bbg .ColorStroking );return nil ;};_bcd ,_bbe :=_bbg .ColorspaceStroking .ColorToRGB (_fda );if _bbe !=nil {_e .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",_bbg .ColorStroking );return nil ;};_cdd ,_geg :=_bcd .(*_bb .PdfColorDeviceRGB );if !_geg {_e .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",_bcd );return nil ;};_aaa .SetStrokeRGBA (_cdd .R (),_cdd .G (),_cdd .B (),1);case "\u0063\u0073","\u0073\u0063","\u0073\u0063\u006e":_cca ,_fdb :=_bbg .ColorspaceNonStroking .ColorToRGB (_bbg .ColorNonStroking );if _fdb !=nil {_e .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",_bbg .ColorNonStroking );return nil ;};_ead ,_aae :=_cca .(*_bb .PdfColorDeviceRGB );if !_aae {_e .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",_cca );return nil ;};_aaa .SetFillRGBA (_ead .R (),_ead .G (),_ead .B (),1);case "\u0043\u0053","\u0053\u0043","\u0053\u0043\u004e":_aaef ,_gfd :=_bbg .ColorspaceStroking .ColorToRGB (_bbg .ColorStroking );if _gfd !=nil {_e .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",_bbg .ColorStroking );return nil ;};_gda ,_fgf :=_aaef .(*_bb .PdfColorDeviceRGB );if !_fgf {_e .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",_aaef );return nil ;};_aaa .SetStrokeRGBA (_gda .R (),_gda .G (),_gda .B (),1);case "\u0044\u006f":if len (_dd .Params )!=1{return _ag ;};_cgb ,_dgf :=_be .GetName (_dd .Params [0]);if !_dgf {return _dfa ;};_ ,_af :=_bbb .GetXObjectByName (*_cgb );switch _af {case _bb .XObjectTypeImage :_e .Log .Debug ("\u0058\u004f\u0062\u006a\u0065\u0063\u0074\u0020\u0069\u006d\u0061\u0067e\u003a\u0020\u0025\u0073",_cgb .String ());_efe ,_cdb :=_bbb .GetXObjectImageByName (*_cgb );if _cdb !=nil {return _cdb ;};_cfd ,_cdb :=_efe .ToImage ();if _cdb !=nil {return _cdb ;};_abe ,_cdb :=_cfd .ToGoImage ();if _cdb !=nil {return _cdb ;};_geb :=_abe .Bounds ();_aaa .Push ();_aaa .Scale (1.0/float64 (_geb .Dx ()),-1.0/float64 (_geb .Dy ()));_aaa .DrawImageAnchored (_abe ,0,0,0,1);_aaa .Pop ();case _bb .XObjectTypeForm :_e .Log .Debug ("\u0058\u004fb\u006a\u0065\u0063t\u0020\u0066\u006f\u0072\u006d\u003a\u0020\u0025\u0073",_cgb .String ());_fb ,_eaa :=_bbb .GetXObjectFormByName (*_cgb );if _eaa !=nil {return _eaa ;};_gcc ,_eaa :=_fb .GetContentStream ();if _eaa !=nil {return _eaa ;};_dff :=_fb .Resources ;if _dff ==nil {_dff =_bbb ;};_aaa .Push ();if _fb .Matrix !=nil {_ecb ,_gcgb :=_be .GetArray (_fb .Matrix );if !_gcgb {return _dfa ;};_eea ,_ded :=_be .GetNumbersAsFloat (_ecb .Elements ());if _ded !=nil {return _ded ;};if len (_eea )!=6{return _ag ;};_bcdb :=_cc .NewMatrix (_eea [0],_eea [1],_eea [2],_eea [3],_eea [4],_eea [5]);_aaa .SetMatrix (_aaa .Matrix ().Mult (_bcdb ));};if _fb .BBox !=nil {_cge ,_dgcf :=_be .GetArray (_fb .BBox );if !_dgcf {return _dfa ;};_cff ,_fee :=_be .GetNumbersAsFloat (_cge .Elements ());if _fee !=nil {return _fee ;};if len (_cff )!=4{_e .Log .Debug ("\u004c\u0065\u006e\u0020\u003d\u0020\u0025\u0064",len (_cff ));return _ag ;};_aaa .DrawRectangle (_cff [0],_cff [1],_cff [2]-_cff [0],_cff [3]-_cff [1]);_aaa .SetRGBA (1,0,0,1);_aaa .Clip ();}else {_e .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");};_eaa =_caa .renderContentStream (_aaa ,string (_gcc ),_dff );if _eaa !=nil {return _eaa ;};_aaa .Pop ();};case "\u0042\u0049":if len (_dd .Params )!=1{return _ag ;};_fad ,_dbbg :=_dd .Params [0].(*_ac .ContentStreamInlineImage );if !_dbbg {return nil ;};_edc ,_degd :=_fad .ToImage (_bbb );if _degd !=nil {return _degd ;};_cdg ,_degd :=_edc .ToGoImage ();if _degd !=nil {return _degd ;};_bag :=_cdg .Bounds ();_aaa .Push ();_aaa .Scale (1.0/float64 (_bag .Dx ()),-1.0/float64 (_bag .Dy ()));_aaa .DrawImageAnchored (_cdg ,0,0,0,1);_aaa .Pop ();case "\u0042\u0054":_gb .Reset ();case "\u0045\u0054":_gb .Reset ();case "\u0054\u004c":if len (_dd .Params )!=1{return _ag ;};_dce ,_dfee :=_be .GetNumberAsFloat (_dd .Params [0]);if _dfee !=nil {return _dfee ;};_gb .Tl =_dce ;case "\u0054\u0063":if len (_dd .Params )!=1{return _ag ;};_ccd ,_ccad :=_be .GetNumberAsFloat (_dd .Params [0]);if _ccad !=nil {return _ccad ;};_gb .Tc =_ccd ;case "\u0054\u0077":if len (_dd .Params )!=1{return _ag ;};_ffe ,_ecc :=_be .GetNumberAsFloat (_dd .Params [0]);if _ecc !=nil {return _ecc ;};_gb .Tw =_ffe ;case "\u0054\u007a":if len (_dd .Params )!=1{return _ag ;};_ddf ,_fca :=_be .GetNumberAsFloat (_dd .Params [0]);if _fca !=nil {return _fca ;};_gb .Th =_ddf ;case "\u0054\u0073":if len (_dd .Params )!=1{return _ag ;};_ecf ,_dbd :=_be .GetNumberAsFloat (_dd .Params [0]);if _dbd !=nil {return _dbd ;};_gb .Ts =_ecf ;case "\u0054\u0064":if len (_dd .Params )!=2{return _ag ;};_bfb ,_fac :=_be .GetNumbersAsFloat (_dd .Params );if _fac !=nil {return _fac ;};_e .Log .Debug ("\u0054\u0064\u003a\u0020\u0025\u0076",_bfb );_gb .ProcTd (_bfb [0],_bfb [1]);case "\u0054\u0044":if len (_dd .Params )!=2{return _ag ;};_gadg ,_gdad :=_be .GetNumbersAsFloat (_dd .Params );if _gdad !=nil {return _gdad ;};_e .Log .Debug ("\u0054\u0044\u003a\u0020\u0025\u0076",_gadg );_gb .ProcTD (_gadg [0],_gadg [1]);case "\u0054\u002a":_gb .ProcTStar ();case "\u0054\u006d":if len (_dd .Params )!=6{return _ag ;};_ebd ,_ccc :=_be .GetNumbersAsFloat (_dd .Params );if _ccc !=nil {return _ccc ;};_e .Log .Debug ("\u0054\u0065x\u0074\u0020\u006da\u0074\u0072\u0069\u0078\u003a\u0020\u0025\u002b\u0076",_ebd );_gb .ProcTm (_ebd [0],_ebd [1],_ebd [2],_ebd [3],_ebd [4],_ebd [5]);case "\u0027":if len (_dd .Params )!=1{return _ag ;};_gbg ,_dag :=_be .GetStringBytes (_dd .Params [0]);if !_dag {return _dfa ;};_e .Log .Debug ("\u0027\u0020\u0073t\u0072\u0069\u006e\u0067\u003a\u0020\u0025\u0073",string (_gbg ));_gb .ProcQ (_gbg ,_aaa );case "\u0022":if len (_dd .Params )!=3{return _ag ;};_cgcc ,_egg :=_be .GetNumberAsFloat (_dd .Params [0]);if _egg !=nil {return _egg ;};_fdc ,_egg :=_be .GetNumberAsFloat (_dd .Params [1]);if _egg !=nil {return _egg ;};_gee ,_dcg :=_be .GetStringBytes (_dd .Params [2]);if !_dcg {return _dfa ;};_gb .ProcDQ (_gee ,_cgcc ,_fdc ,_aaa );case "\u0054\u006a":if len (_dd .Params )!=1{return _ag ;};_cac ,_acb :=_be .GetStringBytes (_dd .Params [0]);if !_acb {return _dfa ;};_e .Log .Debug ("\u0054j\u0020s\u0074\u0072\u0069\u006e\u0067\u003a\u0020\u0060\u0025\u0073\u0060",string (_cac ));_gb .ProcTj (_cac ,_aaa );case "\u0054\u004a":if len (_dd .Params )!=1{return _ag ;};_bga ,_gab :=_be .GetArray (_dd .Params [0]);if !_gab {_e .Log .Debug ("\u0054\u0079\u0070\u0065\u003a\u0020\u0025\u0054",_bga );return _dfa ;};_e .Log .Debug ("\u0054\u004a\u0020\u0061\u0072\u0072\u0061\u0079\u003a\u0020\u0025\u002b\u0076",_bga );for _ ,_ebf :=range _bga .Elements (){switch _bcb :=_ebf .(type ){case *_be .PdfObjectString :if _bcb !=nil {_gb .ProcTj (_bcb .Bytes (),_aaa );};case *_be .PdfObjectFloat ,*_be .PdfObjectInteger :_cbfb ,_acgb :=_be .GetNumberAsFloat (_bcb );if _acgb ==nil {_gb .Translate (-_cbfb *0.001*_gb .Tf .Size ,0);};};};case "\u0054\u0066":if len (_dd .Params )!=2{return _ag ;};_e .Log .Debug ("\u0025\u0023\u0076",_dd .Params );_bcde ,_cddf :=_be .GetName (_dd .Params [0]);if !_cddf ||_bcde ==nil {_e .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",_dd .Params [0]);return _dfa ;};_e .Log .Debug ("\u0046\u006f\u006e\u0074\u0020\u006e\u0061\u006d\u0065\u003a\u0020\u0025\u0073",_bcde .String ());_bef ,_cdf :=_be .GetNumberAsFloat (_dd .Params [1]);if _cdf !=nil {_e .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",_dd .Params [1]);return _dfa ;};_e .Log .Debug ("\u0046\u006f\u006e\u0074\u0020\u0073\u0069\u007a\u0065\u003a\u0020\u0025\u0076",_bef );_bcdf ,_efgc :=_bbb .GetFontByName (*_bcde );if !_efgc {_e .Log .Debug ("\u0045R\u0052\u004f\u0052\u003a\u0020\u0046\u006f\u006e\u0074\u0020\u0025s\u0020\u006e\u006f\u0074\u0020\u0066\u006f\u0075\u006e\u0064",_bcde .String ());return _a .New ("\u0066\u006f\u006e\u0074\u0020\u006e\u006f\u0074\u0020f\u006f\u0075\u006e\u0064");};_e .Log .Debug ("\u0046\u006f\u006e\u0074\u003a\u0020\u0025\u0054",_bcdf );_cdge ,_cddf :=_be .GetDict (_bcdf );if !_cddf {_e .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 _dfa ;};_dba ,_cdf :=_bb .NewPdfFontFromPdfObject (_cdge );if _cdf !=nil {_e .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 _cdf ;};_fgcb :=_dba .BaseFont ();if _fgcb ==""{_fgcb =_bcde .String ();};_fbc ,_cddf :=_gca [_fgcb ];if !_cddf {_fbc ,_cdf =_fg .NewTextFont (_dba ,_bef );if _cdf !=nil {_e .Log .Debug ("\u0045R\u0052\u004f\u0052\u003a\u0020\u0025v",_cdf );};};if _fbc ==nil {if len (_fgcb )> 7&&_fgcb [6]=='+'{_fgcb =_fgcb [7:];};_abga :=[]string {_fgcb ,"\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 _ ,_bcbg :=range _abga {_e .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",_bcbg );if _fbc ,_cddf =_gca [_bcbg ];_cddf {break ;};_afa :=_eb .Match (_bcbg );if _afa ==nil {_e .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",_bcbg );continue ;};_fbc ,_cdf =_fg .NewTextFontFromPath (_afa .Filename ,_bef );if _cdf !=nil {_e .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",_afa .Filename );continue ;};_e .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",_fgcb ,_afa .Name ,_afa .Filename );_gca [_bcbg ]=_fbc ;break ;};};if _fbc ==nil {_e .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 _a .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");};_gb .ProcTf (_fbc .WithSize (_bef ,_dba ));case "\u0042\u004d\u0043","\u0042\u0044\u0043":case "\u0045\u004d\u0043":default:_e .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",_dd .Operand );};return nil ;});_efgg =_fc .Process (_cb );if _efgg !=nil {return _efgg ;};return nil ;};func _bg (_ef string ,_cfe _ca .Image ,_df int )error {_cfce ,_ba :=_ae .Create (_ef );if _ba !=nil {return _ba ;};defer _cfce .Close ();return _fe .Encode (_cfce ,_cfe ,&_fe .Options {Quality :_df });};
// RenderToPath converts the specified PDF page into an image and saves the
// result at the specified location.
func (_dgb *ImageDevice )RenderToPath (page *_bb .PdfPage ,outputPath string )error {_bf ,_ec :=_dgb .Render (page );if _ec !=nil {return _ec ;};_bc :=_f .ToLower (_c .Ext (outputPath ));if _bc ==""{return _a .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 _bc {case "\u002e\u0070\u006e\u0067":return _eee (outputPath ,_bf );case "\u002e\u006a\u0070\u0067","\u002e\u006a\u0070e\u0067":return _bg (outputPath ,_bf ,100);};return _g .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",_bc );};func _eee (_aa string ,_gad _ca .Image )error {_ab ,_cfc :=_ae .Create (_aa );if _cfc !=nil {return _cfc ;};defer _ab .Close ();return _cf .Encode (_ab ,_gad );};
// NewImageDevice returns a new image device.
func NewImageDevice ()*ImageDevice {return &ImageDevice {}};
// ImageDevice is used to render PDF pages to image targets.
type ImageDevice struct{renderer };type renderer struct{};