mirror of
https://github.com/unidoc/unipdf.git
synced 2025-04-26 13:48:55 +08:00
206 lines
54 KiB
Go
206 lines
54 KiB
Go
//
|
|
// Copyright 2020 FoxyUtils ehf. All rights reserved.
|
|
//
|
|
// This is a commercial product and requires a license to operate.
|
|
// A trial license can be obtained at https://unidoc.io
|
|
//
|
|
// DO NOT EDIT: generated by unitwist Go source code obfuscator.
|
|
//
|
|
// Use of this source code is governed by the UniDoc End User License Agreement
|
|
// terms that can be accessed at https://unidoc.io/eula/
|
|
|
|
package render ;import (_a "errors";_be "fmt";_da "github.com/adrg/sysfont";_gg "github.com/unidoc/unipdf/v3/annotator";_e "github.com/unidoc/unipdf/v3/common";_df "github.com/unidoc/unipdf/v3/contentstream";_aab "github.com/unidoc/unipdf/v3/contentstream/draw";
|
|
_fc "github.com/unidoc/unipdf/v3/core";_ce "github.com/unidoc/unipdf/v3/internal/license";_ca "github.com/unidoc/unipdf/v3/internal/transform";_ab "github.com/unidoc/unipdf/v3/model";_cb "github.com/unidoc/unipdf/v3/render/internal/context";_beb "github.com/unidoc/unipdf/v3/render/internal/context/imagerender";
|
|
_cf "golang.org/x/image/draw";_gb "image";_bb "image/color";_f "image/draw";_aa "image/jpeg";_b "image/png";_c "math";_gf "os";_af "path/filepath";_d "strings";);const (ShadingTypeFunctionBased PdfShadingType =1;ShadingTypeAxial PdfShadingType =2;ShadingTypeRadial PdfShadingType =3;
|
|
ShadingTypeFreeForm PdfShadingType =4;ShadingTypeLatticeForm PdfShadingType =5;ShadingTypeCoons PdfShadingType =6;ShadingTypeTensorProduct PdfShadingType =7;);
|
|
|
|
// NewImageDevice returns a new image device.
|
|
func NewImageDevice ()*ImageDevice {const _eg ="r\u0065\u006e\u0064\u0065r.\u004ee\u0077\u0049\u006d\u0061\u0067e\u0044\u0065\u0076\u0069\u0063\u0065";_ce .TrackUse (_eg );return &ImageDevice {};};
|
|
|
|
// Render converts the specified PDF page into an image, flattens annotations by default and returns the result.
|
|
func (_ad *ImageDevice )Render (page *_ab .PdfPage )(_gb .Image ,error ){return _ad .RenderWithOpts (page ,false );};func _cea (_dbe *_ab .Image ,_geff _bb .Color )_gb .Image {_aefa ,_debf :=int (_dbe .Width ),int (_dbe .Height );_fgee :=_gb .NewRGBA (_gb .Rect (0,0,_aefa ,_debf ));
|
|
for _ffac :=0;_ffac < _debf ;_ffac ++{for _feff :=0;_feff < _aefa ;_feff ++{_aea ,_fee :=_dbe .ColorAt (_feff ,_ffac );if _fee !=nil {_e .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",_feff ,_ffac );
|
|
continue ;};_gdb ,_bed ,_dfg ,_ :=_aea .RGBA ();var _ffbd _bb .Color ;if _gdb +_bed +_dfg ==0{_ffbd =_geff ;}else {_ffbd =_bb .Transparent ;};_fgee .Set (_feff ,_ffac ,_ffbd );};};return _fgee ;};func _gfcd (_dfgd ,_gde _gb .Image )_gb .Image {_egea ,_ede :=_gde .Bounds ().Size (),_dfgd .Bounds ().Size ();
|
|
_ccc ,_edc :=_egea .X ,_egea .Y ;if _ede .X > _ccc {_ccc =_ede .X ;};if _ede .Y > _edc {_edc =_ede .Y ;};_gbb :=_gb .Rect (0,0,_ccc ,_edc );if _egea .X !=_ccc ||_egea .Y !=_edc {_aaae :=_gb .NewRGBA (_gbb );_cf .BiLinear .Scale (_aaae ,_gbb ,_dfgd ,_gde .Bounds (),_cf .Over ,nil );
|
|
_gde =_aaae ;};if _ede .X !=_ccc ||_ede .Y !=_edc {_gcaa :=_gb .NewRGBA (_gbb );_cf .BiLinear .Scale (_gcaa ,_gbb ,_dfgd ,_dfgd .Bounds (),_cf .Over ,nil );_dfgd =_gcaa ;};_aefb :=_gb .NewRGBA (_gbb );_cf .DrawMask (_aefb ,_gbb ,_dfgd ,_gb .Point {},_gde ,_gb .Point {},_cf .Over );
|
|
return _aefb ;};func _cab (_cdgc _fc .PdfObject ,_afeb _bb .Color )(_gb .Image ,error ){_fcb ,_ffgd :=_fc .GetStream (_cdgc );if !_ffgd {return nil ,nil ;};_cgfd ,_bega :=_ab .NewXObjectImageFromStream (_fcb );if _bega !=nil {return nil ,_bega ;};_ebea ,_bega :=_cgfd .ToImage ();
|
|
if _bega !=nil {return nil ,_bega ;};return _cea (_ebea ,_afeb ),nil ;};func (_ggd renderer )processRadialShading (_ccec _cb .Context ,_bcg *_ab .PdfShading )(_cb .Gradient ,*_fc .PdfObjectArray ,error ){_fbf :=_bcg .GetContext ().(*_ab .PdfShadingType3 );
|
|
if len (_fbf .Function )==0{return nil ,nil ,_a .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");
|
|
};_dec ,_fff :=_fbf .Coords .ToFloat64Array ();if _fff !=nil {return nil ,nil ,_a .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");
|
|
};_eba :=_bcg .ColorSpace ;_adcd :=_fc .MakeArrayFromFloats ([]float64 {0,0,1,1});var _bege ,_gcdd ,_aegb ,_dagf ,_afb ,_badf float64 ;_bege ,_gcdd =_ccec .Matrix ().Transform (_dec [0],_dec [1]);_aegb ,_dagf =_ccec .Matrix ().Transform (_dec [3],_dec [4]);
|
|
_afb ,_ =_ccec .Matrix ().Transform (_dec [2],0);_badf ,_ =_ccec .Matrix ().Transform (_dec [5],0);_efcf ,_ :=_ccec .Matrix ().Translation ();_afb -=_efcf ;_badf -=_efcf ;for _cec ,_fefc :=range _dec {if _cec ==2||_cec ==5{continue ;};if _fefc > 1.0{_cgb :=_c .Min (_bege -_afb ,_aegb -_badf );
|
|
_eead :=_c .Min (_gcdd -_afb ,_dagf -_badf );_dfea :=_c .Max (_bege +_afb ,_aegb +_badf );_bfe :=_c .Max (_gcdd +_afb ,_dagf +_badf );_dddd :=_dfea -_cgb ;_eaaa :=_eead -_bfe ;_adcd =_fc .MakeArrayFromFloats ([]float64 {_cgb ,_eead ,_dddd ,_eaaa });break ;
|
|
};};_bdf :=_beb .NewRadialGradient (_bege ,_gcdd ,_afb ,_aegb ,_dagf ,_badf );if _ece ,_gaad :=_fbf .Function [0].(*_ab .PdfFunctionType2 );_gaad {_bdf ,_fff =_cecd (_bdf ,_ece ,_eba ,1.0,true );}else if _adfb ,_gcgd :=_fbf .Function [0].(*_ab .PdfFunctionType3 );
|
|
_gcgd {_geeg :=append ([]float64 {0},_adfb .Bounds ...);_geeg =append (_geeg ,1.0);_bdf ,_fff =_gfae (_bdf ,_adfb ,_eba ,_geeg );};if _fff !=nil {return nil ,nil ,_fff ;};return _bdf ,_adcd ,nil ;};func _cdffc (_fdg string ,_eeadg _gb .Image ,_ccg int )error {_afdf ,_dgdf :=_gf .Create (_fdg );
|
|
if _dgdf !=nil {return _dgdf ;};defer _afdf .Close ();return _aa .Encode (_afdf ,_eeadg ,&_aa .Options {Quality :_ccg });};func _cecd (_dcfc _cb .Gradient ,_dgfb *_ab .PdfFunctionType2 ,_eca _ab .PdfColorspace ,_bde float64 ,_dcd bool )(_cb .Gradient ,error ){switch _eca .(type ){case *_ab .PdfColorspaceDeviceRGB :if len (_dgfb .C0 )!=3||len (_dgfb .C1 )!=3{return nil ,_a .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");
|
|
};_aeb :=_dgfb .C0 ;_bade :=_dgfb .C1 ;if _dcd {_dcfc .AddColorStop (0.0,_bb .RGBA {R :uint8 (_aeb [0]*255),G :uint8 (_aeb [1]*255),B :uint8 (_aeb [2]*255),A :255});};_dcfc .AddColorStop (_bde ,_bb .RGBA {R :uint8 (_bade [0]*255),G :uint8 (_bade [1]*255),B :uint8 (_bade [2]*255),A :255});
|
|
case *_ab .PdfColorspaceDeviceCMYK :if len (_dgfb .C0 )!=4||len (_dgfb .C1 )!=4{return nil ,_a .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");
|
|
};_ddc :=_dgfb .C0 ;_fgcf :=_dgfb .C1 ;if _dcd {_dcfc .AddColorStop (0.0,_bb .CMYK {C :uint8 (_ddc [0]*255),M :uint8 (_ddc [1]*255),Y :uint8 (_ddc [2]*255),K :uint8 (_ddc [3]*255)});};_dcfc .AddColorStop (_bde ,_bb .CMYK {C :uint8 (_fgcf [0]*255),M :uint8 (_fgcf [1]*255),Y :uint8 (_fgcf [2]*255),K :uint8 (_fgcf [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",_eca .String ());};return _dcfc ,nil ;};type renderer struct{_dg float64 };
|
|
|
|
// 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 ;};
|
|
|
|
// RenderToPath converts the specified PDF page into an image and saves the
|
|
// result at the specified location.
|
|
func (_beg *ImageDevice )RenderToPath (page *_ab .PdfPage ,outputPath string )error {_fd ,_gcg :=_beg .Render (page );if _gcg !=nil {return _gcg ;};_ge :=_d .ToLower (_af .Ext (outputPath ));if _ge ==""{return _a .New ("\u0063\u006ful\u0064\u0020\u006eo\u0074\u0020\u0072\u0065cog\u006eiz\u0065\u0020\u006f\u0075\u0074\u0070\u0075t \u0066\u0069\u006c\u0065\u0020\u0074\u0079p\u0065");
|
|
};switch _ge {case "\u002e\u0070\u006e\u0067":return _adfbc (outputPath ,_fd );case "\u002e\u006a\u0070\u0067","\u002e\u006a\u0070e\u0067":return _cdffc (outputPath ,_fd ,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",_ge );
|
|
};
|
|
|
|
// PdfShadingType defines PDF shading types.
|
|
// Source: PDF32000_2008.pdf. Chapter 8.7.4.5
|
|
type PdfShadingType int64 ;func _fag (_fdge _fc .PdfObject ,_fadc _bb .Color )(_gb .Image ,error ){_fbg ,_age :=_fc .GetStream (_fdge );if !_age {return nil ,nil ;};_edfe ,_ffdda :=_ab .NewXObjectImageFromStream (_fbg );if _ffdda !=nil {return nil ,_ffdda ;
|
|
};_acac ,_ffdda :=_edfe .ToImage ();if _ffdda !=nil {return nil ,_ffdda ;};return _gbfd (_acac ,_fadc ),nil ;};func (_dga renderer )processLinearShading (_ceef _cb .Context ,_daa *_ab .PdfShading )(_cb .Gradient ,*_fc .PdfObjectArray ,error ){_ddbc :=_daa .GetContext ().(*_ab .PdfShadingType2 );
|
|
if len (_ddbc .Function )==0{return nil ,nil ,_a .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");
|
|
};_eda ,_bcfg :=_ddbc .Coords .ToFloat64Array ();if _bcfg !=nil {return nil ,nil ,_a .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");
|
|
};_eabb :=_daa .ColorSpace ;_gebf ,_abbbg :=_ceef .Matrix ().Transform (_eda [0],_eda [1]);_debab ,_cfge :=_ceef .Matrix ().Transform (_eda [2],_eda [3]);_fea :=_beb .NewLinearGradient (_gebf ,_abbbg ,_debab ,_cfge );_dbgc :=_fc .MakeArrayFromFloats ([]float64 {0,0,1,1});
|
|
for _ ,_aafc :=range _eda {if _aafc > 1{_dbgc =_ddbc .Coords ;break ;};};if _deac ,_cagg :=_ddbc .Function [0].(*_ab .PdfFunctionType2 );_cagg {_fea ,_bcfg =_cecd (_fea ,_deac ,_eabb ,1.0,true );}else if _bdg ,_gccb :=_ddbc .Function [0].(*_ab .PdfFunctionType3 );
|
|
_gccb {_ebe :=append ([]float64 {0},_bdg .Bounds ...);_ebe =append (_ebe ,1.0);_fea ,_bcfg =_gfae (_fea ,_bdg ,_eabb ,_ebe );};return _fea ,_dbgc ,_bcfg ;};func _adfbc (_dacb string ,_fgcc _gb .Image )error {_gcef ,_abae :=_gf .Create (_dacb );if _abae !=nil {return _abae ;
|
|
};defer _gcef .Close ();return _b .Encode (_gcef ,_fgcc );};func (_bgd renderer )renderPage (_eaa _cb .Context ,_de *_ab .PdfPage ,_ga _ca .Matrix ,_ee bool )error {if !_ee {_ace :=_ab .FieldFlattenOpts {AnnotFilterFunc :func (_gfa *_ab .PdfAnnotation )bool {switch _gfa .GetContext ().(type ){case *_ab .PdfAnnotationLine :return true ;
|
|
case *_ab .PdfAnnotationSquare :return true ;case *_ab .PdfAnnotationCircle :return true ;case *_ab .PdfAnnotationPolygon :return true ;case *_ab .PdfAnnotationPolyLine :return true ;};return false ;}};_dcc :=_gg .FieldAppearance {};_ae :=_de .FlattenFieldsWithOpts (_dcc ,&_ace );
|
|
if _ae !=nil {_e .Log .Debug ("\u0045\u0072r\u006f\u0072\u0020\u0064u\u0072\u0069n\u0067\u0020\u0061\u006e\u006e\u006f\u0074\u0061t\u0069\u006f\u006e\u0020\u0066\u006c\u0061\u0074\u0074\u0065\u006e\u0069n\u0067\u0020\u0025\u0076",_ae );};};_gce ,_aaf :=_de .GetAllContentStreams ();
|
|
if _aaf !=nil {return _aaf ;};if _cc :=_ga ;!_cc .Identity (){_gce =_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",_cc [0],_cc [1],_cc [3],_cc [4],_cc [6],_cc [7],_gce );
|
|
};_eaa .Translate (0,float64 (_eaa .Height ()));_eaa .Scale (1,-1);_eaa .Push ();_eaa .SetRGBA (1,1,1,1);_eaa .DrawRectangle (0,0,float64 (_eaa .Width ()),float64 (_eaa .Height ()));_eaa .Fill ();_eaa .Pop ();_eaa .SetLineWidth (1.0);_eaa .SetRGBA (0,0,0,1);
|
|
return _bgd .renderContentStream (_eaa ,_gce ,_de .Resources );};func (_fed renderer )renderContentStream (_bef _cb .Context ,_fef string ,_eaag *_ab .PdfPageResources )error {_cgd ,_bf :=_df .NewContentStreamParser (_fef ).Parse ();if _bf !=nil {return _bf ;
|
|
};_faa :=_bef .TextState ();_faa .GlobalScale =_fed ._dg ;_gff :=map[string ]*_cb .TextFont {};_dcg :=_da .NewFinder (&_da .FinderOpts {Extensions :[]string {"\u002e\u0074\u0074\u0066","\u002e\u0074\u0074\u0063"}});var _fdf *_df .ContentStreamOperation ;
|
|
_cbf :=_df .NewContentStreamProcessor (*_cgd );_cbf .AddHandler (_df .HandlerConditionEnumAllOperands ,"",func (_dac *_df .ContentStreamOperation ,_dfc _df .GraphicsState ,_edb *_ab .PdfPageResources )error {_e .Log .Debug ("\u0050\u0072\u006f\u0063\u0065\u0073\u0073\u0069\u006e\u0067\u0020\u0025\u0073",_dac .Operand );
|
|
switch _dac .Operand {case "\u0071":_bef .Push ();case "\u0051":_bef .Pop ();_faa =_bef .TextState ();case "\u0063\u006d":if len (_dac .Params )!=6{return _ed ;};_ccb ,_ade :=_fc .GetNumbersAsFloat (_dac .Params );if _ade !=nil {return _ade ;};_gdd :=_ca .NewMatrix (_ccb [0],_ccb [1],_ccb [2],_ccb [3],_ccb [4],_ccb [5]);
|
|
_e .Log .Debug ("\u0047\u0072\u0061\u0070\u0068\u0069\u0063\u0073\u0020\u0073\u0074a\u0074\u0065\u0020\u006d\u0061\u0074\u0072\u0069\u0078\u003a \u0025\u002b\u0076",_gdd );_bef .SetMatrix (_bef .Matrix ().Mult (_gdd ));case "\u0077":if len (_dac .Params )!=1{return _ed ;
|
|
};_aca ,_ffd :=_fc .GetNumbersAsFloat (_dac .Params );if _ffd !=nil {return _ffd ;};_bef .SetLineWidth (_aca [0]);case "\u004a":if len (_dac .Params )!=1{return _ed ;};_gda ,_ada :=_fc .GetIntVal (_dac .Params [0]);if !_ada {return _ac ;};switch _gda {case 0:_bef .SetLineCap (_cb .LineCapButt );
|
|
case 1:_bef .SetLineCap (_cb .LineCapRound );case 2:_bef .SetLineCap (_cb .LineCapSquare );default:_e .Log .Debug ("\u0049\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u006c\u0069\u006ee\u0020\u0063\u0061\u0070\u0020\u0073\u0074\u0079\u006c\u0065:\u0020\u0025\u0064",_gda );
|
|
return _ed ;};case "\u006a":if len (_dac .Params )!=1{return _ed ;};_aee ,_bd :=_fc .GetIntVal (_dac .Params [0]);if !_bd {return _ac ;};switch _aee {case 0:_bef .SetLineJoin (_cb .LineJoinBevel );case 1:_bef .SetLineJoin (_cb .LineJoinRound );case 2:_bef .SetLineJoin (_cb .LineJoinBevel );
|
|
default:_e .Log .Debug ("I\u006e\u0076\u0061\u006c\u0069\u0064 \u006c\u0069\u006e\u0065\u0020\u006a\u006f\u0069\u006e \u0073\u0074\u0079l\u0065:\u0020\u0025\u0064",_aee );return _ed ;};case "\u004d":if len (_dac .Params )!=1{return _ed ;};_bgg ,_bdc :=_fc .GetNumbersAsFloat (_dac .Params );
|
|
if _bdc !=nil {return _bdc ;};_ =_bgg ;_e .Log .Debug ("\u004di\u0074\u0065\u0072\u0020l\u0069\u006d\u0069\u0074\u0020n\u006ft\u0020s\u0075\u0070\u0070\u006f\u0072\u0074\u0065d");case "\u0064":if len (_dac .Params )!=2{return _ed ;};_dea ,_deb :=_fc .GetArray (_dac .Params [0]);
|
|
if !_deb {return _ac ;};_def ,_deb :=_fc .GetIntVal (_dac .Params [1]);if !_deb {_ ,_dce :=_fc .GetFloatVal (_dac .Params [1]);if !_dce {return _ac ;};};_ffg ,_ec :=_fc .GetNumbersAsFloat (_dea .Elements ());if _ec !=nil {return _ec ;};_bef .SetDash (_ffg ...);
|
|
_ =_def ;_e .Log .Debug ("\u004c\u0069n\u0065\u0020\u0064\u0061\u0073\u0068\u0020\u0070\u0068\u0061\u0073\u0065\u0020\u006e\u006f\u0074\u0020\u0073\u0075\u0070\u0070\u006frt\u0065\u0064");case "\u0072\u0069":_e .Log .Debug ("\u0052\u0065\u006e\u0064\u0065\u0072\u0069\u006e\u0067\u0020i\u006e\u0074\u0065\u006e\u0074\u0020\u006eo\u0074\u0020\u0073\u0075\u0070\u0070\u006f\u0072\u0074\u0065\u0064");
|
|
case "\u0069":_e .Log .Debug ("\u0046\u006c\u0061\u0074\u006e\u0065\u0073\u0073\u0020\u0074\u006f\u006c\u0065\u0072\u0061n\u0063e\u0020\u006e\u006f\u0074\u0020\u0073\u0075\u0070\u0070\u006f\u0072\u0074\u0065\u0064");case "\u0067\u0073":if len (_dac .Params )!=1{return _ed ;
|
|
};_ba ,_gca :=_fc .GetName (_dac .Params [0]);if !_gca {return _ac ;};if _ba ==nil {return _ed ;};_eac ,_gca :=_edb .GetExtGState (*_ba );if !_gca {_e .Log .Debug ("\u0045\u0052\u0052OR\u003a\u0020\u0063\u006f\u0075\u006c\u0064\u0020\u006eo\u0074 \u0066i\u006ed\u0020\u0072\u0065\u0073\u006f\u0075\u0072\u0063\u0065\u003a\u0020\u0025\u0073",*_ba );
|
|
return _a .New ("\u0072e\u0073o\u0075\u0072\u0063\u0065\u0020n\u006f\u0074 \u0066\u006f\u0075\u006e\u0064");};_acea ,_gca :=_fc .GetDict (_eac );if !_gca {_e .Log .Debug ("\u0045\u0052RO\u0052\u003a\u0020c\u006f\u0075\u006c\u0064 ge\u0074 g\u0072\u0061\u0070\u0068\u0069\u0063\u0073 s\u0074\u0061\u0074\u0065\u0020\u0064\u0069c\u0074");
|
|
return _ac ;};_e .Log .Debug ("G\u0053\u0020\u0064\u0069\u0063\u0074\u003a\u0020\u0025\u0073",_acea .String ());case "\u006d":if len (_dac .Params )!=2{_e .Log .Debug ("\u0057\u0041\u0052\u004e\u003a\u0020\u0065\u0072\u0072o\u0072\u0020\u0077\u0068\u0069\u006c\u0065\u0020\u0070\u0072\u006f\u0063\u0065\u0073\u0073\u0069\u006e\u0067\u0020\u0060\u006d\u0060\u0020o\u0070\u0065r\u0061\u0074o\u0072\u003a\u0020\u0025\u0073\u002e\u0020\u004f\u0075\u0074\u0070\u0075\u0074 m\u0061\u0079\u0020\u0062\u0065\u0020\u0069\u006e\u0063o\u0072\u0072\u0065\u0063\u0074\u002e",_ed );
|
|
return nil ;};_fg ,_ddfd :=_fc .GetNumbersAsFloat (_dac .Params );if _ddfd !=nil {return _ddfd ;};_e .Log .Debug ("M\u006f\u0076\u0065\u0020\u0074\u006f\u003a\u0020\u0025\u0076",_fg );_bef .NewSubPath ();_bef .MoveTo (_fg [0],_fg [1]);case "\u006c":if len (_dac .Params )!=2{_e .Log .Debug ("\u0057\u0041\u0052\u004e\u003a\u0020\u0065\u0072\u0072o\u0072\u0020\u0077\u0068\u0069\u006c\u0065\u0020\u0070\u0072\u006f\u0063\u0065\u0073\u0073\u0069\u006e\u0067\u0020\u0060\u006c\u0060\u0020o\u0070\u0065r\u0061\u0074o\u0072\u003a\u0020\u0025\u0073\u002e\u0020\u004f\u0075\u0074\u0070\u0075\u0074 m\u0061\u0079\u0020\u0062\u0065\u0020\u0069\u006e\u0063o\u0072\u0072\u0065\u0063\u0074\u002e",_ed );
|
|
return nil ;};_bad ,_db :=_fc .GetNumbersAsFloat (_dac .Params );if _db !=nil {return _db ;};_bef .LineTo (_bad [0],_bad [1]);case "\u0063":if len (_dac .Params )!=6{return _ed ;};_eeb ,_acag :=_fc .GetNumbersAsFloat (_dac .Params );if _acag !=nil {return _acag ;
|
|
};_e .Log .Debug ("\u0043u\u0062\u0069\u0063\u0020\u0062\u0065\u007a\u0069\u0065\u0072\u0020p\u0061\u0072\u0061\u006d\u0073\u003a\u0020\u0025\u002b\u0076",_eeb );_bef .CubicTo (_eeb [0],_eeb [1],_eeb [2],_eeb [3],_eeb [4],_eeb [5]);case "\u0076","\u0079":if len (_dac .Params )!=4{return _ed ;
|
|
};_deba ,_dca :=_fc .GetNumbersAsFloat (_dac .Params );if _dca !=nil {return _dca ;};_e .Log .Debug ("\u0043u\u0062\u0069\u0063\u0020\u0062\u0065\u007a\u0069\u0065\u0072\u0020p\u0061\u0072\u0061\u006d\u0073\u003a\u0020\u0025\u002b\u0076",_deba );_bef .QuadraticTo (_deba [0],_deba [1],_deba [2],_deba [3]);
|
|
case "\u0068":_bef .ClosePath ();_bef .NewSubPath ();case "\u0072\u0065":if len (_dac .Params )!=4{return _ed ;};_ceg ,_debg :=_fc .GetNumbersAsFloat (_dac .Params );if _debg !=nil {return _debg ;};_bef .DrawRectangle (_ceg [0],_ceg [1],_ceg [2],_ceg [3]);
|
|
_bef .NewSubPath ();case "\u0053":_fad ,_fb :=_dfc .ColorspaceStroking .ColorToRGB (_dfc .ColorStroking );if _fb !=nil {_e .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_fb );
|
|
return _fb ;};_bc ,_cef :=_fad .(*_ab .PdfColorDeviceRGB );if !_cef {_e .Log .Debug ("\u0045\u0072\u0072\u006fr \u0063\u006f\u006e\u0076\u0065\u0072\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006co\u0072");return _fb ;};_bef .SetRGBA (_bc .R (),_bc .G (),_bc .B (),1);
|
|
_bef .Stroke ();case "\u0073":_ebf ,_fde :=_dfc .ColorspaceStroking .ColorToRGB (_dfc .ColorStroking );if _fde !=nil {_e .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_fde );
|
|
return _fde ;};_ebb ,_agb :=_ebf .(*_ab .PdfColorDeviceRGB );if !_agb {_e .Log .Debug ("\u0045\u0072\u0072\u006fr \u0063\u006f\u006e\u0076\u0065\u0072\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006co\u0072");return _fde ;};_bef .ClosePath ();_bef .NewSubPath ();
|
|
_bef .SetRGBA (_ebb .R (),_ebb .G (),_ebb .B (),1);_bef .Stroke ();case "\u0066","\u0046":_eab ,_ebfc :=_dfc .ColorspaceNonStroking .ColorToRGB (_dfc .ColorNonStroking );if _ebfc !=nil {_e .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_ebfc );
|
|
return _ebfc ;};switch _edd :=_eab .(type ){case *_ab .PdfColorDeviceRGB :_bef .SetRGBA (_edd .R (),_edd .G (),_edd .B (),1);_bef .SetFillRule (_cb .FillRuleWinding );_bef .Fill ();case *_ab .PdfColorPattern :_bef .Fill ();};_e .Log .Debug ("\u0045\u0072\u0072\u006fr \u0063\u006f\u006e\u0076\u0065\u0072\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006co\u0072");
|
|
case "\u0066\u002a":_cfc ,_caa :=_dfc .ColorspaceNonStroking .ColorToRGB (_dfc .ColorNonStroking );if _caa !=nil {_e .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_caa );
|
|
return _caa ;};_edf ,_bgc :=_cfc .(*_ab .PdfColorDeviceRGB );if !_bgc {_e .Log .Debug ("\u0045\u0072\u0072\u006fr \u0063\u006f\u006e\u0076\u0065\u0072\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006co\u0072");return _caa ;};_bef .SetRGBA (_edf .R (),_edf .G (),_edf .B (),1);
|
|
_bef .SetFillRule (_cb .FillRuleEvenOdd );_bef .Fill ();case "\u0042":_aae ,_cca :=_dfc .ColorspaceNonStroking .ColorToRGB (_dfc .ColorNonStroking );if _cca !=nil {_e .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_cca );
|
|
return _cca ;};switch _fgb :=_aae .(type ){case *_ab .PdfColorDeviceRGB :_bef .SetRGBA (_fgb .R (),_fgb .G (),_fgb .B (),1);_bef .SetFillRule (_cb .FillRuleWinding );_bef .FillPreserve ();_aae ,_cca =_dfc .ColorspaceStroking .ColorToRGB (_dfc .ColorStroking );
|
|
if _cca !=nil {_e .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_cca );return _cca ;};if _cbe ,_dgd :=_aae .(*_ab .PdfColorDeviceRGB );_dgd {_bef .SetRGBA (_cbe .R (),_cbe .G (),_cbe .B (),1);
|
|
_bef .Stroke ();};case *_ab .PdfColorPattern :_bef .SetFillRule (_cb .FillRuleWinding );_bef .Fill ();_bef .StrokePattern ();};case "\u0042\u002a":_egb ,_abb :=_dfc .ColorspaceNonStroking .ColorToRGB (_dfc .ColorNonStroking );if _abb !=nil {_e .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_abb );
|
|
return _abb ;};switch _fdd :=_egb .(type ){case *_ab .PdfColorDeviceRGB :_bef .SetRGBA (_fdd .R (),_fdd .G (),_fdd .B (),1);_bef .SetFillRule (_cb .FillRuleEvenOdd );_bef .FillPreserve ();_egb ,_abb =_dfc .ColorspaceStroking .ColorToRGB (_dfc .ColorStroking );
|
|
if _abb !=nil {_e .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_abb );return _abb ;};if _afd ,_fdb :=_egb .(*_ab .PdfColorDeviceRGB );_fdb {_bef .SetRGBA (_afd .R (),_afd .G (),_afd .B (),1);
|
|
_bef .Stroke ();};case *_ab .PdfColorPattern :_bef .SetFillRule (_cb .FillRuleEvenOdd );_bef .Fill ();_bef .StrokePattern ();};case "\u0062":_bef .ClosePath ();_ebfe ,_cefb :=_dfc .ColorspaceNonStroking .ColorToRGB (_dfc .ColorNonStroking );if _cefb !=nil {_e .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_cefb );
|
|
return _cefb ;};switch _adf :=_ebfe .(type ){case *_ab .PdfColorDeviceRGB :_bef .SetRGBA (_adf .R (),_adf .G (),_adf .B (),1);_bef .NewSubPath ();_bef .SetFillRule (_cb .FillRuleWinding );_bef .FillPreserve ();_ebfe ,_cefb =_dfc .ColorspaceStroking .ColorToRGB (_dfc .ColorStroking );
|
|
if _cefb !=nil {_e .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_cefb );return _cefb ;};if _abe ,_gbg :=_ebfe .(*_ab .PdfColorDeviceRGB );
|
|
_gbg {_bef .SetRGBA (_abe .R (),_abe .G (),_abe .B (),1);_bef .Stroke ();};case *_ab .PdfColorPattern :_bef .NewSubPath ();_bef .SetFillRule (_cb .FillRuleWinding );_bef .Fill ();_bef .StrokePattern ();};case "\u0062\u002a":_bef .ClosePath ();_gef ,_gefa :=_dfc .ColorspaceNonStroking .ColorToRGB (_dfc .ColorNonStroking );
|
|
if _gefa !=nil {_e .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_gefa );return _gefa ;};switch _bbb :=_gef .(type ){case *_ab .PdfColorDeviceRGB :_bef .SetRGBA (_bbb .R (),_bbb .G (),_bbb .B (),1);
|
|
_bef .NewSubPath ();_bef .SetFillRule (_cb .FillRuleEvenOdd );_bef .FillPreserve ();_gef ,_gefa =_dfc .ColorspaceStroking .ColorToRGB (_dfc .ColorStroking );if _gefa !=nil {_e .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_gefa );
|
|
return _gefa ;};if _caf ,_cbg :=_gef .(*_ab .PdfColorDeviceRGB );_cbg {_bef .SetRGBA (_caf .R (),_caf .G (),_caf .B (),1);_bef .Stroke ();};case *_ab .PdfColorPattern :_bef .NewSubPath ();_bef .SetFillRule (_cb .FillRuleEvenOdd );_bef .Fill ();_bef .StrokePattern ();
|
|
};case "\u006e":_bef .ClearPath ();case "\u0057":_bef .SetFillRule (_cb .FillRuleWinding );_bef .ClipPreserve ();case "\u0057\u002a":_bef .SetFillRule (_cb .FillRuleEvenOdd );_bef .ClipPreserve ();case "\u0072\u0067":_fbd ,_cdgd :=_dfc .ColorNonStroking .(*_ab .PdfColorDeviceRGB );
|
|
if !_cdgd {_e .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_dfc .ColorNonStroking );return nil ;};_bef .SetFillRGBA (_fbd .R (),_fbd .G (),_fbd .B (),1);
|
|
case "\u0052\u0047":_fge ,_fce :=_dfc .ColorStroking .(*_ab .PdfColorDeviceRGB );if !_fce {_e .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_dfc .ColorStroking );
|
|
return nil ;};_bef .SetStrokeRGBA (_fge .R (),_fge .G (),_fge .B (),1);case "\u006b":_adef ,_ebd :=_dfc .ColorNonStroking .(*_ab .PdfColorDeviceCMYK );if !_ebd {_e .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_dfc .ColorNonStroking );
|
|
return nil ;};_cfb ,_fdfb :=_dfc .ColorspaceNonStroking .ColorToRGB (_adef );if _fdfb !=nil {_e .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_dfc .ColorNonStroking );
|
|
return nil ;};_fgc ,_ebd :=_cfb .(*_ab .PdfColorDeviceRGB );if !_ebd {_e .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_cfb );return nil ;
|
|
};_bef .SetFillRGBA (_fgc .R (),_fgc .G (),_fgc .B (),1);case "\u004b":_dgb ,_dcf :=_dfc .ColorStroking .(*_ab .PdfColorDeviceCMYK );if !_dcf {_e .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_dfc .ColorStroking );
|
|
return nil ;};_ccd ,_aef :=_dfc .ColorspaceStroking .ColorToRGB (_dgb );if _aef !=nil {_e .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_dfc .ColorStroking );
|
|
return nil ;};_cdc ,_dcf :=_ccd .(*_ab .PdfColorDeviceRGB );if !_dcf {_e .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_ccd );return nil ;
|
|
};_bef .SetStrokeRGBA (_cdc .R (),_cdc .G (),_cdc .B (),1);case "\u0067":_feb ,_cgde :=_dfc .ColorNonStroking .(*_ab .PdfColorDeviceGray );if !_cgde {_e .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_dfc .ColorNonStroking );
|
|
return nil ;};_bbd ,_gfaf :=_dfc .ColorspaceNonStroking .ColorToRGB (_feb );if _gfaf !=nil {_e .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_dfc .ColorNonStroking );
|
|
return nil ;};_ddb ,_cgde :=_bbd .(*_ab .PdfColorDeviceRGB );if !_cgde {_e .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_bbd );return nil ;
|
|
};_bef .SetFillRGBA (_ddb .R (),_ddb .G (),_ddb .B (),1);case "\u0047":_ef ,_gfe :=_dfc .ColorStroking .(*_ab .PdfColorDeviceGray );if !_gfe {_e .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_dfc .ColorStroking );
|
|
return nil ;};_bgcb ,_adfg :=_dfc .ColorspaceStroking .ColorToRGB (_ef );if _adfg !=nil {_e .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_dfc .ColorStroking );
|
|
return nil ;};_cce ,_gfe :=_bgcb .(*_ab .PdfColorDeviceRGB );if !_gfe {_e .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_bgcb );return nil ;
|
|
};_bef .SetStrokeRGBA (_cce .R (),_cce .G (),_cce .B (),1);case "\u0063\u0073":if len (_dac .Params )> 0{if _ffb ,_efc :=_fc .GetName (_dac .Params [0]);_efc &&_ffb .String ()=="\u0050a\u0074\u0074\u0065\u0072\u006e"{break ;};};_geb ,_acf :=_dfc .ColorspaceNonStroking .ColorToRGB (_dfc .ColorNonStroking );
|
|
if _acf !=nil {_e .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_dfc .ColorNonStroking );return nil ;};_fcec ,_gddd :=_geb .(*_ab .PdfColorDeviceRGB );
|
|
if !_gddd {_e .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_geb );return nil ;};_bef .SetFillRGBA (_fcec .R (),_fcec .G (),_fcec .B (),1);
|
|
case "\u0073\u0063":_bgb ,_gfg :=_dfc .ColorspaceNonStroking .ColorToRGB (_dfc .ColorNonStroking );if _gfg !=nil {_e .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_dfc .ColorNonStroking );
|
|
return nil ;};_bcd ,_bae :=_bgb .(*_ab .PdfColorDeviceRGB );if !_bae {_e .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_bgb );return nil ;
|
|
};_bef .SetFillRGBA (_bcd .R (),_bcd .G (),_bcd .B (),1);case "\u0073\u0063\u006e":if len (_dac .Params )> 0&&len (_fdf .Params )> 0{if _dcgb ,_eeg :=_fc .GetName (_fdf .Params [0]);_eeg &&_dcgb .String ()=="\u0050a\u0074\u0074\u0065\u0072\u006e"{if _ged ,_efg :=_fc .GetName (_dac .Params [0]);
|
|
_efg {_bgf ,_ffa :=_fed .processGradient (_bef ,_dac ,_edb ,_ged );if _ffa !=nil {_e .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",_ffa );
|
|
break ;};if _bgf ==nil {_e .Log .Debug ("\u0055\u006ek\u006e\u006f\u0077n\u0020\u0067\u0072\u0061\u0064\u0069\u0065\u006e\u0074");break ;};_bef .SetFillStyle (_bgf );_bef .SetStrokeStyle (_bgf );break ;};};};_edbg ,_gfbf :=_dfc .ColorspaceNonStroking .ColorToRGB (_dfc .ColorNonStroking );
|
|
if _gfbf !=nil {_e .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_dfc .ColorNonStroking );return nil ;};_gbc ,_fab :=_edbg .(*_ab .PdfColorDeviceRGB );
|
|
if !_fab {_e .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_edbg );return nil ;};_bef .SetFillRGBA (_gbc .R (),_gbc .G (),_gbc .B (),1);
|
|
case "\u0043\u0053":if len (_dac .Params )> 0{if _gaf ,_acfb :=_fc .GetName (_dac .Params [0]);_acfb &&_gaf .String ()=="\u0050a\u0074\u0074\u0065\u0072\u006e"{break ;};};_fga ,_caff :=_dfc .ColorspaceStroking .ColorToRGB (_dfc .ColorStroking );if _caff !=nil {_e .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_dfc .ColorStroking );
|
|
return nil ;};_fabd ,_ddd :=_fga .(*_ab .PdfColorDeviceRGB );if !_ddd {_e .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_fga );return nil ;
|
|
};_bef .SetStrokeRGBA (_fabd .R (),_fabd .G (),_fabd .B (),1);case "\u0053\u0043":_ccac ,_egg :=_dfc .ColorspaceStroking .ColorToRGB (_dfc .ColorStroking );if _egg !=nil {_e .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_dfc .ColorStroking );
|
|
return nil ;};_ggcg ,_faad :=_ccac .(*_ab .PdfColorDeviceRGB );if !_faad {_e .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_ccac );return nil ;
|
|
};_bef .SetStrokeRGBA (_ggcg .R (),_ggcg .G (),_ggcg .B (),1);case "\u0053\u0043\u004e":if len (_dac .Params )> 0&&len (_fdf .Params )> 0{if _dbd ,_dee :=_fc .GetName (_fdf .Params [0]);_dee &&_dbd .String ()=="\u0050a\u0074\u0074\u0065\u0072\u006e"{if _cfd ,_bba :=_fc .GetName (_dac .Params [0]);
|
|
_bba {_aaa ,_ccbb :=_fed .processGradient (_bef ,_dac ,_edb ,_cfd );if _ccbb !=nil {_e .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",_ccbb );
|
|
break ;};if _aaa ==nil {_e .Log .Debug ("\u0055\u006ek\u006e\u006f\u0077n\u0020\u0067\u0072\u0061\u0064\u0069\u0065\u006e\u0074");break ;};_bef .SetFillStyle (_aaa );_bef .SetStrokeStyle (_aaa );break ;};};};_fca ,_cfg :=_dfc .ColorspaceStroking .ColorToRGB (_dfc .ColorStroking );
|
|
if _cfg !=nil {_e .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_dfc .ColorStroking );return nil ;};_dgf ,_ecg :=_fca .(*_ab .PdfColorDeviceRGB );
|
|
if !_ecg {_e .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_fca );return nil ;};_bef .SetStrokeRGBA (_dgf .R (),_dgf .G (),_dgf .B (),1);
|
|
case "\u0073\u0068":if len (_dac .Params )!=1{_e .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 ;};_gbfc ,_cga :=_fc .GetName (_dac .Params [0]);
|
|
if !_cga {_e .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 ;};_ffe ,_cga :=_edb .GetShadingByName (*_gbfc );if !_cga {_e .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 ;};_fdef ,_gcc ,_cced :=_fed .processShading (_bef ,_ffe );if _cced !=nil {_e .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",_cced );
|
|
break ;};if _fdef ==nil {_e .Log .Debug ("\u0055\u006ek\u006e\u006f\u0077n\u0020\u0067\u0072\u0061\u0064\u0069\u0065\u006e\u0074");break ;};_dcfb ,_cced :=_gcc .ToFloat64Array ();if _cced !=nil {_e .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",_cced );
|
|
break ;};_bef .DrawRectangle (_dcfb [0],_dcfb [1],_dcfb [2],_dcfb [3]);_bef .NewSubPath ();_bef .SetFillStyle (_fdef );_bef .SetStrokeStyle (_fdef );_bef .Fill ();case "\u0044\u006f":if len (_dac .Params )!=1{return _ed ;};_fgae ,_bca :=_fc .GetName (_dac .Params [0]);
|
|
if !_bca {return _ac ;};_ ,_ecb :=_edb .GetXObjectByName (*_fgae );switch _ecb {case _ab .XObjectTypeImage :_e .Log .Debug ("\u0058\u004f\u0062\u006a\u0065\u0063\u0074\u0020\u0069\u006d\u0061\u0067e\u003a\u0020\u0025\u0073",_fgae .String ());_afec ,_gfab :=_edb .GetXObjectImageByName (*_fgae );
|
|
if _gfab !=nil {return _gfab ;};_cdf ,_gfab :=_afec .ToImage ();if _gfab !=nil {_e .Log .Debug ("\u0052\u0065\u006e\u0064\u0065\u0072\u0069\u006e\u0067\u0020\u0072\u0065\u0073\u0075\u006c\u0074\u0020\u006day\u0020b\u0065\u0020\u0069\u006e\u0063\u006f\u006d\u0070\u006c\u0065\u0074\u0065.\u0020\u0049\u006d\u0061\u0067\u0065\u0020\u0063\u006f\u006e\u0076\u0065\u0072\u0073\u0069\u006f\u006e \u0065\u0072\u0072\u006f\u0072\u003a\u0020\u0025\u0076",_gfab );
|
|
return nil ;};if _acc :=_afec .ColorSpace ;_acc !=nil {var _gfaff bool ;switch _acc .(type ){case *_ab .PdfColorspaceSpecialIndexed :_gfaff =true ;};if _gfaff {if _cba ,_febc :=_acc .ImageToRGB (*_cdf );_febc !=nil {_e .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 {_cdf =&_cba ;};};};_cbgf :=_bef .FillPattern ().ColorAt (0,0);var _gcd _gb .Image ;if _afec .Mask !=nil {if _gcd ,_gfab =_cab (_afec .Mask ,_cbgf );_gfab !=nil {_e .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 _afec .SMask !=nil {if _gcd ,_gfab =_fag (_afec .SMask ,_cbgf );_gfab !=nil {_e .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 _gaa _gb .Image ;if _cffd ,_ :=_fc .GetBoolVal (_afec .ImageMask );_cffd {_gaa =_cea (_cdf ,_cbgf );}else {_gaa ,_gfab =_cdf .ToGoImage ();if _gfab !=nil {_e .Log .Debug ("\u0052\u0065\u006e\u0064\u0065\u0072\u0069\u006e\u0067\u0020\u0072\u0065\u0073\u0075\u006c\u0074\u0020\u006day\u0020b\u0065\u0020\u0069\u006e\u0063\u006f\u006d\u0070\u006c\u0065\u0074\u0065.\u0020\u0049\u006d\u0061\u0067\u0065\u0020\u0063\u006f\u006e\u0076\u0065\u0072\u0073\u0069\u006f\u006e \u0065\u0072\u0072\u006f\u0072\u003a\u0020\u0025\u0076",_gfab );
|
|
return nil ;};};if _gcd !=nil {_gaa =_gfcd (_gaa ,_gcd );};_cad :=_gaa .Bounds ();_bef .Push ();_bef .Scale (1.0/float64 (_cad .Dx ()),-1.0/float64 (_cad .Dy ()));_bef .DrawImageAnchored (_gaa ,0,0,0,1);_bef .Pop ();case _ab .XObjectTypeForm :_e .Log .Debug ("\u0058\u004fb\u006a\u0065\u0063t\u0020\u0066\u006f\u0072\u006d\u003a\u0020\u0025\u0073",_fgae .String ());
|
|
_aaab ,_abc :=_edb .GetXObjectFormByName (*_fgae );if _abc !=nil {return _abc ;};_bab ,_abc :=_aaab .GetContentStream ();if _abc !=nil {return _abc ;};_agf :=_aaab .Resources ;if _agf ==nil {_agf =_edb ;};_bef .Push ();if _aaab .Matrix !=nil {_efa ,_bce :=_fc .GetArray (_aaab .Matrix );
|
|
if !_bce {return _ac ;};_abd ,_gee :=_fc .GetNumbersAsFloat (_efa .Elements ());if _gee !=nil {return _gee ;};if len (_abd )!=6{return _ed ;};_ffdd :=_ca .NewMatrix (_abd [0],_abd [1],_abd [2],_abd [3],_abd [4],_abd [5]);_bef .SetMatrix (_bef .Matrix ().Mult (_ffdd ));
|
|
};if _aaab .BBox !=nil {_dbc ,_aeg :=_fc .GetArray (_aaab .BBox );if !_aeg {return _ac ;};_edbe ,_dad :=_fc .GetNumbersAsFloat (_dbc .Elements ());if _dad !=nil {return _dad ;};if len (_edbe )!=4{_e .Log .Debug ("\u004c\u0065\u006e\u0020\u003d\u0020\u0025\u0064",len (_edbe ));
|
|
return _ed ;};_bef .DrawRectangle (_edbe [0],_edbe [1],_edbe [2]-_edbe [0],_edbe [3]-_edbe [1]);_bef .SetRGBA (1,0,0,1);_bef .Clip ();}else {_e .Log .Debug ("\u0045R\u0052\u004fR\u003a\u0020\u0052\u0065q\u0075\u0069\u0072e\u0064\u0020\u0042\u0042\u006f\u0078\u0020\u006d\u0069ss\u0069\u006e\u0067 \u006f\u006e \u0058\u004f\u0062\u006a\u0065\u0063t\u0020\u0046o\u0072\u006d");
|
|
};_abc =_fed .renderContentStream (_bef ,string (_bab ),_agf );if _abc !=nil {return _abc ;};_bef .Pop ();};case "\u0042\u0049":if len (_dac .Params )!=1{return _ed ;};_bac ,_gfeb :=_dac .Params [0].(*_df .ContentStreamInlineImage );if !_gfeb {return nil ;
|
|
};_aec ,_fdff :=_bac .ToImage (_edb );if _fdff !=nil {_e .Log .Debug ("\u0052\u0065\u006e\u0064\u0065\u0072\u0069\u006e\u0067\u0020\u0072\u0065\u0073\u0075\u006c\u0074\u0020\u006day\u0020b\u0065\u0020\u0069\u006e\u0063\u006f\u006d\u0070\u006c\u0065\u0074\u0065.\u0020\u0049\u006d\u0061\u0067\u0065\u0020\u0063\u006f\u006e\u0076\u0065\u0072\u0073\u0069\u006f\u006e \u0065\u0072\u0072\u006f\u0072\u003a\u0020\u0025\u0076",_fdff );
|
|
return nil ;};_ebc ,_fdff :=_aec .ToGoImage ();if _fdff !=nil {_e .Log .Debug ("\u0052\u0065\u006e\u0064\u0065\u0072\u0069\u006e\u0067\u0020\u0072\u0065\u0073\u0075\u006c\u0074\u0020\u006day\u0020b\u0065\u0020\u0069\u006e\u0063\u006f\u006d\u0070\u006c\u0065\u0074\u0065.\u0020\u0049\u006d\u0061\u0067\u0065\u0020\u0063\u006f\u006e\u0076\u0065\u0072\u0073\u0069\u006f\u006e \u0065\u0072\u0072\u006f\u0072\u003a\u0020\u0025\u0076",_fdff );
|
|
return nil ;};_gdg :=_ebc .Bounds ();_bef .Push ();_bef .Scale (1.0/float64 (_gdg .Dx ()),-1.0/float64 (_gdg .Dy ()));_bef .DrawImageAnchored (_ebc ,0,0,0,1);_bef .Pop ();case "\u0042\u0054":_faa .Reset ();case "\u0045\u0054":_faa .Reset ();case "\u0054\u0072":if len (_dac .Params )!=1{return _ed ;
|
|
};_cee ,_fgd :=_fc .GetNumberAsFloat (_dac .Params [0]);if _fgd !=nil {return _fgd ;};_faa .Tr =_cb .TextRenderingMode (_cee );case "\u0054\u004c":if len (_dac .Params )!=1{return _ed ;};_bfd ,_cgf :=_fc .GetNumberAsFloat (_dac .Params [0]);if _cgf !=nil {return _cgf ;
|
|
};_faa .Tl =_bfd ;case "\u0054\u0063":if len (_dac .Params )!=1{return _ed ;};_dab ,_fae :=_fc .GetNumberAsFloat (_dac .Params [0]);if _fae !=nil {return _fae ;};_e .Log .Debug ("\u0054\u0063\u003a\u0020\u0025\u0076",_dab );_faa .Tc =_dab ;case "\u0054\u0077":if len (_dac .Params )!=1{return _ed ;
|
|
};_gga ,_gac :=_fc .GetNumberAsFloat (_dac .Params [0]);if _gac !=nil {return _gac ;};_e .Log .Debug ("\u0054\u0077\u003a\u0020\u0025\u0076",_gga );_faa .Tw =_gga ;case "\u0054\u007a":if len (_dac .Params )!=1{return _ed ;};_aaea ,_cac :=_fc .GetNumberAsFloat (_dac .Params [0]);
|
|
if _cac !=nil {return _cac ;};_faa .Th =_aaea ;case "\u0054\u0073":if len (_dac .Params )!=1{return _ed ;};_ggb ,_bcac :=_fc .GetNumberAsFloat (_dac .Params [0]);if _bcac !=nil {return _bcac ;};_faa .Ts =_ggb ;case "\u0054\u0064":if len (_dac .Params )!=2{return _ed ;
|
|
};_cag ,_aff :=_fc .GetNumbersAsFloat (_dac .Params );if _aff !=nil {return _aff ;};_e .Log .Debug ("\u0054\u0064\u003a\u0020\u0025\u0076",_cag );_faa .ProcTd (_cag [0],_cag [1]);case "\u0054\u0044":if len (_dac .Params )!=2{return _ed ;};_bcdd ,_deg :=_fc .GetNumbersAsFloat (_dac .Params );
|
|
if _deg !=nil {return _deg ;};_e .Log .Debug ("\u0054\u0044\u003a\u0020\u0025\u0076",_bcdd );_faa .ProcTD (_bcdd [0],_bcdd [1]);case "\u0054\u002a":_faa .ProcTStar ();case "\u0054\u006d":if len (_dac .Params )!=6{return _ed ;};_bcf ,_faag :=_fc .GetNumbersAsFloat (_dac .Params );
|
|
if _faag !=nil {return _faag ;};_e .Log .Debug ("\u0054\u0065x\u0074\u0020\u006da\u0074\u0072\u0069\u0078\u003a\u0020\u0025\u002b\u0076",_bcf );_faa .ProcTm (_bcf [0],_bcf [1],_bcf [2],_bcf [3],_bcf [4],_bcf [5]);case "\u0027":if len (_dac .Params )!=1{return _ed ;
|
|
};_abf ,_ecgg :=_fc .GetStringBytes (_dac .Params [0]);if !_ecgg {return _ac ;};_e .Log .Debug ("\u0027\u0020\u0073t\u0072\u0069\u006e\u0067\u003a\u0020\u0025\u0073",string (_abf ));_faa .ProcQ (_abf ,_bef );case "\u0022":if len (_dac .Params )!=3{return _ed ;
|
|
};_faf ,_feba :=_fc .GetNumberAsFloat (_dac .Params [0]);if _feba !=nil {return _feba ;};_ege ,_feba :=_fc .GetNumberAsFloat (_dac .Params [1]);if _feba !=nil {return _feba ;};_eae ,_agd :=_fc .GetStringBytes (_dac .Params [2]);if !_agd {return _ac ;};
|
|
_faa .ProcDQ (_eae ,_faf ,_ege ,_bef );case "\u0054\u006a":if len (_dac .Params )!=1{return _ed ;};_fda ,_edfd :=_fc .GetStringBytes (_dac .Params [0]);if !_edfd {return _ac ;};_e .Log .Debug ("\u0054j\u0020s\u0074\u0072\u0069\u006e\u0067\u003a\u0020\u0060\u0025\u0073\u0060",string (_fda ));
|
|
_faa .ProcTj (_fda ,_bef );case "\u0054\u004a":if len (_dac .Params )!=1{return _ed ;};_caeb ,_gdge :=_fc .GetArray (_dac .Params [0]);if !_gdge {_e .Log .Debug ("\u0054\u0079\u0070\u0065\u003a\u0020\u0025\u0054",_caeb );return _ac ;};_e .Log .Debug ("\u0054\u004a\u0020\u0061\u0072\u0072\u0061\u0079\u003a\u0020\u0025\u002b\u0076",_caeb );
|
|
for _ ,_fcg :=range _caeb .Elements (){switch _adfa :=_fcg .(type ){case *_fc .PdfObjectString :if _adfa !=nil {_faa .ProcTj (_adfa .Bytes (),_bef );};case *_fc .PdfObjectFloat ,*_fc .PdfObjectInteger :_agbf ,_dbg :=_fc .GetNumberAsFloat (_adfa );if _dbg ==nil {_faa .Translate (-_agbf *0.001*_faa .Tf .Size *_faa .Th /100.0,0);
|
|
};};};case "\u0054\u0066":if len (_dac .Params )!=2{return _ed ;};_e .Log .Debug ("\u0025\u0023\u0076",_dac .Params );_dag ,_cbd :=_fc .GetName (_dac .Params [0]);if !_cbd ||_dag ==nil {_e .Log .Debug ("\u0069\u006e\u0076\u0061l\u0069\u0064\u0020\u0066\u006f\u006e\u0074\u0020\u006e\u0061m\u0065 \u006f\u0062\u006a\u0065\u0063\u0074\u003a \u0025\u0076",_dac .Params [0]);
|
|
return _ac ;};_e .Log .Debug ("\u0046\u006f\u006e\u0074\u0020\u006e\u0061\u006d\u0065\u003a\u0020\u0025\u0073",_dag .String ());_cefbc ,_becc :=_fc .GetNumberAsFloat (_dac .Params [1]);if _becc !=nil {_e .Log .Debug ("\u0069\u006e\u0076\u0061l\u0069\u0064\u0020\u0066\u006f\u006e\u0074\u0020\u0073\u0069z\u0065 \u006f\u0062\u006a\u0065\u0063\u0074\u003a \u0025\u0076",_dac .Params [1]);
|
|
return _ac ;};_e .Log .Debug ("\u0046\u006f\u006e\u0074\u0020\u0073\u0069\u007a\u0065\u003a\u0020\u0025\u0076",_cefbc );_efgb ,_fcf :=_edb .GetFontByName (*_dag );if !_fcf {_e .Log .Debug ("\u0045R\u0052\u004f\u0052\u003a\u0020\u0046\u006f\u006e\u0074\u0020\u0025s\u0020\u006e\u006f\u0074\u0020\u0066\u006f\u0075\u006e\u0064",_dag .String ());
|
|
return _a .New ("\u0066\u006f\u006e\u0074\u0020\u006e\u006f\u0074\u0020f\u006f\u0075\u006e\u0064");};_e .Log .Debug ("\u0046\u006f\u006e\u0074\u003a\u0020\u0025\u0054",_efgb );_dagd ,_cbd :=_fc .GetDict (_efgb );if !_cbd {_e .Log .Debug ("\u0045\u0052\u0052\u004f\u0052\u003a\u0020\u0063\u006f\u0075l\u0064\u0020\u006e\u006f\u0074\u0020\u0067e\u0074\u0020\u0066\u006f\u006e\u0074\u0020\u0064\u0069\u0063\u0074");
|
|
return _ac ;};_abbb ,_becc :=_ab .NewPdfFontFromPdfObject (_dagd );if _becc !=nil {_e .Log .Debug ("\u0045\u0052\u0052\u004f\u0052\u003a\u0020\u0063\u006f\u0075\u006c\u0064\u0020\u006e\u006f\u0074\u0020\u006c\u006f\u0061\u0064\u0020\u0066\u006fn\u0074\u0020\u0066\u0072\u006fm\u0020\u006fb\u006a\u0065\u0063\u0074");
|
|
return _becc ;};_acb :=_abbb .BaseFont ();if _acb ==""{_acb =_dag .String ();};_cfba ,_cbd :=_gff [_acb ];if !_cbd {_cfba ,_becc =_cb .NewTextFont (_abbb ,_cefbc );if _becc !=nil {_e .Log .Debug ("\u0045R\u0052\u004f\u0052\u003a\u0020\u0025v",_becc );};
|
|
};if _cfba ==nil {if len (_acb )> 7&&_acb [6]=='+'{_acb =_acb [7:];};_baf :=[]string {_acb ,"\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 _ ,_bbdd :=range _baf {_e .Log .Debug ("\u0044\u0045\u0042\u0055\u0047\u003a \u0073\u0065\u0061\u0072\u0063\u0068\u0069\u006e\u0067\u0020\u0073\u0079\u0073t\u0065\u006d\u0020\u0066\u006f\u006e\u0074 \u0060\u0025\u0073\u0060",_bbdd );if _cfba ,_cbd =_gff [_bbdd ];
|
|
_cbd {break ;};_gge :=_dcg .Match (_bbdd );if _gge ==nil {_e .Log .Debug ("c\u006f\u0075\u006c\u0064\u0020\u006eo\u0074\u0020\u0066\u0069\u006e\u0064\u0020\u0066\u006fn\u0074\u0020\u0066i\u006ce\u0020\u0025\u0073",_bbdd );continue ;};_cfba ,_becc =_cb .NewTextFontFromPath (_gge .Filename ,_cefbc );
|
|
if _becc !=nil {_e .Log .Debug ("c\u006f\u0075\u006c\u0064\u0020\u006eo\u0074\u0020\u006c\u006f\u0061\u0064\u0020\u0066\u006fn\u0074\u0020\u0066i\u006ce\u0020\u0025\u0073",_gge .Filename );continue ;};_e .Log .Debug ("\u0053\u0075\u0062\u0073\u0074\u0069t\u0075\u0074\u0069\u006e\u0067\u0020\u0066\u006f\u006e\u0074\u0020\u0025\u0073 \u0077\u0069\u0074\u0068\u0020\u0025\u0073 \u0028\u0025\u0073\u0029",_acb ,_gge .Name ,_gge .Filename );
|
|
_gff [_bbdd ]=_cfba ;break ;};};if _cfba ==nil {_e .Log .Debug ("\u0045\u0052\u0052\u004f\u0052\u003a\u0020\u0063\u006f\u0075\u006c\u0064\u0020n\u006f\u0074\u0020\u0066\u0069\u006ed\u0020\u0061\u006e\u0079\u0020\u0073\u0075\u0069\u0074\u0061\u0062\u006c\u0065 \u0066\u006f\u006e\u0074");
|
|
return _a .New ("\u0063\u006f\u0075\u006c\u0064\u0020\u006e\u006f\u0074\u0020\u0066\u0069\u006e\u0064\u0020a\u006ey\u0020\u0073\u0075\u0069\u0074\u0061\u0062\u006c\u0065\u0020\u0066\u006f\u006e\u0074");};_faa .ProcTf (_cfba .WithSize (_cefbc ,_abbb ));
|
|
case "\u0042\u004d\u0043","\u0042\u0044\u0043":case "\u0045\u004d\u0043":default:_e .Log .Debug ("\u0045\u0052\u0052\u004f\u0052\u003a\u0020\u0075\u006e\u0073u\u0070\u0070\u006f\u0072\u0074\u0065\u0064 \u006f\u0070\u0065\u0072\u0061\u006e\u0064\u003a\u0020\u0025\u0073",_dac .Operand );
|
|
};_fdf =_dac ;return nil ;});_bf =_cbf .Process (_eaag );if _bf !=nil {return _bf ;};return nil ;};
|
|
|
|
// RenderWithOpts converts the specified PDF page into an image, optionally flattens annotations and returns the result.
|
|
func (_bec *ImageDevice )RenderWithOpts (page *_ab .PdfPage ,skipFlattening bool )(_gb .Image ,error ){_gc ,_bg :=page .GetMediaBox ();if _bg !=nil {return nil ,_bg ;};_gc .Normalize ();_becb :=page .CropBox ;var _cd ,_ag float64 ;if _becb !=nil {_becb .Normalize ();
|
|
_cd ,_ag =_becb .Width (),_becb .Height ();};_gfb :=page .Rotate ;_dd ,_cdg ,_fa ,_eb :=_gc .Llx ,_gc .Lly ,_gc .Width (),_gc .Height ();_ggc :=_ca .IdentityMatrix ();if _gfb !=nil &&*_gfb %360!=0&&*_gfb %90==0{_gd :=-float64 (*_gfb );_gfc :=_fdgd (_fa ,_eb ,_gd );
|
|
_ggc =_ggc .Translate ((_gfc .Width -_fa )/2+_fa /2,(_gfc .Height -_eb )/2+_eb /2).Rotate (_gd *_c .Pi /180).Translate (-_fa /2,-_eb /2);_fa ,_eb =_gfc .Width ,_gfc .Height ;if _becb !=nil {_cae :=_fdgd (_cd ,_ag ,_gd );_cd ,_ag =_cae .Width ,_cae .Height ;
|
|
};};if _dd !=0||_cdg !=0{_ggc =_ggc .Translate (-_dd ,-_cdg );};_bec ._dg =1.0;if _bec .OutputWidth !=0{_gbf :=_fa ;if _becb !=nil {_gbf =_cd ;};_bec ._dg =float64 (_bec .OutputWidth )/_gbf ;_fa ,_eb ,_cd ,_ag =_fa *_bec ._dg ,_eb *_bec ._dg ,_cd *_bec ._dg ,_ag *_bec ._dg ;
|
|
_ggc =_ca .ScaleMatrix (_bec ._dg ,_bec ._dg ).Mult (_ggc );};_dc :=_beb .NewContext (int (_fa ),int (_eb ));if _dfe :=_bec .renderPage (_dc ,page ,_ggc ,skipFlattening );_dfe !=nil {return nil ,_dfe ;};_ea :=_dc .Image ();if _becb !=nil {_ddf ,_afe :=(_becb .Llx -_dd )*_bec ._dg ,(_becb .Lly -_cdg )*_bec ._dg ;
|
|
_ff :=_gb .Rect (0,0,int (_cd ),int (_ag ));_cg :=_gb .Pt (int (_ddf ),int (_eb -_afe -_ag ));_fe :=_gb .NewRGBA (_ff );_f .Draw (_fe ,_ff ,_ea ,_cg ,_f .Src );_ea =_fe ;};return _ea ,nil ;};func (_adc renderer )processGradient (_eea _cb .Context ,_accg *_df .ContentStreamOperation ,_gaaf *_ab .PdfPageResources ,_dfef *_fc .PdfObjectName )(_cb .Gradient ,error ){if _ebcc ,_gdde :=_gaaf .GetPatternByName (*_dfef );
|
|
_gdde &&_ebcc .IsShading (){_fddb :=_ebcc .GetAsShadingPattern ().Shading ;_cda ,_ ,_egc :=_adc .processShading (_eea ,_fddb );if _egc !=nil {return nil ,_egc ;};return _cda ,nil ;};return nil ,nil ;};func _gbfd (_ffgf *_ab .Image ,_eggf _bb .Color )_gb .Image {_eacf ,_gdf :=int (_ffgf .Width ),int (_ffgf .Height );
|
|
_dcffe :=_gb .NewRGBA (_gb .Rect (0,0,_eacf ,_gdf ));for _cbag :=0;_cbag < _gdf ;_cbag ++{for _eaf :=0;_eaf < _eacf ;_eaf ++{_ebce ,_dgc :=_ffgf .ColorAt (_eaf ,_cbag );if _dgc !=nil {_e .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",_eaf ,_cbag );
|
|
continue ;};_cgdc ,_fbbd ,_babf ,_ :=_ebce .RGBA ();var _dbcg _bb .Color ;if _cgdc +_fbbd +_babf ==0{_dbcg =_bb .Transparent ;}else {_dbcg =_eggf ;};_dcffe .Set (_eaf ,_cbag ,_dbcg );};};return _dcffe ;};func _gfae (_gbfb _cb .Gradient ,_cfbg *_ab .PdfFunctionType3 ,_aba _ab .PdfColorspace ,_dddf []float64 )(_cb .Gradient ,error ){var _fbb error ;
|
|
for _ceb :=0;_ceb < len (_cfbg .Functions );_ceb ++{if _bgbb ,_dcff :=_cfbg .Functions [_ceb ].(*_ab .PdfFunctionType2 );_dcff {_gbfb ,_fbb =_cecd (_gbfb ,_bgbb ,_aba ,_dddf [_ceb +1],_ceb ==0);if _fbb !=nil {return nil ,_fbb ;};};};return _gbfb ,nil ;
|
|
};func _fdgd (_eag ,_ddcg ,_fcc float64 )_aab .BoundingBox {return _aab .Path {Points :[]_aab .Point {_aab .NewPoint (0,0).Rotate (_fcc ),_aab .NewPoint (_eag ,0).Rotate (_fcc ),_aab .NewPoint (0,_ddcg ).Rotate (_fcc ),_aab .NewPoint (_eag ,_ddcg ).Rotate (_fcc )}}.GetBoundingBox ();
|
|
};var (_ac =_a .New ("\u0074\u0079p\u0065\u0020\u0063h\u0065\u0063\u006b\u0020\u0065\u0072\u0072\u006f\u0072");_ed =_a .New ("\u0072\u0061\u006e\u0067\u0065\u0020\u0063\u0068\u0065\u0063\u006b\u0020e\u0072\u0072\u006f\u0072"););func (_cdff renderer )processShading (_dgba _cb .Context ,_beba *_ab .PdfShading )(_cb .Gradient ,*_fc .PdfObjectArray ,error ){_dbgb :=int64 (*_beba .ShadingType );
|
|
if _dbgb ==int64 (ShadingTypeAxial ){return _cdff .processLinearShading (_dgba ,_beba );}else if _dbgb ==int64 (ShadingTypeRadial ){return _cdff .processRadialShading (_dgba ,_beba );}else {_e .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",_dbgb ));
|
|
};return nil ,nil ,nil ;}; |