mirror of
https://github.com/unidoc/unipdf.git
synced 2025-04-26 13:48:55 +08:00
144 lines
37 KiB
Go
144 lines
37 KiB
Go
//
|
|
// Copyright 2020 FoxyUtils ehf. All rights reserved.
|
|
//
|
|
// This is a commercial product and requires a license to operate.
|
|
// A trial license can be obtained at https://unidoc.io
|
|
//
|
|
// DO NOT EDIT: generated by unitwist Go source code obfuscator.
|
|
//
|
|
// Use of this source code is governed by the UniDoc End User License Agreement
|
|
// terms that can be accessed at https://unidoc.io/eula/
|
|
|
|
package render ;import (_b "errors";_abb "fmt";_fbc "github.com/adrg/sysfont";_c "github.com/unidoc/unipdf/v3/common";_fb "github.com/unidoc/unipdf/v3/contentstream";_adb "github.com/unidoc/unipdf/v3/contentstream/draw";_ac "github.com/unidoc/unipdf/v3/core";
|
|
_ba "github.com/unidoc/unipdf/v3/internal/license";_cf "github.com/unidoc/unipdf/v3/internal/transform";_fe "github.com/unidoc/unipdf/v3/model";_eg "github.com/unidoc/unipdf/v3/render/internal/context";_bd "github.com/unidoc/unipdf/v3/render/internal/context/imagerender";
|
|
_ga "golang.org/x/image/draw";_ad "image";_g "image/color";_a "image/draw";_fdd "image/jpeg";_ab "image/png";_d "math";_fd "os";_e "path/filepath";_bb "strings";);var (_cg =_b .New ("\u0074\u0079p\u0065\u0020\u0063h\u0065\u0063\u006b\u0020\u0065\u0072\u0072\u006f\u0072");
|
|
_gfc =_b .New ("\u0072\u0061\u006e\u0067\u0065\u0020\u0063\u0068\u0065\u0063\u006b\u0020e\u0072\u0072\u006f\u0072"););
|
|
|
|
// Render converts the specified PDF page into an image and returns the result.
|
|
func (_cb *ImageDevice )Render (page *_fe .PdfPage )(_ad .Image ,error ){_abd ,_gf :=page .GetMediaBox ();if _gf !=nil {return nil ,_gf ;};_abd .Normalize ();_abg :=page .CropBox ;var _dg ,_gd float64 ;if _abg !=nil {_abg .Normalize ();_dg ,_gd =_abg .Width (),_abg .Height ();
|
|
};_eb :=page .Rotate ;_fde ,_baf ,_fbe ,_da :=_abd .Llx ,_abd .Lly ,_abd .Width (),_abd .Height ();_ce :=_cf .IdentityMatrix ();if _eb !=nil &&*_eb %360!=0&&*_eb %90==0{_cbe :=-float64 (*_eb );_acc :=_gbg (_fbe ,_da ,_cbe );_ce =_ce .Translate ((_acc .Width -_fbe )/2+_fbe /2,(_acc .Height -_da )/2+_da /2).Rotate (_cbe *_d .Pi /180).Translate (-_fbe /2,-_da /2);
|
|
_fbe ,_da =_acc .Width ,_acc .Height ;if _abg !=nil {_aa :=_gbg (_dg ,_gd ,_cbe );_dg ,_gd =_aa .Width ,_aa .Height ;};};if _fde !=0||_baf !=0{_ce =_ce .Translate (-_fde ,-_baf );};_cb ._ced =1.0;if _cb .OutputWidth !=0{_dab :=_fbe ;if _abg !=nil {_dab =_dg ;
|
|
};_cb ._ced =float64 (_cb .OutputWidth )/_dab ;_fbe ,_da ,_dg ,_gd =_fbe *_cb ._ced ,_da *_cb ._ced ,_dg *_cb ._ced ,_gd *_cb ._ced ;_ce =_cf .ScaleMatrix (_cb ._ced ,_cb ._ced ).Mult (_ce );};_dgb :=_bd .NewContext (int (_fbe ),int (_da ));if _cbg :=_cb .renderPage (_dgb ,page ,_ce );
|
|
_cbg !=nil {return nil ,_cbg ;};_bbf :=_dgb .Image ();if _abg !=nil {_fdc ,_dd :=(_abg .Llx -_fde )*_cb ._ced ,(_abg .Lly -_baf )*_cb ._ced ;_bf :=_ad .Rect (0,0,int (_dg ),int (_gd ));_ff :=_ad .Pt (int (_fdc ),int (_da -_dd -_gd ));_ed :=_ad .NewRGBA (_bf );
|
|
_a .Draw (_ed ,_bf ,_bbf ,_ff ,_a .Src );_bbf =_ed ;};return _bbf ,nil ;};func (_be renderer )renderContentStream (_ae _eg .Context ,_ge string ,_af *_fe .PdfPageResources )error {_afa ,_ebg :=_fb .NewContentStreamParser (_ge ).Parse ();if _ebg !=nil {return _ebg ;
|
|
};_adc :=_ae .TextState ();_adc .GlobalScale =_be ._ced ;_aea :=map[string ]*_eg .TextFont {};_fef :=_fbc .NewFinder (&_fbc .FinderOpts {Extensions :[]string {"\u002e\u0074\u0074\u0066","\u002e\u0074\u0074\u0063"}});_feg :=_fb .NewContentStreamProcessor (*_afa );
|
|
_feg .AddHandler (_fb .HandlerConditionEnumAllOperands ,"",func (_dgf *_fb .ContentStreamOperation ,_fag _fb .GraphicsState ,_ef *_fe .PdfPageResources )error {_c .Log .Debug ("\u0050\u0072\u006f\u0063\u0065\u0073\u0073\u0069\u006e\u0067\u0020\u0025\u0073",_dgf .Operand );
|
|
switch _dgf .Operand {case "\u0071":_ae .Push ();case "\u0051":_ae .Pop ();_adc =_ae .TextState ();case "\u0063\u006d":if len (_dgf .Params )!=6{return _gfc ;};_ee ,_cce :=_ac .GetNumbersAsFloat (_dgf .Params );if _cce !=nil {return _cce ;};_gfa :=_cf .NewMatrix (_ee [0],_ee [1],_ee [2],_ee [3],_ee [4],_ee [5]);
|
|
_c .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",_gfa );_ae .SetMatrix (_ae .Matrix ().Mult (_gfa ));case "\u0077":if len (_dgf .Params )!=1{return _gfc ;
|
|
};_feb ,_fg :=_ac .GetNumbersAsFloat (_dgf .Params );if _fg !=nil {return _fg ;};_ae .SetLineWidth (_feb [0]);case "\u004a":if len (_dgf .Params )!=1{return _gfc ;};_ebb ,_efd :=_ac .GetIntVal (_dgf .Params [0]);if !_efd {return _cg ;};switch _ebb {case 0:_ae .SetLineCap (_eg .LineCapButt );
|
|
case 1:_ae .SetLineCap (_eg .LineCapRound );case 2:_ae .SetLineCap (_eg .LineCapSquare );default:_c .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",_ebb );
|
|
return _gfc ;};case "\u006a":if len (_dgf .Params )!=1{return _gfc ;};_gg ,_ag :=_ac .GetIntVal (_dgf .Params [0]);if !_ag {return _cg ;};switch _gg {case 0:_ae .SetLineJoin (_eg .LineJoinBevel );case 1:_ae .SetLineJoin (_eg .LineJoinRound );case 2:_ae .SetLineJoin (_eg .LineJoinBevel );
|
|
default:_c .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",_gg );return _gfc ;};case "\u004d":if len (_dgf .Params )!=1{return _gfc ;};_ea ,_fffb :=_ac .GetNumbersAsFloat (_dgf .Params );
|
|
if _fffb !=nil {return _fffb ;};_ =_ea ;_c .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 (_dgf .Params )!=2{return _gfc ;};_bab ,_cbc :=_ac .GetArray (_dgf .Params [0]);
|
|
if !_cbc {return _cg ;};_gb ,_cbc :=_ac .GetIntVal (_dgf .Params [1]);if !_cbc {return _cg ;};_aba ,_fge :=_ac .GetNumbersAsFloat (_bab .Elements ());if _fge !=nil {return _fge ;};_ae .SetDash (_aba ...);_ =_gb ;_c .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":_c .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":_c .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 (_dgf .Params )!=1{return _gfc ;};_db ,_caa :=_ac .GetName (_dgf .Params [0]);if !_caa {return _cg ;};if _db ==nil {return _gfc ;};_aaa ,_caa :=_ef .GetExtGState (*_db );if !_caa {_c .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",*_db );
|
|
return _b .New ("\u0072e\u0073o\u0075\u0072\u0063\u0065\u0020n\u006f\u0074 \u0066\u006f\u0075\u006e\u0064");};_faf ,_caa :=_ac .GetDict (_aaa );if !_caa {_c .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 _cg ;};_c .Log .Debug ("G\u0053\u0020\u0064\u0069\u0063\u0074\u003a\u0020\u0025\u0073",_faf .String ());case "\u006d":if len (_dgf .Params )!=2{_c .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",_gfc );
|
|
return nil ;};_edg ,_ddb :=_ac .GetNumbersAsFloat (_dgf .Params );if _ddb !=nil {return _ddb ;};_c .Log .Debug ("M\u006f\u0076\u0065\u0020\u0074\u006f\u003a\u0020\u0025\u0076",_edg );_ae .NewSubPath ();_ae .MoveTo (_edg [0],_edg [1]);case "\u006c":if len (_dgf .Params )!=2{_c .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",_gfc );
|
|
return nil ;};_ddg ,_ceb :=_ac .GetNumbersAsFloat (_dgf .Params );if _ceb !=nil {return _ceb ;};_ae .LineTo (_ddg [0],_ddg [1]);case "\u0063":if len (_dgf .Params )!=6{return _gfc ;};_dba ,_gfg :=_ac .GetNumbersAsFloat (_dgf .Params );if _gfg !=nil {return _gfg ;
|
|
};_c .Log .Debug ("\u0043u\u0062\u0069\u0063\u0020\u0062\u0065\u007a\u0069\u0065\u0072\u0020p\u0061\u0072\u0061\u006d\u0073\u003a\u0020\u0025\u002b\u0076",_dba );_ae .CubicTo (_dba [0],_dba [1],_dba [2],_dba [3],_dba [4],_dba [5]);case "\u0076","\u0079":if len (_dgf .Params )!=4{return _gfc ;
|
|
};_ffe ,_fba :=_ac .GetNumbersAsFloat (_dgf .Params );if _fba !=nil {return _fba ;};_c .Log .Debug ("\u0043u\u0062\u0069\u0063\u0020\u0062\u0065\u007a\u0069\u0065\u0072\u0020p\u0061\u0072\u0061\u006d\u0073\u003a\u0020\u0025\u002b\u0076",_ffe );_ae .QuadraticTo (_ffe [0],_ffe [1],_ffe [2],_ffe [3]);
|
|
case "\u0068":_ae .ClosePath ();_ae .NewSubPath ();case "\u0072\u0065":if len (_dgf .Params )!=4{return _gfc ;};_eae ,_gab :=_ac .GetNumbersAsFloat (_dgf .Params );if _gab !=nil {return _gab ;};_ae .DrawRectangle (_eae [0],_eae [1],_eae [2],_eae [3]);_ae .NewSubPath ();
|
|
case "\u0053":_cge ,_cbb :=_fag .ColorspaceStroking .ColorToRGB (_fag .ColorStroking );if _cbb !=nil {_c .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",_cbb );
|
|
return _cbb ;};_ec ,_efg :=_cge .(*_fe .PdfColorDeviceRGB );if !_efg {_c .Log .Debug ("\u0045\u0072\u0072\u006fr \u0063\u006f\u006e\u0076\u0065\u0072\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006co\u0072");return _cbb ;};_ae .SetRGBA (_ec .R (),_ec .G (),_ec .B (),1);
|
|
_ae .Stroke ();case "\u0073":_gc ,_fcd :=_fag .ColorspaceStroking .ColorToRGB (_fag .ColorStroking );if _fcd !=nil {_c .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",_fcd );
|
|
return _fcd ;};_gbb ,_aef :=_gc .(*_fe .PdfColorDeviceRGB );if !_aef {_c .Log .Debug ("\u0045\u0072\u0072\u006fr \u0063\u006f\u006e\u0076\u0065\u0072\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006co\u0072");return _fcd ;};_ae .ClosePath ();_ae .NewSubPath ();
|
|
_ae .SetRGBA (_gbb .R (),_gbb .G (),_gbb .B (),1);_ae .Stroke ();case "\u0066","\u0046":_geg ,_ecc :=_fag .ColorspaceNonStroking .ColorToRGB (_fag .ColorNonStroking );if _ecc !=nil {_c .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 ;};_dc ,_bac :=_geg .(*_fe .PdfColorDeviceRGB );if !_bac {_c .Log .Debug ("\u0045\u0072\u0072\u006fr \u0063\u006f\u006e\u0076\u0065\u0072\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006co\u0072");return _ecc ;};_ae .SetRGBA (_dc .R (),_dc .G (),_dc .B (),1);
|
|
_ae .SetFillRule (_eg .FillRuleWinding );_ae .Fill ();case "\u0066\u002a":_dbg ,_abgg :=_fag .ColorspaceNonStroking .ColorToRGB (_fag .ColorNonStroking );if _abgg !=nil {_c .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",_abgg );
|
|
return _abgg ;};_afd ,_bga :=_dbg .(*_fe .PdfColorDeviceRGB );if !_bga {_c .Log .Debug ("\u0045\u0072\u0072\u006fr \u0063\u006f\u006e\u0076\u0065\u0072\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006co\u0072");return _abgg ;};_ae .SetRGBA (_afd .R (),_afd .G (),_afd .B (),1);
|
|
_ae .SetFillRule (_eg .FillRuleEvenOdd );_ae .Fill ();case "\u0042":_ffd ,_aga :=_fag .ColorspaceNonStroking .ColorToRGB (_fag .ColorNonStroking );if _aga !=nil {_c .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 ;};_cebc :=_ffd .(*_fe .PdfColorDeviceRGB );_ae .SetRGBA (_cebc .R (),_cebc .G (),_cebc .B (),1);_ae .SetFillRule (_eg .FillRuleWinding );_ae .FillPreserve ();_ffd ,_aga =_fag .ColorspaceStroking .ColorToRGB (_fag .ColorStroking );if _aga !=nil {_c .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 ;};_cebc =_ffd .(*_fe .PdfColorDeviceRGB );_ae .SetRGBA (_cebc .R (),_cebc .G (),_cebc .B (),1);_ae .Stroke ();case "\u0042\u002a":_dcf ,_bfg :=_fag .ColorspaceNonStroking .ColorToRGB (_fag .ColorNonStroking );if _bfg !=nil {_c .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",_bfg );
|
|
return _bfg ;};_abc :=_dcf .(*_fe .PdfColorDeviceRGB );_ae .SetRGBA (_abc .R (),_abc .G (),_abc .B (),1);_ae .SetFillRule (_eg .FillRuleEvenOdd );_ae .FillPreserve ();_dcf ,_bfg =_fag .ColorspaceStroking .ColorToRGB (_fag .ColorStroking );if _bfg !=nil {_c .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",_bfg );
|
|
return _bfg ;};_abc =_dcf .(*_fe .PdfColorDeviceRGB );_ae .SetRGBA (_abc .R (),_abc .G (),_abc .B (),1);_ae .Stroke ();case "\u0062":_cd ,_dcd :=_fag .ColorspaceNonStroking .ColorToRGB (_fag .ColorNonStroking );if _dcd !=nil {_c .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",_dcd );
|
|
return _dcd ;};_ecca :=_cd .(*_fe .PdfColorDeviceRGB );_ae .SetRGBA (_ecca .R (),_ecca .G (),_ecca .B (),1);_ae .ClosePath ();_ae .NewSubPath ();_ae .SetFillRule (_eg .FillRuleWinding );_ae .FillPreserve ();_cd ,_dcd =_fag .ColorspaceStroking .ColorToRGB (_fag .ColorStroking );
|
|
if _dcd !=nil {_c .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",_dcd );return _dcd ;};_ecca =_cd .(*_fe .PdfColorDeviceRGB );_ae .SetRGBA (_ecca .R (),_ecca .G (),_ecca .B (),1);
|
|
_ae .Stroke ();case "\u0062\u002a":_ae .ClosePath ();_bfd ,_gfb :=_fag .ColorspaceNonStroking .ColorToRGB (_fag .ColorNonStroking );if _gfb !=nil {_c .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",_gfb );
|
|
return _gfb ;};_gadf :=_bfd .(*_fe .PdfColorDeviceRGB );_ae .SetRGBA (_gadf .R (),_gadf .G (),_gadf .B (),1);_ae .NewSubPath ();_ae .SetFillRule (_eg .FillRuleEvenOdd );_ae .FillPreserve ();_bfd ,_gfb =_fag .ColorspaceStroking .ColorToRGB (_fag .ColorStroking );
|
|
if _gfb !=nil {_c .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",_gfb );return _gfb ;};_gadf =_bfd .(*_fe .PdfColorDeviceRGB );_ae .SetRGBA (_gadf .R (),_gadf .G (),_gadf .B (),1);
|
|
_ae .Stroke ();case "\u006e":_ae .ClearPath ();case "\u0057":_ae .SetFillRule (_eg .FillRuleWinding );_ae .ClipPreserve ();case "\u0057\u002a":_ae .SetFillRule (_eg .FillRuleEvenOdd );_ae .ClipPreserve ();case "\u0072\u0067":_bc ,_fgg :=_fag .ColorNonStroking .(*_fe .PdfColorDeviceRGB );
|
|
if !_fgg {_c .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",_fag .ColorNonStroking );return nil ;};_ae .SetFillRGBA (_bc .R (),_bc .G (),_bc .B (),1);
|
|
case "\u0052\u0047":_bgd ,_cgc :=_fag .ColorStroking .(*_fe .PdfColorDeviceRGB );if !_cgc {_c .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",_fag .ColorStroking );
|
|
return nil ;};_ae .SetStrokeRGBA (_bgd .R (),_bgd .G (),_bgd .B (),1);case "\u006b":_ffdb ,_cbcg :=_fag .ColorNonStroking .(*_fe .PdfColorDeviceCMYK );if !_cbcg {_c .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",_fag .ColorNonStroking );
|
|
return nil ;};_bec ,_agf :=_fag .ColorspaceNonStroking .ColorToRGB (_ffdb );if _agf !=nil {_c .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",_fag .ColorNonStroking );
|
|
return nil ;};_df ,_cbcg :=_bec .(*_fe .PdfColorDeviceRGB );if !_cbcg {_c .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",_bec );return nil ;
|
|
};_ae .SetFillRGBA (_df .R (),_df .G (),_df .B (),1);case "\u004b":_aff ,_adbd :=_fag .ColorStroking .(*_fe .PdfColorDeviceCMYK );if !_adbd {_c .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",_fag .ColorStroking );
|
|
return nil ;};_bbfe ,_acf :=_fag .ColorspaceStroking .ColorToRGB (_aff );if _acf !=nil {_c .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",_fag .ColorStroking );
|
|
return nil ;};_cbgc ,_adbd :=_bbfe .(*_fe .PdfColorDeviceRGB );if !_adbd {_c .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",_bbfe );return nil ;
|
|
};_ae .SetStrokeRGBA (_cbgc .R (),_cbgc .G (),_cbgc .B (),1);case "\u0067":_cde ,_abbd :=_fag .ColorNonStroking .(*_fe .PdfColorDeviceGray );if !_abbd {_c .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",_fag .ColorNonStroking );
|
|
return nil ;};_gec ,_dgfe :=_fag .ColorspaceNonStroking .ColorToRGB (_cde );if _dgfe !=nil {_c .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",_fag .ColorNonStroking );
|
|
return nil ;};_gbf ,_abbd :=_gec .(*_fe .PdfColorDeviceRGB );if !_abbd {_c .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",_gec );return nil ;
|
|
};_ae .SetFillRGBA (_gbf .R (),_gbf .G (),_gbf .B (),1);case "\u0047":_gbc ,_dbe :=_fag .ColorStroking .(*_fe .PdfColorDeviceGray );if !_dbe {_c .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",_fag .ColorStroking );
|
|
return nil ;};_egg ,_baa :=_fag .ColorspaceStroking .ColorToRGB (_gbc );if _baa !=nil {_c .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",_fag .ColorStroking );
|
|
return nil ;};_cga ,_dbe :=_egg .(*_fe .PdfColorDeviceRGB );if !_dbe {_c .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",_egg );return nil ;
|
|
};_ae .SetStrokeRGBA (_cga .R (),_cga .G (),_cga .B (),1);case "\u0063\u0073","\u0073\u0063","\u0073\u0063\u006e":_bca ,_dea :=_fag .ColorspaceNonStroking .ColorToRGB (_fag .ColorNonStroking );if _dea !=nil {_c .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",_fag .ColorNonStroking );
|
|
return nil ;};_bda ,_fgc :=_bca .(*_fe .PdfColorDeviceRGB );if !_fgc {_c .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",_bca );return nil ;
|
|
};_ae .SetFillRGBA (_bda .R (),_bda .G (),_bda .B (),1);case "\u0043\u0053","\u0053\u0043","\u0053\u0043\u004e":_afg ,_deb :=_fag .ColorspaceStroking .ColorToRGB (_fag .ColorStroking );if _deb !=nil {_c .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",_fag .ColorStroking );
|
|
return nil ;};_gaa ,_ebgc :=_afg .(*_fe .PdfColorDeviceRGB );if !_ebgc {_c .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",_afg );return nil ;
|
|
};_ae .SetStrokeRGBA (_gaa .R (),_gaa .G (),_gaa .B (),1);case "\u0044\u006f":if len (_dgf .Params )!=1{return _gfc ;};_fgeb ,_fbae :=_ac .GetName (_dgf .Params [0]);if !_fbae {return _cg ;};_ ,_bdg :=_ef .GetXObjectByName (*_fgeb );switch _bdg {case _fe .XObjectTypeImage :_c .Log .Debug ("\u0058\u004f\u0062\u006a\u0065\u0063\u0074\u0020\u0069\u006d\u0061\u0067e\u003a\u0020\u0025\u0073",_fgeb .String ());
|
|
_dcc ,_fffc :=_ef .GetXObjectImageByName (*_fgeb );if _fffc !=nil {return _fffc ;};_gfd ,_fffc :=_dcc .ToImage ();if _fffc !=nil {return _fffc ;};if _bfb :=_dcc .ColorSpace ;_bfb !=nil {var _agfg bool ;switch _bfb .(type ){case *_fe .PdfColorspaceSpecialIndexed :_agfg =true ;
|
|
};if _agfg {if _dgbf ,_fad :=_bfb .ImageToRGB (*_gfd );_fad !=nil {_c .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 {_gfd =&_dgbf ;};};};_cbd :=_ae .FillPattern ().ColorAt (0,0);var _bbd _ad .Image ;if _dcc .Mask !=nil {if _bbd ,_fffc =_ffg (_dcc .Mask ,_cbd );_fffc !=nil {_c .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");
|
|
};};var _afab _ad .Image ;if _aac ,_ :=_ac .GetBoolVal (_dcc .ImageMask );_aac {_afab =_eeff (_gfd ,_cbd );}else {_afab ,_fffc =_gfd .ToGoImage ();if _fffc !=nil {return _fffc ;};};if _bbd !=nil {_afab =_beb (_afab ,_bbd );};_fcf :=_afab .Bounds ();_ae .Push ();
|
|
_ae .Scale (1.0/float64 (_fcf .Dx ()),-1.0/float64 (_fcf .Dy ()));_ae .DrawImageAnchored (_afab ,0,0,0,1);_ae .Pop ();case _fe .XObjectTypeForm :_c .Log .Debug ("\u0058\u004fb\u006a\u0065\u0063t\u0020\u0066\u006f\u0072\u006d\u003a\u0020\u0025\u0073",_fgeb .String ());
|
|
_afb ,_aed :=_ef .GetXObjectFormByName (*_fgeb );if _aed !=nil {return _aed ;};_fdf ,_aed :=_afb .GetContentStream ();if _aed !=nil {return _aed ;};_cgf :=_afb .Resources ;if _cgf ==nil {_cgf =_ef ;};_ae .Push ();if _afb .Matrix !=nil {_fgef ,_dfe :=_ac .GetArray (_afb .Matrix );
|
|
if !_dfe {return _cg ;};_dbad ,_fga :=_ac .GetNumbersAsFloat (_fgef .Elements ());if _fga !=nil {return _fga ;};if len (_dbad )!=6{return _gfc ;};_ecg :=_cf .NewMatrix (_dbad [0],_dbad [1],_dbad [2],_dbad [3],_dbad [4],_dbad [5]);_ae .SetMatrix (_ae .Matrix ().Mult (_ecg ));
|
|
};if _afb .BBox !=nil {_bcc ,_gcc :=_ac .GetArray (_afb .BBox );if !_gcc {return _cg ;};_fdfa ,_gdf :=_ac .GetNumbersAsFloat (_bcc .Elements ());if _gdf !=nil {return _gdf ;};if len (_fdfa )!=4{_c .Log .Debug ("\u004c\u0065\u006e\u0020\u003d\u0020\u0025\u0064",len (_fdfa ));
|
|
return _gfc ;};_ae .DrawRectangle (_fdfa [0],_fdfa [1],_fdfa [2]-_fdfa [0],_fdfa [3]-_fdfa [1]);_ae .SetRGBA (1,0,0,1);_ae .Clip ();}else {_c .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");
|
|
};_aed =_be .renderContentStream (_ae ,string (_fdf ),_cgf );if _aed !=nil {return _aed ;};_ae .Pop ();};case "\u0042\u0049":if len (_dgf .Params )!=1{return _gfc ;};_bgde ,_dfb :=_dgf .Params [0].(*_fb .ContentStreamInlineImage );if !_dfb {return nil ;
|
|
};_fdeb ,_fege :=_bgde .ToImage (_ef );if _fege !=nil {return _fege ;};_bbdg ,_fege :=_fdeb .ToGoImage ();if _fege !=nil {return _fege ;};_edf :=_bbdg .Bounds ();_ae .Push ();_ae .Scale (1.0/float64 (_edf .Dx ()),-1.0/float64 (_edf .Dy ()));_ae .DrawImageAnchored (_bbdg ,0,0,0,1);
|
|
_ae .Pop ();case "\u0042\u0054":_adc .Reset ();case "\u0045\u0054":_adc .Reset ();case "\u0054\u0072":if len (_dgf .Params )!=1{return _gfc ;};_dge ,_febc :=_ac .GetNumberAsFloat (_dgf .Params [0]);if _febc !=nil {return _febc ;};_adc .Tr =_eg .TextRenderingMode (_dge );
|
|
case "\u0054\u004c":if len (_dgf .Params )!=1{return _gfc ;};_affa ,_efb :=_ac .GetNumberAsFloat (_dgf .Params [0]);if _efb !=nil {return _efb ;};_adc .Tl =_affa ;case "\u0054\u0063":if len (_dgf .Params )!=1{return _gfc ;};_edgg ,_fdg :=_ac .GetNumberAsFloat (_dgf .Params [0]);
|
|
if _fdg !=nil {return _fdg ;};_c .Log .Debug ("\u0054\u0063\u003a\u0020\u0025\u0076",_edgg );_adc .Tc =_edgg ;case "\u0054\u0077":if len (_dgf .Params )!=1{return _gfc ;};_add ,_adcd :=_ac .GetNumberAsFloat (_dgf .Params [0]);if _adcd !=nil {return _adcd ;
|
|
};_c .Log .Debug ("\u0054\u0077\u003a\u0020\u0025\u0076",_add );_adc .Tw =_add ;case "\u0054\u007a":if len (_dgf .Params )!=1{return _gfc ;};_cfc ,_gde :=_ac .GetNumberAsFloat (_dgf .Params [0]);if _gde !=nil {return _gde ;};_adc .Th =_cfc ;case "\u0054\u0073":if len (_dgf .Params )!=1{return _gfc ;
|
|
};_afc ,_dccd :=_ac .GetNumberAsFloat (_dgf .Params [0]);if _dccd !=nil {return _dccd ;};_adc .Ts =_afc ;case "\u0054\u0064":if len (_dgf .Params )!=2{return _gfc ;};_bba ,_ged :=_ac .GetNumbersAsFloat (_dgf .Params );if _ged !=nil {return _ged ;};_c .Log .Debug ("\u0054\u0064\u003a\u0020\u0025\u0076",_bba );
|
|
_adc .ProcTd (_bba [0],_bba [1]);case "\u0054\u0044":if len (_dgf .Params )!=2{return _gfc ;};_eag ,_fae :=_ac .GetNumbersAsFloat (_dgf .Params );if _fae !=nil {return _fae ;};_c .Log .Debug ("\u0054\u0044\u003a\u0020\u0025\u0076",_eag );_adc .ProcTD (_eag [0],_eag [1]);
|
|
case "\u0054\u002a":_adc .ProcTStar ();case "\u0054\u006d":if len (_dgf .Params )!=6{return _gfc ;};_gfca ,_gbe :=_ac .GetNumbersAsFloat (_dgf .Params );if _gbe !=nil {return _gbe ;};_c .Log .Debug ("\u0054\u0065x\u0074\u0020\u006da\u0074\u0072\u0069\u0078\u003a\u0020\u0025\u002b\u0076",_gfca );
|
|
_adc .ProcTm (_gfca [0],_gfca [1],_gfca [2],_gfca [3],_gfca [4],_gfca [5]);case "\u0027":if len (_dgf .Params )!=1{return _gfc ;};_cebcb ,_cfd :=_ac .GetStringBytes (_dgf .Params [0]);if !_cfd {return _cg ;};_c .Log .Debug ("\u0027\u0020\u0073t\u0072\u0069\u006e\u0067\u003a\u0020\u0025\u0073",string (_cebcb ));
|
|
_adc .ProcQ (_cebcb ,_ae );case "\u0022":if len (_dgf .Params )!=3{return _gfc ;};_abge ,_gfbe :=_ac .GetNumberAsFloat (_dgf .Params [0]);if _gfbe !=nil {return _gfbe ;};_daf ,_gfbe :=_ac .GetNumberAsFloat (_dgf .Params [1]);if _gfbe !=nil {return _gfbe ;
|
|
};_dcdb ,_cebe :=_ac .GetStringBytes (_dgf .Params [2]);if !_cebe {return _cg ;};_adc .ProcDQ (_dcdb ,_abge ,_daf ,_ae );case "\u0054\u006a":if len (_dgf .Params )!=1{return _gfc ;};_ebgca ,_gda :=_ac .GetStringBytes (_dgf .Params [0]);if !_gda {return _cg ;
|
|
};_c .Log .Debug ("\u0054j\u0020s\u0074\u0072\u0069\u006e\u0067\u003a\u0020\u0060\u0025\u0073\u0060",string (_ebgca ));_adc .ProcTj (_ebgca ,_ae );case "\u0054\u004a":if len (_dgf .Params )!=1{return _gfc ;};_eab ,_fbca :=_ac .GetArray (_dgf .Params [0]);
|
|
if !_fbca {_c .Log .Debug ("\u0054\u0079\u0070\u0065\u003a\u0020\u0025\u0054",_eab );return _cg ;};_c .Log .Debug ("\u0054\u004a\u0020\u0061\u0072\u0072\u0061\u0079\u003a\u0020\u0025\u002b\u0076",_eab );for _ ,_gfgg :=range _eab .Elements (){switch _gabe :=_gfgg .(type ){case *_ac .PdfObjectString :if _gabe !=nil {_adc .ProcTj (_gabe .Bytes (),_ae );
|
|
};case *_ac .PdfObjectFloat ,*_ac .PdfObjectInteger :_cfcb ,_fdgb :=_ac .GetNumberAsFloat (_gabe );if _fdgb ==nil {_adc .Translate (-_cfcb *0.001*_adc .Tf .Size *_adc .Th /100.0,0);};};};case "\u0054\u0066":if len (_dgf .Params )!=2{return _gfc ;};_c .Log .Debug ("\u0025\u0023\u0076",_dgf .Params );
|
|
_bgab ,_ecb :=_ac .GetName (_dgf .Params [0]);if !_ecb ||_bgab ==nil {_c .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",_dgf .Params [0]);
|
|
return _cg ;};_c .Log .Debug ("\u0046\u006f\u006e\u0074\u0020\u006e\u0061\u006d\u0065\u003a\u0020\u0025\u0073",_bgab .String ());_bfe ,_eccd :=_ac .GetNumberAsFloat (_dgf .Params [1]);if _eccd !=nil {_c .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",_dgf .Params [1]);
|
|
return _cg ;};_c .Log .Debug ("\u0046\u006f\u006e\u0074\u0020\u0073\u0069\u007a\u0065\u003a\u0020\u0025\u0076",_bfe );_eef ,_fdcf :=_ef .GetFontByName (*_bgab );if !_fdcf {_c .Log .Debug ("\u0045R\u0052\u004f\u0052\u003a\u0020\u0046\u006f\u006e\u0074\u0020\u0025s\u0020\u006e\u006f\u0074\u0020\u0066\u006f\u0075\u006e\u0064",_bgab .String ());
|
|
return _b .New ("\u0066\u006f\u006e\u0074\u0020\u006e\u006f\u0074\u0020f\u006f\u0075\u006e\u0064");};_c .Log .Debug ("\u0046\u006f\u006e\u0074\u003a\u0020\u0025\u0054",_eef );_fbf ,_ecb :=_ac .GetDict (_eef );if !_ecb {_c .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 _cg ;};_def ,_eccd :=_fe .NewPdfFontFromPdfObject (_fbf );if _eccd !=nil {_c .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 _eccd ;};_agb :=_def .BaseFont ();if _agb ==""{_agb =_bgab .String ();};_ade ,_ecb :=_aea [_agb ];if !_ecb {_ade ,_eccd =_eg .NewTextFont (_def ,_bfe );if _eccd !=nil {_c .Log .Debug ("\u0045R\u0052\u004f\u0052\u003a\u0020\u0025v",_eccd );};};if _ade ==nil {if len (_agb )> 7&&_agb [6]=='+'{_agb =_agb [7:];
|
|
};_adcdf :=[]string {_agb ,"\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 _ ,_dgc :=range _adcdf {_c .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",_dgc );
|
|
if _ade ,_ecb =_aea [_dgc ];_ecb {break ;};_dbd :=_fef .Match (_dgc );if _dbd ==nil {_c .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",_dgc );continue ;
|
|
};_ade ,_eccd =_eg .NewTextFontFromPath (_dbd .Filename ,_bfe );if _eccd !=nil {_c .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",_dbd .Filename );
|
|
continue ;};_c .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",_agb ,_dbd .Name ,_dbd .Filename );_aea [_dgc ]=_ade ;
|
|
break ;};};if _ade ==nil {_c .Log .Debug ("\u0045\u0052\u0052\u004f\u0052\u003a\u0020\u0063\u006f\u0075\u006c\u0064\u0020n\u006f\u0074\u0020\u0066\u0069\u006ed\u0020\u0061\u006e\u0079\u0020\u0073\u0075\u0069\u0074\u0061\u0062\u006c\u0065 \u0066\u006f\u006e\u0074");
|
|
return _b .New ("\u0063\u006f\u0075\u006c\u0064\u0020\u006e\u006f\u0074\u0020\u0066\u0069\u006e\u0064\u0020a\u006ey\u0020\u0073\u0075\u0069\u0074\u0061\u0062\u006c\u0065\u0020\u0066\u006f\u006e\u0074");};_adc .ProcTf (_ade .WithSize (_bfe ,_def ));case "\u0042\u004d\u0043","\u0042\u0044\u0043":case "\u0045\u004d\u0043":default:_c .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",_dgf .Operand );
|
|
};return nil ;});_ebg =_feg .Process (_af );if _ebg !=nil {return _ebg ;};return nil ;};func _beb (_cda ,_ebf _ad .Image )_ad .Image {_gdef ,_gacg :=_ebf .Bounds ().Size (),_cda .Bounds ().Size ();_cac ,_bfc :=_gdef .X ,_gdef .Y ;if _gacg .X > _cac {_cac =_gacg .X ;
|
|
};if _gacg .Y > _bfc {_bfc =_gacg .Y ;};_bea :=_ad .Rect (0,0,_cac ,_bfc );if _gdef .X !=_cac ||_gdef .Y !=_bfc {_eee :=_ad .NewRGBA (_bea );_ga .BiLinear .Scale (_eee ,_bea ,_cda ,_ebf .Bounds (),_ga .Over ,nil );_ebf =_eee ;};if _gacg .X !=_cac ||_gacg .Y !=_bfc {_bdc :=_ad .NewRGBA (_bea );
|
|
_ga .BiLinear .Scale (_bdc ,_bea ,_cda ,_cda .Bounds (),_ga .Over ,nil );_cda =_bdc ;};_cfea :=_ad .NewRGBA (_bea );_ga .DrawMask (_cfea ,_bea ,_cda ,_ad .Point {},_ebf ,_ad .Point {},_ga .Over );return _cfea ;};func (_ace renderer )renderPage (_cab _eg .Context ,_fc *_fe .PdfPage ,_gac _cf .Matrix )error {_de ,_cc :=_fc .GetAllContentStreams ();
|
|
if _cc !=nil {return _cc ;};if _cabb :=_gac ;!_cabb .Identity (){_de =_abb .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",_cabb [0],_cabb [1],_cabb [3],_cabb [4],_cabb [6],_cabb [7],_de );
|
|
};_cab .Translate (0,float64 (_cab .Height ()));_cab .Scale (1,-1);_cab .Push ();_cab .SetRGBA (1,1,1,1);_cab .DrawRectangle (0,0,float64 (_cab .Width ()),float64 (_cab .Height ()));_cab .Fill ();_cab .Pop ();_cab .SetLineWidth (1.0);_cab .SetRGBA (0,0,0,1);
|
|
return _ace .renderContentStream (_cab ,_de ,_fc .Resources );};func _eeff (_fcde *_fe .Image ,_bdb _g .Color )_ad .Image {_eccaf ,_egc :=int (_fcde .Width ),int (_fcde .Height );_dad :=_ad .NewRGBA (_ad .Rect (0,0,_eccaf ,_egc ));for _efc :=0;_efc < _egc ;
|
|
_efc ++{for _cgd :=0;_cgd < _eccaf ;_cgd ++{_ebc ,_agc :=_fcde .ColorAt (_cgd ,_efc );if _agc !=nil {_c .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",_cgd ,_efc );
|
|
continue ;};_eefc ,_cdg ,_cbcd ,_ :=_ebc .RGBA ();var _egb _g .Color ;if _eefc +_cdg +_cbcd ==0{_egb =_bdb ;}else {_egb =_g .Transparent ;};_dad .Set (_cgd ,_efc ,_egb );};};return _dad ;};
|
|
|
|
// NewImageDevice returns a new image device.
|
|
func NewImageDevice ()*ImageDevice {const _abf ="r\u0065\u006e\u0064\u0065r.\u004ee\u0077\u0049\u006d\u0061\u0067e\u0044\u0065\u0076\u0069\u0063\u0065";_ba .TrackUse (_abf );return &ImageDevice {};};
|
|
|
|
// RenderToPath converts the specified PDF page into an image and saves the
|
|
// result at the specified location.
|
|
func (_gad *ImageDevice )RenderToPath (page *_fe .PdfPage ,outputPath string )error {_fff ,_fa :=_gad .Render (page );if _fa !=nil {return _fa ;};_ca :=_bb .ToLower (_e .Ext (outputPath ));if _ca ==""{return _b .New ("\u0063\u006ful\u0064\u0020\u006eo\u0074\u0020\u0072\u0065cog\u006eiz\u0065\u0020\u006f\u0075\u0074\u0070\u0075t \u0066\u0069\u006c\u0065\u0020\u0074\u0079p\u0065");
|
|
};switch _ca {case "\u002e\u0070\u006e\u0067":return _abfd (outputPath ,_fff );case "\u002e\u006a\u0070\u0067","\u002e\u006a\u0070e\u0067":return _gff (outputPath ,_fff ,100);};return _abb .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",_ca );
|
|
};func _gff (_abgb string ,_gfbef _ad .Image ,_addb int )error {_bcd ,_bcdc :=_fd .Create (_abgb );if _bcdc !=nil {return _bcdc ;};defer _bcd .Close ();return _fdd .Encode (_bcd ,_gfbef ,&_fdd .Options {Quality :_addb });};type renderer struct{_ced float64 };
|
|
func _abfd (_bgda string ,_gdad _ad .Image )error {_fcb ,_ccc :=_fd .Create (_bgda );if _ccc !=nil {return _ccc ;};defer _fcb .Close ();return _ab .Encode (_fcb ,_gdad );};func _gbg (_bfa ,_aca ,_eefa float64 )_adb .BoundingBox {return _adb .Path {Points :[]_adb .Point {_adb .NewPoint (0,0).Rotate (_eefa ),_adb .NewPoint (_bfa ,0).Rotate (_eefa ),_adb .NewPoint (0,_aca ).Rotate (_eefa ),_adb .NewPoint (_bfa ,_aca ).Rotate (_eefa )}}.GetBoundingBox ();
|
|
};func _ffg (_cgeb _ac .PdfObject ,_eba _g .Color )(_ad .Image ,error ){_ead ,_gag :=_ac .GetStream (_cgeb );if !_gag {return nil ,nil ;};_gcd ,_fbaf :=_fe .NewXObjectImageFromStream (_ead );if _fbaf !=nil {return nil ,_fbaf ;};_efe ,_fbaf :=_gcd .ToImage ();
|
|
if _fbaf !=nil {return nil ,_fbaf ;};return _eeff (_efe ,_eba ),nil ;};
|
|
|
|
// ImageDevice is used to render PDF pages to image targets.
|
|
type ImageDevice struct{renderer ;
|
|
|
|
// OutputWidth represents the width of the rendered images in pixels.
|
|
// The heights of the output images are calculated based on the selected
|
|
// width and the original height of each rendered page.
|
|
OutputWidth int ;}; |