mirror of
https://github.com/unidoc/unipdf.git
synced 2025-04-26 13:48:55 +08:00
196 lines
52 KiB
Go
196 lines
52 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 (_c "errors";_be "fmt";_e "github.com/adrg/sysfont";_beg "github.com/unidoc/unipdf/v3/common";_aga "github.com/unidoc/unipdf/v3/contentstream";_cdf "github.com/unidoc/unipdf/v3/contentstream/draw";_gg "github.com/unidoc/unipdf/v3/core";
|
|
_ce "github.com/unidoc/unipdf/v3/internal/license";_fc "github.com/unidoc/unipdf/v3/internal/transform";_aa "github.com/unidoc/unipdf/v3/model";_ga "github.com/unidoc/unipdf/v3/render/internal/context";_bff "github.com/unidoc/unipdf/v3/render/internal/context/imagerender";
|
|
_cb "golang.org/x/image/draw";_ag "image";_g "image/color";_df "image/draw";_da "image/jpeg";_bf "image/png";_cd "math";_f "os";_d "path/filepath";_b "strings";);const (ShadingTypeFunctionBased PdfShadingType =1;ShadingTypeAxial PdfShadingType =2;ShadingTypeRadial PdfShadingType =3;
|
|
ShadingTypeFreeForm PdfShadingType =4;ShadingTypeLatticeForm PdfShadingType =5;ShadingTypeCoons PdfShadingType =6;ShadingTypeTensorProduct PdfShadingType =7;);type renderer struct{_aaa float64 };func (_cea renderer )processGradient (_dcga _ga .Context ,_ccbf *_aga .ContentStreamOperation ,_edag *_aa .PdfPageResources ,_bage *_gg .PdfObjectName )(_ga .Gradient ,error ){if _fgg ,_bef :=_edag .GetPatternByName (*_bage );
|
|
_bef &&_fgg .IsShading (){_deac :=_fgg .GetAsShadingPattern ().Shading ;_bbe ,_ ,_bea :=_cea .processShading (_dcga ,_deac );if _bea !=nil {return nil ,_bea ;};return _bbe ,nil ;};return nil ,nil ;};func _cfg (_feg ,_bgd _ag .Image )_ag .Image {_bdgg ,_edd :=_bgd .Bounds ().Size (),_feg .Bounds ().Size ();
|
|
_gaaf ,_dbc :=_bdgg .X ,_bdgg .Y ;if _edd .X > _gaaf {_gaaf =_edd .X ;};if _edd .Y > _dbc {_dbc =_edd .Y ;};_gace :=_ag .Rect (0,0,_gaaf ,_dbc );if _bdgg .X !=_gaaf ||_bdgg .Y !=_dbc {_cba :=_ag .NewRGBA (_gace );_cb .BiLinear .Scale (_cba ,_gace ,_feg ,_bgd .Bounds (),_cb .Over ,nil );
|
|
_bgd =_cba ;};if _edd .X !=_gaaf ||_edd .Y !=_dbc {_abc :=_ag .NewRGBA (_gace );_cb .BiLinear .Scale (_abc ,_gace ,_feg ,_feg .Bounds (),_cb .Over ,nil );_feg =_abc ;};_bgc :=_ag .NewRGBA (_gace );_cb .DrawMask (_bgc ,_gace ,_feg ,_ag .Point {},_bgd ,_ag .Point {},_cb .Over );
|
|
return _bgc ;};
|
|
|
|
// RenderToPath converts the specified PDF page into an image and saves the
|
|
// result at the specified location.
|
|
func (_ffb *ImageDevice )RenderToPath (page *_aa .PdfPage ,outputPath string )error {_fgb ,_af :=_ffb .Render (page );if _af !=nil {return _af ;};_begg :=_b .ToLower (_d .Ext (outputPath ));if _begg ==""{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 _begg {case "\u002e\u0070\u006e\u0067":return _fcc (outputPath ,_fgb );case "\u002e\u006a\u0070\u0067","\u002e\u006a\u0070e\u0067":return _eef (outputPath ,_fgb ,100);};return _be .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",_begg );
|
|
};func (_dddg renderer )processShading (_fde _ga .Context ,_egfg *_aa .PdfShading )(_ga .Gradient ,*_gg .PdfObjectArray ,error ){_fead :=int64 (*_egfg .ShadingType );if _fead ==int64 (ShadingTypeAxial ){return _dddg .processLinearShading (_fde ,_egfg );
|
|
}else if _fead ==int64 (ShadingTypeRadial ){return _dddg .processRadialShading (_fde ,_egfg );}else {_beg .Log .Debug (_be .Sprintf ("\u0050r\u006f\u0063e\u0073\u0073\u0069n\u0067\u0020\u0067\u0072\u0061\u0064\u0069e\u006e\u0074\u0020\u0074\u0079\u0070e\u0020\u0025\u0064\u0020\u006e\u006f\u0074\u0020\u0079\u0065\u0074 \u0073\u0075\u0070\u0070\u006f\u0072\u0074\u0065\u0064",_fead ));
|
|
};return nil ,nil ,nil ;};func _fcc (_dbe string ,_bbag _ag .Image )error {_egec ,_eae :=_f .Create (_dbe );if _eae !=nil {return _eae ;};defer _egec .Close ();return _bf .Encode (_egec ,_bbag );};
|
|
|
|
// 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 ;};func _bfgb (_eccb _ga .Gradient ,_dfe *_aa .PdfFunctionType2 ,_eeg _aa .PdfColorspace ,_ddf float64 ,_fbg bool )(_ga .Gradient ,error ){switch _eeg .(type ){case *_aa .PdfColorspaceDeviceRGB :if len (_dfe .C0 )!=3||len (_dfe .C1 )!=3{return nil ,_c .New ("\u0069\u006e\u0063\u006f\u0072\u0072\u0065\u0063\u0074\u0020\u0052\u0047\u0042\u0020\u0063o\u006co\u0072\u0020\u0061\u0072\u0072\u0061\u0079\u0020\u006c\u0065\u006e\u0067\u0074\u0068");
|
|
};_ggee :=_dfe .C0 ;_bffg :=_dfe .C1 ;if _fbg {_eccb .AddColorStop (0.0,_g .RGBA {R :uint8 (_ggee [0]*255),G :uint8 (_ggee [1]*255),B :uint8 (_ggee [2]*255),A :255});};_eccb .AddColorStop (_ddf ,_g .RGBA {R :uint8 (_bffg [0]*255),G :uint8 (_bffg [1]*255),B :uint8 (_bffg [2]*255),A :255});
|
|
case *_aa .PdfColorspaceDeviceCMYK :if len (_dfe .C0 )!=4||len (_dfe .C1 )!=4{return nil ,_c .New ("\u0069\u006e\u0063\u006f\u0072\u0072e\u0063\u0074\u0020\u0043\u004d\u0059\u004b\u0020\u0063\u006f\u006c\u006f\u0072 \u0061\u0072\u0072\u0061\u0079\u0020\u006ce\u006e\u0067\u0074\u0068");
|
|
};_beaf :=_dfe .C0 ;_bbga :=_dfe .C1 ;if _fbg {_eccb .AddColorStop (0.0,_g .CMYK {C :uint8 (_beaf [0]*255),M :uint8 (_beaf [1]*255),Y :uint8 (_beaf [2]*255),K :uint8 (_beaf [3]*255)});};_eccb .AddColorStop (_ddf ,_g .CMYK {C :uint8 (_bbga [0]*255),M :uint8 (_bbga [1]*255),Y :uint8 (_bbga [2]*255),K :uint8 (_bbga [3]*255)});
|
|
default:return nil ,_be .Errorf ("u\u006e\u0073\u0075\u0070\u0070\u006fr\u0074\u0065\u0064\u0020\u0063\u006f\u006c\u006f\u0072 \u0073\u0070\u0061c\u0065:\u0020\u0025\u0073",_eeg .String ());};return _eccb ,nil ;};func (_acc renderer )renderContentStream (_ddg _ga .Context ,_bfd string ,_egf *_aa .PdfPageResources )error {_baf ,_afc :=_aga .NewContentStreamParser (_bfd ).Parse ();
|
|
if _afc !=nil {return _afc ;};_agb :=_ddg .TextState ();_agb .GlobalScale =_acc ._aaa ;_ec :=map[string ]*_ga .TextFont {};_faf :=_e .NewFinder (&_e .FinderOpts {Extensions :[]string {"\u002e\u0074\u0074\u0066","\u002e\u0074\u0074\u0063"}});var _cg *_aga .ContentStreamOperation ;
|
|
_dag :=_aga .NewContentStreamProcessor (*_baf );_dag .AddHandler (_aga .HandlerConditionEnumAllOperands ,"",func (_gef *_aga .ContentStreamOperation ,_bae _aga .GraphicsState ,_eca *_aa .PdfPageResources )error {_beg .Log .Debug ("\u0050\u0072\u006f\u0063\u0065\u0073\u0073\u0069\u006e\u0067\u0020\u0025\u0073",_gef .Operand );
|
|
switch _gef .Operand {case "\u0071":_ddg .Push ();case "\u0051":_ddg .Pop ();_agb =_ddg .TextState ();case "\u0063\u006d":if len (_gef .Params )!=6{return _ac ;};_aac ,_bcg :=_gg .GetNumbersAsFloat (_gef .Params );if _bcg !=nil {return _bcg ;};_gfb :=_fc .NewMatrix (_aac [0],_aac [1],_aac [2],_aac [3],_aac [4],_aac [5]);
|
|
_beg .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",_gfb );_ddg .SetMatrix (_ddg .Matrix ().Mult (_gfb ));case "\u0077":if len (_gef .Params )!=1{return _ac ;
|
|
};_cad ,_ee :=_gg .GetNumbersAsFloat (_gef .Params );if _ee !=nil {return _ee ;};_ddg .SetLineWidth (_cad [0]);case "\u004a":if len (_gef .Params )!=1{return _ac ;};_gd ,_ceb :=_gg .GetIntVal (_gef .Params [0]);if !_ceb {return _eg ;};switch _gd {case 0:_ddg .SetLineCap (_ga .LineCapButt );
|
|
case 1:_ddg .SetLineCap (_ga .LineCapRound );case 2:_ddg .SetLineCap (_ga .LineCapSquare );default:_beg .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",_gd );
|
|
return _ac ;};case "\u006a":if len (_gef .Params )!=1{return _ac ;};_ecg ,_gde :=_gg .GetIntVal (_gef .Params [0]);if !_gde {return _eg ;};switch _ecg {case 0:_ddg .SetLineJoin (_ga .LineJoinBevel );case 1:_ddg .SetLineJoin (_ga .LineJoinRound );case 2:_ddg .SetLineJoin (_ga .LineJoinBevel );
|
|
default:_beg .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",_ecg );return _ac ;};case "\u004d":if len (_gef .Params )!=1{return _ac ;};_gbb ,_ab :=_gg .GetNumbersAsFloat (_gef .Params );
|
|
if _ab !=nil {return _ab ;};_ =_gbb ;_beg .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 (_gef .Params )!=2{return _ac ;};_cfe ,_fcg :=_gg .GetArray (_gef .Params [0]);
|
|
if !_fcg {return _eg ;};_dfab ,_fcg :=_gg .GetIntVal (_gef .Params [1]);if !_fcg {_ ,_ef :=_gg .GetFloatVal (_gef .Params [1]);if !_ef {return _eg ;};};_bag ,_ad :=_gg .GetNumbersAsFloat (_cfe .Elements ());if _ad !=nil {return _ad ;};_ddg .SetDash (_bag ...);
|
|
_ =_dfab ;_beg .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":_beg .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":_beg .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 (_gef .Params )!=1{return _ac ;
|
|
};_bfc ,_agc :=_gg .GetName (_gef .Params [0]);if !_agc {return _eg ;};if _bfc ==nil {return _ac ;};_gaf ,_agc :=_eca .GetExtGState (*_bfc );if !_agc {_beg .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",*_bfc );
|
|
return _c .New ("\u0072e\u0073o\u0075\u0072\u0063\u0065\u0020n\u006f\u0074 \u0066\u006f\u0075\u006e\u0064");};_fd ,_agc :=_gg .GetDict (_gaf );if !_agc {_beg .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 _eg ;};_beg .Log .Debug ("G\u0053\u0020\u0064\u0069\u0063\u0074\u003a\u0020\u0025\u0073",_fd .String ());case "\u006d":if len (_gef .Params )!=2{_beg .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",_ac );
|
|
return nil ;};_dfg ,_cgf :=_gg .GetNumbersAsFloat (_gef .Params );if _cgf !=nil {return _cgf ;};_beg .Log .Debug ("M\u006f\u0076\u0065\u0020\u0074\u006f\u003a\u0020\u0025\u0076",_dfg );_ddg .NewSubPath ();_ddg .MoveTo (_dfg [0],_dfg [1]);case "\u006c":if len (_gef .Params )!=2{_beg .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",_ac );
|
|
return nil ;};_cdef ,_fca :=_gg .GetNumbersAsFloat (_gef .Params );if _fca !=nil {return _fca ;};_ddg .LineTo (_cdef [0],_cdef [1]);case "\u0063":if len (_gef .Params )!=6{return _ac ;};_agaa ,_bagc :=_gg .GetNumbersAsFloat (_gef .Params );if _bagc !=nil {return _bagc ;
|
|
};_beg .Log .Debug ("\u0043u\u0062\u0069\u0063\u0020\u0062\u0065\u007a\u0069\u0065\u0072\u0020p\u0061\u0072\u0061\u006d\u0073\u003a\u0020\u0025\u002b\u0076",_agaa );_ddg .CubicTo (_agaa [0],_agaa [1],_agaa [2],_agaa [3],_agaa [4],_agaa [5]);case "\u0076","\u0079":if len (_gef .Params )!=4{return _ac ;
|
|
};_aba ,_afb :=_gg .GetNumbersAsFloat (_gef .Params );if _afb !=nil {return _afb ;};_beg .Log .Debug ("\u0043u\u0062\u0069\u0063\u0020\u0062\u0065\u007a\u0069\u0065\u0072\u0020p\u0061\u0072\u0061\u006d\u0073\u003a\u0020\u0025\u002b\u0076",_aba );_ddg .QuadraticTo (_aba [0],_aba [1],_aba [2],_aba [3]);
|
|
case "\u0068":_ddg .ClosePath ();_ddg .NewSubPath ();case "\u0072\u0065":if len (_gef .Params )!=4{return _ac ;};_caa ,_ceg :=_gg .GetNumbersAsFloat (_gef .Params );if _ceg !=nil {return _ceg ;};_ddg .DrawRectangle (_caa [0],_caa [1],_caa [2],_caa [3]);
|
|
_ddg .NewSubPath ();case "\u0053":_afd ,_cdeg :=_bae .ColorspaceStroking .ColorToRGB (_bae .ColorStroking );if _cdeg !=nil {_beg .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",_cdeg );
|
|
return _cdeg ;};_dee ,_cff :=_afd .(*_aa .PdfColorDeviceRGB );if !_cff {_beg .Log .Debug ("\u0045\u0072\u0072\u006fr \u0063\u006f\u006e\u0076\u0065\u0072\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006co\u0072");return _cdeg ;};_ddg .SetRGBA (_dee .R (),_dee .G (),_dee .B (),1);
|
|
_ddg .Stroke ();case "\u0073":_aef ,_agaf :=_bae .ColorspaceStroking .ColorToRGB (_bae .ColorStroking );if _agaf !=nil {_beg .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",_agaf );
|
|
return _agaf ;};_ffdg ,_feaf :=_aef .(*_aa .PdfColorDeviceRGB );if !_feaf {_beg .Log .Debug ("\u0045\u0072\u0072\u006fr \u0063\u006f\u006e\u0076\u0065\u0072\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006co\u0072");return _agaf ;};_ddg .ClosePath ();_ddg .NewSubPath ();
|
|
_ddg .SetRGBA (_ffdg .R (),_ffdg .G (),_ffdg .B (),1);_ddg .Stroke ();case "\u0066","\u0046":_fgc ,_eb :=_bae .ColorspaceNonStroking .ColorToRGB (_bae .ColorNonStroking );if _eb !=nil {_beg .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",_eb );
|
|
return _eb ;};switch _db :=_fgc .(type ){case *_aa .PdfColorDeviceRGB :_ddg .SetRGBA (_db .R (),_db .G (),_db .B (),1);_ddg .SetFillRule (_ga .FillRuleWinding );_ddg .Fill ();case *_aa .PdfColorPattern :_ddg .Fill ();};_beg .Log .Debug ("\u0045\u0072\u0072\u006fr \u0063\u006f\u006e\u0076\u0065\u0072\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006co\u0072");
|
|
case "\u0066\u002a":_fgd ,_cca :=_bae .ColorspaceNonStroking .ColorToRGB (_bae .ColorNonStroking );if _cca !=nil {_beg .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_cca );
|
|
return _cca ;};_bb ,_beb :=_fgd .(*_aa .PdfColorDeviceRGB );if !_beb {_beg .Log .Debug ("\u0045\u0072\u0072\u006fr \u0063\u006f\u006e\u0076\u0065\u0072\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006co\u0072");return _cca ;};_ddg .SetRGBA (_bb .R (),_bb .G (),_bb .B (),1);
|
|
_ddg .SetFillRule (_ga .FillRuleEvenOdd );_ddg .Fill ();case "\u0042":_aeg ,_fbd :=_bae .ColorspaceNonStroking .ColorToRGB (_bae .ColorNonStroking );if _fbd !=nil {_beg .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",_fbd );
|
|
return _fbd ;};switch _aee :=_aeg .(type ){case *_aa .PdfColorDeviceRGB :_ddg .SetRGBA (_aee .R (),_aee .G (),_aee .B (),1);_ddg .SetFillRule (_ga .FillRuleWinding );_ddg .FillPreserve ();_aeg ,_fbd =_bae .ColorspaceStroking .ColorToRGB (_bae .ColorStroking );
|
|
if _fbd !=nil {_beg .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",_fbd );return _fbd ;};if _bfae ,_egg :=_aeg .(*_aa .PdfColorDeviceRGB );
|
|
_egg {_ddg .SetRGBA (_bfae .R (),_bfae .G (),_bfae .B (),1);_ddg .Stroke ();};case *_aa .PdfColorPattern :_ddg .SetFillRule (_ga .FillRuleWinding );_ddg .Fill ();_ddg .StrokePattern ();};case "\u0042\u002a":_dc ,_ecf :=_bae .ColorspaceNonStroking .ColorToRGB (_bae .ColorNonStroking );
|
|
if _ecf !=nil {_beg .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",_ecf );return _ecf ;};switch _acf :=_dc .(type ){case *_aa .PdfColorDeviceRGB :_ddg .SetRGBA (_acf .R (),_acf .G (),_acf .B (),1);
|
|
_ddg .SetFillRule (_ga .FillRuleEvenOdd );_ddg .FillPreserve ();_dc ,_ecf =_bae .ColorspaceStroking .ColorToRGB (_bae .ColorStroking );if _ecf !=nil {_beg .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",_ecf );
|
|
return _ecf ;};if _bdd ,_gded :=_dc .(*_aa .PdfColorDeviceRGB );_gded {_ddg .SetRGBA (_bdd .R (),_bdd .G (),_bdd .B (),1);_ddg .Stroke ();};case *_aa .PdfColorPattern :_ddg .SetFillRule (_ga .FillRuleEvenOdd );_ddg .Fill ();_ddg .StrokePattern ();};case "\u0062":_ddg .ClosePath ();
|
|
_cgb ,_gac :=_bae .ColorspaceNonStroking .ColorToRGB (_bae .ColorNonStroking );if _gac !=nil {_beg .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",_gac );
|
|
return _gac ;};switch _afdf :=_cgb .(type ){case *_aa .PdfColorDeviceRGB :_ddg .SetRGBA (_afdf .R (),_afdf .G (),_afdf .B (),1);_ddg .NewSubPath ();_ddg .SetFillRule (_ga .FillRuleWinding );_ddg .FillPreserve ();_cgb ,_gac =_bae .ColorspaceStroking .ColorToRGB (_bae .ColorStroking );
|
|
if _gac !=nil {_beg .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",_gac );return _gac ;};if _bdc ,_ede :=_cgb .(*_aa .PdfColorDeviceRGB );
|
|
_ede {_ddg .SetRGBA (_bdc .R (),_bdc .G (),_bdc .B (),1);_ddg .Stroke ();};case *_aa .PdfColorPattern :_ddg .NewSubPath ();_ddg .SetFillRule (_ga .FillRuleWinding );_ddg .Fill ();_ddg .StrokePattern ();};case "\u0062\u002a":_ddg .ClosePath ();_agbe ,_ffa :=_bae .ColorspaceNonStroking .ColorToRGB (_bae .ColorNonStroking );
|
|
if _ffa !=nil {_beg .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",_ffa );return _ffa ;};switch _bba :=_agbe .(type ){case *_aa .PdfColorDeviceRGB :_ddg .SetRGBA (_bba .R (),_bba .G (),_bba .B (),1);
|
|
_ddg .NewSubPath ();_ddg .SetFillRule (_ga .FillRuleEvenOdd );_ddg .FillPreserve ();_agbe ,_ffa =_bae .ColorspaceStroking .ColorToRGB (_bae .ColorStroking );if _ffa !=nil {_beg .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",_ffa );
|
|
return _ffa ;};if _fbb ,_dbf :=_agbe .(*_aa .PdfColorDeviceRGB );_dbf {_ddg .SetRGBA (_fbb .R (),_fbb .G (),_fbb .B (),1);_ddg .Stroke ();};case *_aa .PdfColorPattern :_ddg .NewSubPath ();_ddg .SetFillRule (_ga .FillRuleEvenOdd );_ddg .Fill ();_ddg .StrokePattern ();
|
|
};case "\u006e":_ddg .ClearPath ();case "\u0057":_ddg .SetFillRule (_ga .FillRuleWinding );_ddg .ClipPreserve ();case "\u0057\u002a":_ddg .SetFillRule (_ga .FillRuleEvenOdd );_ddg .ClipPreserve ();case "\u0072\u0067":_dce ,_fcgc :=_bae .ColorNonStroking .(*_aa .PdfColorDeviceRGB );
|
|
if !_fcgc {_beg .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",_bae .ColorNonStroking );return nil ;};_ddg .SetFillRGBA (_dce .R (),_dce .G (),_dce .B (),1);
|
|
case "\u0052\u0047":_gdef ,_ced :=_bae .ColorStroking .(*_aa .PdfColorDeviceRGB );if !_ced {_beg .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",_bae .ColorStroking );
|
|
return nil ;};_ddg .SetStrokeRGBA (_gdef .R (),_gdef .G (),_gdef .B (),1);case "\u006b":_deg ,_bcgg :=_bae .ColorNonStroking .(*_aa .PdfColorDeviceCMYK );if !_bcgg {_beg .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",_bae .ColorNonStroking );
|
|
return nil ;};_dfgg ,_dgb :=_bae .ColorspaceNonStroking .ColorToRGB (_deg );if _dgb !=nil {_beg .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",_bae .ColorNonStroking );
|
|
return nil ;};_aega ,_bcgg :=_dfgg .(*_aa .PdfColorDeviceRGB );if !_bcgg {_beg .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",_dfgg );return nil ;
|
|
};_ddg .SetFillRGBA (_aega .R (),_aega .G (),_aega .B (),1);case "\u004b":_daga ,_fba :=_bae .ColorStroking .(*_aa .PdfColorDeviceCMYK );if !_fba {_beg .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",_bae .ColorStroking );
|
|
return nil ;};_aae ,_ecb :=_bae .ColorspaceStroking .ColorToRGB (_daga );if _ecb !=nil {_beg .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",_bae .ColorStroking );
|
|
return nil ;};_fdd ,_fba :=_aae .(*_aa .PdfColorDeviceRGB );if !_fba {_beg .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",_aae );return nil ;
|
|
};_ddg .SetStrokeRGBA (_fdd .R (),_fdd .G (),_fdd .B (),1);case "\u0067":_fag ,_cfc :=_bae .ColorNonStroking .(*_aa .PdfColorDeviceGray );if !_cfc {_beg .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",_bae .ColorNonStroking );
|
|
return nil ;};_acb ,_bg :=_bae .ColorspaceNonStroking .ColorToRGB (_fag );if _bg !=nil {_beg .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",_bae .ColorNonStroking );
|
|
return nil ;};_gge ,_cfc :=_acb .(*_aa .PdfColorDeviceRGB );if !_cfc {_beg .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",_acb );return nil ;
|
|
};_ddg .SetFillRGBA (_gge .R (),_gge .G (),_gge .B (),1);case "\u0047":_gbc ,_fec :=_bae .ColorStroking .(*_aa .PdfColorDeviceGray );if !_fec {_beg .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",_bae .ColorStroking );
|
|
return nil ;};_bgf ,_eba :=_bae .ColorspaceStroking .ColorToRGB (_gbc );if _eba !=nil {_beg .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",_bae .ColorStroking );
|
|
return nil ;};_ggb ,_fec :=_bgf .(*_aa .PdfColorDeviceRGB );if !_fec {_beg .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",_bgf );return nil ;
|
|
};_ddg .SetStrokeRGBA (_ggb .R (),_ggb .G (),_ggb .B (),1);case "\u0063\u0073":if len (_gef .Params )> 0{if _fed ,_abe :=_gg .GetName (_gef .Params [0]);_abe &&_fed .String ()=="\u0050a\u0074\u0074\u0065\u0072\u006e"{break ;};};_fbf ,_eff :=_bae .ColorspaceNonStroking .ColorToRGB (_bae .ColorNonStroking );
|
|
if _eff !=nil {_beg .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",_bae .ColorNonStroking );return nil ;};_ddc ,_eggd :=_fbf .(*_aa .PdfColorDeviceRGB );
|
|
if !_eggd {_beg .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",_fbf );return nil ;};_ddg .SetFillRGBA (_ddc .R (),_ddc .G (),_ddc .B (),1);
|
|
case "\u0073\u0063":_abg ,_afce :=_bae .ColorspaceNonStroking .ColorToRGB (_bae .ColorNonStroking );if _afce !=nil {_beg .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",_bae .ColorNonStroking );
|
|
return nil ;};_dcg ,_ccd :=_abg .(*_aa .PdfColorDeviceRGB );if !_ccd {_beg .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",_abg );return nil ;
|
|
};_ddg .SetFillRGBA (_dcg .R (),_dcg .G (),_dcg .B (),1);case "\u0073\u0063\u006e":if len (_gef .Params )> 0&&len (_cg .Params )> 0{if _aaed ,_bbf :=_gg .GetName (_cg .Params [0]);_bbf &&_aaed .String ()=="\u0050a\u0074\u0074\u0065\u0072\u006e"{if _bgg ,_ggc :=_gg .GetName (_gef .Params [0]);
|
|
_ggc {_agg ,_gc :=_acc .processGradient (_ddg ,_gef ,_eca ,_bgg );if _gc !=nil {_beg .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0077\u0068\u0065\u006e\u0020\u0070\u0072o\u0063\u0065\u0073\u0073\u0069\u006eg\u0020\u0067\u0072\u0061\u0064\u0069\u0065\u006e\u0074\u0020\u0064\u0061\u0074a\u003a\u0020\u0025\u0076",_gc );
|
|
break ;};if _agg ==nil {_beg .Log .Debug ("\u0055\u006ek\u006e\u006f\u0077n\u0020\u0067\u0072\u0061\u0064\u0069\u0065\u006e\u0074");break ;};_ddg .SetFillStyle (_agg );_ddg .SetStrokeStyle (_agg );break ;};};};_ead ,_abgf :=_bae .ColorspaceNonStroking .ColorToRGB (_bae .ColorNonStroking );
|
|
if _abgf !=nil {_beg .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",_bae .ColorNonStroking );return nil ;};_bfdc ,_ggf :=_ead .(*_aa .PdfColorDeviceRGB );
|
|
if !_ggf {_beg .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 nil ;};_ddg .SetFillRGBA (_bfdc .R (),_bfdc .G (),_bfdc .B (),1);
|
|
case "\u0043\u0053":if len (_gef .Params )> 0{if _adf ,_dcee :=_gg .GetName (_gef .Params [0]);_dcee &&_adf .String ()=="\u0050a\u0074\u0074\u0065\u0072\u006e"{break ;};};_bec ,_ddd :=_bae .ColorspaceStroking .ColorToRGB (_bae .ColorStroking );if _ddd !=nil {_beg .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",_bae .ColorStroking );
|
|
return nil ;};_cbg ,_bfg :=_bec .(*_aa .PdfColorDeviceRGB );if !_bfg {_beg .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 ;
|
|
};_ddg .SetStrokeRGBA (_cbg .R (),_cbg .G (),_cbg .B (),1);case "\u0053\u0043":_egfc ,_dfae :=_bae .ColorspaceStroking .ColorToRGB (_bae .ColorStroking );if _dfae !=nil {_beg .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",_bae .ColorStroking );
|
|
return nil ;};_cga ,_dfgf :=_egfc .(*_aa .PdfColorDeviceRGB );if !_dfgf {_beg .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",_egfc );return nil ;
|
|
};_ddg .SetStrokeRGBA (_cga .R (),_cga .G (),_cga .B (),1);case "\u0053\u0043\u004e":if len (_gef .Params )> 0&&len (_cg .Params )> 0{if _ebg ,_afbc :=_gg .GetName (_cg .Params [0]);_afbc &&_ebg .String ()=="\u0050a\u0074\u0074\u0065\u0072\u006e"{if _cbee ,_dea :=_gg .GetName (_gef .Params [0]);
|
|
_dea {_gacd ,_add :=_acc .processGradient (_ddg ,_gef ,_eca ,_cbee );if _add !=nil {_beg .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0077\u0068\u0065\u006e\u0020\u0070\u0072o\u0063\u0065\u0073\u0073\u0069\u006eg\u0020\u0067\u0072\u0061\u0064\u0069\u0065\u006e\u0074\u0020\u0064\u0061\u0074a\u003a\u0020\u0025\u0076",_add );
|
|
break ;};if _gacd ==nil {_beg .Log .Debug ("\u0055\u006ek\u006e\u006f\u0077n\u0020\u0067\u0072\u0061\u0064\u0069\u0065\u006e\u0074");break ;};_ddg .SetFillStyle (_gacd );_ddg .SetStrokeStyle (_gacd );break ;};};};_addg ,_dff :=_bae .ColorspaceStroking .ColorToRGB (_bae .ColorStroking );
|
|
if _dff !=nil {_beg .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",_bae .ColorStroking );return nil ;};_bddg ,_bbae :=_addg .(*_aa .PdfColorDeviceRGB );
|
|
if !_bbae {_beg .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",_addg );return nil ;};_ddg .SetStrokeRGBA (_bddg .R (),_bddg .G (),_bddg .B (),1);
|
|
case "\u0073\u0068":if len (_gef .Params )!=1{_beg .Log .Debug ("\u0049n\u0076\u0061\u006c\u0069\u0064\u0020\u0073\u0068\u0020\u0070\u0061r\u0061\u006d\u0073\u0020\u0066\u006f\u0072\u006d\u0061\u0074");break ;};_dda ,_gbbg :=_gg .GetName (_gef .Params [0]);
|
|
if !_gbbg {_beg .Log .Debug ("F\u0061\u0069\u006c\u0065\u0064\u0020g\u0065\u0074\u0074\u0069\u006e\u0067\u0020\u0073\u0068a\u0064\u0069\u006eg\u0020n\u0061\u006d\u0065");break ;};_fgf ,_gbbg :=_eca .GetShadingByName (*_dda );if !_gbbg {_beg .Log .Debug ("F\u0061\u0069\u006c\u0065\u0064\u0020g\u0065\u0074\u0074\u0069\u006e\u0067\u0020\u0073\u0068a\u0064\u0069\u006eg\u0020d\u0061\u0074\u0061");
|
|
break ;};_gff ,_bcgb ,_eac :=_acc .processShading (_ddg ,_fgf );if _eac !=nil {_beg .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0077\u0068\u0065\u006e\u0020\u0070\u0072\u006f\u0063\u0065\u0073\u0073\u0069\u006e\u0067\u0020\u0073\u0068a\u0064\u0069\u006e\u0067\u0020d\u0061\u0074a\u003a\u0020\u0025\u0076",_eac );
|
|
break ;};if _gff ==nil {_beg .Log .Debug ("\u0055\u006ek\u006e\u006f\u0077n\u0020\u0067\u0072\u0061\u0064\u0069\u0065\u006e\u0074");break ;};_agf ,_eac :=_bcgb .ToFloat64Array ();if _eac !=nil {_beg .Log .Debug ("\u0045\u0072r\u006f\u0072\u0020\u0070\u0061\u0072\u0073\u0069\u006e\u0067\u0020\u0063\u006f\u006f\u0072\u0064\u0069\u006e\u0061\u0074\u0065\u0073: \u0025\u0076",_eac );
|
|
break ;};_ddg .DrawRectangle (_agf [0],_agf [1],_agf [2],_agf [3]);_ddg .NewSubPath ();_ddg .SetFillStyle (_gff );_ddg .SetStrokeStyle (_gff );_ddg .Fill ();case "\u0044\u006f":if len (_gef .Params )!=1{return _ac ;};_geb ,_abf :=_gg .GetName (_gef .Params [0]);
|
|
if !_abf {return _eg ;};_ ,_fac :=_eca .GetXObjectByName (*_geb );switch _fac {case _aa .XObjectTypeImage :_beg .Log .Debug ("\u0058\u004f\u0062\u006a\u0065\u0063\u0074\u0020\u0069\u006d\u0061\u0067e\u003a\u0020\u0025\u0073",_geb .String ());_aeec ,_bbd :=_eca .GetXObjectImageByName (*_geb );
|
|
if _bbd !=nil {return _bbd ;};_dab ,_bbd :=_aeec .ToImage ();if _bbd !=nil {return _bbd ;};if _afa :=_aeec .ColorSpace ;_afa !=nil {var _cbb bool ;switch _afa .(type ){case *_aa .PdfColorspaceSpecialIndexed :_cbb =true ;};if _cbb {if _dgg ,_gffg :=_afa .ImageToRGB (*_dab );
|
|
_gffg !=nil {_beg .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 {_dab =&_dgg ;};};};_dbd :=_ddg .FillPattern ().ColorAt (0,0);var _cbf _ag .Image ;if _aeec .Mask !=nil {if _cbf ,_bbd =_fad (_aeec .Mask ,_dbd );_bbd !=nil {_beg .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 _aeec .SMask !=nil {if _cbf ,_bbd =_gefd (_aeec .SMask ,_dbd );_bbd !=nil {_beg .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 _cee _ag .Image ;if _abee ,_ :=_gg .GetBoolVal (_aeec .ImageMask );_abee {_cee =_acg (_dab ,_dbd );}else {_cee ,_bbd =_dab .ToGoImage ();if _bbd !=nil {return _bbd ;};};if _cbf !=nil {_cee =_cfg (_cee ,_cbf );};_gdf :=_cee .Bounds ();_ddg .Push ();
|
|
_ddg .Scale (1.0/float64 (_gdf .Dx ()),-1.0/float64 (_gdf .Dy ()));_ddg .DrawImageAnchored (_cee ,0,0,0,1);_ddg .Pop ();case _aa .XObjectTypeForm :_beg .Log .Debug ("\u0058\u004fb\u006a\u0065\u0063t\u0020\u0066\u006f\u0072\u006d\u003a\u0020\u0025\u0073",_geb .String ());
|
|
_becg ,_gebc :=_eca .GetXObjectFormByName (*_geb );if _gebc !=nil {return _gebc ;};_cbd ,_gebc :=_becg .GetContentStream ();if _gebc !=nil {return _gebc ;};_ded :=_becg .Resources ;if _ded ==nil {_ded =_eca ;};_ddg .Push ();if _becg .Matrix !=nil {_ecfg ,_cfb :=_gg .GetArray (_becg .Matrix );
|
|
if !_cfb {return _eg ;};_acd ,_egd :=_gg .GetNumbersAsFloat (_ecfg .Elements ());if _egd !=nil {return _egd ;};if len (_acd )!=6{return _ac ;};_cgd :=_fc .NewMatrix (_acd [0],_acd [1],_acd [2],_acd [3],_acd [4],_acd [5]);_ddg .SetMatrix (_ddg .Matrix ().Mult (_cgd ));
|
|
};if _becg .BBox !=nil {_abfe ,_ccb :=_gg .GetArray (_becg .BBox );if !_ccb {return _eg ;};_gce ,_abd :=_gg .GetNumbersAsFloat (_abfe .Elements ());if _abd !=nil {return _abd ;};if len (_gce )!=4{_beg .Log .Debug ("\u004c\u0065\u006e\u0020\u003d\u0020\u0025\u0064",len (_gce ));
|
|
return _ac ;};_ddg .DrawRectangle (_gce [0],_gce [1],_gce [2]-_gce [0],_gce [3]-_gce [1]);_ddg .SetRGBA (1,0,0,1);_ddg .Clip ();}else {_beg .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");
|
|
};_gebc =_acc .renderContentStream (_ddg ,string (_cbd ),_ded );if _gebc !=nil {return _gebc ;};_ddg .Pop ();};case "\u0042\u0049":if len (_gef .Params )!=1{return _ac ;};_ege ,_bedd :=_gef .Params [0].(*_aga .ContentStreamInlineImage );if !_bedd {return nil ;
|
|
};_cfd ,_dgbb :=_ege .ToImage (_eca );if _dgbb !=nil {return _dgbb ;};_bbg ,_dgbb :=_cfd .ToGoImage ();if _dgbb !=nil {return _dgbb ;};_aca :=_bbg .Bounds ();_ddg .Push ();_ddg .Scale (1.0/float64 (_aca .Dx ()),-1.0/float64 (_aca .Dy ()));_ddg .DrawImageAnchored (_bbg ,0,0,0,1);
|
|
_ddg .Pop ();case "\u0042\u0054":_agb .Reset ();case "\u0045\u0054":_agb .Reset ();case "\u0054\u0072":if len (_gef .Params )!=1{return _ac ;};_fbab ,_gee :=_gg .GetNumberAsFloat (_gef .Params [0]);if _gee !=nil {return _gee ;};_agb .Tr =_ga .TextRenderingMode (_fbab );
|
|
case "\u0054\u004c":if len (_gef .Params )!=1{return _ac ;};_ffg ,_egdd :=_gg .GetNumberAsFloat (_gef .Params [0]);if _egdd !=nil {return _egdd ;};_agb .Tl =_ffg ;case "\u0054\u0063":if len (_gef .Params )!=1{return _ac ;};_aaee ,_gbd :=_gg .GetNumberAsFloat (_gef .Params [0]);
|
|
if _gbd !=nil {return _gbd ;};_beg .Log .Debug ("\u0054\u0063\u003a\u0020\u0025\u0076",_aaee );_agb .Tc =_aaee ;case "\u0054\u0077":if len (_gef .Params )!=1{return _ac ;};_bcgbg ,_efg :=_gg .GetNumberAsFloat (_gef .Params [0]);if _efg !=nil {return _efg ;
|
|
};_beg .Log .Debug ("\u0054\u0077\u003a\u0020\u0025\u0076",_bcgbg );_agb .Tw =_bcgbg ;case "\u0054\u007a":if len (_gef .Params )!=1{return _ac ;};_ffbg ,_gfg :=_gg .GetNumberAsFloat (_gef .Params [0]);if _gfg !=nil {return _gfg ;};_agb .Th =_ffbg ;case "\u0054\u0073":if len (_gef .Params )!=1{return _ac ;
|
|
};_fddd ,_gdd :=_gg .GetNumberAsFloat (_gef .Params [0]);if _gdd !=nil {return _gdd ;};_agb .Ts =_fddd ;case "\u0054\u0064":if len (_gef .Params )!=2{return _ac ;};_ece ,_afbd :=_gg .GetNumbersAsFloat (_gef .Params );if _afbd !=nil {return _afbd ;};_beg .Log .Debug ("\u0054\u0064\u003a\u0020\u0025\u0076",_ece );
|
|
_agb .ProcTd (_ece [0],_ece [1]);case "\u0054\u0044":if len (_gef .Params )!=2{return _ac ;};_cgfb ,_cgbe :=_gg .GetNumbersAsFloat (_gef .Params );if _cgbe !=nil {return _cgbe ;};_beg .Log .Debug ("\u0054\u0044\u003a\u0020\u0025\u0076",_cgfb );_agb .ProcTD (_cgfb [0],_cgfb [1]);
|
|
case "\u0054\u002a":_agb .ProcTStar ();case "\u0054\u006d":if len (_gef .Params )!=6{return _ac ;};_bcf ,_deae :=_gg .GetNumbersAsFloat (_gef .Params );if _deae !=nil {return _deae ;};_beg .Log .Debug ("\u0054\u0065x\u0074\u0020\u006da\u0074\u0072\u0069\u0078\u003a\u0020\u0025\u002b\u0076",_bcf );
|
|
_agb .ProcTm (_bcf [0],_bcf [1],_bcf [2],_bcf [3],_bcf [4],_bcf [5]);case "\u0027":if len (_gef .Params )!=1{return _ac ;};_egda ,_bga :=_gg .GetStringBytes (_gef .Params [0]);if !_bga {return _eg ;};_beg .Log .Debug ("\u0027\u0020\u0073t\u0072\u0069\u006e\u0067\u003a\u0020\u0025\u0073",string (_egda ));
|
|
_agb .ProcQ (_egda ,_ddg );case "\u0022":if len (_gef .Params )!=3{return _ac ;};_eed ,_bad :=_gg .GetNumberAsFloat (_gef .Params [0]);if _bad !=nil {return _bad ;};_ggbb ,_bad :=_gg .GetNumberAsFloat (_gef .Params [1]);if _bad !=nil {return _bad ;};_eeb ,_cfcb :=_gg .GetStringBytes (_gef .Params [2]);
|
|
if !_cfcb {return _eg ;};_agb .ProcDQ (_eeb ,_eed ,_ggbb ,_ddg );case "\u0054\u006a":if len (_gef .Params )!=1{return _ac ;};_gefe ,_ade :=_gg .GetStringBytes (_gef .Params [0]);if !_ade {return _eg ;};_beg .Log .Debug ("\u0054j\u0020s\u0074\u0072\u0069\u006e\u0067\u003a\u0020\u0060\u0025\u0073\u0060",string (_gefe ));
|
|
_agb .ProcTj (_gefe ,_ddg );case "\u0054\u004a":if len (_gef .Params )!=1{return _ac ;};_gaa ,_fgba :=_gg .GetArray (_gef .Params [0]);if !_fgba {_beg .Log .Debug ("\u0054\u0079\u0070\u0065\u003a\u0020\u0025\u0054",_gaa );return _eg ;};_beg .Log .Debug ("\u0054\u004a\u0020\u0061\u0072\u0072\u0061\u0079\u003a\u0020\u0025\u002b\u0076",_gaa );
|
|
for _ ,_cgdg :=range _gaa .Elements (){switch _eee :=_cgdg .(type ){case *_gg .PdfObjectString :if _eee !=nil {_agb .ProcTj (_eee .Bytes (),_ddg );};case *_gg .PdfObjectFloat ,*_gg .PdfObjectInteger :_cdfb ,_dagb :=_gg .GetNumberAsFloat (_eee );if _dagb ==nil {_agb .Translate (-_cdfb *0.001*_agb .Tf .Size *_agb .Th /100.0,0);
|
|
};};};case "\u0054\u0066":if len (_gef .Params )!=2{return _ac ;};_beg .Log .Debug ("\u0025\u0023\u0076",_gef .Params );_dde ,_deaa :=_gg .GetName (_gef .Params [0]);if !_deaa ||_dde ==nil {_beg .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",_gef .Params [0]);
|
|
return _eg ;};_beg .Log .Debug ("\u0046\u006f\u006e\u0074\u0020\u006e\u0061\u006d\u0065\u003a\u0020\u0025\u0073",_dde .String ());_aec ,_gba :=_gg .GetNumberAsFloat (_gef .Params [1]);if _gba !=nil {_beg .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",_gef .Params [1]);
|
|
return _eg ;};_beg .Log .Debug ("\u0046\u006f\u006e\u0074\u0020\u0073\u0069\u007a\u0065\u003a\u0020\u0025\u0076",_aec );_gbe ,_ecd :=_eca .GetFontByName (*_dde );if !_ecd {_beg .Log .Debug ("\u0045R\u0052\u004f\u0052\u003a\u0020\u0046\u006f\u006e\u0074\u0020\u0025s\u0020\u006e\u006f\u0074\u0020\u0066\u006f\u0075\u006e\u0064",_dde .String ());
|
|
return _c .New ("\u0066\u006f\u006e\u0074\u0020\u006e\u006f\u0074\u0020f\u006f\u0075\u006e\u0064");};_beg .Log .Debug ("\u0046\u006f\u006e\u0074\u003a\u0020\u0025\u0054",_gbe );_fga ,_deaa :=_gg .GetDict (_gbe );if !_deaa {_beg .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 _eg ;};_addc ,_gba :=_aa .NewPdfFontFromPdfObject (_fga );if _gba !=nil {_beg .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 _gba ;};_ecge :=_addc .BaseFont ();if _ecge ==""{_ecge =_dde .String ();};_daba ,_deaa :=_ec [_ecge ];if !_deaa {_daba ,_gba =_ga .NewTextFont (_addc ,_aec );if _gba !=nil {_beg .Log .Debug ("\u0045R\u0052\u004f\u0052\u003a\u0020\u0025v",_gba );
|
|
};};if _daba ==nil {if len (_ecge )> 7&&_ecge [6]=='+'{_ecge =_ecge [7:];};_ffbb :=[]string {_ecge ,"\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 _ ,_cebb :=range _ffbb {_beg .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",_cebb );if _daba ,_deaa =_ec [_cebb ];
|
|
_deaa {break ;};_eda :=_faf .Match (_cebb );if _eda ==nil {_beg .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",_cebb );continue ;};_daba ,_gba =_ga .NewTextFontFromPath (_eda .Filename ,_aec );
|
|
if _gba !=nil {_beg .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",_eda .Filename );continue ;};_beg .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",_ecge ,_eda .Name ,_eda .Filename );
|
|
_ec [_cebb ]=_daba ;break ;};};if _daba ==nil {_beg .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");};_agb .ProcTf (_daba .WithSize (_aec ,_addc ));case "\u0042\u004d\u0043","\u0042\u0044\u0043":case "\u0045\u004d\u0043":default:_beg .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",_gef .Operand );
|
|
};_cg =_gef ;return nil ;});_afc =_dag .Process (_egf );if _afc !=nil {return _afc ;};return nil ;};func _eef (_cdgg string ,_dgbf _ag .Image ,_fgag int )error {_bac ,_cfcbg :=_f .Create (_cdgg );if _cfcbg !=nil {return _cfcbg ;};defer _bac .Close ();return _da .Encode (_bac ,_dgbf ,&_da .Options {Quality :_fgag });
|
|
};func _fad (_eab _gg .PdfObject ,_afag _g .Color )(_ag .Image ,error ){_edf ,_begb :=_gg .GetStream (_eab );if !_begb {return nil ,nil ;};_ebf ,_ccg :=_aa .NewXObjectImageFromStream (_edf );if _ccg !=nil {return nil ,_ccg ;};_ccf ,_ccg :=_ebf .ToImage ();
|
|
if _ccg !=nil {return nil ,_ccg ;};return _acg (_ccf ,_afag ),nil ;};
|
|
|
|
// PdfShadingType defines PDF shading types.
|
|
// Source: PDF32000_2008.pdf. Chapter 8.7.4.5
|
|
type PdfShadingType int64 ;func (_de renderer )renderPage (_fea _ga .Context ,_bedg *_aa .PdfPage ,_ca _fc .Matrix )error {_dg ,_cde :=_bedg .GetAllContentStreams ();if _cde !=nil {return _cde ;};if _ea :=_ca ;!_ea .Identity (){_dg =_be .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",_ea [0],_ea [1],_ea [3],_ea [4],_ea [6],_ea [7],_dg );
|
|
};_fea .Translate (0,float64 (_fea .Height ()));_fea .Scale (1,-1);_fea .Push ();_fea .SetRGBA (1,1,1,1);_fea .DrawRectangle (0,0,float64 (_fea .Width ()),float64 (_fea .Height ()));_fea .Fill ();_fea .Pop ();_fea .SetLineWidth (1.0);_fea .SetRGBA (0,0,0,1);
|
|
return _de .renderContentStream (_fea ,_dg ,_bedg .Resources );};func (_agcc renderer )processLinearShading (_befb _ga .Context ,_aada *_aa .PdfShading )(_ga .Gradient ,*_gg .PdfObjectArray ,error ){_ggbc :=_aada .GetContext ().(*_aa .PdfShadingType2 );
|
|
if len (_ggbc .Function )==0{return nil ,nil ,_c .New ("\u006e\u006f\u0020\u0067\u0072\u0061\u0064i\u0065\u006e\u0074 \u0066\u0075\u006e\u0063t\u0069\u006f\u006e\u0020\u0066\u006f\u0075\u006e\u0064\u002c\u0020\u0073\u006b\u0069\u0070\u0020\u0063\u006f\u006e\u0076\u0065\u0072\u0073\u0069\u006f\u006e");
|
|
};_gbbc ,_ebab :=_ggbc .Coords .ToFloat64Array ();if _ebab !=nil {return nil ,nil ,_c .New ("\u0066\u0061\u0069l\u0065\u0064\u0020\u0067e\u0074\u0074\u0069\u006e\u0067\u0020\u0073h\u0061\u0064\u0069\u006e\u0067\u0020\u0070\u006f\u0073\u0069\u0074\u0069\u006f\u006e");
|
|
};_dad :=_aada .ColorSpace ;_ccc ,_gfd :=_befb .Matrix ().Transform (_gbbc [0],_gbbc [1]);_ecdc ,_agfb :=_befb .Matrix ().Transform (_gbbc [2],_gbbc [3]);_efe :=_bff .NewLinearGradient (_ccc ,_gfd ,_ecdc ,_agfb );_bfca :=_gg .MakeArrayFromFloats ([]float64 {0,0,1,1});
|
|
for _ ,_dbb :=range _gbbc {if _dbb > 1{_bfca =_ggbc .Coords ;break ;};};if _dge ,_cgbg :=_ggbc .Function [0].(*_aa .PdfFunctionType2 );_cgbg {_efe ,_ebab =_bfgb (_efe ,_dge ,_dad ,1.0,true );}else if _gfdb ,_agccf :=_ggbc .Function [0].(*_aa .PdfFunctionType3 );
|
|
_agccf {_bdg :=append ([]float64 {0},_gfdb .Bounds ...);_bdg =append (_bdg ,1.0);_efe ,_ebab =_gddf (_efe ,_gfdb ,_dad ,_bdg );};return _efe ,_bfca ,_ebab ;};
|
|
|
|
// NewImageDevice returns a new image device.
|
|
func NewImageDevice ()*ImageDevice {const _fe ="r\u0065\u006e\u0064\u0065r.\u004ee\u0077\u0049\u006d\u0061\u0067e\u0044\u0065\u0076\u0069\u0063\u0065";_ce .TrackUse (_fe );return &ImageDevice {};};func _gefd (_accg _gg .PdfObject ,_aadg _g .Color )(_ag .Image ,error ){_aeeb ,_dgeb :=_gg .GetStream (_accg );
|
|
if !_dgeb {return nil ,nil ;};_ccbg ,_ebgg :=_aa .NewXObjectImageFromStream (_aeeb );if _ebgg !=nil {return nil ,_ebgg ;};_gdc ,_ebgg :=_ccbg .ToImage ();if _ebgg !=nil {return nil ,_ebgg ;};return _ccab (_gdc ,_aadg ),nil ;};func _gddf (_gabg _ga .Gradient ,_deeg *_aa .PdfFunctionType3 ,_fddc _aa .PdfColorspace ,_fee []float64 )(_ga .Gradient ,error ){var _fdg error ;
|
|
for _gbg :=0;_gbg < len (_deeg .Functions );_gbg ++{if _cag ,_bfb :=_deeg .Functions [_gbg ].(*_aa .PdfFunctionType2 );_bfb {_gabg ,_fdg =_bfgb (_gabg ,_cag ,_fddc ,_fee [_gbg +1],_gbg ==0);if _fdg !=nil {return nil ,_fdg ;};};};return _gabg ,nil ;};func _eag (_gcc ,_bfgc ,_eec float64 )_cdf .BoundingBox {return _cdf .Path {Points :[]_cdf .Point {_cdf .NewPoint (0,0).Rotate (_eec ),_cdf .NewPoint (_gcc ,0).Rotate (_eec ),_cdf .NewPoint (0,_bfgc ).Rotate (_eec ),_cdf .NewPoint (_gcc ,_bfgc ).Rotate (_eec )}}.GetBoundingBox ();
|
|
};func (_cbc renderer )processRadialShading (_ega _ga .Context ,_gffe *_aa .PdfShading )(_ga .Gradient ,*_gg .PdfObjectArray ,error ){_bfcad :=_gffe .GetContext ().(*_aa .PdfShadingType3 );if len (_bfcad .Function )==0{return nil ,nil ,_c .New ("\u006e\u006f\u0020\u0067\u0072\u0061\u0064i\u0065\u006e\u0074 \u0066\u0075\u006e\u0063t\u0069\u006f\u006e\u0020\u0066\u006f\u0075\u006e\u0064\u002c\u0020\u0073\u006b\u0069\u0070\u0020\u0063\u006f\u006e\u0076\u0065\u0072\u0073\u0069\u006f\u006e");
|
|
};_cab ,_daf :=_bfcad .Coords .ToFloat64Array ();if _daf !=nil {return nil ,nil ,_c .New ("\u0066\u0061\u0069l\u0065\u0064\u0020\u0067e\u0074\u0074\u0069\u006e\u0067\u0020\u0073h\u0061\u0064\u0069\u006e\u0067\u0020\u0070\u006f\u0073\u0069\u0074\u0069\u006f\u006e");
|
|
};_adea :=_gffe .ColorSpace ;_ebd :=_gg .MakeArrayFromFloats ([]float64 {0,0,1,1});var _dfb ,_faga ,_cdea ,_edae ,_gab ,_gaab float64 ;_dfb ,_faga =_ega .Matrix ().Transform (_cab [0],_cab [1]);_cdea ,_edae =_ega .Matrix ().Transform (_cab [3],_cab [4]);
|
|
_gab ,_ =_ega .Matrix ().Transform (_cab [2],0);_gaab ,_ =_ega .Matrix ().Transform (_cab [5],0);_facc ,_ :=_ega .Matrix ().Translation ();_gab -=_facc ;_gaab -=_facc ;for _ceda ,_cdg :=range _cab {if _ceda ==2||_ceda ==5{continue ;};if _cdg > 1.0{_dcec :=_cd .Min (_dfb -_gab ,_cdea -_gaab );
|
|
_egddc :=_cd .Min (_faga -_gab ,_edae -_gaab );_bee :=_cd .Max (_dfb +_gab ,_cdea +_gaab );_dbbc :=_cd .Max (_faga +_gab ,_edae +_gaab );_gcf :=_bee -_dcec ;_ecc :=_egddc -_dbbc ;_ebd =_gg .MakeArrayFromFloats ([]float64 {_dcec ,_egddc ,_gcf ,_ecc });break ;
|
|
};};_gae :=_bff .NewRadialGradient (_dfb ,_faga ,_gab ,_cdea ,_edae ,_gaab );if _ace ,_aeff :=_bfcad .Function [0].(*_aa .PdfFunctionType2 );_aeff {_gae ,_daf =_bfgb (_gae ,_ace ,_adea ,1.0,true );}else if _ecac ,_beec :=_bfcad .Function [0].(*_aa .PdfFunctionType3 );
|
|
_beec {_bcgga :=append ([]float64 {0},_ecac .Bounds ...);_bcgga =append (_bcgga ,1.0);_gae ,_daf =_gddf (_gae ,_ecac ,_adea ,_bcgga );};if _daf !=nil {return nil ,nil ,_daf ;};return _gae ,_ebd ,nil ;};func _acg (_edee *_aa .Image ,_fce _g .Color )_ag .Image {_beddf ,_deaed :=int (_edee .Width ),int (_edee .Height );
|
|
_cdd :=_ag .NewRGBA (_ag .Rect (0,0,_beddf ,_deaed ));for _efff :=0;_efff < _deaed ;_efff ++{for _cccc :=0;_cccc < _beddf ;_cccc ++{_bebb ,_gdfa :=_edee .ColorAt (_cccc ,_efff );if _gdfa !=nil {_beg .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",_cccc ,_efff );
|
|
continue ;};_cffg ,_geef ,_bafb ,_ :=_bebb .RGBA ();var _cdb _g .Color ;if _cffg +_geef +_bafb ==0{_cdb =_fce ;}else {_cdb =_g .Transparent ;};_cdd .Set (_cccc ,_efff ,_cdb );};};return _cdd ;};
|
|
|
|
// Render converts the specified PDF page into an image and returns the result.
|
|
func (_fa *ImageDevice )Render (page *_aa .PdfPage )(_ag .Image ,error ){_aag ,_gb :=page .GetMediaBox ();if _gb !=nil {return nil ,_gb ;};_aag .Normalize ();_bfa :=page .CropBox ;var _gbf ,_dfa float64 ;if _bfa !=nil {_bfa .Normalize ();_gbf ,_dfa =_bfa .Width (),_bfa .Height ();
|
|
};_ed :=page .Rotate ;_bc ,_ff ,_dd ,_gf :=_aag .Llx ,_aag .Lly ,_aag .Width (),_aag .Height ();_cc :=_fc .IdentityMatrix ();if _ed !=nil &&*_ed %360!=0&&*_ed %90==0{_fb :=-float64 (*_ed );_ffd :=_eag (_dd ,_gf ,_fb );_cc =_cc .Translate ((_ffd .Width -_dd )/2+_dd /2,(_ffd .Height -_gf )/2+_gf /2).Rotate (_fb *_cd .Pi /180).Translate (-_dd /2,-_gf /2);
|
|
_dd ,_gf =_ffd .Width ,_ffd .Height ;if _bfa !=nil {_ffe :=_eag (_gbf ,_dfa ,_fb );_gbf ,_dfa =_ffe .Width ,_ffe .Height ;};};if _bc !=0||_ff !=0{_cc =_cc .Translate (-_bc ,-_ff );};_fa ._aaa =1.0;if _fa .OutputWidth !=0{_cf :=_dd ;if _bfa !=nil {_cf =_gbf ;
|
|
};_fa ._aaa =float64 (_fa .OutputWidth )/_cf ;_dd ,_gf ,_gbf ,_dfa =_dd *_fa ._aaa ,_gf *_fa ._aaa ,_gbf *_fa ._aaa ,_dfa *_fa ._aaa ;_cc =_fc .ScaleMatrix (_fa ._aaa ,_fa ._aaa ).Mult (_cc );};_ge :=_bff .NewContext (int (_dd ),int (_gf ));if _fg :=_fa .renderPage (_ge ,page ,_cc );
|
|
_fg !=nil {return nil ,_fg ;};_aad :=_ge .Image ();if _bfa !=nil {_ba ,_cbe :=(_bfa .Llx -_bc )*_fa ._aaa ,(_bfa .Lly -_ff )*_fa ._aaa ;_bd :=_ag .Rect (0,0,int (_gbf ),int (_dfa ));_daa :=_ag .Pt (int (_ba ),int (_gf -_cbe -_dfa ));_bed :=_ag .NewRGBA (_bd );
|
|
_df .Draw (_bed ,_bd ,_aad ,_daa ,_df .Src );_aad =_bed ;};return _aad ,nil ;};func _ccab (_ebfe *_aa .Image ,_gebb _g .Color )_ag .Image {_eace ,_fgga :=int (_ebfe .Width ),int (_ebfe .Height );_abcd :=_ag .NewRGBA (_ag .Rect (0,0,_eace ,_fgga ));for _age :=0;
|
|
_age < _fgga ;_age ++{for _gcb :=0;_gcb < _eace ;_gcb ++{_gcd ,_bbc :=_ebfe .ColorAt (_gcb ,_age );if _bbc !=nil {_beg .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",_gcb ,_age );
|
|
continue ;};_bgb ,_adc ,_adfa ,_ :=_gcd .RGBA ();var _dec _g .Color ;if _bgb +_adc +_adfa ==0{_dec =_g .Transparent ;}else {_dec =_gebb ;};_abcd .Set (_gcb ,_age ,_dec );};};return _abcd ;};var (_eg =_c .New ("\u0074\u0079p\u0065\u0020\u0063h\u0065\u0063\u006b\u0020\u0065\u0072\u0072\u006f\u0072");
|
|
_ac =_c .New ("\u0072\u0061\u006e\u0067\u0065\u0020\u0063\u0068\u0065\u0063\u006b\u0020e\u0072\u0072\u006f\u0072");); |