mirror of
https://github.com/unidoc/unipdf.git
synced 2025-05-01 22:17:29 +08:00
25 lines
31 KiB
Go
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 (_f "errors";_cd "fmt";_gb "github.com/adrg/sysfont";_bb "github.com/unidoc/unipdf/v3/common";_e "github.com/unidoc/unipdf/v3/contentstream";_ag "github.com/unidoc/unipdf/v3/core";_fe "github.com/unidoc/unipdf/v3/internal/transform";_gg "github.com/unidoc/unipdf/v3/model";_ec "github.com/unidoc/unipdf/v3/render/internal/context";_cda "github.com/unidoc/unipdf/v3/render/internal/context/imagerender";_bd "image";_fc "image/draw";_a "image/jpeg";_b "image/png";_cf "os";_c "path/filepath";_g "strings";);func _fdd (_ac string ,_dc _bd .Image )error {_ab ,_abc :=_cf .Create (_ac );if _abc !=nil {return _abc ;};defer _ab .Close ();return _b .Encode (_ab ,_dc );};
|
|
|
|
// Render converts the specified PDF page into an image and returns the result.
|
|
func (_fd *ImageDevice )Render (page *_gg .PdfPage )(_bd .Image ,error ){_cg ,_cge :=page .GetMediaBox ();if _cge !=nil {return nil ,_cge ;};_aa ,_df :=_cg .Llx +_cg .Width (),_cg .Lly +_cg .Height ();_cc :=_cda .NewContext (int (_aa ),int (_df ));if _ca :=_fd .renderPage (_cc ,page );_ca !=nil {return nil ,_ca ;};_ce :=_cc .Image ();if _ff :=page .CropBox ;_ff !=nil {_bc :=_bd .Rect (0,0,int (_ff .Width ()),int (_ff .Height ()));_bdf :=_bd .Pt (int (_ff .Llx ),int (_df -_ff .Ury ));_fb :=_bd .NewRGBA (_bc );_fc .Draw (_fb ,_bc ,_ce ,_bdf ,_fc .Src );_ce =_fb ;};return _ce ,nil ;};
|
|
|
|
// RenderToPath converts the specified PDF page into an image and saves the
|
|
// result at the specified location.
|
|
func (_bbg *ImageDevice )RenderToPath (page *_gg .PdfPage ,outputPath string )error {_dfg ,_dd :=_bbg .Render (page );if _dd !=nil {return _dd ;};_fba :=_g .ToLower (_c .Ext (outputPath ));if _fba ==""{return _f .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 _fba {case "\u002e\u0070\u006e\u0067":return _fdd (outputPath ,_dfg );case "\u002e\u006a\u0070\u0067","\u002e\u006a\u0070e\u0067":return _fcc (outputPath ,_dfg ,100);};return _cd .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",_fba );};var (_ee =_f .New ("\u0074\u0079p\u0065\u0020\u0063h\u0065\u0063\u006b\u0020\u0065\u0072\u0072\u006f\u0072");_ddf =_f .New ("\u0072\u0061\u006e\u0067\u0065\u0020\u0063\u0068\u0065\u0063\u006b\u0020e\u0072\u0072\u006f\u0072"););
|
|
|
|
// ImageDevice is used to render PDF pages to image targets.
|
|
type ImageDevice struct{renderer };
|
|
|
|
// NewImageDevice returns a new image device.
|
|
func NewImageDevice ()*ImageDevice {return &ImageDevice {}};func (_be renderer )renderPage (_dgb _ec .Context ,_gc *_gg .PdfPage )error {_cfe ,_fbd :=_gc .GetAllContentStreams ();if _fbd !=nil {return _fbd ;};_dgb .Translate (0,float64 (_dgb .Height ()));_dgb .Scale (1,-1);_dgb .Push ();_dgb .SetRGBA (1,1,1,1);_dgb .DrawRectangle (0,0,float64 (_dgb .Width ()),float64 (_dgb .Height ()));_dgb .Fill ();_dgb .Pop ();_dgb .SetLineWidth (1.0);_dgb .SetRGBA (0,0,0,1);return _be .renderContentStream (_dgb ,_cfe ,_gc .Resources );};func _fcc (_ggd string ,_fg _bd .Image ,_fgf int )error {_dg ,_eca :=_cf .Create (_ggd );if _eca !=nil {return _eca ;};defer _dg .Close ();return _a .Encode (_dg ,_fg ,&_a .Options {Quality :_fgf });};type renderer struct{};func (_aba renderer )renderContentStream (_ecb _ec .Context ,_eec string ,_ggdb *_gg .PdfPageResources )error {_gd ,_ae :=_e .NewContentStreamParser (_eec ).Parse ();if _ae !=nil {return _ae ;};_db :=_ecb .TextState ();_fa :=map[string ]*_ec .TextFont {};_dgbd :=_gb .NewFinder (&_gb .FinderOpts {Extensions :[]string {"\u002e\u0074\u0074\u0066","\u002e\u0074\u0074\u0063"}});_ga :=_e .NewContentStreamProcessor (*_gd );_ga .AddHandler (_e .HandlerConditionEnumAllOperands ,"",func (_eb *_e .ContentStreamOperation ,_ed _e .GraphicsState ,_acd *_gg .PdfPageResources )error {_bb .Log .Debug ("\u0050\u0072\u006f\u0063\u0065\u0073\u0073\u0069\u006e\u0067\u0020\u0025\u0073",_eb .Operand );switch _eb .Operand {case "\u0071":_ecb .Push ();case "\u0051":_ecb .Pop ();case "\u0063\u006d":if len (_eb .Params )!=6{return _ddf ;};_bdb ,_eeb :=_ag .GetNumbersAsFloat (_eb .Params );if _eeb !=nil {return _eeb ;};_bba :=_fe .NewMatrix (_bdb [0],_bdb [1],_bdb [2],_bdb [3],_bdb [4],_bdb [5]);_bb .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",_bba );_ecb .SetMatrix (_ecb .Matrix ().Mult (_bba ));_abcd :=(_ed .CTM .ScalingFactorX ()+_ed .CTM .ScalingFactorY ())/2.0;_ecb .SetLineWidth (_abcd *_ecb .LineWidth ());case "\u0077":if len (_eb .Params )!=1{return _ddf ;};_gaa ,_aad :=_ag .GetNumbersAsFloat (_eb .Params );if _aad !=nil {return _aad ;};_dgf :=(_ed .CTM .ScalingFactorX ()+_ed .CTM .ScalingFactorY ())/2.0;_ecb .SetLineWidth (_dgf *_gaa [0]);case "\u004a":if len (_eb .Params )!=1{return _ddf ;};_ffd ,_fab :=_ag .GetIntVal (_eb .Params [0]);if !_fab {return _ee ;};switch _ffd {case 0:_ecb .SetLineCap (_ec .LineCapButt );case 1:_ecb .SetLineCap (_ec .LineCapRound );case 2:_ecb .SetLineCap (_ec .LineCapSquare );default:_bb .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",_ffd );return _ddf ;};case "\u006a":if len (_eb .Params )!=1{return _ddf ;};_cgg ,_af :=_ag .GetIntVal (_eb .Params [0]);if !_af {return _ee ;};switch _cgg {case 0:_ecb .SetLineJoin (_ec .LineJoinBevel );case 1:_ecb .SetLineJoin (_ec .LineJoinRound );case 2:_ecb .SetLineJoin (_ec .LineJoinBevel );default:_bb .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",_cgg );return _ddf ;};case "\u004d":if len (_eb .Params )!=1{return _ddf ;};_ea ,_ggf :=_ag .GetNumbersAsFloat (_eb .Params );if _ggf !=nil {return _ggf ;};_ =_ea ;_bb .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 (_eb .Params )!=2{return _ddf ;};_dfe ,_cdc :=_ag .GetArray (_eb .Params [0]);if !_cdc {return _ee ;};_ef ,_cdc :=_ag .GetIntVal (_eb .Params [1]);if !_cdc {return _ee ;};_edd ,_aeg :=_ag .GetNumbersAsFloat (_dfe .Elements ());if _aeg !=nil {return _aeg ;};_ecb .SetDash (_edd ...);_ =_ef ;_bb .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":_bb .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":_bb .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 (_eb .Params )!=1{return _ddf ;};_efd ,_ace :=_ag .GetName (_eb .Params [0]);if !_ace {return _ee ;};if _efd ==nil {return _ddf ;};_abd ,_ace :=_acd .GetExtGState (*_efd );if !_ace {_bb .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",*_efd );return _f .New ("\u0072e\u0073o\u0075\u0072\u0063\u0065\u0020n\u006f\u0074 \u0066\u006f\u0075\u006e\u0064");};_bdc ,_ace :=_ag .GetDict (_abd );if !_ace {_bb .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 _ee ;};_bb .Log .Debug ("G\u0053\u0020\u0064\u0069\u0063\u0074\u003a\u0020\u0025\u0073",_bdc .String ());case "\u006d":if len (_eb .Params )!=2{_bb .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",_ddf );return nil ;};_aeb ,_efe :=_ag .GetNumbersAsFloat (_eb .Params );if _efe !=nil {return _efe ;};_bb .Log .Debug ("M\u006f\u0076\u0065\u0020\u0074\u006f\u003a\u0020\u0025\u0076",_aeb );_ecb .NewSubPath ();_ecb .MoveTo (_aeb [0],_aeb [1]);case "\u006c":if len (_eb .Params )!=2{_bb .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",_ddf );return nil ;};_fcb ,_gcg :=_ag .GetNumbersAsFloat (_eb .Params );if _gcg !=nil {return _gcg ;};_ecb .LineTo (_fcb [0],_fcb [1]);case "\u0063":if len (_eb .Params )!=6{return _ddf ;};_gcd ,_aec :=_ag .GetNumbersAsFloat (_eb .Params );if _aec !=nil {return _aec ;};_bb .Log .Debug ("\u0043u\u0062\u0069\u0063\u0020\u0062\u0065\u007a\u0069\u0065\u0072\u0020p\u0061\u0072\u0061\u006d\u0073\u003a\u0020\u0025\u002b\u0076",_gcd );_ecb .CubicTo (_gcd [0],_gcd [1],_gcd [2],_gcd [3],_gcd [4],_gcd [5]);case "\u0076","\u0079":if len (_eb .Params )!=4{return _ddf ;};_de ,_afg :=_ag .GetNumbersAsFloat (_eb .Params );if _afg !=nil {return _afg ;};_bb .Log .Debug ("\u0043u\u0062\u0069\u0063\u0020\u0062\u0065\u007a\u0069\u0065\u0072\u0020p\u0061\u0072\u0061\u006d\u0073\u003a\u0020\u0025\u002b\u0076",_de );_ecb .QuadraticTo (_de [0],_de [1],_de [2],_de [3]);case "\u0068":_ecb .ClosePath ();_ecb .NewSubPath ();case "\u0072\u0065":if len (_eb .Params )!=4{return _ddf ;};_dda ,_eg :=_ag .GetNumbersAsFloat (_eb .Params );if _eg !=nil {return _eg ;};_ecb .DrawRectangle (_dda [0],_dda [1],_dda [2],_dda [3]);_ecb .NewSubPath ();case "\u0053":_fda ,_fbde :=_ed .ColorspaceStroking .ColorToRGB (_ed .ColorStroking );if _fbde !=nil {_bb .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",_fbde );return _fbde ;};_cb ,_dfb :=_fda .(*_gg .PdfColorDeviceRGB );if !_dfb {_bb .Log .Debug ("\u0045\u0072\u0072\u006fr \u0063\u006f\u006e\u0076\u0065\u0072\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006co\u0072");return _fbde ;};_ecb .SetRGBA (_cb .R (),_cb .G (),_cb .B (),1);_ecb .Stroke ();case "\u0073":_egf ,_bf :=_ed .ColorspaceStroking .ColorToRGB (_ed .ColorStroking );if _bf !=nil {_bb .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",_bf );return _bf ;};_dfd ,_dff :=_egf .(*_gg .PdfColorDeviceRGB );if !_dff {_bb .Log .Debug ("\u0045\u0072\u0072\u006fr \u0063\u006f\u006e\u0076\u0065\u0072\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006co\u0072");return _bf ;};_ecb .ClosePath ();_ecb .NewSubPath ();_ecb .SetRGBA (_dfd .R (),_dfd .G (),_dfd .B (),1);_ecb .Stroke ();case "\u0066","\u0046":_dffc ,_gga :=_ed .ColorspaceNonStroking .ColorToRGB (_ed .ColorNonStroking );if _gga !=nil {_bb .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",_gga );return _gga ;};_gbb ,_eda :=_dffc .(*_gg .PdfColorDeviceRGB );if !_eda {_bb .Log .Debug ("\u0045\u0072\u0072\u006fr \u0063\u006f\u006e\u0076\u0065\u0072\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006co\u0072");return _gga ;};_ecb .SetRGBA (_gbb .R (),_gbb .G (),_gbb .B (),1);_ecb .SetFillRule (_ec .FillRuleWinding );_ecb .Fill ();case "\u0066\u002a":_fbe ,_aga :=_ed .ColorspaceNonStroking .ColorToRGB (_ed .ColorNonStroking );if _aga !=nil {_bb .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",_aga );return _aga ;};_ba ,_bg :=_fbe .(*_gg .PdfColorDeviceRGB );if !_bg {_bb .Log .Debug ("\u0045\u0072\u0072\u006fr \u0063\u006f\u006e\u0076\u0065\u0072\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006co\u0072");return _aga ;};_ecb .SetRGBA (_ba .R (),_ba .G (),_ba .B (),1);_ecb .SetFillRule (_ec .FillRuleEvenOdd );_ecb .Fill ();case "\u0042":_fbag ,_ecc :=_ed .ColorspaceNonStroking .ColorToRGB (_ed .ColorNonStroking );if _ecc !=nil {_bb .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",_ecc );return _ecc ;};_ecac :=_fbag .(*_gg .PdfColorDeviceRGB );_ecb .SetRGBA (_ecac .R (),_ecac .G (),_ecac .B (),1);_ecb .SetFillRule (_ec .FillRuleWinding );_ecb .FillPreserve ();_fbag ,_ecc =_ed .ColorspaceStroking .ColorToRGB (_ed .ColorStroking );if _ecc !=nil {_bb .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",_ecc );return _ecc ;};_ecac =_fbag .(*_gg .PdfColorDeviceRGB );_ecb .SetRGBA (_ecac .R (),_ecac .G (),_ecac .B (),1);_ecb .Stroke ();case "\u0042\u002a":_ced ,_gab :=_ed .ColorspaceNonStroking .ColorToRGB (_ed .ColorNonStroking );if _gab !=nil {_bb .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",_gab );return _gab ;};_agc :=_ced .(*_gg .PdfColorDeviceRGB );_ecb .SetRGBA (_agc .R (),_agc .G (),_agc .B (),1);_ecb .SetFillRule (_ec .FillRuleEvenOdd );_ecb .FillPreserve ();_ced ,_gab =_ed .ColorspaceStroking .ColorToRGB (_ed .ColorStroking );if _gab !=nil {_bb .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",_gab );return _gab ;};_agc =_ced .(*_gg .PdfColorDeviceRGB );_ecb .SetRGBA (_agc .R (),_agc .G (),_agc .B (),1);_ecb .Stroke ();case "\u0062":_fbea ,_aaa :=_ed .ColorspaceNonStroking .ColorToRGB (_ed .ColorNonStroking );if _aaa !=nil {_bb .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",_aaa );return _aaa ;};_dbc :=_fbea .(*_gg .PdfColorDeviceRGB );_ecb .SetRGBA (_dbc .R (),_dbc .G (),_dbc .B (),1);_ecb .ClosePath ();_ecb .NewSubPath ();_ecb .SetFillRule (_ec .FillRuleWinding );_ecb .FillPreserve ();_fbea ,_aaa =_ed .ColorspaceStroking .ColorToRGB (_ed .ColorStroking );if _aaa !=nil {_bb .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",_aaa );return _aaa ;};_dbc =_fbea .(*_gg .PdfColorDeviceRGB );_ecb .SetRGBA (_dbc .R (),_dbc .G (),_dbc .B (),1);_ecb .Stroke ();case "\u0062\u002a":_ecb .ClosePath ();_bgf ,_ege :=_ed .ColorspaceNonStroking .ColorToRGB (_ed .ColorNonStroking );if _ege !=nil {_bb .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",_ege );return _ege ;};_dcb :=_bgf .(*_gg .PdfColorDeviceRGB );_ecb .SetRGBA (_dcb .R (),_dcb .G (),_dcb .B (),1);_ecb .NewSubPath ();_ecb .SetFillRule (_ec .FillRuleEvenOdd );_ecb .FillPreserve ();_bgf ,_ege =_ed .ColorspaceStroking .ColorToRGB (_ed .ColorStroking );if _ege !=nil {_bb .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",_ege );return _ege ;};_dcb =_bgf .(*_gg .PdfColorDeviceRGB );_ecb .SetRGBA (_dcb .R (),_dcb .G (),_dcb .B (),1);_ecb .Stroke ();case "\u006e":_ecb .ClearPath ();case "\u0057":_ecb .SetFillRule (_ec .FillRuleWinding );_ecb .ClipPreserve ();case "\u0057\u002a":_ecb .SetFillRule (_ec .FillRuleEvenOdd );_ecb .ClipPreserve ();case "\u0072\u0067":_age ,_acc :=_ed .ColorNonStroking .(*_gg .PdfColorDeviceRGB );if !_acc {_bb .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",_ed .ColorNonStroking );return nil ;};_ecb .SetFillRGBA (_age .R (),_age .G (),_age .B (),1);case "\u0052\u0047":_bag ,_gf :=_ed .ColorStroking .(*_gg .PdfColorDeviceRGB );if !_gf {_bb .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",_ed .ColorStroking );return nil ;};_ecb .SetStrokeRGBA (_bag .R (),_bag .G (),_bag .B (),1);case "\u006b":_abe ,_bbgg :=_ed .ColorNonStroking .(*_gg .PdfColorDeviceCMYK );if !_bbgg {_bb .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",_ed .ColorNonStroking );return nil ;};_abb ,_gdg :=_ed .ColorspaceNonStroking .ColorToRGB (_abe );if _gdg !=nil {_bb .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",_ed .ColorNonStroking );return nil ;};_bee ,_bbgg :=_abb .(*_gg .PdfColorDeviceRGB );if !_bbgg {_bb .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",_abb );return nil ;};_ecb .SetFillRGBA (_bee .R (),_bee .G (),_bee .B (),1);case "\u004b":_dbd ,_dffb :=_ed .ColorStroking .(*_gg .PdfColorDeviceCMYK );if !_dffb {_bb .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",_ed .ColorStroking );return nil ;};_cfa ,_eee :=_ed .ColorspaceStroking .ColorToRGB (_dbd );if _eee !=nil {_bb .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",_ed .ColorStroking );return nil ;};_egd ,_dffb :=_cfa .(*_gg .PdfColorDeviceRGB );if !_dffb {_bb .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",_cfa );return nil ;};_ecb .SetStrokeRGBA (_egd .R (),_egd .G (),_egd .B (),1);case "\u0067":_bce ,_bbd :=_ed .ColorNonStroking .(*_gg .PdfColorDeviceGray );if !_bbd {_bb .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",_ed .ColorNonStroking );return nil ;};_ffdg ,_ecbg :=_ed .ColorspaceNonStroking .ColorToRGB (_bce );if _ecbg !=nil {_bb .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",_ed .ColorNonStroking );return nil ;};_bab ,_bbd :=_ffdg .(*_gg .PdfColorDeviceRGB );if !_bbd {_bb .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",_ffdg );return nil ;};_ecb .SetFillRGBA (_bab .R (),_bab .G (),_bab .B (),1);case "\u0047":_gca ,_fcd :=_ed .ColorStroking .(*_gg .PdfColorDeviceGray );if !_fcd {_bb .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",_ed .ColorStroking );return nil ;};_fddf ,_bfb :=_ed .ColorspaceStroking .ColorToRGB (_gca );if _bfb !=nil {_bb .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",_ed .ColorStroking );return nil ;};_gbbc ,_fcd :=_fddf .(*_gg .PdfColorDeviceRGB );if !_fcd {_bb .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",_fddf );return nil ;};_ecb .SetStrokeRGBA (_gbbc .R (),_gbbc .G (),_gbbc .B (),1);case "\u0063\u0073","\u0073\u0063","\u0073\u0063\u006e":_ge ,_bfg :=_ed .ColorspaceNonStroking .ColorToRGB (_ed .ColorNonStroking );if _bfg !=nil {_bb .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",_ed .ColorNonStroking );return nil ;};_fgd ,_bbge :=_ge .(*_gg .PdfColorDeviceRGB );if !_bbge {_bb .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",_ge );return nil ;};_ecb .SetFillRGBA (_fgd .R (),_fgd .G (),_fgd .B (),1);case "\u0043\u0053","\u0053\u0043","\u0053\u0043\u004e":_fcg ,_bdd :=_ed .ColorspaceStroking .ColorToRGB (_ed .ColorStroking );if _bdd !=nil {_bb .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",_ed .ColorStroking );return nil ;};_gbg ,_egg :=_fcg .(*_gg .PdfColorDeviceRGB );if !_egg {_bb .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",_fcg );return nil ;};_ecb .SetStrokeRGBA (_gbg .R (),_gbg .G (),_gbg .B (),1);case "\u0044\u006f":if len (_eb .Params )!=1{return _ddf ;};_aaag ,_ded :=_ag .GetName (_eb .Params [0]);if !_ded {return _ee ;};_ ,_bac :=_acd .GetXObjectByName (*_aaag );switch _bac {case _gg .XObjectTypeImage :_bb .Log .Debug ("\u0058\u004f\u0062\u006a\u0065\u0063\u0074\u0020\u0069\u006d\u0061\u0067e\u003a\u0020\u0025\u0073",_aaag .String ());_beg ,_aff :=_acd .GetXObjectImageByName (*_aaag );if _aff !=nil {return _aff ;};_efde ,_aff :=_beg .ToImage ();if _aff !=nil {return _aff ;};_dfc ,_aff :=_efde .ToGoImage ();if _aff !=nil {return _aff ;};_ebg :=_dfc .Bounds ();_ecb .Push ();_ecb .Scale (1.0/float64 (_ebg .Dx ()),-1.0/float64 (_ebg .Dy ()));_ecb .DrawImageAnchored (_dfc ,0,0,0,1);_ecb .Pop ();case _gg .XObjectTypeForm :_bb .Log .Debug ("\u0058\u004fb\u006a\u0065\u0063t\u0020\u0066\u006f\u0072\u006d\u003a\u0020\u0025\u0073",_aaag .String ());_ggab ,_efa :=_acd .GetXObjectFormByName (*_aaag );if _efa !=nil {return _efa ;};_bef ,_efa :=_ggab .GetContentStream ();if _efa !=nil {return _efa ;};_ffde :=_ggab .Resources ;if _ffde ==nil {_ffde =_acd ;};_ecb .Push ();if _ggab .Matrix !=nil {_gfd ,_eaf :=_ag .GetArray (_ggab .Matrix );if !_eaf {return _ee ;};_da ,_afe :=_ag .GetNumbersAsFloat (_gfd .Elements ());if _afe !=nil {return _afe ;};if len (_da )!=6{return _ddf ;};_ega :=_fe .NewMatrix (_da [0],_da [1],_da [2],_da [3],_da [4],_da [5]);_ecb .SetMatrix (_ecb .Matrix ().Mult (_ega ));};if _ggab .BBox !=nil {_cbc ,_deb :=_ag .GetArray (_ggab .BBox );if !_deb {return _ee ;};_caa ,_gfg :=_ag .GetNumbersAsFloat (_cbc .Elements ());if _gfg !=nil {return _gfg ;};if len (_caa )!=4{_bb .Log .Debug ("\u004c\u0065\u006e\u0020\u003d\u0020\u0025\u0064",len (_caa ));return _ddf ;};_ecb .DrawRectangle (_caa [0],_caa [1],_caa [2]-_caa [0],_caa [3]-_caa [1]);_ecb .SetRGBA (1,0,0,1);_ecb .Clip ();}else {_bb .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");};_efa =_aba .renderContentStream (_ecb ,string (_bef ),_ffde );if _efa !=nil {return _efa ;};_ecb .Pop ();};case "\u0042\u0049":if len (_eb .Params )!=1{return _ddf ;};_aab ,_dbf :=_eb .Params [0].(*_e .ContentStreamInlineImage );if !_dbf {return nil ;};_eed ,_gac :=_aab .ToImage (_acd );if _gac !=nil {return _gac ;};_gbe ,_gac :=_eed .ToGoImage ();if _gac !=nil {return _gac ;};_aea :=_gbe .Bounds ();_ecb .Push ();_ecb .Scale (1.0/float64 (_aea .Dx ()),-1.0/float64 (_aea .Dy ()));_ecb .DrawImageAnchored (_gbe ,0,0,0,1);_ecb .Pop ();case "\u0042\u0054":_db .Reset ();case "\u0045\u0054":_db .Reset ();case "\u0054\u004c":if len (_eb .Params )!=1{return _ddf ;};_gcdc ,_gdf :=_ag .GetNumberAsFloat (_eb .Params [0]);if _gdf !=nil {return _gdf ;};_db .Tl =_gcdc ;case "\u0054\u0063":if len (_eb .Params )!=1{return _ddf ;};_fga ,_bagd :=_ag .GetNumberAsFloat (_eb .Params [0]);if _bagd !=nil {return _bagd ;};_db .Tc =_fga ;case "\u0054\u0077":if len (_eb .Params )!=1{return _ddf ;};_faa ,_bbc :=_ag .GetNumberAsFloat (_eb .Params [0]);if _bbc !=nil {return _bbc ;};_db .Tw =_faa ;case "\u0054\u007a":if len (_eb .Params )!=1{return _ddf ;};_dca ,_afga :=_ag .GetNumberAsFloat (_eb .Params [0]);if _afga !=nil {return _afga ;};_db .Th =_dca ;case "\u0054\u0073":if len (_eb .Params )!=1{return _ddf ;};_aca ,_afb :=_ag .GetNumberAsFloat (_eb .Params [0]);if _afb !=nil {return _afb ;};_db .Ts =_aca ;case "\u0054\u0064":if len (_eb .Params )!=2{return _ddf ;};_bde ,_bdbd :=_ag .GetNumbersAsFloat (_eb .Params );if _bdbd !=nil {return _bdbd ;};_bb .Log .Debug ("\u0054\u0064\u003a\u0020\u0025\u0076",_bde );_db .ProcTd (_bde [0],_bde [1]);case "\u0054\u0044":if len (_eb .Params )!=2{return _ddf ;};_dfec ,_ccb :=_ag .GetNumbersAsFloat (_eb .Params );if _ccb !=nil {return _ccb ;};_bb .Log .Debug ("\u0054\u0044\u003a\u0020\u0025\u0076",_dfec );_db .ProcTD (_dfec [0],_dfec [1]);case "\u0054\u002a":_db .ProcTStar ();case "\u0054\u006d":if len (_eb .Params )!=6{return _ddf ;};_gff ,_dbb :=_ag .GetNumbersAsFloat (_eb .Params );if _dbb !=nil {return _dbb ;};_bb .Log .Debug ("\u0054\u0065x\u0074\u0020\u006da\u0074\u0072\u0069\u0078\u003a\u0020\u0025\u002b\u0076",_gff );_db .ProcTm (_gff [0],_gff [1],_gff [2],_gff [3],_gff [4],_gff [5]);case "\u0027":if len (_eb .Params )!=1{return _ddf ;};_eebb ,_afbg :=_ag .GetStringBytes (_eb .Params [0]);if !_afbg {return _ee ;};_bb .Log .Debug ("\u0027\u0020\u0073t\u0072\u0069\u006e\u0067\u003a\u0020\u0025\u0073",string (_eebb ));_db .ProcQ (_eebb ,_ecb );case "\u0022":if len (_eb .Params )!=3{return _ddf ;};_abbc ,_ecg :=_ag .GetNumberAsFloat (_eb .Params [0]);if _ecg !=nil {return _ecg ;};_cbe ,_ecg :=_ag .GetNumberAsFloat (_eb .Params [1]);if _ecg !=nil {return _ecg ;};_fgb ,_bga :=_ag .GetStringBytes (_eb .Params [2]);if !_bga {return _ee ;};_db .ProcDQ (_fgb ,_abbc ,_cbe ,_ecb );case "\u0054\u006a":if len (_eb .Params )!=1{return _ddf ;};_bcc ,_bgb :=_ag .GetStringBytes (_eb .Params [0]);if !_bgb {return _ee ;};_bb .Log .Debug ("\u0054j\u0020s\u0074\u0072\u0069\u006e\u0067\u003a\u0020\u0060\u0025\u0073\u0060",string (_bcc ));_db .ProcTj (_bcc ,_ecb );case "\u0054\u004a":if len (_eb .Params )!=1{return _ddf ;};_ged ,_fbab :=_ag .GetArray (_eb .Params [0]);if !_fbab {_bb .Log .Debug ("\u0054\u0079\u0070\u0065\u003a\u0020\u0025\u0054",_ged );return _ee ;};_bb .Log .Debug ("\u0054\u004a\u0020\u0061\u0072\u0072\u0061\u0079\u003a\u0020\u0025\u002b\u0076",_ged );for _ ,_dgc :=range _ged .Elements (){switch _ggc :=_dgc .(type ){case *_ag .PdfObjectString :if _ggc !=nil {_db .ProcTj (_ggc .Bytes (),_ecb );};case *_ag .PdfObjectFloat ,*_ag .PdfObjectInteger :_bbe ,_ead :=_ag .GetNumberAsFloat (_ggc );if _ead ==nil {_db .Translate (-_bbe *0.001*_db .Tf .Size ,0);};};};case "\u0054\u0066":if len (_eb .Params )!=2{return _ddf ;};_bb .Log .Debug ("\u0025\u0023\u0076",_eb .Params );_acdc ,_dec :=_ag .GetName (_eb .Params [0]);if !_dec ||_acdc ==nil {_bb .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",_eb .Params [0]);return _ee ;};_bb .Log .Debug ("\u0046\u006f\u006e\u0074\u0020\u006e\u0061\u006d\u0065\u003a\u0020\u0025\u0073",_acdc .String ());_eecc ,_agd :=_ag .GetNumberAsFloat (_eb .Params [1]);if _agd !=nil {_bb .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",_eb .Params [1]);return _ee ;};_bb .Log .Debug ("\u0046\u006f\u006e\u0074\u0020\u0073\u0069\u007a\u0065\u003a\u0020\u0025\u0076",_eecc );_agg ,_bbf :=_acd .GetFontByName (*_acdc );if !_bbf {_bb .Log .Debug ("\u0045R\u0052\u004f\u0052\u003a\u0020\u0046\u006f\u006e\u0074\u0020\u0025s\u0020\u006e\u006f\u0074\u0020\u0066\u006f\u0075\u006e\u0064",_acdc .String ());return _f .New ("\u0066\u006f\u006e\u0074\u0020\u006e\u006f\u0074\u0020f\u006f\u0075\u006e\u0064");};_bb .Log .Debug ("\u0046\u006f\u006e\u0074\u003a\u0020\u0025\u0054",_agg );_afed ,_dec :=_ag .GetDict (_agg );if !_dec {_bb .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 _ee ;};_gea ,_agd :=_gg .NewPdfFontFromPdfObject (_afed );if _agd !=nil {_bb .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 _agd ;};_eddb :=_gea .BaseFont ();if _eddb ==""{_eddb =_acdc .String ();};_gge ,_dec :=_fa [_eddb ];if !_dec {_gge ,_agd =_ec .NewTextFont (_gea ,_eecc );if _agd !=nil {_bb .Log .Debug ("\u0045R\u0052\u004f\u0052\u003a\u0020\u0025v",_agd );};};if _gge ==nil {if len (_eddb )> 7&&_eddb [6]=='+'{_eddb =_eddb [7:];};_ddab :=[]string {_eddb ,"\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 _ ,_bceb :=range _ddab {_bb .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",_bceb );if _gge ,_dec =_fa [_bceb ];_dec {break ;};_ad :=_dgbd .Match (_bceb );if _ad ==nil {_bb .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",_bceb );continue ;};_gge ,_agd =_ec .NewTextFontFromPath (_ad .Filename ,_eecc );if _agd !=nil {_bb .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",_ad .Filename );continue ;};_bb .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",_eddb ,_ad .Name ,_ad .Filename );_fa [_bceb ]=_gge ;break ;};};if _gge ==nil {_bb .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 _f .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 (_gge .WithSize (_eecc ,_gea ));case "\u0042\u004d\u0043","\u0042\u0044\u0043":case "\u0045\u004d\u0043":default:_bb .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",_eb .Operand );};return nil ;});_ae =_ga .Process (_ggdb );if _ae !=nil {return _ae ;};return nil ;}; |