2020-08-27 21:45:09 +00:00
|
|
|
//
|
|
|
|
// 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/
|
|
|
|
|
2022-07-13 21:28:43 +00:00
|
|
|
package render ;import (_c "errors";_b "fmt";_bae "github.com/adrg/sysfont";_da "github.com/unidoc/unipdf/v3/common";_cd "github.com/unidoc/unipdf/v3/contentstream";_bf "github.com/unidoc/unipdf/v3/contentstream/draw";_cbf "github.com/unidoc/unipdf/v3/core";
|
|
|
|
_af "github.com/unidoc/unipdf/v3/internal/license";_eb "github.com/unidoc/unipdf/v3/internal/transform";_ca "github.com/unidoc/unipdf/v3/model";_aa "github.com/unidoc/unipdf/v3/render/internal/context";_bad "github.com/unidoc/unipdf/v3/render/internal/context/imagerender";
|
|
|
|
_ba "golang.org/x/image/draw";_abg "image";_ea "image/color";_cb "image/draw";_ab "image/jpeg";_dg "image/png";_f "math";_cf "os";_a "path/filepath";_e "strings";);func (_fd renderer )renderPage (_afe _aa .Context ,_ef *_ca .PdfPage ,_ebee _eb .Matrix )error {_deb ,_cbc :=_ef .GetAllContentStreams ();
|
|
|
|
if _cbc !=nil {return _cbc ;};if _cgd :=_ebee ;!_cgd .Identity (){_deb =_b .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",_cgd [0],_cgd [1],_cgd [3],_cgd [4],_cgd [6],_cgd [7],_deb );
|
|
|
|
};_afe .Translate (0,float64 (_afe .Height ()));_afe .Scale (1,-1);_afe .Push ();_afe .SetRGBA (1,1,1,1);_afe .DrawRectangle (0,0,float64 (_afe .Width ()),float64 (_afe .Height ()));_afe .Fill ();_afe .Pop ();_afe .SetLineWidth (1.0);_afe .SetRGBA (0,0,0,1);
|
|
|
|
return _fd .renderContentStream (_afe ,_deb ,_ef .Resources );};func (_dggf renderer )renderContentStream (_fbg _aa .Context ,_bdc string ,_gf *_ca .PdfPageResources )error {_gc ,_db :=_cd .NewContentStreamParser (_bdc ).Parse ();if _db !=nil {return _db ;
|
|
|
|
};_debc :=_fbg .TextState ();_debc .GlobalScale =_dggf ._ebe ;_ddg :=map[string ]*_aa .TextFont {};_ggd :=_bae .NewFinder (&_bae .FinderOpts {Extensions :[]string {"\u002e\u0074\u0074\u0066","\u002e\u0074\u0074\u0063"}});_fde :=_cd .NewContentStreamProcessor (*_gc );
|
|
|
|
_fde .AddHandler (_cd .HandlerConditionEnumAllOperands ,"",func (_gbe *_cd .ContentStreamOperation ,_cgdf _cd .GraphicsState ,_ecd *_ca .PdfPageResources )error {_da .Log .Debug ("\u0050\u0072\u006f\u0063\u0065\u0073\u0073\u0069\u006e\u0067\u0020\u0025\u0073",_gbe .Operand );
|
|
|
|
switch _gbe .Operand {case "\u0071":_fbg .Push ();case "\u0051":_fbg .Pop ();_debc =_fbg .TextState ();case "\u0063\u006d":if len (_gbe .Params )!=6{return _ecf ;};_dde ,_cgc :=_cbf .GetNumbersAsFloat (_gbe .Params );if _cgc !=nil {return _cgc ;};_bgf :=_eb .NewMatrix (_dde [0],_dde [1],_dde [2],_dde [3],_dde [4],_dde [5]);
|
|
|
|
_da .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",_bgf );_fbg .SetMatrix (_fbg .Matrix ().Mult (_bgf ));case "\u0077":if len (_gbe .Params )!=1{return _ecf ;
|
|
|
|
};_cca ,_ggf :=_cbf .GetNumbersAsFloat (_gbe .Params );if _ggf !=nil {return _ggf ;};_fbg .SetLineWidth (_cca [0]);case "\u004a":if len (_gbe .Params )!=1{return _ecf ;};_ff ,_aad :=_cbf .GetIntVal (_gbe .Params [0]);if !_aad {return _be ;};switch _ff {case 0:_fbg .SetLineCap (_aa .LineCapButt );
|
|
|
|
case 1:_fbg .SetLineCap (_aa .LineCapRound );case 2:_fbg .SetLineCap (_aa .LineCapSquare );default:_da .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",_ff );
|
|
|
|
return _ecf ;};case "\u006a":if len (_gbe .Params )!=1{return _ecf ;};_dad ,_aff :=_cbf .GetIntVal (_gbe .Params [0]);if !_aff {return _be ;};switch _dad {case 0:_fbg .SetLineJoin (_aa .LineJoinBevel );case 1:_fbg .SetLineJoin (_aa .LineJoinRound );case 2:_fbg .SetLineJoin (_aa .LineJoinBevel );
|
|
|
|
default:_da .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",_dad );return _ecf ;};case "\u004d":if len (_gbe .Params )!=1{return _ecf ;};_ge ,_ed :=_cbf .GetNumbersAsFloat (_gbe .Params );
|
|
|
|
if _ed !=nil {return _ed ;};_ =_ge ;_da .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 (_gbe .Params )!=2{return _ecf ;};_dae ,_aaf :=_cbf .GetArray (_gbe .Params [0]);
|
|
|
|
if !_aaf {return _be ;};_gca ,_aaf :=_cbf .GetIntVal (_gbe .Params [1]);if !_aaf {return _be ;};_dac ,_bda :=_cbf .GetNumbersAsFloat (_dae .Elements ());if _bda !=nil {return _bda ;};_fbg .SetDash (_dac ...);_ =_gca ;_da .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":_da .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":_da .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 (_gbe .Params )!=1{return _ecf ;};_bgc ,_cgf :=_cbf .GetName (_gbe .Params [0]);if !_cgf {return _be ;};if _bgc ==nil {return _ecf ;};_df ,_cgf :=_ecd .GetExtGState (*_bgc );if !_cgf {_da .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",*_bgc );
|
|
|
|
return _c .New ("\u0072e\u0073o\u0075\u0072\u0063\u0065\u0020n\u006f\u0074 \u0066\u006f\u0075\u006e\u0064");};_abga ,_cgf :=_cbf .GetDict (_df );if !_cgf {_da .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 _be ;};_da .Log .Debug ("G\u0053\u0020\u0064\u0069\u0063\u0074\u003a\u0020\u0025\u0073",_abga .String ());case "\u006d":if len (_gbe .Params )!=2{_da .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",_ecf );
|
|
|
|
return nil ;};_gfe ,_gfd :=_cbf .GetNumbersAsFloat (_gbe .Params );if _gfd !=nil {return _gfd ;};_da .Log .Debug ("M\u006f\u0076\u0065\u0020\u0074\u006f\u003a\u0020\u0025\u0076",_gfe );_fbg .NewSubPath ();_fbg .MoveTo (_gfe [0],_gfe [1]);case "\u006c":if len (_gbe .Params )!=2{_da .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",_ecf );
|
|
|
|
return nil ;};_cae ,_efd :=_cbf .GetNumbersAsFloat (_gbe .Params );if _efd !=nil {return _efd ;};_fbg .LineTo (_cae [0],_cae [1]);case "\u0063":if len (_gbe .Params )!=6{return _ecf ;};_ce ,_eg :=_cbf .GetNumbersAsFloat (_gbe .Params );if _eg !=nil {return _eg ;
|
|
|
|
};_da .Log .Debug ("\u0043u\u0062\u0069\u0063\u0020\u0062\u0065\u007a\u0069\u0065\u0072\u0020p\u0061\u0072\u0061\u006d\u0073\u003a\u0020\u0025\u002b\u0076",_ce );_fbg .CubicTo (_ce [0],_ce [1],_ce [2],_ce [3],_ce [4],_ce [5]);case "\u0076","\u0079":if len (_gbe .Params )!=4{return _ecf ;
|
|
|
|
};_fg ,_fdc :=_cbf .GetNumbersAsFloat (_gbe .Params );if _fdc !=nil {return _fdc ;};_da .Log .Debug ("\u0043u\u0062\u0069\u0063\u0020\u0062\u0065\u007a\u0069\u0065\u0072\u0020p\u0061\u0072\u0061\u006d\u0073\u003a\u0020\u0025\u002b\u0076",_fg );_fbg .QuadraticTo (_fg [0],_fg [1],_fg [2],_fg [3]);
|
|
|
|
case "\u0068":_fbg .ClosePath ();_fbg .NewSubPath ();case "\u0072\u0065":if len (_gbe .Params )!=4{return _ecf ;};_bcf ,_dda :=_cbf .GetNumbersAsFloat (_gbe .Params );if _dda !=nil {return _dda ;};_fbg .DrawRectangle (_bcf [0],_bcf [1],_bcf [2],_bcf [3]);
|
|
|
|
_fbg .NewSubPath ();case "\u0053":_bb ,_bgb :=_cgdf .ColorspaceStroking .ColorToRGB (_cgdf .ColorStroking );if _bgb !=nil {_da .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",_bgb );
|
|
|
|
return _bgb ;};_ee ,_cfb :=_bb .(*_ca .PdfColorDeviceRGB );if !_cfb {_da .Log .Debug ("\u0045\u0072\u0072\u006fr \u0063\u006f\u006e\u0076\u0065\u0072\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006co\u0072");return _bgb ;};_fbg .SetRGBA (_ee .R (),_ee .G (),_ee .B (),1);
|
|
|
|
_fbg .Stroke ();case "\u0073":_bfc ,_ad :=_cgdf .ColorspaceStroking .ColorToRGB (_cgdf .ColorStroking );if _ad !=nil {_da .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",_ad );
|
|
|
|
return _ad ;};_cgca ,_bcd :=_bfc .(*_ca .PdfColorDeviceRGB );if !_bcd {_da .Log .Debug ("\u0045\u0072\u0072\u006fr \u0063\u006f\u006e\u0076\u0065\u0072\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006co\u0072");return _ad ;};_fbg .ClosePath ();_fbg .NewSubPath ();
|
|
|
|
_fbg .SetRGBA (_cgca .R (),_cgca .G (),_cgca .B (),1);_fbg .Stroke ();case "\u0066","\u0046":_bba ,_ecfa :=_cgdf .ColorspaceNonStroking .ColorToRGB (_cgdf .ColorNonStroking );if _ecfa !=nil {_da .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",_ecfa );
|
|
|
|
return _ecfa ;};_ecg ,_dbb :=_bba .(*_ca .PdfColorDeviceRGB );if !_dbb {_da .Log .Debug ("\u0045\u0072\u0072\u006fr \u0063\u006f\u006e\u0076\u0065\u0072\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006co\u0072");return _ecfa ;};_fbg .SetRGBA (_ecg .R (),_ecg .G (),_ecg .B (),1);
|
|
|
|
_fbg .SetFillRule (_aa .FillRuleWinding );_fbg .Fill ();case "\u0066\u002a":_ae ,_ac :=_cgdf .ColorspaceNonStroking .ColorToRGB (_cgdf .ColorNonStroking );if _ac !=nil {_da .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",_ac );
|
|
|
|
return _ac ;};_feb ,_acg :=_ae .(*_ca .PdfColorDeviceRGB );if !_acg {_da .Log .Debug ("\u0045\u0072\u0072\u006fr \u0063\u006f\u006e\u0076\u0065\u0072\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006co\u0072");return _ac ;};_fbg .SetRGBA (_feb .R (),_feb .G (),_feb .B (),1);
|
|
|
|
_fbg .SetFillRule (_aa .FillRuleEvenOdd );_fbg .Fill ();case "\u0042":_efb ,_ead :=_cgdf .ColorspaceNonStroking .ColorToRGB (_cgdf .ColorNonStroking );if _ead !=nil {_da .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",_ead );
|
|
|
|
return _ead ;};_ccd :=_efb .(*_ca .PdfColorDeviceRGB );_fbg .SetRGBA (_ccd .R (),_ccd .G (),_ccd .B (),1);_fbg .SetFillRule (_aa .FillRuleWinding );_fbg .FillPreserve ();_efb ,_ead =_cgdf .ColorspaceStroking .ColorToRGB (_cgdf .ColorStroking );if _ead !=nil {_da .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",_ead );
|
|
|
|
return _ead ;};_ccd =_efb .(*_ca .PdfColorDeviceRGB );_fbg .SetRGBA (_ccd .R (),_ccd .G (),_ccd .B (),1);_fbg .Stroke ();case "\u0042\u002a":_gd ,_bade :=_cgdf .ColorspaceNonStroking .ColorToRGB (_cgdf .ColorNonStroking );if _bade !=nil {_da .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",_bade );
|
|
|
|
return _bade ;};_acd :=_gd .(*_ca .PdfColorDeviceRGB );_fbg .SetRGBA (_acd .R (),_acd .G (),_acd .B (),1);_fbg .SetFillRule (_aa .FillRuleEvenOdd );_fbg .FillPreserve ();_gd ,_bade =_cgdf .ColorspaceStroking .ColorToRGB (_cgdf .ColorStroking );if _bade !=nil {_da .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",_bade );
|
|
|
|
return _bade ;};_acd =_gd .(*_ca .PdfColorDeviceRGB );_fbg .SetRGBA (_acd .R (),_acd .G (),_acd .B (),1);_fbg .Stroke ();case "\u0062":_bee ,_aca :=_cgdf .ColorspaceNonStroking .ColorToRGB (_cgdf .ColorNonStroking );if _aca !=nil {_da .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",_aca );
|
|
|
|
return _aca ;};_fbgc :=_bee .(*_ca .PdfColorDeviceRGB );_fbg .SetRGBA (_fbgc .R (),_fbgc .G (),_fbgc .B (),1);_fbg .ClosePath ();_fbg .NewSubPath ();_fbg .SetFillRule (_aa .FillRuleWinding );_fbg .FillPreserve ();_bee ,_aca =_cgdf .ColorspaceStroking .ColorToRGB (_cgdf .ColorStroking );
|
|
|
|
if _aca !=nil {_da .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",_aca );return _aca ;};_fbgc =_bee .(*_ca .PdfColorDeviceRGB );_fbg .SetRGBA (_fbgc .R (),_fbgc .G (),_fbgc .B (),1);
|
|
|
|
_fbg .Stroke ();case "\u0062\u002a":_fbg .ClosePath ();_dfa ,_cbcf :=_cgdf .ColorspaceNonStroking .ColorToRGB (_cgdf .ColorNonStroking );if _cbcf !=nil {_da .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",_cbcf );
|
|
|
|
return _cbcf ;};_bbe :=_dfa .(*_ca .PdfColorDeviceRGB );_fbg .SetRGBA (_bbe .R (),_bbe .G (),_bbe .B (),1);_fbg .NewSubPath ();_fbg .SetFillRule (_aa .FillRuleEvenOdd );_fbg .FillPreserve ();_dfa ,_cbcf =_cgdf .ColorspaceStroking .ColorToRGB (_cgdf .ColorStroking );
|
|
|
|
if _cbcf !=nil {_da .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",_cbcf );return _cbcf ;};_bbe =_dfa .(*_ca .PdfColorDeviceRGB );_fbg .SetRGBA (_bbe .R (),_bbe .G (),_bbe .B (),1);
|
|
|
|
_fbg .Stroke ();case "\u006e":_fbg .ClearPath ();case "\u0057":_fbg .SetFillRule (_aa .FillRuleWinding );_fbg .ClipPreserve ();case "\u0057\u002a":_fbg .SetFillRule (_aa .FillRuleEvenOdd );_fbg .ClipPreserve ();case "\u0072\u0067":_bfce ,_dc :=_cgdf .ColorNonStroking .(*_ca .PdfColorDeviceRGB );
|
|
|
|
if !_dc {_da .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",_cgdf .ColorNonStroking );return nil ;};_fbg .SetFillRGBA (_bfce .R (),_bfce .G (),_bfce .B (),1);
|
|
|
|
case "\u0052\u0047":_eee ,_aeb :=_cgdf .ColorStroking .(*_ca .PdfColorDeviceRGB );if !_aeb {_da .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",_cgdf .ColorStroking );
|
|
|
|
return nil ;};_fbg .SetStrokeRGBA (_eee .R (),_eee .G (),_eee .B (),1);case "\u006b":_eef ,_ebce :=_cgdf .ColorNonStroking .(*_ca .PdfColorDeviceCMYK );if !_ebce {_da .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",_cgdf .ColorNonStroking );
|
|
|
|
return nil ;};_eag ,_ffb :=_cgdf .ColorspaceNonStroking .ColorToRGB (_eef );if _ffb !=nil {_da .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",_cgdf .ColorNonStroking );
|
|
|
|
return nil ;};_caa ,_ebce :=_eag .(*_ca .PdfColorDeviceRGB );if !_ebce {_da .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",_eag );return nil ;
|
|
|
|
};_fbg .SetFillRGBA (_caa .R (),_caa .G (),_caa .B (),1);case "\u004b":_cdc ,_aada :=_cgdf .ColorStroking .(*_ca .PdfColorDeviceCMYK );if !_aada {_da .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",_cgdf .ColorStroking );
|
|
|
|
return nil ;};_dbbg ,_ceg :=_cgdf .ColorspaceStroking .ColorToRGB (_cdc );if _ceg !=nil {_da .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",_cgdf .ColorStroking );
|
|
|
|
return nil ;};_ddgc ,_aada :=_dbbg .(*_ca .PdfColorDeviceRGB );if !_aada {_da .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",_dbbg );return nil ;
|
|
|
|
};_fbg .SetStrokeRGBA (_ddgc .R (),_ddgc .G (),_ddgc .B (),1);case "\u0067":_cdf ,_cef :=_cgdf .ColorNonStroking .(*_ca .PdfColorDeviceGray );if !_cef {_da .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",_cgdf .ColorNonStroking );
|
|
|
|
return nil ;};_dggb ,_caea :=_cgdf .ColorspaceNonStroking .ColorToRGB (_cdf );if _caea !=nil {_da .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",_cgdf .ColorNonStroking );
|
|
|
|
return nil ;};_cege ,_cef :=_dggb .(*_ca .PdfColorDeviceRGB );if !_cef {_da .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",_dggb );return nil ;
|
|
|
|
};_fbg .SetFillRGBA (_cege .R (),_cege .G (),_cege .B (),1);case "\u0047":_acb ,_baef :=_cgdf .ColorStroking .(*_ca .PdfColorDeviceGray );if !_baef {_da .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",_cgdf .ColorStroking );
|
|
|
|
return nil ;};_bbac ,_cfba :=_cgdf .ColorspaceStroking .ColorToRGB (_acb );if _cfba !=nil {_da .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",_cgdf .ColorStroking );
|
|
|
|
return nil ;};_afee ,_baef :=_bbac .(*_ca .PdfColorDeviceRGB );if !_baef {_da .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",_bbac );return nil ;
|
|
|
|
};_fbg .SetStrokeRGBA (_afee .R (),_afee .G (),_afee .B (),1);case "\u0063\u0073","\u0073\u0063","\u0073\u0063\u006e":_bfa ,_gad :=_cgdf .ColorspaceNonStroking .ColorToRGB (_cgdf .ColorNonStroking );if _gad !=nil {_da .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",_cgdf .ColorNonStroking );
|
|
|
|
return nil ;};_ddf ,_ddga :=_bfa .(*_ca .PdfColorDeviceRGB );if !_ddga {_da .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",_bfa );return nil ;
|
|
|
|
};_fbg .SetFillRGBA (_ddf .R (),_ddf .G (),_ddf .B (),1);case "\u0043\u0053","\u0053\u0043","\u0053\u0043\u004e":_caag ,_fad :=_cgdf .ColorspaceStroking .ColorToRGB (_cgdf .ColorStroking );if _fad !=nil {_da .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",_cgdf .ColorStroking );
|
|
|
|
return nil ;};_cga ,_dcb :=_caag .(*_ca .PdfColorDeviceRGB );if !_dcb {_da .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",_caag );return nil ;
|
|
|
|
};_fbg .SetStrokeRGBA (_cga .R (),_cga .G (),_cga .B (),1);case "\u0044\u006f":if len (_gbe .Params )!=1{return _ecf ;};_gcag ,_abb :=_cbf .GetName (_gbe .Params [0]);if !_abb {return _be ;};_ ,_edf :=_ecd .GetXObjectByName (*_gcag );switch _edf {case _ca .XObjectTypeImage :_da .Log .Debug ("\u0058\u004f\u0062\u006a\u0065\u0063\u0074\u0020\u0069\u006d\u0061\u0067e\u003a\u0020\u0025\u0073",_gcag .String ());
|
|
|
|
_cfc ,_gae :=_ecd .GetXObjectImageByName (*_gcag );if _gae !=nil {return _gae ;};_efdg ,_gae :=_cfc .ToImage ();if _gae !=nil {return _gae ;};if _ffd :=_cfc .ColorSpace ;_ffd !=nil {var _cdd bool ;switch _ffd .(type ){case *_ca .PdfColorspaceSpecialIndexed :_cdd =true ;
|
|
|
|
};if _cdd {if _bdd ,_cba :=_ffd .ImageToRGB (*_efdg );_cba !=nil {_da .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 {_efdg =&_bdd ;};};};_geb :=_fbg .FillPattern ().ColorAt (0,0);var _cee _abg .Image ;if _cfc .Mask !=nil {if _cee ,_gae =_eae (_cfc .Mask ,_geb );_gae !=nil {_da .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 _cfc .SMask !=nil {if _cee ,_gae =_baeg (_cfc .SMask ,_geb );_gae !=nil {_da .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 _ccdb _abg .Image ;if _gbee ,_ :=_cbf .GetBoolVal (_cfc .ImageMask );_gbee {_ccdb =_bbb (_efdg ,_geb );}else {_ccdb ,_gae =_efdg .ToGoImage ();if _gae !=nil {return _gae ;};};if _cee !=nil {_ccdb =_bbcf (_ccdb ,_cee );};_gdb :=_ccdb .Bounds ();
|
|
|
|
_fbg .Push ();_fbg .Scale (1.0/float64 (_gdb .Dx ()),-1.0/float64 (_gdb .Dy ()));_fbg .DrawImageAnchored (_ccdb ,0,0,0,1);_fbg .Pop ();case _ca .XObjectTypeForm :_da .Log .Debug ("\u0058\u004fb\u006a\u0065\u0063t\u0020\u0066\u006f\u0072\u006d\u003a\u0020\u0025\u0073",_gcag .String ());
|
|
|
|
_cdg ,_fca :=_ecd .GetXObjectFormByName (*_gcag );if _fca !=nil {return _fca ;};_ebf ,_fca :=_cdg .GetContentStream ();if _fca !=nil {return _fca ;};_abd :=_cdg .Resources ;if _abd ==nil {_abd =_ecd ;};_fbg .Push ();if _cdg .Matrix !=nil {_fdf ,_ffba :=_cbf .GetArray (_cdg .Matrix );
|
|
|
|
if !_ffba {return _be ;};_cgab ,_gba :=_cbf .GetNumbersAsFloat (_fdf .Elements ());if _gba !=nil {return _gba ;};if len (_cgab )!=6{return _ecf ;};_egf :=_eb .NewMatrix (_cgab [0],_cgab [1],_cgab [2],_cgab [3],_cgab [4],_cgab [5]);_fbg .SetMatrix (_fbg .Matrix ().Mult (_egf ));
|
|
|
|
};if _cdg .BBox !=nil {_ebea ,_bgfd :=_cbf .GetArray (_cdg .BBox );if !_bgfd {return _be ;};_bed ,_cda :=_cbf .GetNumbersAsFloat (_ebea .Elements ());if _cda !=nil {return _cda ;};if len (_bed )!=4{_da .Log .Debug ("\u004c\u0065\u006e\u0020\u003d\u0020\u0025\u0064",len (_bed ));
|
|
|
|
return _ecf ;};_fbg .DrawRectangle (_bed [0],_bed [1],_bed [2]-_bed [0],_bed [3]-_bed [1]);_fbg .SetRGBA (1,0,0,1);_fbg .Clip ();}else {_da .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");
|
|
|
|
};_fca =_dggf .renderContentStream (_fbg ,string (_ebf ),_abd );if _fca !=nil {return _fca ;};_fbg .Pop ();};case "\u0042\u0049":if len (_gbe .Params )!=1{return _ecf ;};_eea ,_cde :=_gbe .Params [0].(*_cd .ContentStreamInlineImage );if !_cde {return nil ;
|
|
|
|
};_bec ,_edg :=_eea .ToImage (_ecd );if _edg !=nil {return _edg ;};_ddag ,_edg :=_bec .ToGoImage ();if _edg !=nil {return _edg ;};_dfac :=_ddag .Bounds ();_fbg .Push ();_fbg .Scale (1.0/float64 (_dfac .Dx ()),-1.0/float64 (_dfac .Dy ()));_fbg .DrawImageAnchored (_ddag ,0,0,0,1);
|
|
|
|
_fbg .Pop ();case "\u0042\u0054":_debc .Reset ();case "\u0045\u0054":_debc .Reset ();case "\u0054\u0072":if len (_gbe .Params )!=1{return _ecf ;};_afeea ,_fef :=_cbf .GetNumberAsFloat (_gbe .Params [0]);if _fef !=nil {return _fef ;};_debc .Tr =_aa .TextRenderingMode (_afeea );
|
|
|
|
case "\u0054\u004c":if len (_gbe .Params )!=1{return _ecf ;};_afa ,_bgfdd :=_cbf .GetNumberAsFloat (_gbe .Params [0]);if _bgfdd !=nil {return _bgfdd ;};_debc .Tl =_afa ;case "\u0054\u0063":if len (_gbe .Params )!=1{return _ecf ;};_abad ,_fed :=_cbf .GetNumberAsFloat (_gbe .Params [0]);
|
|
|
|
if _fed !=nil {return _fed ;};_da .Log .Debug ("\u0054\u0063\u003a\u0020\u0025\u0076",_abad );_debc .Tc =_abad ;case "\u0054\u0077":if len (_gbe .Params )!=1{return _ecf ;};_eeg ,_faf :=_cbf .GetNumberAsFloat (_gbe .Params [0]);if _faf !=nil {return _faf ;
|
|
|
|
};_da .Log .Debug ("\u0054\u0077\u003a\u0020\u0025\u0076",_eeg );_debc .Tw =_eeg ;case "\u0054\u007a":if len (_gbe .Params )!=1{return _ecf ;};_eec ,_afac :=_cbf .GetNumberAsFloat (_gbe .Params [0]);if _afac !=nil {return _afac ;};_debc .Th =_eec ;case "\u0054\u0073":if len (_gbe .Params )!=1{return _ecf ;
|
|
|
|
};_bgbc ,_gcd :=_cbf .GetNumberAsFloat (_gbe .Params [0]);if _gcd !=nil {return _gcd ;};_debc .Ts =_bgbc ;case "\u0054\u0064":if len (_gbe .Params )!=2{return _ecf ;};_aaa ,_cfe :=_cbf .GetNumbersAsFloat (_gbe .Params );if _cfe !=nil {return _cfe ;};_da .Log .Debug ("\u0054\u0064\u003a\u0020\u0025\u0076",_aaa );
|
|
|
|
_debc .ProcTd (_aaa [0],_aaa [1]);case "\u0054\u0044":if len (_gbe .Params )!=2{return _ecf ;};_gbc ,_bgcb :=_cbf .GetNumbersAsFloat (_gbe .Params );if _bgcb !=nil {return _bgcb ;};_da .Log .Debug ("\u0054\u0044\u003a\u0020\u0025\u0076",_gbc );_debc .ProcTD (_gbc [0],_gbc [1]);
|
|
|
|
case "\u0054\u002a":_debc .ProcTStar ();case "\u0054\u006d":if len (_gbe .Params )!=6{return _ecf ;};_dff ,_dgf :=_cbf .GetNumbersAsFloat (_gbe .Params );if _dgf !=nil {return _dgf ;};_da .Log .Debug ("\u0054\u0065x\u0074\u0020\u006da\u0074\u0072\u0069\u0078\u003a\u0020\u0025\u002b\u0076",_dff );
|
|
|
|
_debc .ProcTm (_dff [0],_dff [1],_dff [2],_dff [3],_dff [4],_dff [5]);case "\u0027":if len (_gbe .Params )!=1{return _ecf ;};_cff ,_ccf :=_cbf .GetStringBytes (_gbe .Params [0]);if !_ccf {return _be ;};_da .Log .Debug ("\u0027\u0020\u0073t\u0072\u0069\u006e\u0067\u003a\u0020\u0025\u0073",string (_cff ));
|
|
|
|
_debc .ProcQ (_cff ,_fbg );case "\u0022":if len (_gbe .Params )!=3{return _ecf ;};_cfbf ,_eagf :=_cbf .GetNumberAsFloat (_gbe .Params [0]);if _eagf !=nil {return _eagf ;};_egc ,_eagf :=_cbf .GetNumberAsFloat (_gbe .Params [1]);if _eagf !=nil {return _eagf ;
|
|
|
|
};_fbc ,_abdf :=_cbf .GetStringBytes (_gbe .Params [2]);if !_abdf {return _be ;};_debc .ProcDQ (_fbc ,_cfbf ,_egc ,_fbg );case "\u0054\u006a":if len (_gbe .Params )!=1{return _ecf ;};_gab ,_bbc :=_cbf .GetStringBytes (_gbe .Params [0]);if !_bbc {return _be ;
|
|
|
|
};_da .Log .Debug ("\u0054j\u0020s\u0074\u0072\u0069\u006e\u0067\u003a\u0020\u0060\u0025\u0073\u0060",string (_gab ));_debc .ProcTj (_gab ,_fbg );case "\u0054\u004a":if len (_gbe .Params )!=1{return _ecf ;};_cgb ,_eaa :=_cbf .GetArray (_gbe .Params [0]);
|
|
|
|
if !_eaa {_da .Log .Debug ("\u0054\u0079\u0070\u0065\u003a\u0020\u0025\u0054",_cgb );return _be ;};_da .Log .Debug ("\u0054\u004a\u0020\u0061\u0072\u0072\u0061\u0079\u003a\u0020\u0025\u002b\u0076",_cgb );for _ ,_eac :=range _cgb .Elements (){switch _ded :=_eac .(type ){case *_cbf .PdfObjectString :if _ded !=nil {_debc .ProcTj (_ded .Bytes (),_fbg );
|
|
|
|
};case *_cbf .PdfObjectFloat ,*_cbf .PdfObjectInteger :_aea ,_dgfa :=_cbf .GetNumberAsFloat (_ded );if _dgfa ==nil {_debc .Translate (-_aea *0.001*_debc .Tf .Size *_debc .Th /100.0,0);};};};case "\u0054\u0066":if len (_gbe .Params )!=2{return _ecf ;};_da .Log .Debug ("\u0025\u0023\u0076",_gbe .Params );
|
|
|
|
_gaef ,_eacd :=_cbf .GetName (_gbe .Params [0]);if !_eacd ||_gaef ==nil {_da .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",_gbe .Params [0]);
|
|
|
|
return _be ;};_da .Log .Debug ("\u0046\u006f\u006e\u0074\u0020\u006e\u0061\u006d\u0065\u003a\u0020\u0025\u0073",_gaef .String ());_eff ,_gef :=_cbf .GetNumberAsFloat (_gbe .Params [1]);if _gef !=nil {_da .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",_gbe .Params [1]);
|
|
|
|
return _be ;};_da .Log .Debug ("\u0046\u006f\u006e\u0074\u0020\u0073\u0069\u007a\u0065\u003a\u0020\u0025\u0076",_eff );_bddf ,_edd :=_ecd .GetFontByName (*_gaef );if !_edd {_da .Log .Debug ("\u0045R\u0052\u004f\u0052\u003a\u0020\u0046\u006f\u006e\u0074\u0020\u0025s\u0020\u006e\u006f\u0074\u0020\u0066\u006f\u0075\u006e\u0064",_gaef .String ());
|
|
|
|
return _c .New ("\u0066\u006f\u006e\u0074\u0020\u006e\u006f\u0074\u0020f\u006f\u0075\u006e\u0064");};_da .Log .Debug ("\u0046\u006f\u006e\u0074\u003a\u0020\u0025\u0054",_bddf );_bcdb ,_eacd :=_cbf .GetDict (_bddf );if !_eacd {_da .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 _be ;};_dffe ,_gef :=_ca .NewPdfFontFromPdfObject (_bcdb );if _gef !=nil {_da .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 _gef ;};_bgd :=_dffe .BaseFont ();if _bgd ==""{_bgd =_gaef .String ();};_gcagf ,_eacd :=_ddg [_bgd ];if !_eacd {_gcagf ,_gef =_aa .NewTextFont (_dffe ,_eff );if _gef !=nil {_da .Log .Debug ("\u0045R\u0052\u004f\u0052\u003a\u0020\u0025v",_gef );};
|
|
|
|
};if _gcagf ==nil {if len (_bgd )> 7&&_bgd [6]=='+'{_bgd =_bgd [7:];};_dbg :=[]string {_bgd ,"\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 _ ,_ecdd :=range _dbg {_da .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",_ecdd );if _gcagf ,_eacd =_ddg [_ecdd ];
|
|
|
|
_eacd {break ;};_bdaa :=_ggd .Match (_ecdd );if _bdaa ==nil {_da .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",_ecdd );continue ;};_gcagf ,_gef =_aa .NewTextFontFromPath (_bdaa .Filename ,_eff );
|
|
|
|
if _gef !=nil {_da .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",_bdaa .Filename );continue ;};_da .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",_bgd ,_bdaa .Name ,_bdaa .Filename );
|
|
|
|
_ddg [_ecdd ]=_gcagf ;break ;};};if _gcagf ==nil {_da .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 _c .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");};_debc .ProcTf (_gcagf .WithSize (_eff ,_dffe ));
|
|
|
|
case "\u0042\u004d\u0043","\u0042\u0044\u0043":case "\u0045\u004d\u0043":default:_da .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",_gbe .Operand );
|
|
|
|
};return nil ;});_db =_fde .Process (_gf );if _db !=nil {return _db ;};return nil ;};var (_be =_c .New ("\u0074\u0079p\u0065\u0020\u0063h\u0065\u0063\u006b\u0020\u0065\u0072\u0072\u006f\u0072");_ecf =_c .New ("\u0072\u0061\u006e\u0067\u0065\u0020\u0063\u0068\u0065\u0063\u006b\u0020e\u0072\u0072\u006f\u0072");
|
|
|
|
);func _eca (_gfc string ,_fdeb _abg .Image )error {_ffc ,_fba :=_cf .Create (_gfc );if _fba !=nil {return _fba ;};defer _ffc .Close ();return _dg .Encode (_ffc ,_fdeb );};func _bbcf (_dba ,_cec _abg .Image )_abg .Image {_cdcg ,_add :=_cec .Bounds ().Size (),_dba .Bounds ().Size ();
|
|
|
|
_age ,_ebcc :=_cdcg .X ,_cdcg .Y ;if _add .X > _age {_age =_add .X ;};if _add .Y > _ebcc {_ebcc =_add .Y ;};_fab :=_abg .Rect (0,0,_age ,_ebcc );if _cdcg .X !=_age ||_cdcg .Y !=_ebcc {_abgc :=_abg .NewRGBA (_fab );_ba .BiLinear .Scale (_abgc ,_fab ,_dba ,_cec .Bounds (),_ba .Over ,nil );
|
|
|
|
_cec =_abgc ;};if _add .X !=_age ||_add .Y !=_ebcc {_efc :=_abg .NewRGBA (_fab );_ba .BiLinear .Scale (_efc ,_fab ,_dba ,_dba .Bounds (),_ba .Over ,nil );_dba =_efc ;};_bgce :=_abg .NewRGBA (_fab );_ba .DrawMask (_bgce ,_fab ,_dba ,_abg .Point {},_cec ,_abg .Point {},_ba .Over );
|
|
|
|
return _bgce ;};
|
2022-06-06 22:48:24 +00:00
|
|
|
|
|
|
|
// RenderToPath converts the specified PDF page into an image and saves the
|
|
|
|
// result at the specified location.
|
2022-07-13 21:28:43 +00:00
|
|
|
func (_gb *ImageDevice )RenderToPath (page *_ca .PdfPage ,outputPath string )error {_feaf ,_aag :=_gb .Render (page );if _aag !=nil {return _aag ;};_aac :=_e .ToLower (_a .Ext (outputPath ));if _aac ==""{return _c .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 _aac {case "\u002e\u0070\u006e\u0067":return _eca (outputPath ,_feaf );case "\u002e\u006a\u0070\u0067","\u002e\u006a\u0070e\u0067":return _cfff (outputPath ,_feaf ,100);};return _b .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",_aac );
|
|
|
|
};func _eae (_efff _cbf .PdfObject ,_feda _ea .Color )(_abg .Image ,error ){_ace ,_adb :=_cbf .GetStream (_efff );if !_adb {return nil ,nil ;};_dga ,_fbge :=_ca .NewXObjectImageFromStream (_ace );if _fbge !=nil {return nil ,_fbge ;};_fbcc ,_fbge :=_dga .ToImage ();
|
|
|
|
if _fbge !=nil {return nil ,_fbge ;};return _bbb (_fbcc ,_feda ),nil ;};func _baeg (_abc _cbf .PdfObject ,_cfcb _ea .Color )(_abg .Image ,error ){_ece ,_fafe :=_cbf .GetStream (_abc );if !_fafe {return nil ,nil ;};_abca ,_gdg :=_ca .NewXObjectImageFromStream (_ece );
|
|
|
|
if _gdg !=nil {return nil ,_gdg ;};_ega ,_gdg :=_abca .ToImage ();if _gdg !=nil {return nil ,_gdg ;};return _ceeb (_ega ,_cfcb ),nil ;};func _ceeb (_dbab *_ca .Image ,_fgg _ea .Color )_abg .Image {_efde ,_edc :=int (_dbab .Width ),int (_dbab .Height );
|
|
|
|
_cbbb :=_abg .NewRGBA (_abg .Rect (0,0,_efde ,_edc ));for _cdef :=0;_cdef < _edc ;_cdef ++{for _cfbg :=0;_cfbg < _efde ;_cfbg ++{_edab ,_cace :=_dbab .ColorAt (_cfbg ,_cdef );if _cace !=nil {_da .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",_cfbg ,_cdef );
|
|
|
|
continue ;};_egb ,_bde ,_bedf ,_ :=_edab .RGBA ();var _gdf _ea .Color ;if _egb +_bde +_bedf ==0{_gdf =_ea .Transparent ;}else {_gdf =_fgg ;};_cbbb .Set (_cfbg ,_cdef ,_gdf );};};return _cbbb ;};func _cfff (_fefc string ,_cgcb _abg .Image ,_gda int )error {_aacg ,_cbb :=_cf .Create (_fefc );
|
|
|
|
if _cbb !=nil {return _cbb ;};defer _aacg .Close ();return _ab .Encode (_aacg ,_cgcb ,&_ab .Options {Quality :_gda });};
|
2022-06-06 22:48:24 +00:00
|
|
|
|
|
|
|
// Render converts the specified PDF page into an image and returns the result.
|
2022-07-13 21:28:43 +00:00
|
|
|
func (_bd *ImageDevice )Render (page *_ca .PdfPage )(_abg .Image ,error ){_g ,_bg :=page .GetMediaBox ();if _bg !=nil {return nil ,_bg ;};_g .Normalize ();_cc :=page .CropBox ;var _fe ,_cbfg float64 ;if _cc !=nil {_cc .Normalize ();_fe ,_cbfg =_cc .Width (),_cc .Height ();
|
|
|
|
};_cg :=page .Rotate ;_ccc ,_ga ,_eba ,_ec :=_g .Llx ,_g .Lly ,_g .Width (),_g .Height ();_bfb :=_eb .IdentityMatrix ();if _cg !=nil &&*_cg %360!=0&&*_cg %90==0{_dd :=-float64 (*_cg );_de :=_gge (_eba ,_ec ,_dd );_bfb =_bfb .Translate ((_de .Width -_eba )/2+_eba /2,(_de .Height -_ec )/2+_ec /2).Rotate (_dd *_f .Pi /180).Translate (-_eba /2,-_ec /2);
|
|
|
|
_eba ,_ec =_de .Width ,_de .Height ;if _cc !=nil {_fea :=_gge (_fe ,_cbfg ,_dd );_fe ,_cbfg =_fea .Width ,_fea .Height ;};};if _ccc !=0||_ga !=0{_bfb =_bfb .Translate (-_ccc ,-_ga );};_bd ._ebe =1.0;if _bd .OutputWidth !=0{_fb :=_eba ;if _cc !=nil {_fb =_fe ;
|
|
|
|
};_bd ._ebe =float64 (_bd .OutputWidth )/_fb ;_eba ,_ec ,_fe ,_cbfg =_eba *_bd ._ebe ,_ec *_bd ._ebe ,_fe *_bd ._ebe ,_cbfg *_bd ._ebe ;_bfb =_eb .ScaleMatrix (_bd ._ebe ,_bd ._ebe ).Mult (_bfb );};_cac :=_bad .NewContext (int (_eba ),int (_ec ));if _cgg :=_bd .renderPage (_cac ,page ,_bfb );
|
|
|
|
_cgg !=nil {return nil ,_cgg ;};_gg :=_cac .Image ();if _cc !=nil {_dgg ,_ebc :=(_cc .Llx -_ccc )*_bd ._ebe ,(_cc .Lly -_ga )*_bd ._ebe ;_baf :=_abg .Rect (0,0,int (_fe ),int (_cbfg ));_fa :=_abg .Pt (int (_dgg ),int (_ec -_ebc -_cbfg ));_fc :=_abg .NewRGBA (_baf );
|
|
|
|
_cb .Draw (_fc ,_baf ,_gg ,_fa ,_cb .Src );_gg =_fc ;};return _gg ,nil ;};func _bbb (_ecfe *_ca .Image ,_cdb _ea .Color )_abg .Image {_aagf ,_eda :=int (_ecfe .Width ),int (_ecfe .Height );_bcc :=_abg .NewRGBA (_abg .Rect (0,0,_aagf ,_eda ));for _gde :=0;
|
|
|
|
_gde < _eda ;_gde ++{for _cdad :=0;_cdad < _aagf ;_cdad ++{_geg ,_efdb :=_ecfe .ColorAt (_cdad ,_gde );if _efdb !=nil {_da .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",_cdad ,_gde );
|
|
|
|
continue ;};_gbb ,_baa ,_cfcd ,_ :=_geg .RGBA ();var _eeee _ea .Color ;if _gbb +_baa +_cfcd ==0{_eeee =_cdb ;}else {_eeee =_ea .Transparent ;};_bcc .Set (_cdad ,_gde ,_eeee );};};return _bcc ;};func _gge (_bdce ,_dcd ,_afacg float64 )_bf .BoundingBox {return _bf .Path {Points :[]_bf .Point {_bf .NewPoint (0,0).Rotate (_afacg ),_bf .NewPoint (_bdce ,0).Rotate (_afacg ),_bf .NewPoint (0,_dcd ).Rotate (_afacg ),_bf .NewPoint (_bdce ,_dcd ).Rotate (_afacg )}}.GetBoundingBox ();
|
|
|
|
};type renderer struct{_ebe float64 };
|
2021-04-23 20:28:14 +00:00
|
|
|
|
2021-05-11 00:01:27 +00:00
|
|
|
// 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.
|
2022-07-13 21:28:43 +00:00
|
|
|
OutputWidth int ;};
|
|
|
|
|
|
|
|
// NewImageDevice returns a new image device.
|
|
|
|
func NewImageDevice ()*ImageDevice {const _afc ="r\u0065\u006e\u0064\u0065r.\u004ee\u0077\u0049\u006d\u0061\u0067e\u0044\u0065\u0076\u0069\u0063\u0065";_af .TrackUse (_afc );return &ImageDevice {};};
|