mirror of
https://github.com/unidoc/unipdf.git
synced 2025-04-26 13:48:55 +08:00
148 lines
39 KiB
Go
148 lines
39 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 (_ba "errors";_f "fmt";_ga "github.com/adrg/sysfont";_gf "github.com/unidoc/unipdf/v3/common";_cde "github.com/unidoc/unipdf/v3/contentstream";_ff "github.com/unidoc/unipdf/v3/contentstream/draw";_bfg "github.com/unidoc/unipdf/v3/core";
|
|
_bgb "github.com/unidoc/unipdf/v3/internal/license";_e "github.com/unidoc/unipdf/v3/internal/transform";_gfa "github.com/unidoc/unipdf/v3/model";_gd "github.com/unidoc/unipdf/v3/render/internal/context";_fff "github.com/unidoc/unipdf/v3/render/internal/context/imagerender";
|
|
_fg "golang.org/x/image/draw";_cd "image";_gg "image/color";_bc "image/draw";_c "image/jpeg";_bg "image/png";_bf "math";_d "os";_g "path/filepath";_a "strings";);func _febc (_dec ,_cga ,_fcc float64 )_ff .BoundingBox {return _ff .Path {Points :[]_ff .Point {_ff .NewPoint (0,0).Rotate (_fcc ),_ff .NewPoint (_dec ,0).Rotate (_fcc ),_ff .NewPoint (0,_cga ).Rotate (_fcc ),_ff .NewPoint (_dec ,_cga ).Rotate (_fcc )}}.GetBoundingBox ();
|
|
};func (_dcc renderer )renderPage (_bfgc _gd .Context ,_cec *_gfa .PdfPage ,_cb _e .Matrix )error {_ab ,_ebe :=_cec .GetAllContentStreams ();if _ebe !=nil {return _ebe ;};if _bce :=_cb ;!_bce .Identity (){_ab =_f .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",_bce [0],_bce [1],_bce [3],_bce [4],_bce [6],_bce [7],_ab );
|
|
};_bfgc .Translate (0,float64 (_bfgc .Height ()));_bfgc .Scale (1,-1);_bfgc .Push ();_bfgc .SetRGBA (1,1,1,1);_bfgc .DrawRectangle (0,0,float64 (_bfgc .Width ()),float64 (_bfgc .Height ()));_bfgc .Fill ();_bfgc .Pop ();_bfgc .SetLineWidth (1.0);_bfgc .SetRGBA (0,0,0,1);
|
|
return _dcc .renderContentStream (_bfgc ,_ab ,_cec .Resources );};func (_aea renderer )renderContentStream (_bb _gd .Context ,_ed string ,_aac *_gfa .PdfPageResources )error {_ec ,_bcb :=_cde .NewContentStreamParser (_ed ).Parse ();if _bcb !=nil {return _bcb ;
|
|
};_afa :=_bb .TextState ();_afa .GlobalScale =_aea ._fgc ;_eec :=map[string ]*_gd .TextFont {};_ad :=_ga .NewFinder (&_ga .FinderOpts {Extensions :[]string {"\u002e\u0074\u0074\u0066","\u002e\u0074\u0074\u0063"}});_aeb :=_cde .NewContentStreamProcessor (*_ec );
|
|
_aeb .AddHandler (_cde .HandlerConditionEnumAllOperands ,"",func (_de *_cde .ContentStreamOperation ,_aaa _cde .GraphicsState ,_ggab *_gfa .PdfPageResources )error {_gf .Log .Debug ("\u0050\u0072\u006f\u0063\u0065\u0073\u0073\u0069\u006e\u0067\u0020\u0025\u0073",_de .Operand );
|
|
switch _de .Operand {case "\u0071":_bb .Push ();case "\u0051":_bb .Pop ();_afa =_bb .TextState ();case "\u0063\u006d":if len (_de .Params )!=6{return _aa ;};_dcab ,_cda :=_bfg .GetNumbersAsFloat (_de .Params );if _cda !=nil {return _cda ;};_eaf :=_e .NewMatrix (_dcab [0],_dcab [1],_dcab [2],_dcab [3],_dcab [4],_dcab [5]);
|
|
_gf .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",_eaf );_bb .SetMatrix (_bb .Matrix ().Mult (_eaf ));case "\u0077":if len (_de .Params )!=1{return _aa ;
|
|
};_gdf ,_cdef :=_bfg .GetNumbersAsFloat (_de .Params );if _cdef !=nil {return _cdef ;};_bb .SetLineWidth (_gdf [0]);case "\u004a":if len (_de .Params )!=1{return _aa ;};_ac ,_ge :=_bfg .GetIntVal (_de .Params [0]);if !_ge {return _bad ;};switch _ac {case 0:_bb .SetLineCap (_gd .LineCapButt );
|
|
case 1:_bb .SetLineCap (_gd .LineCapRound );case 2:_bb .SetLineCap (_gd .LineCapSquare );default:_gf .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",_ac );
|
|
return _aa ;};case "\u006a":if len (_de .Params )!=1{return _aa ;};_dga ,_df :=_bfg .GetIntVal (_de .Params [0]);if !_df {return _bad ;};switch _dga {case 0:_bb .SetLineJoin (_gd .LineJoinBevel );case 1:_bb .SetLineJoin (_gd .LineJoinRound );case 2:_bb .SetLineJoin (_gd .LineJoinBevel );
|
|
default:_gf .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",_dga );return _aa ;};case "\u004d":if len (_de .Params )!=1{return _aa ;};_aab ,_aba :=_bfg .GetNumbersAsFloat (_de .Params );
|
|
if _aba !=nil {return _aba ;};_ =_aab ;_gf .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 (_de .Params )!=2{return _aa ;};_caa ,_fgb :=_bfg .GetArray (_de .Params [0]);
|
|
if !_fgb {return _bad ;};_fca ,_fgb :=_bfg .GetIntVal (_de .Params [1]);if !_fgb {return _bad ;};_ade ,_cg :=_bfg .GetNumbersAsFloat (_caa .Elements ());if _cg !=nil {return _cg ;};_bb .SetDash (_ade ...);_ =_fca ;_gf .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":_gf .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":_gf .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 (_de .Params )!=1{return _aa ;};_fcg ,_bbf :=_bfg .GetName (_de .Params [0]);if !_bbf {return _bad ;};if _fcg ==nil {return _aa ;};_cee ,_bbf :=_ggab .GetExtGState (*_fcg );if !_bbf {_gf .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",*_fcg );
|
|
return _ba .New ("\u0072e\u0073o\u0075\u0072\u0063\u0065\u0020n\u006f\u0074 \u0066\u006f\u0075\u006e\u0064");};_afg ,_bbf :=_bfg .GetDict (_cee );if !_bbf {_gf .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 _bad ;};_gf .Log .Debug ("G\u0053\u0020\u0064\u0069\u0063\u0074\u003a\u0020\u0025\u0073",_afg .String ());case "\u006d":if len (_de .Params )!=2{_gf .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",_aa );
|
|
return nil ;};_gcc ,_dff :=_bfg .GetNumbersAsFloat (_de .Params );if _dff !=nil {return _dff ;};_gf .Log .Debug ("M\u006f\u0076\u0065\u0020\u0074\u006f\u003a\u0020\u0025\u0076",_gcc );_bb .NewSubPath ();_bb .MoveTo (_gcc [0],_gcc [1]);case "\u006c":if len (_de .Params )!=2{_gf .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",_aa );
|
|
return nil ;};_gfed ,_fgbb :=_bfg .GetNumbersAsFloat (_de .Params );if _fgbb !=nil {return _fgbb ;};_bb .LineTo (_gfed [0],_gfed [1]);case "\u0063":if len (_de .Params )!=6{return _aa ;};_bd ,_bga :=_bfg .GetNumbersAsFloat (_de .Params );if _bga !=nil {return _bga ;
|
|
};_gf .Log .Debug ("\u0043u\u0062\u0069\u0063\u0020\u0062\u0065\u007a\u0069\u0065\u0072\u0020p\u0061\u0072\u0061\u006d\u0073\u003a\u0020\u0025\u002b\u0076",_bd );_bb .CubicTo (_bd [0],_bd [1],_bd [2],_bd [3],_bd [4],_bd [5]);case "\u0076","\u0079":if len (_de .Params )!=4{return _aa ;
|
|
};_gfg ,_ef :=_bfg .GetNumbersAsFloat (_de .Params );if _ef !=nil {return _ef ;};_gf .Log .Debug ("\u0043u\u0062\u0069\u0063\u0020\u0062\u0065\u007a\u0069\u0065\u0072\u0020p\u0061\u0072\u0061\u006d\u0073\u003a\u0020\u0025\u002b\u0076",_gfg );_bb .QuadraticTo (_gfg [0],_gfg [1],_gfg [2],_gfg [3]);
|
|
case "\u0068":_bb .ClosePath ();_bb .NewSubPath ();case "\u0072\u0065":if len (_de .Params )!=4{return _aa ;};_ace ,_bcbc :=_bfg .GetNumbersAsFloat (_de .Params );if _bcbc !=nil {return _bcbc ;};_bb .DrawRectangle (_ace [0],_ace [1],_ace [2],_ace [3]);
|
|
_bb .NewSubPath ();case "\u0053":_fgcf ,_ag :=_aaa .ColorspaceStroking .ColorToRGB (_aaa .ColorStroking );if _ag !=nil {_gf .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",_ag );
|
|
return _ag ;};_dgd ,_dgb :=_fgcf .(*_gfa .PdfColorDeviceRGB );if !_dgb {_gf .Log .Debug ("\u0045\u0072\u0072\u006fr \u0063\u006f\u006e\u0076\u0065\u0072\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006co\u0072");return _ag ;};_bb .SetRGBA (_dgd .R (),_dgd .G (),_dgd .B (),1);
|
|
_bb .Stroke ();case "\u0073":_ecd ,_fde :=_aaa .ColorspaceStroking .ColorToRGB (_aaa .ColorStroking );if _fde !=nil {_gf .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 ;};_eda ,_aad :=_ecd .(*_gfa .PdfColorDeviceRGB );if !_aad {_gf .Log .Debug ("\u0045\u0072\u0072\u006fr \u0063\u006f\u006e\u0076\u0065\u0072\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006co\u0072");return _fde ;};_bb .ClosePath ();_bb .NewSubPath ();
|
|
_bb .SetRGBA (_eda .R (),_eda .G (),_eda .B (),1);_bb .Stroke ();case "\u0066","\u0046":_cgc ,_dd :=_aaa .ColorspaceNonStroking .ColorToRGB (_aaa .ColorNonStroking );if _dd !=nil {_gf .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",_dd );
|
|
return _dd ;};_cea ,_cag :=_cgc .(*_gfa .PdfColorDeviceRGB );if !_cag {_gf .Log .Debug ("\u0045\u0072\u0072\u006fr \u0063\u006f\u006e\u0076\u0065\u0072\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006co\u0072");return _dd ;};_bb .SetRGBA (_cea .R (),_cea .G (),_cea .B (),1);
|
|
_bb .SetFillRule (_gd .FillRuleWinding );_bb .Fill ();case "\u0066\u002a":_bcg ,_edg :=_aaa .ColorspaceNonStroking .ColorToRGB (_aaa .ColorNonStroking );if _edg !=nil {_gf .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",_edg );
|
|
return _edg ;};_bbb ,_geg :=_bcg .(*_gfa .PdfColorDeviceRGB );if !_geg {_gf .Log .Debug ("\u0045\u0072\u0072\u006fr \u0063\u006f\u006e\u0076\u0065\u0072\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006co\u0072");return _edg ;};_bb .SetRGBA (_bbb .R (),_bbb .G (),_bbb .B (),1);
|
|
_bb .SetFillRule (_gd .FillRuleEvenOdd );_bb .Fill ();case "\u0042":_bfge ,_gbf :=_aaa .ColorspaceNonStroking .ColorToRGB (_aaa .ColorNonStroking );if _gbf !=nil {_gf .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",_gbf );
|
|
return _gbf ;};_bae :=_bfge .(*_gfa .PdfColorDeviceRGB );_bb .SetRGBA (_bae .R (),_bae .G (),_bae .B (),1);_bb .SetFillRule (_gd .FillRuleWinding );_bb .FillPreserve ();_bfge ,_gbf =_aaa .ColorspaceStroking .ColorToRGB (_aaa .ColorStroking );if _gbf !=nil {_gf .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",_gbf );
|
|
return _gbf ;};_bae =_bfge .(*_gfa .PdfColorDeviceRGB );_bb .SetRGBA (_bae .R (),_bae .G (),_bae .B (),1);_bb .Stroke ();case "\u0042\u002a":_daff ,_gde :=_aaa .ColorspaceNonStroking .ColorToRGB (_aaa .ColorNonStroking );if _gde !=nil {_gf .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",_gde );
|
|
return _gde ;};_dgf :=_daff .(*_gfa .PdfColorDeviceRGB );_bb .SetRGBA (_dgf .R (),_dgf .G (),_dgf .B (),1);_bb .SetFillRule (_gd .FillRuleEvenOdd );_bb .FillPreserve ();_daff ,_gde =_aaa .ColorspaceStroking .ColorToRGB (_aaa .ColorStroking );if _gde !=nil {_gf .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",_gde );
|
|
return _gde ;};_dgf =_daff .(*_gfa .PdfColorDeviceRGB );_bb .SetRGBA (_dgf .R (),_dgf .G (),_dgf .B (),1);_bb .Stroke ();case "\u0062":_ggf ,_eg :=_aaa .ColorspaceNonStroking .ColorToRGB (_aaa .ColorNonStroking );if _eg !=nil {_gf .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",_eg );
|
|
return _eg ;};_ddf :=_ggf .(*_gfa .PdfColorDeviceRGB );_bb .SetRGBA (_ddf .R (),_ddf .G (),_ddf .B (),1);_bb .ClosePath ();_bb .NewSubPath ();_bb .SetFillRule (_gd .FillRuleWinding );_bb .FillPreserve ();_ggf ,_eg =_aaa .ColorspaceStroking .ColorToRGB (_aaa .ColorStroking );
|
|
if _eg !=nil {_gf .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",_eg );return _eg ;};_ddf =_ggf .(*_gfa .PdfColorDeviceRGB );_bb .SetRGBA (_ddf .R (),_ddf .G (),_ddf .B (),1);
|
|
_bb .Stroke ();case "\u0062\u002a":_bb .ClosePath ();_bab ,_fac :=_aaa .ColorspaceNonStroking .ColorToRGB (_aaa .ColorNonStroking );if _fac !=nil {_gf .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",_fac );
|
|
return _fac ;};_bbc :=_bab .(*_gfa .PdfColorDeviceRGB );_bb .SetRGBA (_bbc .R (),_bbc .G (),_bbc .B (),1);_bb .NewSubPath ();_bb .SetFillRule (_gd .FillRuleEvenOdd );_bb .FillPreserve ();_bab ,_fac =_aaa .ColorspaceStroking .ColorToRGB (_aaa .ColorStroking );
|
|
if _fac !=nil {_gf .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",_fac );return _fac ;};_bbc =_bab .(*_gfa .PdfColorDeviceRGB );_bb .SetRGBA (_bbc .R (),_bbc .G (),_bbc .B (),1);
|
|
_bb .Stroke ();case "\u006e":_bb .ClearPath ();case "\u0057":_bb .SetFillRule (_gd .FillRuleWinding );_bb .ClipPreserve ();case "\u0057\u002a":_bb .SetFillRule (_gd .FillRuleEvenOdd );_bb .ClipPreserve ();case "\u0072\u0067":_dgfd ,_abf :=_aaa .ColorNonStroking .(*_gfa .PdfColorDeviceRGB );
|
|
if !_abf {_gf .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_aaa .ColorNonStroking );return nil ;};_bb .SetFillRGBA (_dgfd .R (),_dgfd .G (),_dgfd .B (),1);
|
|
case "\u0052\u0047":_gae ,_ecc :=_aaa .ColorStroking .(*_gfa .PdfColorDeviceRGB );if !_ecc {_gf .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_aaa .ColorStroking );
|
|
return nil ;};_bb .SetStrokeRGBA (_gae .R (),_gae .G (),_gae .B (),1);case "\u006b":_cbb ,_fcd :=_aaa .ColorNonStroking .(*_gfa .PdfColorDeviceCMYK );if !_fcd {_gf .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_aaa .ColorNonStroking );
|
|
return nil ;};_dccf ,_ddc :=_aaa .ColorspaceNonStroking .ColorToRGB (_cbb );if _ddc !=nil {_gf .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_aaa .ColorNonStroking );
|
|
return nil ;};_fag ,_fcd :=_dccf .(*_gfa .PdfColorDeviceRGB );if !_fcd {_gf .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",_dccf );return nil ;
|
|
};_bb .SetFillRGBA (_fag .R (),_fag .G (),_fag .B (),1);case "\u004b":_eed ,_acd :=_aaa .ColorStroking .(*_gfa .PdfColorDeviceCMYK );if !_acd {_gf .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_aaa .ColorStroking );
|
|
return nil ;};_fb ,_afb :=_aaa .ColorspaceStroking .ColorToRGB (_eed );if _afb !=nil {_gf .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_aaa .ColorStroking );
|
|
return nil ;};_bgg ,_acd :=_fb .(*_gfa .PdfColorDeviceRGB );if !_acd {_gf .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 nil ;
|
|
};_bb .SetStrokeRGBA (_bgg .R (),_bgg .G (),_bgg .B (),1);case "\u0067":_be ,_gdd :=_aaa .ColorNonStroking .(*_gfa .PdfColorDeviceGray );if !_gdd {_gf .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_aaa .ColorNonStroking );
|
|
return nil ;};_ggag ,_gbe :=_aaa .ColorspaceNonStroking .ColorToRGB (_be );if _gbe !=nil {_gf .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_aaa .ColorNonStroking );
|
|
return nil ;};_fbd ,_gdd :=_ggag .(*_gfa .PdfColorDeviceRGB );if !_gdd {_gf .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",_ggag );return nil ;
|
|
};_bb .SetFillRGBA (_fbd .R (),_fbd .G (),_fbd .B (),1);case "\u0047":_dae ,_egc :=_aaa .ColorStroking .(*_gfa .PdfColorDeviceGray );if !_egc {_gf .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_aaa .ColorStroking );
|
|
return nil ;};_faga ,_cc :=_aaa .ColorspaceStroking .ColorToRGB (_dae );if _cc !=nil {_gf .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_aaa .ColorStroking );
|
|
return nil ;};_ebed ,_egc :=_faga .(*_gfa .PdfColorDeviceRGB );if !_egc {_gf .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",_faga );return nil ;
|
|
};_bb .SetStrokeRGBA (_ebed .R (),_ebed .G (),_ebed .B (),1);case "\u0063\u0073","\u0073\u0063","\u0073\u0063\u006e":_ada ,_aeaf :=_aaa .ColorspaceNonStroking .ColorToRGB (_aaa .ColorNonStroking );if _aeaf !=nil {_gf .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_aaa .ColorNonStroking );
|
|
return nil ;};_edc ,_dce :=_ada .(*_gfa .PdfColorDeviceRGB );if !_dce {_gf .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",_ada );return nil ;
|
|
};_bb .SetFillRGBA (_edc .R (),_edc .G (),_edc .B (),1);case "\u0043\u0053","\u0053\u0043","\u0053\u0043\u004e":_abc ,_abcd :=_aaa .ColorspaceStroking .ColorToRGB (_aaa .ColorStroking );if _abcd !=nil {_gf .Log .Debug ("\u0045\u0072\u0072\u006f\u0072\u0020\u0063\u006f\u006e\u0076\u0065r\u0074\u0069\u006e\u0067\u0020\u0063\u006f\u006c\u006f\u0072:\u0020\u0025\u0076",_aaa .ColorStroking );
|
|
return nil ;};_ecf ,_gda :=_abc .(*_gfa .PdfColorDeviceRGB );if !_gda {_gf .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",_abc );return nil ;
|
|
};_bb .SetStrokeRGBA (_ecf .R (),_ecf .G (),_ecf .B (),1);case "\u0044\u006f":if len (_de .Params )!=1{return _aa ;};_edgf ,_dccfe :=_bfg .GetName (_de .Params [0]);if !_dccfe {return _bad ;};_ ,_fbf :=_ggab .GetXObjectByName (*_edgf );switch _fbf {case _gfa .XObjectTypeImage :_gf .Log .Debug ("\u0058\u004f\u0062\u006a\u0065\u0063\u0074\u0020\u0069\u006d\u0061\u0067e\u003a\u0020\u0025\u0073",_edgf .String ());
|
|
_bfec ,_eee :=_ggab .GetXObjectImageByName (*_edgf );if _eee !=nil {return _eee ;};_ddb ,_eee :=_bfec .ToImage ();if _eee !=nil {return _eee ;};if _afae :=_bfec .ColorSpace ;_afae !=nil {var _bdd bool ;switch _afae .(type ){case *_gfa .PdfColorspaceSpecialIndexed :_bdd =true ;
|
|
};if _bdd {if _aga ,_gaef :=_afae .ImageToRGB (*_ddb );_gaef !=nil {_gf .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 {_ddb =&_aga ;};};};_adaf :=_bb .FillPattern ().ColorAt (0,0);var _gfaf _cd .Image ;if _bfec .Mask !=nil {if _gfaf ,_eee =_gdeg (_bfec .Mask ,_adaf );_eee !=nil {_gf .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 _bfec .SMask !=nil {if _gfaf ,_eee =_cff (_bfec .SMask ,_adaf );_eee !=nil {_gf .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 _cd .Image ;if _ddfd ,_ :=_bfg .GetBoolVal (_bfec .ImageMask );_ddfd {_gaa =_gfd (_ddb ,_adaf );}else {_gaa ,_eee =_ddb .ToGoImage ();if _eee !=nil {return _eee ;};};if _gfaf !=nil {_gaa =_fge (_gaa ,_gfaf );};_deg :=_gaa .Bounds ();_bb .Push ();
|
|
_bb .Scale (1.0/float64 (_deg .Dx ()),-1.0/float64 (_deg .Dy ()));_bb .DrawImageAnchored (_gaa ,0,0,0,1);_bb .Pop ();case _gfa .XObjectTypeForm :_gf .Log .Debug ("\u0058\u004fb\u006a\u0065\u0063t\u0020\u0066\u006f\u0072\u006d\u003a\u0020\u0025\u0073",_edgf .String ());
|
|
_cbc ,_cagc :=_ggab .GetXObjectFormByName (*_edgf );if _cagc !=nil {return _cagc ;};_dbe ,_cagc :=_cbc .GetContentStream ();if _cagc !=nil {return _cagc ;};_caf :=_cbc .Resources ;if _caf ==nil {_caf =_ggab ;};_bb .Push ();if _cbc .Matrix !=nil {_gaec ,_cef :=_bfg .GetArray (_cbc .Matrix );
|
|
if !_cef {return _bad ;};_cfa ,_ffg :=_bfg .GetNumbersAsFloat (_gaec .Elements ());if _ffg !=nil {return _ffg ;};if len (_cfa )!=6{return _aa ;};_fec :=_e .NewMatrix (_cfa [0],_cfa [1],_cfa [2],_cfa [3],_cfa [4],_cfa [5]);_bb .SetMatrix (_bb .Matrix ().Mult (_fec ));
|
|
};if _cbc .BBox !=nil {_edf ,_bfgee :=_bfg .GetArray (_cbc .BBox );if !_bfgee {return _bad ;};_cfd ,_ddcc :=_bfg .GetNumbersAsFloat (_edf .Elements ());if _ddcc !=nil {return _ddcc ;};if len (_cfd )!=4{_gf .Log .Debug ("\u004c\u0065\u006e\u0020\u003d\u0020\u0025\u0064",len (_cfd ));
|
|
return _aa ;};_bb .DrawRectangle (_cfd [0],_cfd [1],_cfd [2]-_cfd [0],_cfd [3]-_cfd [1]);_bb .SetRGBA (1,0,0,1);_bb .Clip ();}else {_gf .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");
|
|
};_cagc =_aea .renderContentStream (_bb ,string (_dbe ),_caf );if _cagc !=nil {return _cagc ;};_bb .Pop ();};case "\u0042\u0049":if len (_de .Params )!=1{return _aa ;};_fae ,_aada :=_de .Params [0].(*_cde .ContentStreamInlineImage );if !_aada {return nil ;
|
|
};_bbcf ,_agd :=_fae .ToImage (_ggab );if _agd !=nil {return _agd ;};_bba ,_agd :=_bbcf .ToGoImage ();if _agd !=nil {return _agd ;};_afe :=_bba .Bounds ();_bb .Push ();_bb .Scale (1.0/float64 (_afe .Dx ()),-1.0/float64 (_afe .Dy ()));_bb .DrawImageAnchored (_bba ,0,0,0,1);
|
|
_bb .Pop ();case "\u0042\u0054":_afa .Reset ();case "\u0045\u0054":_afa .Reset ();case "\u0054\u0072":if len (_de .Params )!=1{return _aa ;};_cfg ,_dbf :=_bfg .GetNumberAsFloat (_de .Params [0]);if _dbf !=nil {return _dbf ;};_afa .Tr =_gd .TextRenderingMode (_cfg );
|
|
case "\u0054\u004c":if len (_de .Params )!=1{return _aa ;};_ebd ,_ede :=_bfg .GetNumberAsFloat (_de .Params [0]);if _ede !=nil {return _ede ;};_afa .Tl =_ebd ;case "\u0054\u0063":if len (_de .Params )!=1{return _aa ;};_gfedc ,_fee :=_bfg .GetNumberAsFloat (_de .Params [0]);
|
|
if _fee !=nil {return _fee ;};_gf .Log .Debug ("\u0054\u0063\u003a\u0020\u0025\u0076",_gfedc );_afa .Tc =_gfedc ;case "\u0054\u0077":if len (_de .Params )!=1{return _aa ;};_gadg ,_ega :=_bfg .GetNumberAsFloat (_de .Params [0]);if _ega !=nil {return _ega ;
|
|
};_gf .Log .Debug ("\u0054\u0077\u003a\u0020\u0025\u0076",_gadg );_afa .Tw =_gadg ;case "\u0054\u007a":if len (_de .Params )!=1{return _aa ;};_cae ,_eeeb :=_bfg .GetNumberAsFloat (_de .Params [0]);if _eeeb !=nil {return _eeeb ;};_afa .Th =_cae ;case "\u0054\u0073":if len (_de .Params )!=1{return _aa ;
|
|
};_aee ,_fbde :=_bfg .GetNumberAsFloat (_de .Params [0]);if _fbde !=nil {return _fbde ;};_afa .Ts =_aee ;case "\u0054\u0064":if len (_de .Params )!=2{return _aa ;};_cgg ,_edae :=_bfg .GetNumbersAsFloat (_de .Params );if _edae !=nil {return _edae ;};_gf .Log .Debug ("\u0054\u0064\u003a\u0020\u0025\u0076",_cgg );
|
|
_afa .ProcTd (_cgg [0],_cgg [1]);case "\u0054\u0044":if len (_de .Params )!=2{return _aa ;};_bcgd ,_cded :=_bfg .GetNumbersAsFloat (_de .Params );if _cded !=nil {return _cded ;};_gf .Log .Debug ("\u0054\u0044\u003a\u0020\u0025\u0076",_bcgd );_afa .ProcTD (_bcgd [0],_bcgd [1]);
|
|
case "\u0054\u002a":_afa .ProcTStar ();case "\u0054\u006d":if len (_de .Params )!=6{return _aa ;};_efe ,_dag :=_bfg .GetNumbersAsFloat (_de .Params );if _dag !=nil {return _dag ;};_gf .Log .Debug ("\u0054\u0065x\u0074\u0020\u006da\u0074\u0072\u0069\u0078\u003a\u0020\u0025\u002b\u0076",_efe );
|
|
_afa .ProcTm (_efe [0],_efe [1],_efe [2],_efe [3],_efe [4],_efe [5]);case "\u0027":if len (_de .Params )!=1{return _aa ;};_badc ,_adf :=_bfg .GetStringBytes (_de .Params [0]);if !_adf {return _bad ;};_gf .Log .Debug ("\u0027\u0020\u0073t\u0072\u0069\u006e\u0067\u003a\u0020\u0025\u0073",string (_badc ));
|
|
_afa .ProcQ (_badc ,_bb );case "\u0022":if len (_de .Params )!=3{return _aa ;};_bde ,_bdf :=_bfg .GetNumberAsFloat (_de .Params [0]);if _bdf !=nil {return _bdf ;};_gba ,_bdf :=_bfg .GetNumberAsFloat (_de .Params [1]);if _bdf !=nil {return _bdf ;};_agdd ,_dbg :=_bfg .GetStringBytes (_de .Params [2]);
|
|
if !_dbg {return _bad ;};_afa .ProcDQ (_agdd ,_bde ,_gba ,_bb );case "\u0054\u006a":if len (_de .Params )!=1{return _aa ;};_fcf ,_aed :=_bfg .GetStringBytes (_de .Params [0]);if !_aed {return _bad ;};_gf .Log .Debug ("\u0054j\u0020s\u0074\u0072\u0069\u006e\u0067\u003a\u0020\u0060\u0025\u0073\u0060",string (_fcf ));
|
|
_afa .ProcTj (_fcf ,_bb );case "\u0054\u004a":if len (_de .Params )!=1{return _aa ;};_gdc ,_cbbe :=_bfg .GetArray (_de .Params [0]);if !_cbbe {_gf .Log .Debug ("\u0054\u0079\u0070\u0065\u003a\u0020\u0025\u0054",_gdc );return _bad ;};_gf .Log .Debug ("\u0054\u004a\u0020\u0061\u0072\u0072\u0061\u0079\u003a\u0020\u0025\u002b\u0076",_gdc );
|
|
for _ ,_deb :=range _gdc .Elements (){switch _ebf :=_deb .(type ){case *_bfg .PdfObjectString :if _ebf !=nil {_afa .ProcTj (_ebf .Bytes (),_bb );};case *_bfg .PdfObjectFloat ,*_bfg .PdfObjectInteger :_cece ,_fad :=_bfg .GetNumberAsFloat (_ebf );if _fad ==nil {_afa .Translate (-_cece *0.001*_afa .Tf .Size *_afa .Th /100.0,0);
|
|
};};};case "\u0054\u0066":if len (_de .Params )!=2{return _aa ;};_gf .Log .Debug ("\u0025\u0023\u0076",_de .Params );_ebg ,_ggfe :=_bfg .GetName (_de .Params [0]);if !_ggfe ||_ebg ==nil {_gf .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",_de .Params [0]);
|
|
return _bad ;};_gf .Log .Debug ("\u0046\u006f\u006e\u0074\u0020\u006e\u0061\u006d\u0065\u003a\u0020\u0025\u0073",_ebg .String ());_adff ,_fda :=_bfg .GetNumberAsFloat (_de .Params [1]);if _fda !=nil {_gf .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",_de .Params [1]);
|
|
return _bad ;};_gf .Log .Debug ("\u0046\u006f\u006e\u0074\u0020\u0073\u0069\u007a\u0065\u003a\u0020\u0025\u0076",_adff );_adb ,_cbd :=_ggab .GetFontByName (*_ebg );if !_cbd {_gf .Log .Debug ("\u0045R\u0052\u004f\u0052\u003a\u0020\u0046\u006f\u006e\u0074\u0020\u0025s\u0020\u006e\u006f\u0074\u0020\u0066\u006f\u0075\u006e\u0064",_ebg .String ());
|
|
return _ba .New ("\u0066\u006f\u006e\u0074\u0020\u006e\u006f\u0074\u0020f\u006f\u0075\u006e\u0064");};_gf .Log .Debug ("\u0046\u006f\u006e\u0074\u003a\u0020\u0025\u0054",_adb );_dge ,_ggfe :=_bfg .GetDict (_adb );if !_ggfe {_gf .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 _bad ;};_dbd ,_fda :=_gfa .NewPdfFontFromPdfObject (_dge );if _fda !=nil {_gf .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 _fda ;};_adbg :=_dbd .BaseFont ();if _adbg ==""{_adbg =_ebg .String ();};_bed ,_ggfe :=_eec [_adbg ];if !_ggfe {_bed ,_fda =_gd .NewTextFont (_dbd ,_adff );if _fda !=nil {_gf .Log .Debug ("\u0045R\u0052\u004f\u0052\u003a\u0020\u0025v",_fda );};};
|
|
if _bed ==nil {if len (_adbg )> 7&&_adbg [6]=='+'{_adbg =_adbg [7:];};_daa :=[]string {_adbg ,"\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 _ ,_bdg :=range _daa {_gf .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",_bdg );if _bed ,_ggfe =_eec [_bdg ];
|
|
_ggfe {break ;};_aaf :=_ad .Match (_bdg );if _aaf ==nil {_gf .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",_bdg );continue ;};_bed ,_fda =_gd .NewTextFontFromPath (_aaf .Filename ,_adff );
|
|
if _fda !=nil {_gf .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",_aaf .Filename );continue ;};_gf .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",_adbg ,_aaf .Name ,_aaf .Filename );
|
|
_eec [_bdg ]=_bed ;break ;};};if _bed ==nil {_gf .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 _ba .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");};_afa .ProcTf (_bed .WithSize (_adff ,_dbd ));case "\u0042\u004d\u0043","\u0042\u0044\u0043":case "\u0045\u004d\u0043":default:_gf .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",_de .Operand );
|
|
};return nil ;});_bcb =_aeb .Process (_aac );if _bcb !=nil {return _bcb ;};return nil ;};func _gaee (_gfga string ,_fcgd _cd .Image )error {_fef ,_bgag :=_d .Create (_gfga );if _bgag !=nil {return _bgag ;};defer _fef .Close ();return _bg .Encode (_fef ,_fcgd );
|
|
};
|
|
|
|
// RenderToPath converts the specified PDF page into an image and saves the
|
|
// result at the specified location.
|
|
func (_fa *ImageDevice )RenderToPath (page *_gfa .PdfPage ,outputPath string )error {_ca ,_bfe :=_fa .Render (page );if _bfe !=nil {return _bfe ;};_feb :=_a .ToLower (_g .Ext (outputPath ));if _feb ==""{return _ba .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 _feb {case "\u002e\u0070\u006e\u0067":return _gaee (outputPath ,_ca );case "\u002e\u006a\u0070\u0067","\u002e\u006a\u0070e\u0067":return _gff (outputPath ,_ca ,100);};return _f .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",_feb );
|
|
};func _gdeg (_edd _bfg .PdfObject ,_cdfe _gg .Color )(_cd .Image ,error ){_cca ,_gfaa :=_bfg .GetStream (_edd );if !_gfaa {return nil ,nil ;};_daag ,_fcge :=_gfa .NewXObjectImageFromStream (_cca );if _fcge !=nil {return nil ,_fcge ;};_ccc ,_fcge :=_daag .ToImage ();
|
|
if _fcge !=nil {return nil ,_fcge ;};return _gfd (_ccc ,_cdfe ),nil ;};func _gff (_agg string ,_fab _cd .Image ,_dde int )error {_bge ,_fecf :=_d .Create (_agg );if _fecf !=nil {return _fecf ;};defer _bge .Close ();return _c .Encode (_bge ,_fab ,&_c .Options {Quality :_dde });
|
|
};
|
|
|
|
// 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 _gfd (_ceceb *_gfa .Image ,_efa _gg .Color )_cd .Image {_eae ,_beg :=int (_ceceb .Width ),int (_ceceb .Height );_gcb :=_cd .NewRGBA (_cd .Rect (0,0,_eae ,_beg ));for _baeg :=0;_baeg < _beg ;_baeg ++{for _cggf :=0;_cggf < _eae ;_cggf ++{_ceab ,_dfg :=_ceceb .ColorAt (_cggf ,_baeg );
|
|
if _dfg !=nil {_gf .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",_cggf ,_baeg );
|
|
continue ;};_ebff ,_ffe ,_egcg ,_ :=_ceab .RGBA ();var _fffa _gg .Color ;if _ebff +_ffe +_egcg ==0{_fffa =_efa ;}else {_fffa =_gg .Transparent ;};_gcb .Set (_cggf ,_baeg ,_fffa );};};return _gcb ;};
|
|
|
|
// Render converts the specified PDF page into an image and returns the result.
|
|
func (_af *ImageDevice )Render (page *_gfa .PdfPage )(_cd .Image ,error ){_gdb ,_da :=page .GetMediaBox ();if _da !=nil {return nil ,_da ;};_gdb .Normalize ();_dc :=page .CropBox ;var _ae ,_ce float64 ;if _dc !=nil {_dc .Normalize ();_ae ,_ce =_dc .Width (),_dc .Height ();
|
|
};_dg :=page .Rotate ;_ea ,_gfe ,_cdf ,_fe :=_gdb .Llx ,_gdb .Lly ,_gdb .Width (),_gdb .Height ();_gad :=_e .IdentityMatrix ();if _dg !=nil &&*_dg %360!=0&&*_dg %90==0{_fffc :=-float64 (*_dg );_ffc :=_febc (_cdf ,_fe ,_fffc );_gad =_gad .Translate ((_ffc .Width -_cdf )/2+_cdf /2,(_ffc .Height -_fe )/2+_fe /2).Rotate (_fffc *_bf .Pi /180).Translate (-_cdf /2,-_fe /2);
|
|
_cdf ,_fe =_ffc .Width ,_ffc .Height ;if _dc !=nil {_daf :=_febc (_ae ,_ce ,_fffc );_ae ,_ce =_daf .Width ,_daf .Height ;};};if _ea !=0||_gfe !=0{_gad =_gad .Translate (-_ea ,-_gfe );};_af ._fgc =1.0;if _af .OutputWidth !=0{_gb :=_cdf ;if _dc !=nil {_gb =_ae ;
|
|
};_af ._fgc =float64 (_af .OutputWidth )/_gb ;_cdf ,_fe ,_ae ,_ce =_cdf *_af ._fgc ,_fe *_af ._fgc ,_ae *_af ._fgc ,_ce *_af ._fgc ;_gad =_e .ScaleMatrix (_af ._fgc ,_af ._fgc ).Mult (_gad );};_gga :=_fff .NewContext (int (_cdf ),int (_fe ));if _eb :=_af .renderPage (_gga ,page ,_gad );
|
|
_eb !=nil {return nil ,_eb ;};_fd :=_gga .Image ();if _dc !=nil {_fc ,_dca :=(_dc .Llx -_ea )*_af ._fgc ,(_dc .Lly -_gfe )*_af ._fgc ;_gcg :=_cd .Rect (0,0,int (_ae ),int (_ce ));_cdc :=_cd .Pt (int (_fc ),int (_fe -_dca -_ce ));_ee :=_cd .NewRGBA (_gcg );
|
|
_bc .Draw (_ee ,_gcg ,_fd ,_cdc ,_bc .Src );_fd =_ee ;};return _fd ,nil ;};func _cff (_efab _bfg .PdfObject ,_dfd _gg .Color )(_cd .Image ,error ){_aaae ,_dcad :=_bfg .GetStream (_efab );if !_dcad {return nil ,nil ;};_gfea ,_ddec :=_gfa .NewXObjectImageFromStream (_aaae );
|
|
if _ddec !=nil {return nil ,_ddec ;};_gada ,_ddec :=_gfea .ToImage ();if _ddec !=nil {return nil ,_ddec ;};return _ccgf (_gada ,_dfd ),nil ;};var (_bad =_ba .New ("\u0074\u0079p\u0065\u0020\u0063h\u0065\u0063\u006b\u0020\u0065\u0072\u0072\u006f\u0072");
|
|
_aa =_ba .New ("\u0072\u0061\u006e\u0067\u0065\u0020\u0063\u0068\u0065\u0063\u006b\u0020e\u0072\u0072\u006f\u0072"););func _ccgf (_fgeb *_gfa .Image ,_dcg _gg .Color )_cd .Image {_gdbe ,_fba :=int (_fgeb .Width ),int (_fgeb .Height );_bcf :=_cd .NewRGBA (_cd .Rect (0,0,_gdbe ,_fba ));
|
|
for _age :=0;_age < _fba ;_age ++{for _fgd :=0;_fgd < _gdbe ;_fgd ++{_cbbc ,_cgd :=_fgeb .ColorAt (_fgd ,_age );if _cgd !=nil {_gf .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",_fgd ,_age );
|
|
continue ;};_faf ,_cdac ,_gef ,_ :=_cbbc .RGBA ();var _ebb _gg .Color ;if _faf +_cdac +_gef ==0{_ebb =_gg .Transparent ;}else {_ebb =_dcg ;};_bcf .Set (_fgd ,_age ,_ebb );};};return _bcf ;};type renderer struct{_fgc float64 };func _fge (_gffc ,_acc _cd .Image )_cd .Image {_ccg ,_eea :=_acc .Bounds ().Size (),_gffc .Bounds ().Size ();
|
|
_gaea ,_abd :=_ccg .X ,_ccg .Y ;if _eea .X > _gaea {_gaea =_eea .X ;};if _eea .Y > _abd {_abd =_eea .Y ;};_baf :=_cd .Rect (0,0,_gaea ,_abd );if _ccg .X !=_gaea ||_ccg .Y !=_abd {_cad :=_cd .NewRGBA (_baf );_fg .BiLinear .Scale (_cad ,_baf ,_gffc ,_acc .Bounds (),_fg .Over ,nil );
|
|
_acc =_cad ;};if _eea .X !=_gaea ||_eea .Y !=_abd {_fgf :=_cd .NewRGBA (_baf );_fg .BiLinear .Scale (_fgf ,_baf ,_gffc ,_gffc .Bounds (),_fg .Over ,nil );_gffc =_fgf ;};_gbd :=_cd .NewRGBA (_baf );_fg .DrawMask (_gbd ,_baf ,_gffc ,_cd .Point {},_acc ,_cd .Point {},_fg .Over );
|
|
return _gbd ;};
|
|
|
|
// NewImageDevice returns a new image device.
|
|
func NewImageDevice ()*ImageDevice {const _gc ="r\u0065\u006e\u0064\u0065r.\u004ee\u0077\u0049\u006d\u0061\u0067e\u0044\u0065\u0076\u0069\u0063\u0065";_bgb .TrackUse (_gc );return &ImageDevice {};}; |