Merge pull request #4 from unidoc-build/prep-rc-v0.4.0

prepare release v0.4.0
This commit is contained in:
Gunnsteinn Hall 2021-03-27 16:29:13 +00:00 committed by GitHub
commit 2a6f11d3ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 406 additions and 406 deletions

View File

@ -9,54 +9,56 @@
// 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 cmd ;import (_ec "context";_bb "fmt";_bf "github.com/mitchellh/go-homedir";_f "github.com/spf13/cobra";_be "github.com/spf13/viper";_c "github.com/unidoc/unihtml/client";_bc "github.com/unidoc/unihtml/content";_af "github.com/unidoc/unihtml/sizes";
_ce "github.com/unidoc/unipdf/v3/common";_ef "os";_a "path/filepath";_b "time";);func _ad (){_bdf :=_ce .LogLevelInfo ;if _fg {_bdf =_ce .LogLevelDebug ;};if _ed {_bdf =_ce .LogLevelTrace ;};_ce .Log =_ce .NewConsoleLogger (_bdf );};var _gca string ;type generateConfig struct{Port int `mapstructure:"port"`;
Host string `mapstructure:"host"`;Https bool `mapstructure:"https"`;Prefix string `mapstructure:"prefix"`;};
package cmd ;import (_b "context";_ea "fmt";_fg "github.com/mitchellh/go-homedir";_a "github.com/spf13/cobra";_eaf "github.com/spf13/viper";_ad "github.com/unidoc/unihtml/client";_aee "github.com/unidoc/unihtml/content";_d "github.com/unidoc/unihtml/sizes";
_ae "github.com/unidoc/unipdf/v3/common";_e "os";_ga "path/filepath";_f "time";);type generateConfig struct{Port int `mapstructure:"port"`;Host string `mapstructure:"host"`;Https bool `mapstructure:"https"`;Prefix string `mapstructure:"prefix"`;};
// Execute adds all child commands to the root command and sets flags appropriately.
// This is called by main.main(). It only needs to happen once to the rootCmd.
func Execute (){if _ecb :=_dgb .Execute ();_ecb !=nil {_bb .Println (_ecb );_ef .Exit (1);};};func init (){_dgb .AddCommand (_fa );_fa .Flags ().IntP ("\u0070\u006f\u0072\u0074","\u0070",8080,"\u0050\u006f\u0072\u0074\u0020\u006f\u0066\u0020\u0074\u0068\u0065 \u0075\u006e\u0069\u0068\u0074\u006d\u006c\u0020\u0073\u0065r\u0076\u0065\u0072");
_fa .Flags ().String ("\u0068\u006f\u0073\u0074","\u006co\u0063\u0061\u006c\u0068\u006f\u0073t","\u0048\u006f\u0073t\u0020\u006e\u0061\u006de\u0020\u006f\u0066\u0020\u0074\u0068\u0065 \u0075\u006e\u0069\u0068\u0074\u006d\u006c\u0020\u0073\u0065\u0072\u0076\u0065\u0072");
_fa .Flags ().BoolP ("\u0068\u0074\u0074p\u0073","\u0073",false ,"\u0050\u0072o\u0074\u006f\u0063\u006fl\u0020\u0075s\u0065\u0064\u0020\u0069\u006e\u0020\u0073\u0065r\u0076\u0065\u0072\u0020\u0063\u006f\u006d\u006d\u0075\u006e\u0069\u0063a\u0074\u0069\u006f\u006e");
_fa .Flags ().StringP ("\u0070\u0072\u0065\u0066\u0069\u0078","\u0078","","\u0050u\u0062\u006ci\u0063\u0020\u0061\u0070i\u0020\u0070\u0072e\u0066\u0069\u0078\u0020\u0075\u0073\u0065\u0064\u0020by\u0020\u0074\u0068e\u0020\u0075n\u0069\u0068\u0074\u006d\u006c\u0020s\u0065\u0072v\u0065\u0072");
_fa .Flags ().Var (&_ge .PaperWidth ,"p\u0061\u0070\u0065\u0072\u002d\u0077\u0069\u0064\u0074\u0068","\u0073\u0065\u0074s \u0075\u0070\u0020\u0074\u0068\u0065\u0020\u0070\u0061\u0070\u0065\u0072\u002d\u0077\u0069\u0064\u0074\u0068");_fa .Flags ().Var (&_ge .PaperHeight ,"\u0070\u0061\u0070e\u0072\u002d\u0068\u0065\u0069\u0067\u0068\u0074","\u0073e\u0074\u0073\u0020\u0075\u0070\u0020\u0074\u0068\u0065\u0020\u0070a\u0070\u0065\u0072\u002d\u0068\u0065\u0069\u0067\u0068\u0074");
_fa .Flags ().Var (&_ge .PageSize ,"\u0070\u0061\u0070\u0065\u0072\u002d\u0073\u0069\u007a\u0065","s\u0065\u0074\u0073\u0020up\u0020t\u0068\u0065\u0020\u0070\u0061g\u0065\u0020\u0073\u0069\u007a\u0065");_fa .Flags ().Var (&_ge .Orientation ,"o\u0072\u0069\u0065\u006e\u0074\u0061\u0074\u0069\u006f\u006e","\u0073\u0065\u0074\u0073 \u0075\u0070\u0020\u0074\u0068\u0065\u0020\u0070\u0061\u0067e\u0020o\u0072\u0069\u0065\u006e\u0074\u0061\u0074i\u006f\u006e");
_fa .Flags ().Var (&_ge .MarginTop ,"\u006d\u0061\u0072\u0067\u0069\u006e\u002d\u0074\u006f\u0070","\u0073\u0065\u0074\u0073 u\u0070\u0020\u0074\u0068\u0065\u0020\u006d\u0061\u0072\u0067\u0069\u006e\u002d\u0074o\u0070");_fa .Flags ().Var (&_ge .MarginBottom ,"\u006d\u0061\u0072\u0067\u0069\u006e\u002d\u0062\u006f\u0074\u0074\u006f\u006d","\u0073e\u0074\u0073\u0020\u0075p\u0020\u0074\u0068\u0065\u0020m\u0061r\u0067i\u006e\u002d\u0062\u006f\u0074\u0074\u006fm");
_fa .Flags ().Var (&_ge .MarginRight ,"\u006d\u0061\u0072g\u0069\u006e\u002d\u0072\u0069\u0067\u0068\u0074","\u0073e\u0074\u0073\u0020\u0075\u0070\u0020\u0074\u0068\u0065\u0020\u006da\u0072\u0067\u0069\u006e\u002d\u0072\u0069\u0067\u0068\u0074");_fa .Flags ().Var (&_ge .MarginLeft ,"m\u0061\u0072\u0067\u0069\u006e\u002d\u006c\u0065\u0066\u0074","\u0073\u0065\u0074\u0073 u\u0070\u0020\u0074\u0068\u0065\u0020\u0070\u0061\u0070\u0065\u0072\u002d\u006c\u0065f\u0074");
};func _bd (cmd *_f .Command ,_gf []string ){_cd :=_b .Now ();if _gec :=_be .BindPFlags (cmd .Flags ());_gec !=nil {_bb .Printf ("\u0045\u0072\u0072\u003a\u0020\u0025\u0076\u000a",_gec );_ef .Exit (1);};if _gecd :=_be .Unmarshal (&_g );_gecd !=nil {_bb .Printf ("\u0045\u0072\u0072\u003a\u0020\u0025\u0076\u000a",_gecd );
_ef .Exit (1);};_ad ();_d :=_b .Now ();_eg ,_ab :=_ef .Stat (_gf [0]);if _ab !=nil {_bb .Printf ("\u0045\u0072\u0072\u003a\u0020\u0025\u0076\u000a",_ab );_ef .Exit (1);};if !_eg .IsDir (){if _a .Ext (_eg .Name ())!="\u002e\u0068\u0074m\u006c"{_bb .Printf ("\u0045\u0072r\u003a\u0020\u0043\u0075\u0072\u0072\u0065\u006e\u0074\u006c\u0079\u0020\u006f\u006e\u006c\u0079\u0020\u0048\u0054M\u004c\u0020\u0066\u0069\u006c\u0065s\u0020\u0069\u006e\u0070\u0075\u0074\u0053\u0074\u0061\u0074\u0020\u0061\u0072\u0065 \u0073\u0075p\u0070\u006f\u0072\u0074e\u0064\u002e\u0020\u0049\u006ep\u0075\u0074\u003a\u0020\u0025\u0073\u000a",_gf [0]);
_ef .Exit (1);};};_ced ,_ab :=_ef .OpenFile (_gf [1],_ef .O_CREATE |_ef .O_WRONLY |_ef .O_TRUNC ,0700);if _ab !=nil {_bb .Printf ("\u0045\u0072\u0072\u003a\u0020\u0025\u0076\u000a",_ab );_ef .Exit (1);};defer _ced .Close ();_dg :=_c .New (_c .Options {HTTPS :_g .Https ,Hostname :_g .Host ,Port :_g .Port ,Prefix :_g .Prefix });
_ba ,_gg :=_ec .WithTimeout (_ec .Background (),_b .Second *10);defer _gg ();_d =_b .Now ();var _ac _bc .Content ;if _eg .IsDir (){_ac ,_ab =_bc .NewZipDirectory (_gf [0]);}else {_ac ,_ab =_bc .NewHTMLFile (_gf [0]);};if _ab !=nil {_bb .Printf ("\u0045r\u0072\u003a\u0020\u0025\u0076",_ab );
_ef .Exit (1);};_dd ,_ab :=_c .BuildHTMLQuery ().PaperWidth (_ge .PaperWidth .Length ).PaperHeight (_ge .PaperHeight .Length ).PageSize (_ge .PageSize ).MarginTop (_ge .MarginTop .Length ).MarginBottom (_ge .MarginBottom .Length ).MarginLeft (_ge .MarginLeft .Length ).MarginRight (_ge .MarginRight .Length ).Orientation (_ge .Orientation ).SetContent (_ac ).Query ();
if _ab !=nil {_bb .Printf ("\u0045\u0072\u0072\u003a\u0020\u0025\u0076\u000a",_ab );_ef .Exit (1);};_gge ,_ab :=_dg .ConvertHTML (_ba ,_dd );if _ab !=nil {_bb .Printf ("\u0045\u0072\u0072\u003a\u0020\u0025\u0076\u000a",_ab );_ef .Exit (1);};_ce .Log .Trace ("\u0045\u0078\u0065cu\u0074\u0069\u006e\u0067\u0020\u0067\u0065\u006e\u0065r\u0061t\u0065 \u0071u\u0065\u0072\u0079\u0020\u0074\u0061\u006b\u0065\u006e\u003a\u0020\u0025\u0073",_b .Since (_d ));
_d =_b .Now ();_ ,_ab =_ced .Write (_gge .Data );if _ab !=nil {_bb .Printf ("\u0045\u0072\u0072\u003a\u0020\u0025\u0076\u000a",_ab );_ef .Exit (1);};_ce .Log .Trace ("\u0057\u0072\u0069\u0074in\u0067\u0020\u0066\u0069\u006c\u0065\u0020\u0074\u0061\u006b\u0065\u006e\u003a\u0020%\u0073",_b .Since (_d ));
_bb .Printf ("\u0047\u0065n\u0065\u0072\u0061\u0074\u0065\u0064\u0020\u0077\u0069\u0074\u0068\u0020\u0073\u0075\u0063\u0063\u0065\u0073\u0073\u0020\u0069\u006e %\u0073\u000a",_b .Since (_cd ));};var (_fg ,_ed bool ;);type parametersConfig struct{
func Execute (){if _gc :=_gaf .Execute ();_gc !=nil {_ea .Println (_gc );_e .Exit (1);};};func _fa (){if _fe !=""{_eaf .SetConfigFile (_fe );}else {_bbg ,_dc :=_fg .Dir ();if _dc !=nil {_ea .Println (_dc );_e .Exit (1);};_eaf .AddConfigPath (_bbg );_eaf .SetConfigName ("\u002e\u0075\u006ei\u0068\u0074\u006d\u006c\u002d\u0073\u0072\u0063");
};_eaf .AutomaticEnv ();if _bae :=_eaf .ReadInConfig ();_bae ==nil {_ea .Println ("\u0055s\u0069n\u0067\u0020\u0063\u006f\u006ef\u0069\u0067 \u0066\u0069\u006c\u0065\u003a",_eaf .ConfigFileUsed ());};};func _bc (cmd *_a .Command ,_da []string ){_gf :=_f .Now ();
if _gfe :=_eaf .BindPFlags (cmd .Flags ());_gfe !=nil {_ea .Printf ("\u0045\u0072\u0072\u003a\u0020\u0025\u0076\u000a",_gfe );_e .Exit (1);};if _gg :=_eaf .Unmarshal (&_c );_gg !=nil {_ea .Printf ("\u0045\u0072\u0072\u003a\u0020\u0025\u0076\u000a",_gg );
_e .Exit (1);};_ff ();_bga :=_f .Now ();_dd ,_ddg :=_e .Stat (_da [0]);if _ddg !=nil {_ea .Printf ("\u0045\u0072\u0072\u003a\u0020\u0025\u0076\u000a",_ddg );_e .Exit (1);};if !_dd .IsDir (){if _ga .Ext (_dd .Name ())!="\u002e\u0068\u0074m\u006c"{_ea .Printf ("\u0045\u0072r\u003a\u0020\u0043\u0075\u0072\u0072\u0065\u006e\u0074\u006c\u0079\u0020\u006f\u006e\u006c\u0079\u0020\u0048\u0054M\u004c\u0020\u0066\u0069\u006c\u0065s\u0020\u0069\u006e\u0070\u0075\u0074\u0053\u0074\u0061\u0074\u0020\u0061\u0072\u0065 \u0073\u0075p\u0070\u006f\u0072\u0074e\u0064\u002e\u0020\u0049\u006ep\u0075\u0074\u003a\u0020\u0025\u0073\u000a",_da [0]);
_e .Exit (1);};};_gfb ,_ddg :=_e .OpenFile (_da [1],_e .O_CREATE |_e .O_WRONLY |_e .O_TRUNC ,0700);if _ddg !=nil {_ea .Printf ("\u0045\u0072\u0072\u003a\u0020\u0025\u0076\u000a",_ddg );_e .Exit (1);};defer _gfb .Close ();_be :=_ad .New (_ad .Options {HTTPS :_c .Https ,Hostname :_c .Host ,Port :_c .Port ,Prefix :_c .Prefix });
_eeb ,_ab :=_b .WithTimeout (_b .Background (),_f .Second *10);defer _ab ();_bga =_f .Now ();var _bcf _aee .Content ;if _dd .IsDir (){_bcf ,_ddg =_aee .NewZipDirectory (_da [0]);}else {_bcf ,_ddg =_aee .NewHTMLFile (_da [0]);};if _ddg !=nil {_ea .Printf ("\u0045r\u0072\u003a\u0020\u0025\u0076",_ddg );
_e .Exit (1);};_ba ,_ddg :=_ad .BuildHTMLQuery ().PaperWidth (_eafc .PaperWidth .Length ).PaperHeight (_eafc .PaperHeight .Length ).PageSize (_eafc .PageSize ).MarginTop (_eafc .MarginTop .Length ).MarginBottom (_eafc .MarginBottom .Length ).MarginLeft (_eafc .MarginLeft .Length ).MarginRight (_eafc .MarginRight .Length ).Orientation (_eafc .Orientation ).SetContent (_bcf ).Query ();
if _ddg !=nil {_ea .Printf ("\u0045\u0072\u0072\u003a\u0020\u0025\u0076\u000a",_ddg );_e .Exit (1);};_gag ,_ddg :=_be .ConvertHTML (_eeb ,_ba );if _ddg !=nil {_ea .Printf ("\u0045\u0072\u0072\u003a\u0020\u0025\u0076\u000a",_ddg );_e .Exit (1);};_ae .Log .Trace ("\u0045\u0078\u0065cu\u0074\u0069\u006e\u0067\u0020\u0067\u0065\u006e\u0065r\u0061t\u0065 \u0071u\u0065\u0072\u0079\u0020\u0074\u0061\u006b\u0065\u006e\u003a\u0020\u0025\u0073",_f .Since (_bga ));
_bga =_f .Now ();_ ,_ddg =_gfb .Write (_gag .Data );if _ddg !=nil {_ea .Printf ("\u0045\u0072\u0072\u003a\u0020\u0025\u0076\u000a",_ddg );_e .Exit (1);};_ae .Log .Trace ("\u0057\u0072\u0069\u0074in\u0067\u0020\u0066\u0069\u006c\u0065\u0020\u0074\u0061\u006b\u0065\u006e\u003a\u0020%\u0073",_f .Since (_bga ));
_ea .Printf ("\u0047\u0065n\u0065\u0072\u0061\u0074\u0065\u0064\u0020\u0077\u0069\u0074\u0068\u0020\u0073\u0075\u0063\u0063\u0065\u0073\u0073\u0020\u0069\u006e %\u0073\u000a",_f .Since (_gf ));};func init (){_gaf .AddCommand (_bb );_bb .Flags ().IntP ("\u0070\u006f\u0072\u0074","\u0070",8080,"\u0050\u006f\u0072\u0074\u0020\u006f\u0066\u0020\u0074\u0068\u0065 \u0075\u006e\u0069\u0068\u0074\u006d\u006c\u0020\u0073\u0065r\u0076\u0065\u0072");
_bb .Flags ().String ("\u0068\u006f\u0073\u0074","\u006co\u0063\u0061\u006c\u0068\u006f\u0073t","\u0048\u006f\u0073t\u0020\u006e\u0061\u006de\u0020\u006f\u0066\u0020\u0074\u0068\u0065 \u0075\u006e\u0069\u0068\u0074\u006d\u006c\u0020\u0073\u0065\u0072\u0076\u0065\u0072");
_bb .Flags ().BoolP ("\u0068\u0074\u0074p\u0073","\u0073",false ,"\u0050\u0072o\u0074\u006f\u0063\u006fl\u0020\u0075s\u0065\u0064\u0020\u0069\u006e\u0020\u0073\u0065r\u0076\u0065\u0072\u0020\u0063\u006f\u006d\u006d\u0075\u006e\u0069\u0063a\u0074\u0069\u006f\u006e");
_bb .Flags ().StringP ("\u0070\u0072\u0065\u0066\u0069\u0078","\u0078","","\u0050u\u0062\u006ci\u0063\u0020\u0061\u0070i\u0020\u0070\u0072e\u0066\u0069\u0078\u0020\u0075\u0073\u0065\u0064\u0020by\u0020\u0074\u0068e\u0020\u0075n\u0069\u0068\u0074\u006d\u006c\u0020s\u0065\u0072v\u0065\u0072");
_bb .Flags ().Var (&_eafc .PaperWidth ,"p\u0061\u0070\u0065\u0072\u002d\u0077\u0069\u0064\u0074\u0068","\u0073\u0065\u0074s \u0075\u0070\u0020\u0074\u0068\u0065\u0020\u0070\u0061\u0070\u0065\u0072\u002d\u0077\u0069\u0064\u0074\u0068");_bb .Flags ().Var (&_eafc .PaperHeight ,"\u0070\u0061\u0070e\u0072\u002d\u0068\u0065\u0069\u0067\u0068\u0074","\u0073e\u0074\u0073\u0020\u0075\u0070\u0020\u0074\u0068\u0065\u0020\u0070a\u0070\u0065\u0072\u002d\u0068\u0065\u0069\u0067\u0068\u0074");
_bb .Flags ().Var (&_eafc .PageSize ,"\u0070\u0061\u0070\u0065\u0072\u002d\u0073\u0069\u007a\u0065","s\u0065\u0074\u0073\u0020up\u0020t\u0068\u0065\u0020\u0070\u0061g\u0065\u0020\u0073\u0069\u007a\u0065");_bb .Flags ().Var (&_eafc .Orientation ,"o\u0072\u0069\u0065\u006e\u0074\u0061\u0074\u0069\u006f\u006e","\u0073\u0065\u0074\u0073 \u0075\u0070\u0020\u0074\u0068\u0065\u0020\u0070\u0061\u0067e\u0020o\u0072\u0069\u0065\u006e\u0074\u0061\u0074i\u006f\u006e");
_bb .Flags ().Var (&_eafc .MarginTop ,"\u006d\u0061\u0072\u0067\u0069\u006e\u002d\u0074\u006f\u0070","\u0073\u0065\u0074\u0073 u\u0070\u0020\u0074\u0068\u0065\u0020\u006d\u0061\u0072\u0067\u0069\u006e\u002d\u0074o\u0070");_bb .Flags ().Var (&_eafc .MarginBottom ,"\u006d\u0061\u0072\u0067\u0069\u006e\u002d\u0062\u006f\u0074\u0074\u006f\u006d","\u0073e\u0074\u0073\u0020\u0075p\u0020\u0074\u0068\u0065\u0020m\u0061r\u0067i\u006e\u002d\u0062\u006f\u0074\u0074\u006fm");
_bb .Flags ().Var (&_eafc .MarginRight ,"\u006d\u0061\u0072g\u0069\u006e\u002d\u0072\u0069\u0067\u0068\u0074","\u0073e\u0074\u0073\u0020\u0075\u0070\u0020\u0074\u0068\u0065\u0020\u006da\u0072\u0067\u0069\u006e\u002d\u0072\u0069\u0067\u0068\u0074");_bb .Flags ().Var (&_eafc .MarginLeft ,"m\u0061\u0072\u0067\u0069\u006e\u002d\u006c\u0065\u0066\u0074","\u0073\u0065\u0074\u0073 u\u0070\u0020\u0074\u0068\u0065\u0020\u0070\u0061\u0070\u0065\u0072\u002d\u006c\u0065f\u0074");
};var _gaf =&_a .Command {Use :"\u0075n\u0069\u0068\u0074\u006d\u006c",Short :"\u0041\u0020\u0062\u0072\u0069\u0065\u0066\u0020\u0064\u0065\u0073\u0063\u0072i\u0070\u0074\u0069\u006f\u006e\u0020o\u0066\u0020\u0079\u006f\u0075\u0072\u0020\u0061\u0070\u0070\u006c\u0069\u0063a\u0074\u0069\u006f\u006e",Long :"\u0041\u0020\u006c\u006f\u006e\u0067\u0065\u0072\u0020\u0064\u0065\u0073c\u0072\u0069\u0070\u0074i\u006f\u006e\u0020\u0074\u0068\u0061\u0074\u0020s\u0070\u0061n\u0073\u0020\u006d\u0075\u006ct\u0069\u0070\u006c\u0065\u0020\u006c\u0069\u006e\u0065\u0073\u0020\u0061nd\u0020\u006c\u0069\u006b\u0065\u006cy\u0020\u0063\u006f\u006e\u0074\u0061\u0069\u006e\u0073\u000a\u0065\u0078\u0061\u006d\u0070\u006c\u0065\u0073\u0020\u0061n\u0064\u0020\u0075s\u0061\u0067\u0065\u0020\u006ff\u0020\u0075\u0073\u0069\u006eg \u0079\u006f\u0075\u0072\u0020\u0061\u0070\u0070\u006c\u0069\u0063\u0061\u0074\u0069\u006fn\u002e\u0020\u0046\u006f\u0072\u0020e\u0078\u0061\u006dp\u006c\u0065\u003a\u000a\u000a\u0043\u006f\u0062\u0072\u0061\u0020\u0069s\u0020\u0061\u0020\u0043L\u0049\u0020\u006c\u0069\u0062\u0072\u0061\u0072\u0079\u0020f\u006f\u0072\u0020\u0047\u006f\u0020t\u0068\u0061t\u0020\u0065\u006dp\u006f\u0077\u0065\u0072\u0073\u0020\u0061p\u0070\u006c\u0069\u0063\u0061\u0074\u0069\u006f\u006e\u0073\u002e\u000a\u0054\u0068\u0069\u0073\u0020\u0061\u0070p\u006c\u0069\u0063\u0061\u0074\u0069\u006f\u006e \u0069\u0073 \u0061\u0020\u0074\u006f\u006f\u006c\u0020\u0074o\u0020g\u0065\u006e\u0065\u0072a\u0074\u0065 \u0074\u0068e\u0020\u006e\u0065\u0065\u0064\u0065\u0064\u0020\u0066\u0069\u006ce\u0073\u000a\u0074\u006f\u0020\u0071\u0075\u0069\u0063\u006b\u006cy\u0020\u0063\u0072\u0065\u0061\u0074\u0065\u0020\u0061\u0020\u0043\u006f\u0062\u0072\u0061\u0020\u0061\u0070pl\u0069ca\u0074\u0069on\u002e"};
type parametersConfig struct{
// PaperWidth sets the width of the paper.
PaperWidth _af .LengthFlag `mapstructure:"paper-width"`;
PaperWidth _d .LengthFlag `mapstructure:"paper-width"`;
// PaperHeight is the height of the output paper.
PaperHeight _af .LengthFlag `mapstructure:"paper-height"`;
PaperHeight _d .LengthFlag `mapstructure:"paper-height"`;
// PageSize is the page size string.
PageSize _af .PageSize `mapstructure:"page-size"`;
PageSize _d .PageSize `mapstructure:"page-size"`;
// Orientation defines if the output should be in a landscape format.
Orientation _af .Orientation `mapstructure:"orientation"`;
Orientation _d .Orientation `mapstructure:"orientation"`;
// MarginTop sets up the Top Margin for the output.
MarginTop _af .LengthFlag `mapstructure:"margin-top"`;
MarginTop _d .LengthFlag `mapstructure:"margin-top"`;
// MarginBottom sets up the Bottom Margin for the output.
MarginBottom _af .LengthFlag `mapstructure:"margin-bottom"`;
MarginBottom _d .LengthFlag `mapstructure:"margin-bottom"`;
// MarginLeft sets up the Left Margin for the output.
MarginLeft _af .LengthFlag `mapstructure:"margin-left"`;
MarginLeft _d .LengthFlag `mapstructure:"margin-left"`;
// MarginRight sets up the Right Margin for the output.
MarginRight _af .LengthFlag `mapstructure:"margin-right"`;};func _ee (){if _gca !=""{_be .SetConfigFile (_gca );}else {_daf ,_cdd :=_bf .Dir ();if _cdd !=nil {_bb .Println (_cdd );_ef .Exit (1);};_be .AddConfigPath (_daf );_be .SetConfigName ("\u002e\u0075\u006ei\u0068\u0074\u006d\u006c\u002d\u0073\u0072\u0063");
};_be .AutomaticEnv ();if _afa :=_be .ReadInConfig ();_afa ==nil {_bb .Println ("\u0055s\u0069n\u0067\u0020\u0063\u006f\u006ef\u0069\u0067 \u0066\u0069\u006c\u0065\u003a",_be .ConfigFileUsed ());};};var (_g =generateConfig {};_ge =parametersConfig {PaperWidth :_af .LengthFlag {Length :_af .Inch (8.5).Millimeters ()},PaperHeight :_af .LengthFlag {Length :_af .Inch (11).Millimeters ()},Orientation :_af .Portrait ,MarginTop :_af .LengthFlag {Length :_af .Millimeter (10)},MarginBottom :_af .LengthFlag {Length :_af .Millimeter (10)},MarginLeft :_af .LengthFlag {Length :_af .Millimeter (10)},MarginRight :_af .LengthFlag {Length :_af .Millimeter (10)}};
);func init (){_f .OnInitialize (_ee );_dgb .PersistentFlags ().BoolVarP (&_fg ,"\u0064\u0065\u0062u\u0067","\u0064",false ,"\u0044e\u0066i\u006e\u0065\u0073\u0020\u0064e\u0062\u0075g\u0020\u006d\u006f\u0064\u0065");_dgb .PersistentFlags ().BoolVarP (&_ed ,"\u0076e\u0072\u0062\u006f\u0073\u0065","\u0076",false ,"\u0056\u0065\u0072\u0062\u006f\u0073e\u0020\u0069\u006e\u0066\u006f\u0072\u006d\u0061\u0074\u0069\u006f\u006e\u0020o\u0066\u0020\u0074\u0068\u0065\u0020\u0063l\u0069\u0065\u006e\u0074");
_dgb .PersistentFlags ().StringVar (&_gca ,"\u0063\u006f\u006e\u0066\u0069\u0067","","\u0063\u006f\u006e\u0066\u0069\u0067\u0020\u0066i\u006c\u0065\u0020(d\u0065\u0066\u0061\u0075\u006c\u0074 \u0069\u0073\u0020\u0024\u0048\u004f\u004d\u0045\u002f\u002e\u0075\u006e\u0069\u0068\u0074m\u006c\u002d\u0073\u0072\u0063\u002e\u0079\u0061m\u006c\u0029");
_dgb .Flags ().BoolP ("\u0074\u006f\u0067\u0067\u006c\u0065","\u0074",false ,"\u0048\u0065\u006cp \u006d\u0065\u0073\u0073\u0061\u0067\u0065\u0020\u0066\u006f\u0072\u0020\u0074\u006f\u0067\u0067\u006c\u0065");};var _fa =&_f .Command {Use :"\u0067\u0065\u006e\u0065\u0072\u0061\u0074\u0065",Short :"\u0047\u0065\u006e\u0065\u0072a\u0074\u0065\u0073\u0020\u0050\u0044F\u0020\u0062\u0061\u0073\u0065\u0064\u0020o\u006e\u0020\u0074h\u0065\u0020\u0070\u0072o\u0076\u0069\u0064\u0065\u0064\u0020H\u0054\u004d\u004c\u0020\u006f\u0072\u0020\u0064\u0069\u0072\u0065\u0063\u0074\u006f\u0072\u0079\u0020w\u0069\u0074\u0068\u0020\u0074\u0068\u0065\u0020\u0048\u0054\u004d\u004c\u0020\u0066\u0069\u006c\u0065\u0073\u002e",Long :"A\u0020\u006c\u006f\u006e\u0067\u0065\u0072\u0020\u0064e\u0073\u0063\u0072\u0069\u0070\u0074\u0069on\u0020\u0074\u0068\u0061\u0074\u0020s\u0070\u0061\u006e\u0073\u0020\u006d\u0075\u006c\u0074\u0069\u0070\u006c\u0065\u0020\u006c\u0069\u006e\u0065\u0073 \u0061\u006e\u0064\u0020\u006c\u0069\u006b\u0065l\u0079\u0020\u0063o\u006e\u0074\u0061\u0069\u006e\u0073\u0020\u0065\u0078\u0061\u006d\u0070\u006c\u0065\u0073\u000a\u0061\u006e\u0064\u0020\u0075\u0073\u0061\u0067\u0065\u0020\u006f\u0066\u0020u\u0073\u0069\u006e\u0067\u0020\u0079o\u0075\u0072\u0020\u0063o\u006d\u006d\u0061\u006e\u0064\u002e\u0020\u0046\u006f\u0072\u0020e\u0078\u0061\u006d\u0070\u006c\u0065\u003a\u000a\u000a\u0043\u006f\u0062r\u0061\u0020\u0069\u0073\u0020\u0061\u0020\u0043\u004c\u0049\u0020\u006c\u0069\u0062\u0072\u0061r\u0079 \u0066\u006f\u0072\u0020\u0047\u006f\u0020\u0074\u0068\u0061\u0074\u0020\u0065\u006d\u0070\u006f\u0077\u0065\u0072\u0073\u0020\u0061\u0070\u0070\u006c\u0069\u0063\u0061t\u0069\u006f\u006e\u0073\u002e\u000a\u0054\u0068\u0069\u0073\u0020\u0061\u0070\u0070\u006c\u0069\u0063\u0061\u0074\u0069\u006f\u006e\u0020\u0069s\u0020\u0061\u0020\u0074\u006f\u006fl\u0020\u0074\u006f\u0020\u0067\u0065\u006e\u0065\u0072\u0061\u0074\u0065\u0020\u0074\u0068e\u0020n\u0065\u0065\u0064\u0065\u0064\u0020\u0066\u0069\u006c\u0065s\u000a\u0074o\u0020\u0071\u0075\u0069\u0063\u006b\u006c\u0079\u0020\u0063\u0072\u0065\u0061\u0074\u0065\u0020\u0061\u0020C\u006fb\u0072\u0061\u0020\u0061\u0070\u0070\u006c\u0069\u0063\u0061\u0074io\u006e\u002e",Run :_bd ,Args :_f .ExactArgs (2),ArgAliases :[]string {"\u0069\u006e\u0070u\u0074","\u006f\u0075\u0074\u0070\u0075\u0074\u002d\u0070\u0064\u0066"},Example :"\u0067\u0065\u006e\u0065\u0072\u0061\u0074\u0065\u0020\u0069\u006ep\u0075\u0074\u002e\u0068\u0074\u006d\u006c\u0020o\u0075t\u0070\u0075\u0074\u002e\u0070\u0064\u0066\u0020\u002d\u002d\u006f\u0072\u0069\u0065\u006e\u0074\u0061\u0074i\u006f\u006e\u0020\u0070\u006f\u0072\u0074\u0072\u0061\u0069\u0074"};
var _dgb =&_f .Command {Use :"\u0075n\u0069\u0068\u0074\u006d\u006c",Short :"\u0041\u0020\u0062\u0072\u0069\u0065\u0066\u0020\u0064\u0065\u0073\u0063\u0072i\u0070\u0074\u0069\u006f\u006e\u0020o\u0066\u0020\u0079\u006f\u0075\u0072\u0020\u0061\u0070\u0070\u006c\u0069\u0063a\u0074\u0069\u006f\u006e",Long :"\u0041\u0020\u006c\u006f\u006e\u0067\u0065\u0072\u0020\u0064\u0065\u0073c\u0072\u0069\u0070\u0074i\u006f\u006e\u0020\u0074\u0068\u0061\u0074\u0020s\u0070\u0061n\u0073\u0020\u006d\u0075\u006ct\u0069\u0070\u006c\u0065\u0020\u006c\u0069\u006e\u0065\u0073\u0020\u0061nd\u0020\u006c\u0069\u006b\u0065\u006cy\u0020\u0063\u006f\u006e\u0074\u0061\u0069\u006e\u0073\u000a\u0065\u0078\u0061\u006d\u0070\u006c\u0065\u0073\u0020\u0061n\u0064\u0020\u0075s\u0061\u0067\u0065\u0020\u006ff\u0020\u0075\u0073\u0069\u006eg \u0079\u006f\u0075\u0072\u0020\u0061\u0070\u0070\u006c\u0069\u0063\u0061\u0074\u0069\u006fn\u002e\u0020\u0046\u006f\u0072\u0020e\u0078\u0061\u006dp\u006c\u0065\u003a\u000a\u000a\u0043\u006f\u0062\u0072\u0061\u0020\u0069s\u0020\u0061\u0020\u0043L\u0049\u0020\u006c\u0069\u0062\u0072\u0061\u0072\u0079\u0020f\u006f\u0072\u0020\u0047\u006f\u0020t\u0068\u0061t\u0020\u0065\u006dp\u006f\u0077\u0065\u0072\u0073\u0020\u0061p\u0070\u006c\u0069\u0063\u0061\u0074\u0069\u006f\u006e\u0073\u002e\u000a\u0054\u0068\u0069\u0073\u0020\u0061\u0070p\u006c\u0069\u0063\u0061\u0074\u0069\u006f\u006e \u0069\u0073 \u0061\u0020\u0074\u006f\u006f\u006c\u0020\u0074o\u0020g\u0065\u006e\u0065\u0072a\u0074\u0065 \u0074\u0068e\u0020\u006e\u0065\u0065\u0064\u0065\u0064\u0020\u0066\u0069\u006ce\u0073\u000a\u0074\u006f\u0020\u0071\u0075\u0069\u0063\u006b\u006cy\u0020\u0063\u0072\u0065\u0061\u0074\u0065\u0020\u0061\u0020\u0043\u006f\u0062\u0072\u0061\u0020\u0061\u0070pl\u0069ca\u0074\u0069on\u002e"};
MarginRight _d .LengthFlag `mapstructure:"margin-right"`;};func _ff (){_eaa :=_ae .LogLevelInfo ;if _fd {_eaa =_ae .LogLevelDebug ;};if _ggb {_eaa =_ae .LogLevelTrace ;};_ae .Log =_ae .NewConsoleLogger (_eaa );};var (_fd ,_ggb bool ;);var _bb =&_a .Command {Use :"\u0067\u0065\u006e\u0065\u0072\u0061\u0074\u0065",Short :"\u0047\u0065\u006e\u0065\u0072a\u0074\u0065\u0073\u0020\u0050\u0044F\u0020\u0062\u0061\u0073\u0065\u0064\u0020o\u006e\u0020\u0074h\u0065\u0020\u0070\u0072o\u0076\u0069\u0064\u0065\u0064\u0020H\u0054\u004d\u004c\u0020\u006f\u0072\u0020\u0064\u0069\u0072\u0065\u0063\u0074\u006f\u0072\u0079\u0020w\u0069\u0074\u0068\u0020\u0074\u0068\u0065\u0020\u0048\u0054\u004d\u004c\u0020\u0066\u0069\u006c\u0065\u0073\u002e",Long :"A\u0020\u006c\u006f\u006e\u0067\u0065\u0072\u0020\u0064e\u0073\u0063\u0072\u0069\u0070\u0074\u0069on\u0020\u0074\u0068\u0061\u0074\u0020s\u0070\u0061\u006e\u0073\u0020\u006d\u0075\u006c\u0074\u0069\u0070\u006c\u0065\u0020\u006c\u0069\u006e\u0065\u0073 \u0061\u006e\u0064\u0020\u006c\u0069\u006b\u0065l\u0079\u0020\u0063o\u006e\u0074\u0061\u0069\u006e\u0073\u0020\u0065\u0078\u0061\u006d\u0070\u006c\u0065\u0073\u000a\u0061\u006e\u0064\u0020\u0075\u0073\u0061\u0067\u0065\u0020\u006f\u0066\u0020u\u0073\u0069\u006e\u0067\u0020\u0079o\u0075\u0072\u0020\u0063o\u006d\u006d\u0061\u006e\u0064\u002e\u0020\u0046\u006f\u0072\u0020e\u0078\u0061\u006d\u0070\u006c\u0065\u003a\u000a\u000a\u0043\u006f\u0062r\u0061\u0020\u0069\u0073\u0020\u0061\u0020\u0043\u004c\u0049\u0020\u006c\u0069\u0062\u0072\u0061r\u0079 \u0066\u006f\u0072\u0020\u0047\u006f\u0020\u0074\u0068\u0061\u0074\u0020\u0065\u006d\u0070\u006f\u0077\u0065\u0072\u0073\u0020\u0061\u0070\u0070\u006c\u0069\u0063\u0061t\u0069\u006f\u006e\u0073\u002e\u000a\u0054\u0068\u0069\u0073\u0020\u0061\u0070\u0070\u006c\u0069\u0063\u0061\u0074\u0069\u006f\u006e\u0020\u0069s\u0020\u0061\u0020\u0074\u006f\u006fl\u0020\u0074\u006f\u0020\u0067\u0065\u006e\u0065\u0072\u0061\u0074\u0065\u0020\u0074\u0068e\u0020n\u0065\u0065\u0064\u0065\u0064\u0020\u0066\u0069\u006c\u0065s\u000a\u0074o\u0020\u0071\u0075\u0069\u0063\u006b\u006c\u0079\u0020\u0063\u0072\u0065\u0061\u0074\u0065\u0020\u0061\u0020C\u006fb\u0072\u0061\u0020\u0061\u0070\u0070\u006c\u0069\u0063\u0061\u0074io\u006e\u002e",Run :_bc ,Args :_a .ExactArgs (2),ArgAliases :[]string {"\u0069\u006e\u0070u\u0074","\u006f\u0075\u0074\u0070\u0075\u0074\u002d\u0070\u0064\u0066"},Example :"\u0067\u0065\u006e\u0065\u0072\u0061\u0074\u0065\u0020\u0069\u006ep\u0075\u0074\u002e\u0068\u0074\u006d\u006c\u0020o\u0075t\u0070\u0075\u0074\u002e\u0070\u0064\u0066\u0020\u002d\u002d\u006f\u0072\u0069\u0065\u006e\u0074\u0061\u0074i\u006f\u006e\u0020\u0070\u006f\u0072\u0074\u0072\u0061\u0069\u0074"};
func init (){_a .OnInitialize (_fa );_gaf .PersistentFlags ().BoolVarP (&_fd ,"\u0064\u0065\u0062u\u0067","\u0064",false ,"\u0044e\u0066i\u006e\u0065\u0073\u0020\u0064e\u0062\u0075g\u0020\u006d\u006f\u0064\u0065");_gaf .PersistentFlags ().BoolVarP (&_ggb ,"\u0076e\u0072\u0062\u006f\u0073\u0065","\u0076",false ,"\u0056\u0065\u0072\u0062\u006f\u0073e\u0020\u0069\u006e\u0066\u006f\u0072\u006d\u0061\u0074\u0069\u006f\u006e\u0020o\u0066\u0020\u0074\u0068\u0065\u0020\u0063l\u0069\u0065\u006e\u0074");
_gaf .PersistentFlags ().StringVar (&_fe ,"\u0063\u006f\u006e\u0066\u0069\u0067","","\u0063\u006f\u006e\u0066\u0069\u0067\u0020\u0066i\u006c\u0065\u0020(d\u0065\u0066\u0061\u0075\u006c\u0074 \u0069\u0073\u0020\u0024\u0048\u004f\u004d\u0045\u002f\u002e\u0075\u006e\u0069\u0068\u0074m\u006c\u002d\u0073\u0072\u0063\u002e\u0079\u0061m\u006c\u0029");
_gaf .Flags ().BoolP ("\u0074\u006f\u0067\u0067\u006c\u0065","\u0074",false ,"\u0048\u0065\u006cp \u006d\u0065\u0073\u0073\u0061\u0067\u0065\u0020\u0066\u006f\u0072\u0020\u0074\u006f\u0067\u0067\u006c\u0065");};var _fe string ;var (_c =generateConfig {};
_eafc =parametersConfig {PaperWidth :_d .LengthFlag {Length :_d .Inch (8.5).Millimeters ()},PaperHeight :_d .LengthFlag {Length :_d .Inch (11).Millimeters ()},Orientation :_d .Portrait ,MarginTop :_d .LengthFlag {Length :_d .Millimeter (10)},MarginBottom :_d .LengthFlag {Length :_d .Millimeter (10)},MarginLeft :_d .LengthFlag {Length :_d .Millimeter (10)},MarginRight :_d .LengthFlag {Length :_d .Millimeter (10)}};
);

View File

@ -9,4 +9,4 @@
// 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 main ;import _cc "github.com/unidoc/unihtml/cli/cmd";func main (){_cc .Execute ()};
package main ;import _c "github.com/unidoc/unihtml/cli/cmd";func main (){_c .Execute ()};

View File

@ -11,164 +11,163 @@
// Package client contains HTML Converter HTTP Client. The Client implements htmlcreator.HTMLConverter interface
// for the UniPDF module and can be used as a plugin for the UniPDF creator.Creator.
package client ;import (_eb "bytes";_b "compress/flate";_c "compress/gzip";_f "context";_ee "errors";_eafc "fmt";_db "github.com/unidoc/unihtml/content";_dc "github.com/unidoc/unihtml/sizes";_bd "github.com/unidoc/unipdf/v3/common";_dg "golang.org/x/xerrors";
_ea "io/ioutil";_d "net";_eaf "net/http";_a "net/url";_fc "strconv";_cb "strings";_ef "time";);
// New creates new client with provided options.
func New (o Options )*Client {o .DefaultTimeout =_ef .Second *30;if o .Port <=0{o .Port =8080;};if o .Hostname ==""{o .Hostname ="\u00312\u0037\u002e\u0030\u002e\u0030\u002e1";};var _ag =&_eaf .Transport {DialContext :(&_d .Dialer {Timeout :5*_ef .Second }).DialContext ,TLSHandshakeTimeout :5*_ef .Second };
_bd .Log .Info ("\u0043l\u0069e\u006e\u0074\u0020\u0041\u0064\u0064\u0072\u003a\u0020\u0025\u0073",o .Addr ());return &Client {Options :o ,Client :&_eaf .Client {Transport :_ag ,Timeout :o .DefaultTimeout }};};
// Client is a structure that is a HTTP client for the unihtml server.
type Client struct{Options Options ;Client *_eaf .Client ;};
// Err gets the error which could occur in the query.
func (_aad *QueryBuilder )Err ()error {return _aad ._fd };
// Validate checks if the parameters are valid.
func (_af *PageParameters )Validate ()error {if _af .PaperWidth !=nil {if _af .PaperWidth .Millimeters ()< 0{return _ee .New ("\u006e\u0065g\u0061\u0074\u0069\u0076\u0065\u0020\u0076\u0061\u006c\u0075\u0065\u0020\u0066\u006f\u0072\u0020\u0050\u0061\u0070\u0065\u0072\u0057id\u0074\u0068");
};};if _af .PaperHeight !=nil {if _af .PaperHeight .Millimeters ()< 0{return _ee .New ("\u006e\u0065\u0067\u0061\u0074\u0069\u0076\u0065\u0020\u0076a\u006c\u0075\u0065\u0020\u0066\u006f\u0072 \u0050\u0061\u0070\u0065\u0072\u0048\u0065\u0069\u0067\u0068\u0074");
};};if _af .MarginTop !=nil {if _af .MarginTop .Millimeters ()< 0{return _ee .New ("\u006e\u0065\u0067\u0061t\u0069\u0076\u0065\u0020\u0076\u0061\u006c\u0075\u0065\u0020f\u006fr\u0020\u004d\u0061\u0072\u0067\u0069\u006eT\u006f\u0070");};};if _af .MarginBottom !=nil {if _af .MarginBottom .Millimeters ()< 0{return _ee .New ("\u006e\u0065\u0067a\u0074\u0069\u0076\u0065 \u0076\u0061\u006c\u0075\u0065\u0020\u0066o\u0072\u0020\u004d\u0061\u0072\u0067\u0069\u006e\u0042\u006f\u0074\u0074\u006f\u006d");
};};if _af .MarginLeft !=nil {if _af .MarginLeft .Millimeters ()< 0{return _ee .New ("\u006e\u0065g\u0061\u0074\u0069\u0076\u0065\u0020\u0076\u0061\u006c\u0075\u0065\u0020\u0066\u006f\u0072\u0020\u004d\u0061\u0072\u0067\u0069\u006eLe\u0066\u0074");};};
if _af .MarginRight !=nil {if _af .MarginRight .Millimeters ()< 0{return _ee .New ("\u006e\u0065\u0067\u0061\u0074\u0069\u0076\u0065\u0020\u0076a\u006c\u0075\u0065\u0020\u0066\u006f\u0072 \u004d\u0061\u0072\u0067\u0069\u006e\u0052\u0069\u0067\u0068\u0074");
};};if _af .PageSize !=nil &&!_af .PageSize .IsAPageSize (){return _ee .New ("\u0069\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u0070\u0061\u0067\u0065 \u0073\u0069\u007a\u0065");};return nil ;};
// HealthCheck connects to the server and check the health status of the server.
func (_cd *Client )HealthCheck (ctx _f .Context )error {_aa :=_cd .Options .Addr ();_aa =_eafc .Sprintf ("\u0025s\u002f\u0068\u0065\u0061\u006c\u0074h",_aa );_bdg ,_cc :=_eaf .NewRequest ("\u0047\u0045\u0054",_aa ,nil );if _cc !=nil {return _cc ;};_bdg =_bdg .WithContext (ctx );
_dbg ,_cc :=_cd .Client .Do (_bdg );if _cc !=nil {return _cc ;};switch _dbg .StatusCode {case _eaf .StatusOK :return nil ;case _eaf .StatusNotFound :return ErrNotFound ;case _eaf .StatusInternalServerError :return ErrInternalError ;case _eaf .StatusBadGateway :return ErrBadGateway ;
default:return ErrNotImplemented ;};};func (_eeg *Client )getRequest (_eeb _f .Context ,_ff *Query )(*_eaf .Request ,error ){_gg :=_eeg .Options .Addr ();_gg =_eafc .Sprintf ("\u0025\u0073\u002f\u0070\u0064\u0066",_gg );_cg ,_dgg :=_eaf .NewRequest ("\u0050\u004f\u0053\u0054",_gg ,_eb .NewReader (_ff .Data ));
if _dgg !=nil {return nil ,_dgg ;};_cg .Header .Set ("\u0043\u006f\u006et\u0065\u006e\u0074\u002d\u0054\u0079\u0070\u0065",_ff .ContentType );_cg .Header .Set ("\u0041c\u0063e\u0070\u0074\u002d\u0045\u006e\u0063\u006f\u0064\u0069\u006e\u0067","\u0064\u0065\u0066\u006ca\u0074\u0065\u002c\u0020\u0067\u007a\u0069\u0070\u003b\u0071=\u0031.\u0030\u002c\u0020\u002a\u003b\u0071\u003d0\u002e\u0035");
_cg =_cg .WithContext (_eeb );_gf :=_cg .URL .Query ();_ad :=_ff .PageParameters ;if _ad .PageSize !=nil {_gf .Set ("\u0070a\u0067\u0065\u002d\u0073\u0069\u007ae",_ad .PageSize .String ());};if _ad .PaperHeight !=nil {_gf .Set ("\u0070\u0061\u0070e\u0072\u002d\u0068\u0065\u0069\u0067\u0068\u0074",_ad .PaperHeight .String ());
};if _ad .PaperWidth !=nil {_gf .Set ("p\u0061\u0070\u0065\u0072\u002d\u0077\u0069\u0064\u0074\u0068",_ad .PaperWidth .String ());};if _ad .MarginTop !=nil {_gf .Set ("\u006d\u0061\u0072\u0067\u0069\u006e\u002d\u0074\u006f\u0070",_ad .MarginTop .String ());
};if _ad .MarginBottom !=nil {_gf .Set ("\u006d\u0061\u0072\u0067\u0069\u006e\u002d\u0062\u006f\u0074\u0074\u006f\u006d",_ad .MarginBottom .String ());};if _ad .MarginRight !=nil {_gf .Set ("\u006d\u0061\u0072g\u0069\u006e\u002d\u0072\u0069\u0067\u0068\u0074",_ad .MarginRight .String ());
};if _ad .MarginLeft !=nil {_gf .Set ("m\u0061\u0072\u0067\u0069\u006e\u002d\u006c\u0065\u0066\u0074",_ad .MarginLeft .String ());};if _ad .Orientation ==_dc .Landscape {_gf .Set ("o\u0072\u0069\u0065\u006e\u0074\u0061\u0074\u0069\u006f\u006e",_ad .Orientation .String ());
};_cg .URL .RawQuery =_gf .Encode ();return _cg ,nil ;};
package client ;import (_daa "bytes";_da "compress/flate";_ba "compress/gzip";_bd "context";_a "errors";_fa "fmt";_aa "github.com/unidoc/unihtml/content";_e "github.com/unidoc/unihtml/sizes";_ff "github.com/unidoc/unipdf/v3/common";_db "golang.org/x/xerrors";
_d "io/ioutil";_f "net";_g "net/http";_c "net/url";_af "strconv";_deb "strings";_de "time";);
// WithHTTPS sets the TLS option for the client options.
func WithHTTPS (useHTTPS bool )Option {return func (_cga *Options ){_cga .HTTPS =useHTTPS }};
func WithHTTPS (useHTTPS bool )Option {return func (_caf *Options ){_caf .HTTPS =useHTTPS }};
// Options are the client options used by the HTTP client.
type Options struct{HTTPS bool ;Hostname string ;Port int ;DefaultTimeout _ef .Duration ;Prefix string ;};
// Err gets the error which could occur in the query.
func (_efg *QueryBuilder )Err ()error {return _efg ._ca };
// HealthCheck connects to the server and check the health status of the server.
func (_fe *Client )HealthCheck (ctx _bd .Context )error {_ab :=_fe .Options .Addr ();_ab =_fa .Sprintf ("\u0025s\u002f\u0068\u0065\u0061\u006c\u0074h",_ab );_dd ,_ea :=_g .NewRequest ("\u0047\u0045\u0054",_ab ,nil );if _ea !=nil {return _ea ;};_dd =_dd .WithContext (ctx );
_ed ,_ea :=_fe .Client .Do (_dd );if _ea !=nil {return _ea ;};switch _ed .StatusCode {case _g .StatusOK :return nil ;case _g .StatusNotFound :return ErrNotFound ;case _g .StatusInternalServerError :return ErrInternalError ;case _g .StatusBadGateway :return ErrBadGateway ;
default:return ErrNotImplemented ;};};
// Query gets the Query from provided query builder. If some error occurred during build process
// or the input is not valid the function would return an error.
func (_ee *QueryBuilder )Query ()(*Query ,error ){if _bgf :=_ee .Validate ();_bgf !=nil {return nil ,_bgf ;};return &_ee ._gfe ,nil ;};
// ConvertHTML converts provided Query input into PDF file data.
// Implements creator.HTMLConverter interface.
func (_bg *Client )ConvertHTML (ctx _bd .Context ,q *Query )(*PDFResponse ,error ){if _ddc :=q .Validate ();_ddc !=nil {return nil ,_ddc ;};_be ,_eg :=_bg .getRequest (ctx ,q );if _eg !=nil {return nil ,_eg ;};_ff .Log .Trace ("\u0052\u0065\u0071\u0075\u0065\u0073\u0074 \u002d\u0020\u0025s\u0020\u002d\u0020\u0025s\u0025\u0073\u002c\u0020\u0048\u0065\u0061\u0064\u0065\u0072\u0073\u003a\u0020\u0025\u0076\u002c\u0020\u0051\u0075\u0065\u0072\u0079\u003a\u0020\u0025\u0076",_be .Method ,_be .URL .Hostname (),_be .URL .Path ,_be .Header ,_be .URL .Query ());
_ef ,_eg :=_bg .Client .Do (_be );if _eg !=nil {return nil ,_eg ;};var _bea error ;switch _ef .StatusCode {case _g .StatusNotFound :_bea =ErrNotFound ;case _g .StatusBadRequest :_bea =ErrBadRequest ;case _g .StatusNotImplemented :_bea =ErrNotImplemented ;
case _g .StatusUnauthorized :_bea =ErrUnauthorized ;case _g .StatusCreated :default:_bea =ErrInternalError ;};_dde :=_ef .Body ;switch _ef .Header .Get ("\u0043\u006fn\u0074\u0065\u006et\u002d\u0045\u006e\u0063\u006f\u0064\u0069\u006e\u0067"){case "\u0067\u007a\u0069\u0070":_dde ,_eg =_ba .NewReader (_ef .Body );
if _eg !=nil {return nil ,_eg ;};case "\u0064e\u0066\u006c\u0061\u0074\u0065":_dde =_da .NewReader (_ef .Body );case "":default:return nil ,_fa .Errorf ("\u0075\u006e\u0073\u0075\u0070\u0070\u006f\u0072\u0074\u0065\u0064\u0020\u0043o\u006e\u0074\u0065\u006e\u0074\u002dE\u006e\u0063\u006f\u0064\u0069\u006e\u0067\u003a\u0020\u0025\u0073\u0020\u0068e\u0061\u0064\u0065\u0072",_ef .Header .Get ("\u0043\u006fn\u0074\u0065\u006et\u002d\u0045\u006e\u0063\u006f\u0064\u0069\u006e\u0067"));
};_aaa ,_eg :=_d .ReadAll (_dde );if _eg !=nil &&_bea ==nil {return nil ,_fa .Errorf ("\u0055\u006e\u0069HT\u004d\u004c\u0020\u0073\u0065\u0072\u0076\u0065\u0072\u0020\u0065\u0072\u0072\u006f\u0072\u0020\u0025\u0073",_eg );};_ff .Log .Trace ("\u005b\u0025\u0064]\u0020\u0025\u0073\u0020\u0025\u0073\u0025\u0073",_ef .StatusCode ,_be .Method ,_be .URL .Host ,_be .URL .Path );
if _bea !=nil {return nil ,_fa .Errorf ("\u0025\u0073\u0020%\u0077",string (_aaa ),_bea );};_afc :=_ef .Header .Get ("\u0058\u002d\u004a\u006f\u0062\u002d\u0049\u0044");_ff .Log .Trace ("\u0052\u0065\u0073\u0070\u006f\u006e\u0073\u0065\u0020I\u0044\u0020\u0025\u0073",_afc );
return &PDFResponse {ID :_afc ,Data :_aaa },nil ;};var (ErrMissingData =_a .New ("\u006di\u0073s\u0069\u006e\u0067\u0020\u0069n\u0070\u0075t\u0020\u0064\u0061\u0074\u0061");ErrContentType =_a .New ("i\u006ev\u0061\u006c\u0069\u0064\u0020\u0063\u006f\u006et\u0065\u006e\u0074\u0020ty\u0070\u0065");
ErrContentTypeDeclared =_a .New ("\u0063\u006f\u006e\u0074\u0065\u006e\u0074\u0020\u0074\u0079\u0070\u0065\u0020\u0069\u0073 \u0061l\u0072\u0065\u0061\u0064\u0079\u0020\u0064\u0065\u0063\u006c\u0061\u0072\u0065\u0064"););
// PaperWidth sets up the PaperWidth (in cm) parameter for the query.
func (_ede *QueryBuilder )PaperWidth (paperWidth _e .Length )*QueryBuilder {_ede ._gfe .PageParameters .PaperWidth =paperWidth ;return _ede ;};
// Validate checks if provided Query is valid.
func (_gg *Query )Validate ()error {if len (_gg .Data )==0{return ErrMissingData ;};if _gg .ContentType ==""{return ErrContentType ;};if _dba :=_gg .PageParameters .Validate ();_dba !=nil {return _dba ;};return nil ;};
// Option is a function that changes client options.
type Option func (_bbf *Options );
// WithPort sets the Port option for the client options.
func WithPort (option int )Option {return func (_gafb *Options ){_gafb .Port =option }};
// New creates new client with provided options.
func New (o Options )*Client {o .DefaultTimeout =_de .Second *30;if o .Port <=0{o .Port =8080;};if o .Hostname ==""{o .Hostname ="\u00312\u0037\u002e\u0030\u002e\u0030\u002e1";};var _dac =&_g .Transport {DialContext :(&_f .Dialer {Timeout :5*_de .Second }).DialContext ,TLSHandshakeTimeout :5*_de .Second };
_ff .Log .Info ("\u0043l\u0069e\u006e\u0074\u0020\u0041\u0064\u0064\u0072\u003a\u0020\u0025\u0073",o .Addr ());return &Client {Options :o ,Client :&_g .Client {Transport :_dac ,Timeout :o .DefaultTimeout }};};
// MarginLeft sets up the MarginLeft parameter for the query.
func (_efa *QueryBuilder )MarginLeft (marginLeft _e .Length )*QueryBuilder {_efa ._gfe .PageParameters .MarginLeft =marginLeft ;return _efa ;};var (ErrNotFound =_a .New ("\u006eo\u0074\u0020\u0066\u006f\u0075\u006ed");ErrBadRequest =_a .New ("b\u0061\u0064\u0020\u0072\u0065\u0071\u0075\u0065\u0073\u0074");
ErrNotImplemented =_a .New ("\u006eo\u0074 \u0069\u006d\u0070\u006c\u0065\u006d\u0065\u006e\u0074\u0065\u0064");ErrInternalError =_a .New ("i\u006e\u0074\u0065\u0072na\u006c \u0073\u0065\u0072\u0076\u0065r\u0020\u0065\u0072\u0072\u006f\u0072");ErrBadGateway =_a .New ("b\u0061\u0064\u0020\u0067\u0061\u0074\u0065\u0077\u0061\u0079");
ErrUnauthorized =_a .New ("\u0075\u006e\u0061u\u0074\u0068\u006f\u0072\u0069\u007a\u0065\u0064"););
// Landscape sets up the landscape portrait orientation.
func (_bc *QueryBuilder )Landscape ()*QueryBuilder {_bc ._gfe .PageParameters .Orientation =_e .Landscape ;return _bc ;};
// Orientation sets the page orientation for the Query.
func (_dga *QueryBuilder )Orientation (orientation _dc .Orientation )*QueryBuilder {_dga ._ca .PageParameters .Orientation =orientation ;return _dga ;};
func (_ga *QueryBuilder )Orientation (orientation _e .Orientation )*QueryBuilder {_ga ._gfe .PageParameters .Orientation =orientation ;return _ga ;};
// Portrait sets up the portrait page orientation.
func (_fg *QueryBuilder )Portrait ()*QueryBuilder {_fg ._gfe .PageParameters .Orientation =_e .Portrait ;return _fg ;};
// WithPrefix sets the client prefix.
func WithPrefix (prefix string )Option {return func (_aeb *Options ){_aeb .Prefix =prefix }};
// QueryBuilder is the query that converts HTMLConverter defined data
type QueryBuilder struct{_gfe Query ;_ca error ;};
// SetContent sets custom data with it's content type.
func (_dc *QueryBuilder )SetContent (content _aa .Content )*QueryBuilder {if _dc ._ca !=nil {return _dc ;};if _dc ._gfe .ContentType !=""{_dc ._ca =ErrContentTypeDeclared ;return _dc ;};if content .ContentType ()==""{_dc ._ca =_db .Errorf ("\u0065\u006d\u0070\u0074y\u0020\u0063\u0075\u0073\u0074\u006f\u006d\u0020\u0063\u006fn\u0074e\u006e\u0074\u0020\u0074\u0079\u0070\u0065 \u0025\u0077",ErrContentType );
return _dc ;};_dc ._gfe .Data =content .Data ();_dc ._gfe .ContentType =content .ContentType ();return _dc ;};
// WithDefaultTimeout sets the DefaultTimeout option for the client options.
func WithDefaultTimeout (option _de .Duration )Option {return func (_fbf *Options ){_fbf .DefaultTimeout =option };};
// Options are the client options used by the HTTP client.
type Options struct{HTTPS bool ;Hostname string ;Port int ;DefaultTimeout _de .Duration ;Prefix string ;};
// ParseOptions parses options for the Client.
func ParseOptions (connectPath string )(Options ,error ){if !_deb .HasPrefix (connectPath ,"\u0068\u0074\u0074\u0070"){connectPath ="\u0068t\u0074\u0070\u003a\u002f\u002f"+connectPath ;};_ce ,_df :=_c .Parse (connectPath );if _df !=nil {return Options {},_db .Errorf ("p\u0072\u006f\u0076\u0069\u0064\u0065d\u0020\u0069\u006e\u0076\u0061\u006ci\u0064\u0020\u0075\u006e\u0069\u0068\u0074m\u006c\u002d\u0073\u0065\u0072\u0076\u0065\u0072\u0020\u0075r\u006c");
};var _gf int ;if _ce .Port ()!=""{_gf ,_df =_af .Atoi (_ce .Port ());if _df !=nil {return Options {},_db .Errorf ("\u0070\u0061\u0072si\u006e\u0067\u0020\u0070\u006f\u0072\u0074\u0020\u0066\u0061\u0069\u006c\u0065\u0064\u003a\u0020\u0025\u0077",_df );
};};return Options {Hostname :_ce .Hostname (),Port :_gf ,HTTPS :_ce .Scheme =="\u0068\u0074\u0074p\u0073",Prefix :_ce .Path },nil ;};
// BuildHTMLQuery creates a Query builder that is supposed to create valid
func BuildHTMLQuery ()*QueryBuilder {return &QueryBuilder {}};
// MarginLeft sets up the MarginLeft parameter for the query.
func (_fe *QueryBuilder )MarginLeft (marginLeft _dc .Length )*QueryBuilder {_fe ._ca .PageParameters .MarginLeft =marginLeft ;return _fe ;};
// Validate checks if the QueryBuilder had no errors during composition and creation.
func (_aac *QueryBuilder )Validate ()error {if _aac ._fd !=nil {return _aac ._fd ;};return _aac ._ca .Validate ();};
// Portrait sets up the portrait page orientation.
func (_bb *QueryBuilder )Portrait ()*QueryBuilder {_bb ._ca .PageParameters .Orientation =_dc .Portrait ;return _bb ;};
// PaperHeight sets up the PaperHeight (in cm) parameter for the query.
func (_cef *QueryBuilder )PaperHeight (paperHeight _dc .Length )*QueryBuilder {_cef ._ca .PageParameters .PaperHeight =paperHeight ;return _cef ;};
// WithDefaultTimeout sets the DefaultTimeout option for the client options.
func WithDefaultTimeout (option _ef .Duration )Option {return func (_cbd *Options ){_cbd .DefaultTimeout =option };};
// Option is a function that changes client options.
type Option func (_adb *Options );
// DefaultPageParameters creates default parameters.
func DefaultPageParameters ()PageParameters {return PageParameters {Orientation :_dc .Portrait }};
// WithPort sets the Port option for the client options.
func WithPort (option int )Option {return func (_efbc *Options ){_efbc .Port =option }};
// MarginBottom sets up the MarginBottom parameter for the query.
func (_efb *QueryBuilder )MarginBottom (marginBottom _dc .Length )*QueryBuilder {_efb ._ca .PageParameters .MarginBottom =marginBottom ;return _efb ;};
// PDFResponse is the response used by the HTMLConverter.
type PDFResponse struct{ID string `json:"id"`;Data []byte `json:"data"`;};
// Landscape sets up the landscape portrait orientation.
func (_cf *QueryBuilder )Landscape ()*QueryBuilder {_cf ._ca .PageParameters .Orientation =_dc .Landscape ;return _cf ;};
// MarginTop sets up the MarginTop parameter for the query.
func (_ga *QueryBuilder )MarginTop (marginTop _dc .Length )*QueryBuilder {_ga ._ca .PageParameters .MarginTop =marginTop ;return _ga ;};
// PaperWidth sets up the PaperWidth (in cm) parameter for the query.
func (_da *QueryBuilder )PaperWidth (paperWidth _dc .Length )*QueryBuilder {_da ._ca .PageParameters .PaperWidth =paperWidth ;return _da ;};var (ErrMissingData =_ee .New ("\u006di\u0073s\u0069\u006e\u0067\u0020\u0069n\u0070\u0075t\u0020\u0064\u0061\u0074\u0061");
ErrContentType =_ee .New ("i\u006ev\u0061\u006c\u0069\u0064\u0020\u0063\u006f\u006et\u0065\u006e\u0074\u0020ty\u0070\u0065");ErrContentTypeDeclared =_ee .New ("\u0063\u006f\u006e\u0074\u0065\u006e\u0074\u0020\u0074\u0079\u0070\u0065\u0020\u0069\u0073 \u0061l\u0072\u0065\u0061\u0064\u0079\u0020\u0064\u0065\u0063\u006c\u0061\u0072\u0065\u0064");
);
// Addr gets the HTTP address URI used by the http.Client.
func (_ae *Options )Addr ()string {_aacf :=_cb .Builder {};_aacf .WriteString ("\u0068\u0074\u0074\u0070");if _ae .HTTPS {_aacf .WriteRune ('s');};_aacf .WriteString ("\u003a\u002f\u002f");_aacf .WriteString (_ae .Hostname );_aacf .WriteRune (':');_aacf .WriteString (_fc .Itoa (_ae .Port ));
if _ae .Prefix !=""{_aacf .WriteString (_ae .Prefix );};return _aacf .String ();};
// Query is a structure that contains query parameters and the content used for the HTMLConverter conversion process.
type Query struct{Data []byte ;ContentType string ;PageParameters PageParameters ;};
// QueryBuilder is the query that converts HTMLConverter defined data
type QueryBuilder struct{_ca Query ;_fd error ;};
// MarginBottom sets up the MarginBottom parameter for the query.
func (_bgb *QueryBuilder )MarginBottom (marginBottom _e .Length )*QueryBuilder {_bgb ._gfe .PageParameters .MarginBottom =marginBottom ;return _bgb ;};
// MarginRight sets up the MarginRight parameter for the query.
func (_dbe *QueryBuilder )MarginRight (marginRight _dc .Length )*QueryBuilder {_dbe ._ca .PageParameters .MarginRight =marginRight ;return _dbe ;};
func (_baac *QueryBuilder )MarginRight (marginRight _e .Length )*QueryBuilder {_baac ._gfe .PageParameters .MarginRight =marginRight ;return _baac ;};
// WithHostname sets the Hostname option for the client options.
func WithHostname (option string )Option {return func (_ba *Options ){_ba .Hostname =option }};
func WithHostname (option string )Option {return func (_gaf *Options ){_gaf .Hostname =option }};
// Validate checks if provided Query is valid.
func (_aab *Query )Validate ()error {if len (_aab .Data )==0{return ErrMissingData ;};if _aab .ContentType ==""{return ErrContentType ;};if _aga :=_aab .PageParameters .Validate ();_aga !=nil {return _aga ;};return nil ;};
// SetContent sets custom data with it's content type.
func (_bee *QueryBuilder )SetContent (content _db .Content )*QueryBuilder {if _bee ._fd !=nil {return _bee ;};if _bee ._ca .ContentType !=""{_bee ._fd =ErrContentTypeDeclared ;return _bee ;};if content .ContentType ()==""{_bee ._fd =_dg .Errorf ("\u0065\u006d\u0070\u0074y\u0020\u0063\u0075\u0073\u0074\u006f\u006d\u0020\u0063\u006fn\u0074e\u006e\u0074\u0020\u0074\u0079\u0070\u0065 \u0025\u0077",ErrContentType );
return _bee ;};_bee ._ca .Data =content .Data ();_bee ._ca .ContentType =content .ContentType ();return _bee ;};
// WithPrefix sets the client prefix.
func WithPrefix (prefix string )Option {return func (_eab *Options ){_eab .Prefix =prefix }};
// ParseOptions parses options for the Client.
func ParseOptions (connectPath string )(Options ,error ){if !_cb .HasPrefix (connectPath ,"\u0068\u0074\u0074\u0070"){connectPath ="\u0068t\u0074\u0070\u003a\u002f\u002f"+connectPath ;};_g ,_be :=_a .Parse (connectPath );if _be !=nil {return Options {},_dg .Errorf ("p\u0072\u006f\u0076\u0069\u0064\u0065d\u0020\u0069\u006e\u0076\u0061\u006ci\u0064\u0020\u0075\u006e\u0069\u0068\u0074m\u006c\u002d\u0073\u0065\u0072\u0076\u0065\u0072\u0020\u0075r\u006c");
};var _eff int ;if _g .Port ()!=""{_eff ,_be =_fc .Atoi (_g .Port ());if _be !=nil {return Options {},_dg .Errorf ("\u0070\u0061\u0072si\u006e\u0067\u0020\u0070\u006f\u0072\u0074\u0020\u0066\u0061\u0069\u006c\u0065\u0064\u003a\u0020\u0025\u0077",_be );
};};return Options {Hostname :_g .Hostname (),Port :_eff ,HTTPS :_g .Scheme =="\u0068\u0074\u0074p\u0073",Prefix :_g .Path },nil ;};
// Query gets the Query from provided query builder. If some error occurred during build process
// or the input is not valid the function would return an error.
func (_agad *QueryBuilder )Query ()(*Query ,error ){if _dcb :=_agad .Validate ();_dcb !=nil {return nil ,_dcb ;};return &_agad ._ca ,nil ;};var (ErrNotFound =_ee .New ("\u006eo\u0074\u0020\u0066\u006f\u0075\u006ed");ErrBadRequest =_ee .New ("b\u0061\u0064\u0020\u0072\u0065\u0071\u0075\u0065\u0073\u0074");
ErrNotImplemented =_ee .New ("\u006eo\u0074 \u0069\u006d\u0070\u006c\u0065\u006d\u0065\u006e\u0074\u0065\u0064");ErrInternalError =_ee .New ("i\u006e\u0074\u0065\u0072na\u006c \u0073\u0065\u0072\u0076\u0065r\u0020\u0065\u0072\u0072\u006f\u0072");ErrBadGateway =_ee .New ("b\u0061\u0064\u0020\u0067\u0061\u0074\u0065\u0077\u0061\u0079");
ErrUnauthorized =_ee .New ("\u0075\u006e\u0061u\u0074\u0068\u006f\u0072\u0069\u007a\u0065\u0064"););
// PageSize sets up the PageSize parameter for the query.
func (_aec *QueryBuilder )PageSize (pageSize _e .PageSize )*QueryBuilder {if pageSize !=_e .Undefined {_aec ._gfe .PageParameters .PageSize =&pageSize ;};return _aec ;};
// PageParameters are the query parameters used in the PDF generation.
type PageParameters struct{
// PaperWidth sets the width of the paper.
PaperWidth _dc .Length `schema:"paper-width" json:"paperWidth"`;
PaperWidth _e .Length `schema:"paper-width" json:"paperWidth"`;
// PaperHeight is the height of the output paper.
PaperHeight _dc .Length `schema:"paper-height" json:"paperHeight"`;
PaperHeight _e .Length `schema:"paper-height" json:"paperHeight"`;
// PageSize is the page size string.
PageSize *_dc .PageSize `schema:"page-size" json:"pageSize"`;
PageSize *_e .PageSize `schema:"page-size" json:"pageSize"`;
// Orientation defines if the output should be in a landscape format.
Orientation _dc .Orientation `schema:"orientation" json:"orientation"`;
Orientation _e .Orientation `schema:"orientation" json:"orientation"`;
// MarginTop sets up the Top Margin for the output.
MarginTop _dc .Length `schema:"margin-top" json:"marginTop"`;
MarginTop _e .Length `schema:"margin-top" json:"marginTop"`;
// MarginBottom sets up the Bottom Margin for the output.
MarginBottom _dc .Length `schema:"margin-bottom" json:"marginBottom"`;
MarginBottom _e .Length `schema:"margin-bottom" json:"marginBottom"`;
// MarginLeft sets up the Left Margin for the output.
MarginLeft _dc .Length `schema:"margin-left" json:"marginLeft"`;
MarginLeft _e .Length `schema:"margin-left" json:"marginLeft"`;
// MarginRight sets up the Right Margin for the output.
MarginRight _dc .Length `schema:"margin-right" json:"marginRight"`;};
MarginRight _e .Length `schema:"margin-right" json:"marginRight"`;};
// PageSize sets up the PageSize parameter for the query.
func (_gc *QueryBuilder )PageSize (pageSize _dc .PageSize )*QueryBuilder {if pageSize !=_dc .Undefined {_gc ._ca .PageParameters .PageSize =&pageSize ;};return _gc ;};
// Validate checks if the QueryBuilder had no errors during composition and creation.
func (_dg *QueryBuilder )Validate ()error {if _dg ._ca !=nil {return _dg ._ca ;};return _dg ._gfe .Validate ();};
// ConvertHTML converts provided Query input into PDF file data.
// Implements creator.HTMLConverter interface.
func (_ec *Client )ConvertHTML (ctx _f .Context ,q *Query )(*PDFResponse ,error ){if _cde :=q .Validate ();_cde !=nil {return nil ,_cde ;};_ebb ,_agd :=_ec .getRequest (ctx ,q );if _agd !=nil {return nil ,_agd ;};_bd .Log .Trace ("\u0052\u0065\u0071\u0075\u0065\u0073\u0074 \u002d\u0020\u0025s\u0020\u002d\u0020\u0025s\u0025\u0073\u002c\u0020\u0048\u0065\u0061\u0064\u0065\u0072\u0073\u003a\u0020\u0025\u0076\u002c\u0020\u0051\u0075\u0065\u0072\u0079\u003a\u0020\u0025\u0076",_ebb .Method ,_ebb .URL .Hostname (),_ebb .URL .Path ,_ebb .Header ,_ebb .URL .Query ());
_bdc ,_agd :=_ec .Client .Do (_ebb );if _agd !=nil {return nil ,_agd ;};var _ce error ;switch _bdc .StatusCode {case _eaf .StatusNotFound :_ce =ErrNotFound ;case _eaf .StatusBadRequest :_ce =ErrBadRequest ;case _eaf .StatusNotImplemented :_ce =ErrNotImplemented ;
case _eaf .StatusUnauthorized :_ce =ErrUnauthorized ;case _eaf .StatusCreated :default:_ce =ErrInternalError ;};_eg :=_bdc .Body ;switch _bdc .Header .Get ("\u0043\u006fn\u0074\u0065\u006et\u002d\u0045\u006e\u0063\u006f\u0064\u0069\u006e\u0067"){case "\u0067\u007a\u0069\u0070":_eg ,_agd =_c .NewReader (_bdc .Body );
if _agd !=nil {return nil ,_agd ;};case "\u0064e\u0066\u006c\u0061\u0074\u0065":_eg =_b .NewReader (_bdc .Body );case "":default:return nil ,_eafc .Errorf ("\u0075\u006e\u0073\u0075\u0070\u0070\u006f\u0072\u0074\u0065\u0064\u0020\u0043o\u006e\u0074\u0065\u006e\u0074\u002dE\u006e\u0063\u006f\u0064\u0069\u006e\u0067\u003a\u0020\u0025\u0073\u0020\u0068e\u0061\u0064\u0065\u0072",_bdc .Header .Get ("\u0043\u006fn\u0074\u0065\u006et\u002d\u0045\u006e\u0063\u006f\u0064\u0069\u006e\u0067"));
};_bdgb ,_agd :=_ea .ReadAll (_eg );if _agd !=nil &&_ce ==nil {return nil ,_eafc .Errorf ("\u0055\u006e\u0069HT\u004d\u004c\u0020\u0073\u0065\u0072\u0076\u0065\u0072\u0020\u0065\u0072\u0072\u006f\u0072\u0020\u0025\u0073",_agd );};_bd .Log .Trace ("\u005b\u0025\u0064]\u0020\u0025\u0073\u0020\u0025\u0073\u0025\u0073",_bdc .StatusCode ,_ebb .Method ,_ebb .URL .Host ,_ebb .URL .Path );
if _ce !=nil {return nil ,_eafc .Errorf ("\u0025\u0073\u0020%\u0077",string (_bdgb ),_ce );};_df :=_bdc .Header .Get ("\u0058\u002d\u004a\u006f\u0062\u002d\u0049\u0044");_bd .Log .Trace ("\u0052\u0065\u0073\u0070\u006f\u006e\u0073\u0065\u0020I\u0044\u0020\u0025\u0073",_df );
return &PDFResponse {ID :_df ,Data :_bdgb },nil ;};
// Client is a structure that is a HTTP client for the unihtml server.
type Client struct{Options Options ;Client *_g .Client ;};
// PaperHeight sets up the PaperHeight (in cm) parameter for the query.
func (_dfc *QueryBuilder )PaperHeight (paperHeight _e .Length )*QueryBuilder {_dfc ._gfe .PageParameters .PaperHeight =paperHeight ;return _dfc ;};
// MarginTop sets up the MarginTop parameter for the query.
func (_ead *QueryBuilder )MarginTop (marginTop _e .Length )*QueryBuilder {_ead ._gfe .PageParameters .MarginTop =marginTop ;return _ead ;};func (_gc *Client )getRequest (_bb _bd .Context ,_fb *Query )(*_g .Request ,error ){_fd :=_gc .Options .Addr ();_fd =_fa .Sprintf ("\u0025\u0073\u002f\u0070\u0064\u0066",_fd );
_ae ,_baa :=_g .NewRequest ("\u0050\u004f\u0053\u0054",_fd ,_daa .NewReader (_fb .Data ));if _baa !=nil {return nil ,_baa ;};_ae .Header .Set ("\u0043\u006f\u006et\u0065\u006e\u0074\u002d\u0054\u0079\u0070\u0065",_fb .ContentType );_ae .Header .Set ("\u0041c\u0063e\u0070\u0074\u002d\u0045\u006e\u0063\u006f\u0064\u0069\u006e\u0067","\u0064\u0065\u0066\u006ca\u0074\u0065\u002c\u0020\u0067\u007a\u0069\u0070\u003b\u0071=\u0031.\u0030\u002c\u0020\u002a\u003b\u0071\u003d0\u002e\u0035");
_ae =_ae .WithContext (_bb );_eb :=_ae .URL .Query ();_cf :=_fb .PageParameters ;if _cf .PageSize !=nil {_eb .Set ("\u0070a\u0067\u0065\u002d\u0073\u0069\u007ae",_cf .PageSize .String ());};if _cf .PaperHeight !=nil {_eb .Set ("\u0070\u0061\u0070e\u0072\u002d\u0068\u0065\u0069\u0067\u0068\u0074",_cf .PaperHeight .String ());
};if _cf .PaperWidth !=nil {_eb .Set ("p\u0061\u0070\u0065\u0072\u002d\u0077\u0069\u0064\u0074\u0068",_cf .PaperWidth .String ());};if _cf .MarginTop !=nil {_eb .Set ("\u006d\u0061\u0072\u0067\u0069\u006e\u002d\u0074\u006f\u0070",_cf .MarginTop .String ());
};if _cf .MarginBottom !=nil {_eb .Set ("\u006d\u0061\u0072\u0067\u0069\u006e\u002d\u0062\u006f\u0074\u0074\u006f\u006d",_cf .MarginBottom .String ());};if _cf .MarginRight !=nil {_eb .Set ("\u006d\u0061\u0072g\u0069\u006e\u002d\u0072\u0069\u0067\u0068\u0074",_cf .MarginRight .String ());
};if _cf .MarginLeft !=nil {_eb .Set ("m\u0061\u0072\u0067\u0069\u006e\u002d\u006c\u0065\u0066\u0074",_cf .MarginLeft .String ());};if _cf .Orientation ==_e .Landscape {_eb .Set ("o\u0072\u0069\u0065\u006e\u0074\u0061\u0074\u0069\u006f\u006e",_cf .Orientation .String ());
};_ae .URL .RawQuery =_eb .Encode ();return _ae ,nil ;};
// Validate checks if the parameters are valid.
func (_fge *PageParameters )Validate ()error {if _fge .PaperWidth !=nil {if _fge .PaperWidth .Millimeters ()< 0{return _a .New ("\u006e\u0065g\u0061\u0074\u0069\u0076\u0065\u0020\u0076\u0061\u006c\u0075\u0065\u0020\u0066\u006f\u0072\u0020\u0050\u0061\u0070\u0065\u0072\u0057id\u0074\u0068");
};};if _fge .PaperHeight !=nil {if _fge .PaperHeight .Millimeters ()< 0{return _a .New ("\u006e\u0065\u0067\u0061\u0074\u0069\u0076\u0065\u0020\u0076a\u006c\u0075\u0065\u0020\u0066\u006f\u0072 \u0050\u0061\u0070\u0065\u0072\u0048\u0065\u0069\u0067\u0068\u0074");
};};if _fge .MarginTop !=nil {if _fge .MarginTop .Millimeters ()< 0{return _a .New ("\u006e\u0065\u0067\u0061t\u0069\u0076\u0065\u0020\u0076\u0061\u006c\u0075\u0065\u0020f\u006fr\u0020\u004d\u0061\u0072\u0067\u0069\u006eT\u006f\u0070");};};if _fge .MarginBottom !=nil {if _fge .MarginBottom .Millimeters ()< 0{return _a .New ("\u006e\u0065\u0067a\u0074\u0069\u0076\u0065 \u0076\u0061\u006c\u0075\u0065\u0020\u0066o\u0072\u0020\u004d\u0061\u0072\u0067\u0069\u006e\u0042\u006f\u0074\u0074\u006f\u006d");
};};if _fge .MarginLeft !=nil {if _fge .MarginLeft .Millimeters ()< 0{return _a .New ("\u006e\u0065g\u0061\u0074\u0069\u0076\u0065\u0020\u0076\u0061\u006c\u0075\u0065\u0020\u0066\u006f\u0072\u0020\u004d\u0061\u0072\u0067\u0069\u006eLe\u0066\u0074");};};
if _fge .MarginRight !=nil {if _fge .MarginRight .Millimeters ()< 0{return _a .New ("\u006e\u0065\u0067\u0061\u0074\u0069\u0076\u0065\u0020\u0076a\u006c\u0075\u0065\u0020\u0066\u006f\u0072 \u004d\u0061\u0072\u0067\u0069\u006e\u0052\u0069\u0067\u0068\u0074");
};};if _fge .PageSize !=nil &&!_fge .PageSize .IsAPageSize (){return _a .New ("\u0069\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u0070\u0061\u0067\u0065 \u0073\u0069\u007a\u0065");};return nil ;};
// Query is a structure that contains query parameters and the content used for the HTMLConverter conversion process.
type Query struct{Data []byte ;ContentType string ;PageParameters PageParameters ;};
// Addr gets the HTTP address URI used by the http.Client.
func (_afb *Options )Addr ()string {_fc :=_deb .Builder {};_fc .WriteString ("\u0068\u0074\u0074\u0070");if _afb .HTTPS {_fc .WriteRune ('s');};_fc .WriteString ("\u003a\u002f\u002f");_fc .WriteString (_afb .Hostname );_fc .WriteRune (':');_fc .WriteString (_af .Itoa (_afb .Port ));
if _afb .Prefix !=""{_fc .WriteString (_afb .Prefix );};return _fc .String ();};
// DefaultPageParameters creates default parameters.
func DefaultPageParameters ()PageParameters {return PageParameters {Orientation :_e .Portrait }};

View File

@ -10,8 +10,8 @@
// terms that can be accessed at https://unidoc.io/eula/
// Package common contains common properties used by the subpackages.
package common ;import _e "time";const _f ="\u0032\u0020\u004aan\u0075\u0061\u0072\u0079\u0020\u0032\u0030\u0030\u0036\u0020\u0061\u0074\u0020\u0031\u0035\u003a\u0030\u0034";var ReleasedAt =_e .Date (_ac ,_b ,_bg ,_ba ,_ad ,0,0,_e .UTC );const _ba =12;
package common ;import _g "time";const _ee =20;const _gb =3;var ReleasedAt =_g .Date (_a ,_gb ,_c ,_af ,_ee ,0,0,_g .UTC );
// UtcTimeFormat returns a formatted string describing a UTC timestamp.
func UtcTimeFormat (t _e .Time )string {return t .Format (_f )+"\u0020\u0055\u0054\u0043"};const _ac =2021;const Version ="\u0030\u002e\u0033.\u0030";const _bg =23;const _ad =20;const _b =3;
func UtcTimeFormat (t _g .Time )string {return t .Format (_e )+"\u0020\u0055\u0054\u0043"};const _e ="\u0032\u0020\u004aan\u0075\u0061\u0072\u0079\u0020\u0032\u0030\u0030\u0036\u0020\u0061\u0074\u0020\u0031\u0035\u003a\u0030\u0034";const _c =27;const Version ="\u0030\u002e\u0034.\u0030";
const _a =2021;const _af =12;

View File

@ -9,41 +9,41 @@
// 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 content ;import (_f "archive/zip";_ca "bytes";_fc "encoding/json";_a "golang.org/x/xerrors";_g "io/ioutil";_bd "net/url";_d "os";_b "strings";);
package content ;import (_b "archive/zip";_g "bytes";_ce "encoding/json";_cgc "golang.org/x/xerrors";_e "io/ioutil";_cg "net/url";_dc "os";_d "strings";);func (_bgd *zipDirectory )zipPath (_ef ,_db string )error {_bc ,_ae :=_e .ReadDir (_ef );if _ae !=nil {return _cgc .Errorf ("\u0072\u0065\u0061di\u006e\u0067\u0020\u0064\u0069\u0072\u0065\u0063\u0074o\u0072y\u003a \u0027%\u0073\u0027\u0020\u0066\u0061\u0069\u006c\u0065\u0064\u003a\u0020\u0025\u0077",_ef ,_ae );
};_bcf :=&_d .Builder {};for _ ,_gb :=range _bc {_bb ,_cgd :=_bgd .zipBasePaths (_gb ,_ef ,_db ,_gb .IsDir (),_bcf );if _gb .IsDir (){if _cbc :=_bgd .zipPath (_bb ,_cgd );_cbc !=nil {return _cbc ;};continue ;};_dg ,_ee :=_e .ReadFile (_bb );if _ee !=nil {return _ee ;
};_bce ,_ee :=_bgd ._cgae .Create (_cgd );if _ee !=nil {return _ee ;};if _ ,_ee =_bce .Write (_dg );_ee !=nil {return _ee ;};};return nil ;};
// NewHTMLFile creates new Content htmFile for provided input path.
func NewHTMLFile (path string )(Content ,error ){_cad ,_ag :=_d .Open (path );if _ag !=nil {return nil ,_ag ;};_df :=&htmFile {_cf :_ca .Buffer {}};if _ ,_ag =_df ._cf .ReadFrom (_cad );_ag !=nil {return nil ,_ag ;};return _df ,nil ;};
func NewHTMLFile (path string )(Content ,error ){_f ,_ed :=_dc .Open (path );if _ed !=nil {return nil ,_ed ;};_gc :=&htmFile {_cb :_g .Buffer {}};if _ ,_ed =_gc ._cb .ReadFrom (_f );_ed !=nil {return nil ,_ed ;};return _gc ,nil ;};
// ContentType implements Content interface.
func (_ce *webURL )ContentType ()string {return "\u0061\u0070p\u006c\u0069\u0063a\u0074\u0069\u006f\u006e\u002f\u006a\u0073\u006f\u006e";};
func (_bg *htmFile )ContentType ()string {return "\u0074e\u0078\u0074\u002f\u0068\u0074\u006dl"};
// Data implements Content interface.
func (_cbb *htmFile )Data ()[]byte {return _cbb ._cb .Bytes ()};
// Data implements Content interface.
func (_ba *webURL )Data ()[]byte {return _ba ._gd };type webURL struct{_a string ;_gd []byte ;};func (_dgf *zipDirectory )zipBasePaths (_ga _dc .FileInfo ,_fac ,_gbg string ,_fag bool ,_cbf *_d .Builder )(string ,string ){_cbf .WriteString (_fac );if !_d .HasSuffix (_fac ,"\u002f"){_cbf .WriteRune ('/');
};_cbf .WriteString (_ga .Name ());if _fag {_cbf .WriteRune ('/');};_de :=_cbf .String ();_cbf .Reset ();_cbf .WriteString (_gbg );_cbf .WriteString (_ga .Name ());if _fag {_cbf .WriteRune ('/');};_eg :=_cbf .String ();_cbf .Reset ();return _de ,_eg ;};
// NewWebURL creates new Content webURL for provided input URL path.
func NewWebURL (path string )(Content ,error ){if _ ,_aa :=_bd .Parse (path );_aa !=nil {return nil ,_aa ;};type urlOutput struct{URL string `json:"url"`;};_cb :=urlOutput {URL :path };_e ,_ae :=_fc .Marshal (_cb );if _ae !=nil {return nil ,_ae ;};return &webURL {_bb :path ,_fg :_e },nil ;
};type webURL struct{_bb string ;_fg []byte ;};
// Data implements Content interface.
func (_ggd *webURL )Data ()[]byte {return _ggd ._fg };
// ContentType implements Content interface.
func (_ab *zipDirectory )ContentType ()string {return "\u0061p\u0070l\u0069\u0063\u0061\u0074\u0069\u006f\u006e\u002f\u007a\u0069\u0070";};
// Data implements Content interface.
func (_gf *htmFile )Data ()[]byte {return _gf ._cf .Bytes ()};type htmFile struct{_cf _ca .Buffer };
func NewWebURL (path string )(Content ,error ){if _ ,_bf :=_cg .Parse (path );_bf !=nil {return nil ,_bf ;};type urlOutput struct{URL string `json:"url"`;};_da :=urlOutput {URL :path };_be ,_bd :=_ce .Marshal (_da );if _bd !=nil {return nil ,_bd ;};return &webURL {_a :path ,_gd :_be },nil ;
};
// NewZipDirectory creates new zip compressed file that recursively reads the directory at the 'dirPath'
// and stores in it's in-memory buffer.
func NewZipDirectory (dirPath string )(Content ,error ){_bc :=&zipDirectory {_bf :_ca .Buffer {}};_bc ._cba =_f .NewWriter (&_bc ._bf );if _gff :=_bc .zipPath (dirPath ,"");_gff !=nil {return nil ,_gff ;};if _ad :=_bc ._cba .Close ();_ad !=nil {return nil ,_ad ;
};return _bc ,nil ;};
// ContentType implements Content interface.
func (_gg *htmFile )ContentType ()string {return "\u0074e\u0078\u0074\u002f\u0068\u0074\u006dl"};
func NewZipDirectory (dirPath string )(Content ,error ){_eb :=&zipDirectory {_cga :_g .Buffer {}};_eb ._cgae =_b .NewWriter (&_eb ._cga );if _fed :=_eb .zipPath (dirPath ,"");_fed !=nil {return nil ,_fed ;};if _dd :=_eb ._cgae .Close ();_dd !=nil {return nil ,_dd ;
};return _eb ,nil ;};
// Content is an interface used for putting the content into Client Query.
type Content interface{ContentType ()string ;Data ()[]byte ;};func (_cc *zipDirectory )zipBasePaths (_fbc _d .FileInfo ,_aeb ,_dgg string ,_ec bool ,_abe *_b .Builder )(string ,string ){_abe .WriteString (_aeb );if !_b .HasSuffix (_aeb ,"\u002f"){_abe .WriteRune ('/');
};_abe .WriteString (_fbc .Name ());if _ec {_abe .WriteRune ('/');};_bfg :=_abe .String ();_abe .Reset ();_abe .WriteString (_dgg );_abe .WriteString (_fbc .Name ());if _ec {_abe .WriteRune ('/');};_gc :=_abe .String ();_abe .Reset ();return _bfg ,_gc ;
};func (_dde *zipDirectory )zipPath (_aed ,_de string )error {_ded ,_dg :=_g .ReadDir (_aed );if _dg !=nil {return _a .Errorf ("\u0072\u0065\u0061di\u006e\u0067\u0020\u0064\u0069\u0072\u0065\u0063\u0074o\u0072y\u003a \u0027%\u0073\u0027\u0020\u0066\u0061\u0069\u006c\u0065\u0064\u003a\u0020\u0025\u0077",_aed ,_dg );
};_add :=&_b .Builder {};for _ ,_cfd :=range _ded {_ceg ,_fb :=_dde .zipBasePaths (_cfd ,_aed ,_de ,_cfd .IsDir (),_add );if _cfd .IsDir (){if _ea :=_dde .zipPath (_ceg ,_fb );_ea !=nil {return _ea ;};continue ;};_bfb ,_gfg :=_g .ReadFile (_ceg );if _gfg !=nil {return _gfg ;
};_cd ,_gfg :=_dde ._cba .Create (_fb );if _gfg !=nil {return _gfg ;};if _ ,_gfg =_cd .Write (_bfb );_gfg !=nil {return _gfg ;};};return nil ;};type zipDirectory struct{_bf _ca .Buffer ;_cba *_f .Writer ;};
type Content interface{ContentType ()string ;Data ()[]byte ;};
// ContentType implements Content interface.
func (_df *zipDirectory )ContentType ()string {return "\u0061p\u0070l\u0069\u0063\u0061\u0074\u0069\u006f\u006e\u002f\u007a\u0069\u0070";};type zipDirectory struct{_cga _g .Buffer ;_cgae *_b .Writer ;};type htmFile struct{_cb _g .Buffer };
// Data implements Content interface.
func (_bdc *zipDirectory )Data ()[]byte {return _bdc ._bf .Bytes ()};
func (_fa *zipDirectory )Data ()[]byte {return _fa ._cga .Bytes ()};
// ContentType implements Content interface.
func (_bgc *webURL )ContentType ()string {return "\u0061\u0070p\u006c\u0069\u0063a\u0074\u0069\u006f\u006e\u002f\u006a\u0073\u006f\u006e";};

View File

@ -12,180 +12,180 @@
// Package sizes defines basic types that determines the size units i.e. lengths.
//
//
package sizes ;import (_ac "encoding/json";_ad "flag";_c "fmt";_g "strconv";_f "strings";);
// ValueString implements pflag.Value interface.
func (_be Inch )ValueString ()string {return _be .String ()};
// String implements fmt.Stringer interface.
func (_gdg Point )String ()string {_ff :=_f .Builder {};_ff .WriteString (_g .FormatFloat (float64 (_gdg ),'f',1,64));_ff .WriteString ("\u0070\u0074");return _ff .String ();};
// Set implements flag.Value interface.
func (_cdg *Point )Set (s string )error {_cbb ,_cba :=_g .ParseFloat (s ,64);if _cba !=nil {return _c .Errorf ("\u0069\u006e\u0076\u0061li\u0064\u0020\u0069\u006e\u0063\u0068\u0020\u0076\u0061\u006c\u0075\u0065\u003a\u0020%\u0077",_cba );};*_cdg =Point (_cbb );
return nil ;};
// Type implements pflag.Value interface.
func (_fgd PageSize )Type ()string {return "\u0070a\u0067\u0065\u002d\u0073\u0069\u007ae"};
// MarshalText implements the encoding.TextMarshaler interface for PageSize
func (_egf PageSize )MarshalText ()([]byte ,error ){return []byte (_egf .String ()),nil };
// Type implements pflag.Value interface.
func (_dac Orientation )Type ()string {return "o\u0072\u0069\u0065\u006e\u0074\u0061\u0074\u0069\u006f\u006e";};
// Millimeters converts the inches value to the millimeters.
func (_eef Inch )Millimeters ()Millimeter {return Millimeter (float64 (_eef )*_cc )};
package sizes ;import (_f "encoding/json";_c "flag";_a "fmt";_e "strconv";_g "strings";);func _fb (_eea string )(Inch ,error ){_eea =_g .TrimSpace (_g .Trim (_eea ,"\u0069\u006e"));_egd ,_df :=_e .ParseFloat (_eea ,64);if _df !=nil {return 0,_a .Errorf ("\u0069\u006e\u0076\u0061li\u0064\u0020\u0069\u006e\u0063\u0068\u0020\u0076\u0061\u006c\u0075\u0065\u003a\u0020%\u0077",_df );
};return Inch (_egd ),nil ;};
// Points implements Length interface.
func (_bed Point )Points ()Point {return _bed };
// HasChanged implements pflag.Value interface.
func (_db *Inch )HasChanged ()bool {return _db !=nil };
// ValueType implements pflag.Value interface.
func (_fdc Inch )ValueType ()string {return _fdc .Type ()};
// Set implements pflag.Value interface.
func (_abac *PageSize )Set (s string )error {_fdb ,_eea :=UnmarshalPageSize (s );if _eea !=nil {return _eea ;};*_abac =_fdb ;return nil ;};
// MarshalUnit marshals the unit into the string.
func MarshalUnit (unit Length )(string ,error ){switch _cgf :=unit .(type ){case Millimeter :return _c .Sprintf ("\u0025\u002e\u0030\u0066\u006d\u006d",_cgf ),nil ;case Inch :return _c .Sprintf ("\u0025\u002e\u0030\u0066\u0069\u006e",_cgf ),nil ;case Point :return _c .Sprintf ("\u0025\u002e\u0030\u0066\u0070\u0074",_cgf ),nil ;
default:return "",_c .Errorf ("i\u006e\u0076\u0061\u006cid\u0020u\u006e\u0069\u0074\u0020\u0074y\u0070\u0065\u003a\u0020\u0025\u0054",unit );};};
// UnmarshalPageSize unmarshals the page size from the string.
func UnmarshalPageSize (pageSize string )(PageSize ,error ){var _cgb PageSize ;if _aed :=(&_cgb ).UnmarshalText ([]byte (pageSize ));_aed !=nil {return 0,_c .Errorf ("\u0070\u0072\u006f\u0076\u0069\u0064\u0065\u0064\u0020\u0069n\u0076\u0061\u006c\u0069\u0064\u0020\u0070a\u0067\u0065\u0020\u0073\u0069\u007a\u0065\u003a\u0020\u0025\u0077",_aed );
};return _cgb ,nil ;};
// Set implements flag.Value interface.
func (_fg *Orientation )Set (s string )error {switch s {case "\u0070\u006f\u0072\u0074\u0072\u0061\u0069\u0074":*_fg =Portrait ;case "\u006ca\u006e\u0064\u0073\u0063\u0061\u0070e":*_fg =Landscape ;default:return _c .Errorf ("\u0069n\u0076\u0061\u006c\u0069d\u0020\u006f\u0072\u0069\u0065n\u0074a\u0074i\u006f\u006e\u003a\u0020\u0027\u0025\u0073'",s );
};return nil ;};const (_d =float64 (1)/float64 (25.4);_cc =25.4;_e =0.0139;_fe =0.3528;_af =1/64;_cf =1/_fe ;);
// Inches gets the inch value. Implements Length interface.
func (_bb Point )Inches ()Inch {return Inch (float64 (_bb )*_e )};
// Points implements Length interface.
func (_cdb Inch )Points ()Point {return Point (float64 (_cdb )*_af )};
// String implements fmt.Stringer interface.
func (_cbg Inch )String ()string {_dd :=_f .Builder {};_dd .WriteString (_g .FormatFloat (float64 (_cbg ),'f',1,64));_dd .WriteString ("\u0069\u006e");return _dd .String ();};var _age =map[string ]PageSize {_gb [0:9]:0,_gb [9:11]:1,_gb [11:13]:2,_gb [13:15]:3,_gb [15:17]:4,_gb [17:19]:5,_gb [19:21]:6,_gb [21:23]:7,_gb [23:25]:8,_gb [25:27]:9,_gb [27:29]:10,_gb [29:32]:11,_gb [32:34]:12,_gb [34:36]:13,_gb [36:38]:14,_gb [38:40]:15,_gb [40:42]:16,_gb [42:44]:17,_gb [44:46]:18,_gb [46:48]:19,_gb [48:50]:20,_gb [50:52]:21,_gb [52:55]:22,_gb [55:61]:23};
func _aea (_cbac string )(Point ,error ){_cbac =_f .TrimSpace (_f .Trim (_cbac ,"\u0070\u0074"));_aff ,_ggf :=_g .ParseFloat (_cbac ,64);if _ggf !=nil {return 0,_ggf ;};return Point (_aff ),nil ;};func (_cad PageSize )String ()string {if _cad < 0||_cad >=PageSize (len (_dee )-1){return _c .Sprintf ("\u0050\u0061\u0067e\u0053\u0069\u007a\u0065\u0028\u0025\u0064\u0029",_cad );
};return _gb [_dee [_cad ]:_dee [_cad +1]];};const (Portrait =Orientation (false );Landscape =Orientation (true ););
// Dimensions gets the dimensions of the given page size.
// If provided page size is not valid than the function returns 0 values.
func (_dg PageSize )Dimensions ()(_eedd ,_fee Millimeter ){switch _dg {case A0 :return 841,1189;case A1 :return 594,841;case A2 :return 420,594;case A3 :return 297,420;case A4 :return 210,297;case A5 :return 148,210;case A6 :return 105,148;case A7 :return 74,105;
case A8 :return 52,74;case A9 :return 37,52;case A10 :return 26,37;case B0 :return 1000,1414;case B1 :return 707,1000;case B2 :return 500,707;case B3 :return 353,500;case B4 :return 250,353;case B5 :return 176,250;case B6 :return 125,176;case B7 :return 88,125;
case B8 :return 66,88;case B9 :return 44,62;case B10 :return 31,44;case Letter :return 215.9,279.4;};return _eedd ,_fee ;};
// Type implements pflag.Value interface.
func (_gc *LengthFlag )Type ()string {return "\u0075\u006e\u0069\u0074"};
// Type implements pflag.Value interface.
func (_ggg Point )Type ()string {return "\u0070\u006f\u0069n\u0074"};
// Inches gets the inches equivalent from provided millimeter value.
func (_b Millimeter )Inches ()Inch {return Inch (float64 (_b )*_d )};
// Name implements viper.FlagValue interface.
func (_cg Point )Name ()string {return "\u0070\u006f\u0069n\u0074"};
// Millimeter is the dimension unit that defines a millimeter.
type Millimeter float64 ;func _ab (_ag string )(Millimeter ,error ){_ag =_f .TrimSpace (_f .TrimSuffix (_ag ,"\u006d\u006d"));_bg ,_ga :=_g .ParseFloat (_ag ,64);if _ga !=nil {return 0,_c .Errorf ("\u0069\u006e\u0076\u0061l\u0069\u0064\u0020\u006d\u0069\u006c\u006c\u0069\u006d\u0065t\u0065r\u0020\u0076\u0061\u006c\u0075\u0065\u003a \u0025\u0077",_ga );
};return Millimeter (_bg ),nil ;};var _ _ad .Value =(*Orientation )(nil );
// String implements fmt.Stringer interface.
func (_eg Millimeter )String ()string {_gg :=_f .Builder {};_gg .WriteString (_g .FormatFloat (float64 (_eg ),'f',1,64));_gg .WriteString ("\u006d\u006d");return _gg .String ();};var _gad =[]PageSize {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23};
func (_gad Point )Points ()Point {return _gad };
// MarshalJSON implements the json.Marshaler interface for PageSize
func (_adcg PageSize )MarshalJSON ()([]byte ,error ){return _ac .Marshal (_adcg .String ())};
// PageSize is the enum used for defining the page size.
type PageSize int ;
func (_ac PageSize )MarshalJSON ()([]byte ,error ){return _f .Marshal (_ac .String ())};
// Millimeters gets the float64 millimeter value.
func (_cfd Millimeter )Millimeters ()Millimeter {return _cfd };var (_ Length =Millimeter (0););
// UnmarshalText implements the encoding.TextUnmarshaler interface for PageSize
func (_ea *PageSize )UnmarshalText (text []byte )error {var _dda error ;*_ea ,_dda =PageSizeString (string (text ));return _dda ;};var _dee =[...]uint8 {0,9,11,13,15,17,19,21,23,25,27,29,32,34,36,38,40,42,44,46,48,50,52,55,61};
// Orientation is the page orientation type wrapper.
type Orientation bool ;func _da (_ega string )(Inch ,error ){_ega =_f .TrimSpace (_f .Trim (_ega ,"\u0069\u006e"));_fa ,_aba :=_g .ParseFloat (_ega ,64);if _aba !=nil {return 0,_c .Errorf ("\u0069\u006e\u0076\u0061li\u0064\u0020\u0069\u006e\u0063\u0068\u0020\u0076\u0061\u006c\u0075\u0065\u003a\u0020%\u0077",_aba );
};return Inch (_fa ),nil ;};
// String gets the string value for given flag.
func (_adc *LengthFlag )String ()string {if _adc .Length ==nil {return "\u0075n\u0064\u0065\u0066\u0069\u006e\u0065d";};return _adc .Length .String ();};
// PageSizeValues returns all values of the enum
func PageSizeValues ()[]PageSize {return _gad };
// PageSizeString retrieves an enum value from the enum constants string name.
// Throws an error if the param is not part of the enum.
func PageSizeString (s string )(PageSize ,error ){if _dae ,_ddc :=_age [s ];_ddc {return _dae ,nil ;};return 0,_c .Errorf ("\u0025\u0073 \u0064\u006f\u0065\u0073 \u006e\u006ft\u0020\u0062\u0065\u006c\u006f\u006e\u0067\u0020t\u006f\u0020\u0050\u0061\u0067\u0065\u0053\u0069\u007a\u0065\u0020\u0076a\u006c\u0075\u0065\u0073",s );
};
// MarshalPageSize marshals the page size into string.
func MarshalPageSize (p PageSize )(string ,error ){_bc ,_fc :=p .MarshalText ();if _fc !=nil {return "",_fc ;};return string (_bc ),nil ;};
// Point is a unit of Length commonly used to measure the height of fonts.
type Point float64 ;const _gb ="U\u006e\u0064\u0065\u0066\u0069\u006e\u0065\u0064\u0041\u0030\u0041\u0031\u0041\u0032\u0041\u0033\u0041\u0034\u0041\u0035\u0041\u0036\u0041\u0037\u0041\u0038A\u0039A\u0031\u0030\u0042\u0030B\u0031\u00422\u0042\u0033\u0042\u0034\u0042\u0035\u0042\u0036\u0042\u0037\u0042\u0038\u0042\u0039\u0042\u0031\u0030\u004c\u0065\u0074\u0074\u0065\u0072";
func (_bf Millimeter )Millimeters ()Millimeter {return _bf };var _ffe =map[string ]PageSize {_da [0:9]:0,_da [9:11]:1,_da [11:13]:2,_da [13:15]:3,_da [15:17]:4,_da [17:19]:5,_da [19:21]:6,_da [21:23]:7,_da [23:25]:8,_da [25:27]:9,_da [27:29]:10,_da [29:32]:11,_da [32:34]:12,_da [34:36]:13,_da [36:38]:14,_da [38:40]:15,_da [40:42]:16,_da [42:44]:17,_da [44:46]:18,_da [46:48]:19,_da [48:50]:20,_da [50:52]:21,_da [52:55]:22,_da [55:61]:23};
// UnmarshalLength unmarshalls string value into Length.
func UnmarshalLength (length string )(Length ,error ){if _f .HasSuffix (length ,"\u006d\u006d"){return _ab (length );};if _f .HasSuffix (length ,"\u0069\u006e"){return _da (length );};if _f .HasSuffix (length ,"\u0070\u0074"){return _aea (length );};return nil ,_c .Errorf ("\u0069n\u0076\u0061\u006c\u0069\u0064\u0020\u006c\u0065\u006e\u0067\u0074h\u0020\u0069\u006e\u0070\u0075\u0074\u003a\u0020\u0025\u0073",length );
};var _ _ad .Value =(*Point )(nil );
// Inches gets the inch value. Implements Length interface.
func (_df Inch )Inches ()Inch {return _df };
// Points implements Length interface.
func (_ee Millimeter )Points ()Point {return Point (_ee *_cf )};const (Undefined PageSize =iota ;A0 ;A1 ;A2 ;A3 ;A4 ;A5 ;A6 ;A7 ;A8 ;A9 ;A10 ;B0 ;B1 ;B2 ;B3 ;B4 ;B5 ;B6 ;B7 ;B8 ;B9 ;B10 ;Letter ;);
// ValueType implements viper.FlagValue interface.
func (_ecb Point )ValueType ()string {return _ecb .Type ()};
// String implements fmt.Stringer interface.
func (_bf Orientation )String ()string {if _bf ==Portrait {return "\u0070\u006f\u0072\u0074\u0072\u0061\u0069\u0074";};return "\u006ca\u006e\u0064\u0073\u0063\u0061\u0070e";};var _ Length =Inch (0);
// Set sets the unit value.
// Implements pflag.Value interface.
func (_ca *LengthFlag )Set (s string )error {if s =="\u0075n\u0064\u0065\u0066\u0069\u006e\u0065d"{_ca .Length =nil ;return nil ;};_gd ,_cd :=UnmarshalLength (s );if _cd !=nil {return _cd ;};_ca .Length =_gd ;return nil ;};
// Name implements pflag.Value interface.
func (_ae Inch )Name ()string {return "\u0069\u006e\u0063\u0068"};
// Length is it the default dimension unit.
type Length interface{Millimeters ()Millimeter ;Inches ()Inch ;Points ()Point ;String ()string ;};
// Type implements pflag.Value interface.
func (_fd Inch )Type ()string {return "\u0069\u006e\u0063\u0068"};
// IsAPageSize returns "true" if the value is listed in the enum definition. "false" otherwise
func (_gac PageSize )IsAPageSize ()bool {for _ ,_ecc :=range _gad {if _gac ==_ecc {return true ;};};return false ;};
// ValueString implements viper.FlagValue interface.
func (_de Point )ValueString ()string {return _de .String ()};
// Millimeters converts the inches value to the millimeters.
func (_fdd Point )Millimeters ()Millimeter {return Millimeter (float64 (_fdd )*_fe )};
// HasChanged implements viper.FlagValue interface.
func (_ed *Point )HasChanged ()bool {return _ed !=nil };
// Set implements pflag.Value interface.
func (_gcf *Inch )Set (s string )error {_cdf ,_fb :=_g .ParseFloat (s ,64);if _fb !=nil {return _c .Errorf ("\u0069\u006e\u0076\u0061li\u0064\u0020\u0069\u006e\u0063\u0068\u0020\u0076\u0061\u006c\u0075\u0065\u003a\u0020%\u0077",_fb );};*_gcf =Inch (_cdf );
// Set implements flag.Value interface.
func (_fe *Point )Set (s string )error {_cd ,_ba :=_e .ParseFloat (s ,64);if _ba !=nil {return _a .Errorf ("\u0069\u006e\u0076\u0061li\u0064\u0020\u0069\u006e\u0063\u0068\u0020\u0076\u0061\u006c\u0075\u0065\u003a\u0020%\u0077",_ba );};*_fe =Point (_cd );
return nil ;};
// UnmarshalInch unmarshalls provided string into unit.
func UnmarshalInch (unit string )(Inch ,error ){if _f .HasSuffix (unit ,"\u006d\u006d"){_aa ,_add :=_ab (unit );if _add !=nil {return 0,_add ;};return _aa .Inches (),nil ;};if _f .HasSuffix (unit ,"\u0069\u006e"){return _da (unit );};return 0,_c .Errorf ("\u0069\u006e\u0076\u0061li\u0064\u0020\u0069\u006e\u0063\u0068\u0020\u0069\u006e\u0070\u0075\u0074\u003a\u0020%\u0073",unit );
};
// ValueString implements pflag.Value interface.
func (_eeg Inch )ValueString ()string {return _eeg .String ()};
// IsAPageSize returns "true" if the value is listed in the enum definition. "false" otherwise
func (_cbae PageSize )IsAPageSize ()bool {for _ ,_gcg :=range _dgc {if _cbae ==_gcg {return true ;};};return false ;};var _ Length =Inch (0);
// Type implements pflag.Value interface.
func (_ae Inch )Type ()string {return "\u0069\u006e\u0063\u0068"};
// Inch is a unit that
type Inch float64 ;
// MarshalUnit marshals the unit into the string.
func MarshalUnit (unit Length )(string ,error ){switch _ag :=unit .(type ){case Millimeter :return _a .Sprintf ("\u0025\u002e\u0030\u0066\u006d\u006d",_ag ),nil ;case Inch :return _a .Sprintf ("\u0025\u002e\u0030\u0066\u0069\u006e",_ag ),nil ;case Point :return _a .Sprintf ("\u0025\u002e\u0030\u0066\u0070\u0074",_ag ),nil ;
default:return "",_a .Errorf ("i\u006e\u0076\u0061\u006cid\u0020u\u006e\u0069\u0074\u0020\u0074y\u0070\u0065\u003a\u0020\u0025\u0054",unit );};};
// UnmarshalPageSize unmarshals the page size from the string.
func UnmarshalPageSize (pageSize string )(PageSize ,error ){var _cbb PageSize ;if _eff :=(&_cbb ).UnmarshalText ([]byte (pageSize ));_eff !=nil {return 0,_a .Errorf ("\u0070\u0072\u006f\u0076\u0069\u0064\u0065\u0064\u0020\u0069n\u0076\u0061\u006c\u0069\u0064\u0020\u0070a\u0067\u0065\u0020\u0073\u0069\u007a\u0065\u003a\u0020\u0025\u0077",_eff );
};return _cbb ,nil ;};
// Type implements pflag.Value interface.
func (_fa Point )Type ()string {return "\u0070\u006f\u0069n\u0074"};
// Millimeters converts the inches value to the millimeters.
func (_gb Point )Millimeters ()Millimeter {return Millimeter (float64 (_gb )*_d )};
// UnmarshalInch unmarshalls provided string into unit.
func UnmarshalInch (unit string )(Inch ,error ){if _g .HasSuffix (unit ,"\u006d\u006d"){_aec ,_bde :=_cg (unit );if _bde !=nil {return 0,_bde ;};return _aec .Inches (),nil ;};if _g .HasSuffix (unit ,"\u0069\u006e"){return _fb (unit );};return 0,_a .Errorf ("\u0069\u006e\u0076\u0061li\u0064\u0020\u0069\u006e\u0063\u0068\u0020\u0069\u006e\u0070\u0075\u0074\u003a\u0020%\u0073",unit );
};
// ValueString implements viper.FlagValue interface.
func (_ebe Point )ValueString ()string {return _ebe .String ()};
// Millimeter is the dimension unit that defines a millimeter.
type Millimeter float64 ;
// MarshalPageSize marshals the page size into string.
func MarshalPageSize (p PageSize )(string ,error ){_gda ,_fbb :=p .MarshalText ();if _fbb !=nil {return "",_fbb ;};return string (_gda ),nil ;};
// PageSize is the enum used for defining the page size.
type PageSize int ;
// ValueType implements viper.FlagValue interface.
func (_baf Point )ValueType ()string {return _baf .Type ()};
// HasChanged implements viper.FlagValue interface.
func (_dcf *Point )HasChanged ()bool {return _dcf !=nil };
// PageSizeValues returns all values of the enum
func PageSizeValues ()[]PageSize {return _dgc };
// Name implements viper.FlagValue interface.
func (_ega Point )Name ()string {return "\u0070\u006f\u0069n\u0074"};func _cg (_edc string )(Millimeter ,error ){_edc =_g .TrimSpace (_g .TrimSuffix (_edc ,"\u006d\u006d"));_fed ,_dbf :=_e .ParseFloat (_edc ,64);if _dbf !=nil {return 0,_a .Errorf ("\u0069\u006e\u0076\u0061l\u0069\u0064\u0020\u006d\u0069\u006c\u006c\u0069\u006d\u0065t\u0065r\u0020\u0076\u0061\u006c\u0075\u0065\u003a \u0025\u0077",_dbf );
};return Millimeter (_fed ),nil ;};var _dgc =[]PageSize {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23};
// Point is a unit of Length commonly used to measure the height of fonts.
type Point float64 ;const (Undefined PageSize =iota ;A0 ;A1 ;A2 ;A3 ;A4 ;A5 ;A6 ;A7 ;A8 ;A9 ;A10 ;B0 ;B1 ;B2 ;B3 ;B4 ;B5 ;B6 ;B7 ;B8 ;B9 ;B10 ;Letter ;);
// Set sets the unit value.
// Implements pflag.Value interface.
func (_ee *LengthFlag )Set (s string )error {if s =="\u0075n\u0064\u0065\u0066\u0069\u006e\u0065d"{_ee .Length =nil ;return nil ;};_ca ,_ed :=UnmarshalLength (s );if _ed !=nil {return _ed ;};_ee .Length =_ca ;return nil ;};
// Inches gets the inches equivalent from provided millimeter value.
func (_bff Millimeter )Inches ()Inch {return Inch (float64 (_bff )*_bd )};var _ _c .Value =(*Orientation )(nil );
// Type implements pflag.Value interface.
func (_gdc Orientation )Type ()string {return "o\u0072\u0069\u0065\u006e\u0074\u0061\u0074\u0069\u006f\u006e";};
// String implements fmt.Stringer interface.
func (_gd Inch )String ()string {_ab :=_g .Builder {};_ab .WriteString (_e .FormatFloat (float64 (_gd ),'f',1,64));_ab .WriteString ("\u0069\u006e");return _ab .String ();};
// Set implements pflag.Value interface.
func (_bfa *PageSize )Set (s string )error {_fg ,_aa :=UnmarshalPageSize (s );if _aa !=nil {return _aa ;};*_bfa =_fg ;return nil ;};
// Set implements flag.Value interface.
func (_dbc *Orientation )Set (s string )error {switch s {case "\u0070\u006f\u0072\u0074\u0072\u0061\u0069\u0074":*_dbc =Portrait ;case "\u006ca\u006e\u0064\u0073\u0063\u0061\u0070e":*_dbc =Landscape ;default:return _a .Errorf ("\u0069n\u0076\u0061\u006c\u0069d\u0020\u006f\u0072\u0069\u0065n\u0074a\u0074i\u006f\u006e\u003a\u0020\u0027\u0025\u0073'",s );
};return nil ;};
// Length is it the default dimension unit.
type Length interface{Millimeters ()Millimeter ;Inches ()Inch ;Points ()Point ;String ()string ;};
// Points implements Length interface.
func (_bdf Inch )Points ()Point {return Point (float64 (_bdf )*_eg )};
// Type implements pflag.Value interface.
func (_af *LengthFlag )Type ()string {return "\u0075\u006e\u0069\u0074"};
// HasChanged implements pflag.Value interface.
func (_cba *Inch )HasChanged ()bool {return _cba !=nil };var (_ Length =Millimeter (0););
// UnmarshalJSON implements the json.Unmarshaler interface for PageSize
func (_ded *PageSize )UnmarshalJSON (data []byte )error {var _aab string ;if _abb :=_f .Unmarshal (data ,&_aab );_abb !=nil {return _a .Errorf ("P\u0061\u0067\u0065\u0053\u0069\u007ae\u0020\u0073\u0068\u006f\u0075\u006cd\u0020\u0062\u0065\u0020\u0061\u0020\u0073t\u0072\u0069\u006e\u0067\u002c\u0020\u0067\u006f\u0074\u0020%\u0073",data );
};var _afd error ;*_ded ,_afd =PageSizeString (_aab );return _afd ;};
// PageSizeString retrieves an enum value from the enum constants string name.
// Throws an error if the param is not part of the enum.
func PageSizeString (s string )(PageSize ,error ){if _bc ,_cac :=_ffe [s ];_cac {return _bc ,nil ;};return 0,_a .Errorf ("\u0025\u0073 \u0064\u006f\u0065\u0073 \u006e\u006ft\u0020\u0062\u0065\u006c\u006f\u006e\u0067\u0020t\u006f\u0020\u0050\u0061\u0067\u0065\u0053\u0069\u007a\u0065\u0020\u0076a\u006c\u0075\u0065\u0073",s );
};
// UnmarshalText implements the encoding.TextUnmarshaler interface for PageSize
func (_afdd *PageSize )UnmarshalText (text []byte )error {var _cdb error ;*_afdd ,_cdb =PageSizeString (string (text ));return _cdb ;};
// Millimeters converts the inches value to the millimeters.
func (_gc Inch )Millimeters ()Millimeter {return Millimeter (float64 (_gc )*_eb )};
// UnmarshalLength unmarshalls string value into Length.
func UnmarshalLength (length string )(Length ,error ){if _g .HasSuffix (length ,"\u006d\u006d"){return _cg (length );};if _g .HasSuffix (length ,"\u0069\u006e"){return _fb (length );};if _g .HasSuffix (length ,"\u0070\u0074"){return _feb (length );};return nil ,_a .Errorf ("\u0069n\u0076\u0061\u006c\u0069\u0064\u0020\u006c\u0065\u006e\u0067\u0074h\u0020\u0069\u006e\u0070\u0075\u0074\u003a\u0020\u0025\u0073",length );
};const (_bd =float64 (1)/float64 (25.4);_eb =25.4;_ga =0.0139;_d =0.3528;_eg =1/64;_de =1/_d ;);
// Set implements pflag.Value interface.
func (_bfe *Inch )Set (s string )error {_gge ,_db :=_e .ParseFloat (s ,64);if _db !=nil {return _a .Errorf ("\u0069\u006e\u0076\u0061li\u0064\u0020\u0069\u006e\u0063\u0068\u0020\u0076\u0061\u006c\u0075\u0065\u003a\u0020%\u0077",_db );};*_bfe =Inch (_gge );
return nil ;};
// MarshalText implements the encoding.TextMarshaler interface for PageSize
func (_cf PageSize )MarshalText ()([]byte ,error ){return []byte (_cf .String ()),nil };
// String implements fmt.Stringer interface.
func (_cb Millimeter )String ()string {_dc :=_g .Builder {};_dc .WriteString (_e .FormatFloat (float64 (_cb ),'f',1,64));_dc .WriteString ("\u006d\u006d");return _dc .String ();};
// Dimensions gets the dimensions of the given page size.
// If provided page size is not valid than the function returns 0 values.
func (_dg PageSize )Dimensions ()(_abg ,_edg Millimeter ){switch _dg {case A0 :return 841,1189;case A1 :return 594,841;case A2 :return 420,594;case A3 :return 297,420;case A4 :return 210,297;case A5 :return 148,210;case A6 :return 105,148;case A7 :return 74,105;
case A8 :return 52,74;case A9 :return 37,52;case A10 :return 26,37;case B0 :return 1000,1414;case B1 :return 707,1000;case B2 :return 500,707;case B3 :return 353,500;case B4 :return 250,353;case B5 :return 176,250;case B6 :return 125,176;case B7 :return 88,125;
case B8 :return 66,88;case B9 :return 44,62;case B10 :return 31,44;case Letter :return 215.9,279.4;};return _abg ,_edg ;};var _gag =[...]uint8 {0,9,11,13,15,17,19,21,23,25,27,29,32,34,36,38,40,42,44,46,48,50,52,55,61};
// Type implements pflag.Value interface.
func (_fdc PageSize )Type ()string {return "\u0070a\u0067\u0065\u002d\u0073\u0069\u007ae"};var _ _c .Value =(*Point )(nil );
// Inches gets the inch value. Implements Length interface.
func (_fef Point )Inches ()Inch {return Inch (float64 (_fef )*_ga )};
// Points implements Length interface.
func (_ge Millimeter )Points ()Point {return Point (_ge *_de )};func _feb (_geb string )(Point ,error ){_geb =_g .TrimSpace (_g .Trim (_geb ,"\u0070\u0074"));_bg ,_bda :=_e .ParseFloat (_geb ,64);if _bda !=nil {return 0,_bda ;};return Point (_bg ),nil ;
};
// String gets the string value for given flag.
func (_ff *LengthFlag )String ()string {if _ff .Length ==nil {return "\u0075n\u0064\u0065\u0066\u0069\u006e\u0065d";};return _ff .Length .String ();};const (Portrait =Orientation (false );Landscape =Orientation (true ););
// ValueType implements pflag.Value interface.
func (_be Inch )ValueType ()string {return _be .Type ()};
// LengthFlag is a pflag wrapper for the Length value.
type LengthFlag struct{Length Length ;};
// UnmarshalJSON implements the json.Unmarshaler interface for PageSize
func (_bce *PageSize )UnmarshalJSON (data []byte )error {var _eb string ;if _aad :=_ac .Unmarshal (data ,&_eb );_aad !=nil {return _c .Errorf ("P\u0061\u0067\u0065\u0053\u0069\u007ae\u0020\u0073\u0068\u006f\u0075\u006cd\u0020\u0062\u0065\u0020\u0061\u0020\u0073t\u0072\u0069\u006e\u0067\u002c\u0020\u0067\u006f\u0074\u0020%\u0073",data );
};var _fgce error ;*_bce ,_fgce =PageSizeString (_eb );return _fgce ;};
// Inches gets the inch value. Implements Length interface.
func (_fd Inch )Inches ()Inch {return _fd };
// Orientation is the page orientation type wrapper.
type Orientation bool ;
// String implements fmt.Stringer interface.
func (_ef Orientation )String ()string {if _ef ==Portrait {return "\u0070\u006f\u0072\u0074\u0072\u0061\u0069\u0074";};return "\u006ca\u006e\u0064\u0073\u0063\u0061\u0070e";};const _da ="U\u006e\u0064\u0065\u0066\u0069\u006e\u0065\u0064\u0041\u0030\u0041\u0031\u0041\u0032\u0041\u0033\u0041\u0034\u0041\u0035\u0041\u0036\u0041\u0037\u0041\u0038A\u0039A\u0031\u0030\u0042\u0030B\u0031\u00422\u0042\u0033\u0042\u0034\u0042\u0035\u0042\u0036\u0042\u0037\u0042\u0038\u0042\u0039\u0042\u0031\u0030\u004c\u0065\u0074\u0074\u0065\u0072";
// Name implements pflag.Value interface.
func (_cabb Inch )Name ()string {return "\u0069\u006e\u0063\u0068"};func (_ce PageSize )String ()string {if _ce < 0||_ce >=PageSize (len (_gag )-1){return _a .Sprintf ("\u0050\u0061\u0067e\u0053\u0069\u007a\u0065\u0028\u0025\u0064\u0029",_ce );};return _da [_gag [_ce ]:_gag [_ce +1]];
};
// String implements fmt.Stringer interface.
func (_dcb Point )String ()string {_ege :=_g .Builder {};_ege .WriteString (_e .FormatFloat (float64 (_dcb ),'f',1,64));_ege .WriteString ("\u0070\u0074");return _ege .String ();};

View File

@ -10,48 +10,43 @@
// terms that can be accessed at https://unidoc.io/eula/
// Package unihtml contains a plugin for the UniDoc.
package unihtml ;import (_ba "bytes";_b "context";_e "errors";_ca "fmt";_bab "github.com/unidoc/unihtml/client";_g "github.com/unidoc/unihtml/content";_fe "github.com/unidoc/unihtml/sizes";_bd "github.com/unidoc/unipdf/v3/common";_ee "github.com/unidoc/unipdf/v3/common/license";
_ef "github.com/unidoc/unipdf/v3/creator";_af "github.com/unidoc/unipdf/v3/model";_cf "github.com/unidoc/unipdf/v3/render";_fc "image";_c "image/color";_f "math";_db "net/url";_d "os";_dbe "time";);func (_fcf *Document )validate ()error {if _gb ==nil {return ErrNoClient ;
};if _fcf ._ea ==nil {return ErrContentNotDefined ;};return nil ;};func _fg (_baec _fc .Image )float64 {_gcc :=_baec .Bounds ();var (_gff int ;_df _c .Color ;_ebg ,_gcg ,_efbd uint32 ;);_bgd ,_bcc :=_gcc .Min .X ,_gcc .Max .Y -1;_bccf :=_baec .At (_bgd ,_bcc );
_bca ,_ab ,_gcf ,_ :=_bccf .RGBA ();_ggd :=_bca ==_f .MaxUint16 &&_ab ==_f .MaxUint16 &&_gcf ==_f .MaxUint16 ;for _bcc =_gcc .Max .Y -1;_bcc >=_gcc .Min .Y ;_bcc --{var _aec bool ;for _bgd =_gcc .Min .X ;_bgd < _gcc .Max .X ;_bgd ++{_df =_baec .At (_bgd ,_bcc );
_ebg ,_gcg ,_efbd ,_ =_df .RGBA ();if (_ggd &&!(_ebg ==_bca &&_gcg ==_ab &&_gcf ==_efbd ))||(!_ggd &&(_f .Abs (float64 (_ebg )-float64 (_bca ))/float64 (_f .MaxUint16 )> 0.03||_f .Abs (float64 (_gcg )-float64 (_ab ))/float64 (_f .MaxUint16 )> 0.03||_f .Abs (float64 (_efbd )-float64 (_gcf ))/float64 (_f .MaxUint16 )> 0.03)){_aec =true ;
break ;};};if _aec {break ;};_gff =_bcc ;};return float64 (_gcc .Max .Y -_gff )/float64 (_gcc .Max .Y );};func (_bed *Document )extract (_gda _b .Context ,_ecb ,_bee _fe .Length ,_aecc margins )([]*_af .PdfPage ,error ){_bcg :=_bab .BuildHTMLQuery ().SetContent (_bed ._ea ).PageSize (_bed ._cd ).PaperWidth (_ecb ).PaperHeight (_bee ).Orientation (_bed ._gd ).MarginLeft (_aecc .Left ).MarginRight (_aecc .Right ).MarginTop (_aecc .Top ).MarginBottom (_aecc .Bottom );
_fgb ,_gdc :=_bcg .Query ();if _gdc !=nil {return nil ,_gdc ;};_gda ,_ge :=_b .WithTimeout (_gda ,_dbe .Second *15);defer _ge ();_egfa ,_gdc :=_gb .ConvertHTML (_gda ,_fgb );if _gdc !=nil {return nil ,_gdc ;};_bbb :=_ba .NewReader (_egfa .Data );_aag ,_gdc :=_af .NewPdfReader (_bbb );
if _gdc !=nil {return nil ,_gdc ;};return _aag .PageList ,nil ;};
package unihtml ;import (_gf "bytes";_g "context";_dg "errors";_ba "fmt";_ea "github.com/unidoc/unihtml/client";_c "github.com/unidoc/unihtml/content";_gc "github.com/unidoc/unihtml/sizes";_ec "github.com/unidoc/unipdf/v3/common";_eab "github.com/unidoc/unipdf/v3/common/license";
_eac "github.com/unidoc/unipdf/v3/creator";_fb "github.com/unidoc/unipdf/v3/model";_be "github.com/unidoc/unipdf/v3/render";_bf "image";_a "image/color";_f "math";_d "net/url";_e "os";_fe "time";);
// ChapterDraw implements creator.containerElement interface.
func (_ega *Document )ContainerComponent (container _eac .Drawable )(_eac .Drawable ,error ){switch container .(type ){case *_eac .Chapter :default:return nil ,_ba .Errorf ("\u0075\u006e\u0069\u0068t\u006d\u006c\u002e\u0044\u006f\u0063\u0075\u006d\u0065n\u0074\u0020\u0063\u0061\u006e\u0027\u0074\u0020\u0062\u0065\u0020\u0061\u0020\u0063\u006f\u006d\u0070\u006fn\u0065\u006e\u0074\u0020\u006ff\u0020\u0074\u0068\u0065\u0020\u0025\u0054\u0020\u0063\u006f\u006e\u0074\u0061\u0069\u006e\u0065\u0072",container );
};return _ega ,nil ;};
// TrimLastPageContent trims the last page content so that next creator blocks are located just at the end of given block.
func (_gfe *Document )TrimLastPageContent (){_gfe ._ca =true };var ErrNoClient =_dg .New ("\u0055n\u0069\u0048\u0054\u004d\u004c\u0020\u0063\u006c\u0069\u0065\u006et\u0020\u006e\u006f\u0074\u0020\u0066\u006f\u0075\u006e\u0064");func (_faa *Document )validate ()error {if _ae ==nil {return ErrNoClient ;
};if _faa ._gfa ==nil {return ErrContentNotDefined ;};return nil ;};
// ConnectOptions creates UniHTML HTTP Client and tries to establish connection with the server.
func ConnectOptions (o Options )error {_gb =_bab .New (_bab .Options {Hostname :o .Hostname ,Port :o .Port ,HTTPS :o .Secure });_bg ,_gc :=_b .WithTimeout (_b .Background (),_dbe .Second *5);defer _gc ();if _cfg :=_gb .HealthCheck (_bg );_cfg !=nil {return _cfg ;
};return nil ;};func _cg ()error {_gbd :=_ee .GetLicenseKey ();if _gbd ==nil {return _e .New ("\u006e\u006f\u0020\u006cic\u0065\u006e\u0073\u0065\u0020\u0070\u0072\u006f\u0076\u0069\u0064\u0065\u0064");};if !_gbd .IsLicensed (){return _e .New ("\u0069\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u006f\u0072 \u006e\u006f\u0020\u006c\u0069\u0063\u0065n\u0073\u0065\u0020\u0070\u0072\u006f\u0076\u0069\u0064\u0065\u0064");
};if !_gbd .UniHTML {return _e .New ("\u0070\u0072\u006f\u0076\u0069\u0064\u0065\u0064\u0020l\u0069\u0063e\u006e\u0073\u0065\u0020\u0069\u0073 \u006e\u006f\u0074\u0020\u0076\u0061\u006c\u0069d\u0020\u0066\u006f\u0072\u0020\u0074\u0068\u0065\u0020U\u006e\u0069\u0048\u0054\u004d\u004c\u0020\u0065\u0078\u0074\u0065n\u0073\u0069\u006f\u006e.\u0020\u0056i\u0073i\u0074\u003a\u0020\u0068\u0074\u0074\u0070s\u003a/\u002f\u0077\u0077\u0077\u002e\u0075\u006e\u0069\u0064\u006f\u0063\u002e\u0069\u006f\u0020\u0061\u006ed\u0020c\u006f\u006e\u0074\u0061\u0063\u0074\u0020\u0073\u0075\u0070\u0070\u006f\u0072t");
};return nil ;};
// GetPdfPages is a function that converts provided input content and
func (_ff *Document )GetPdfPages (ctx _b .Context )([]*_af .PdfPage ,error ){if _dc :=_ff .validate ();_dc !=nil {return nil ,_dc ;};return _ff .extract (ctx ,_ff ._dbb ,_ff ._gcd ,_ff .getMargins ());};
// SetMarginLeft sets the left margin.
func (_dg *Document )SetMarginLeft (margin _fe .Length ){_dg ._cc .Left =margin };
func ConnectOptions (o Options )error {_ae =_ea .New (_ea .Options {Hostname :o .Hostname ,Port :o .Port ,HTTPS :o .Secure });_gcb ,_cg :=_g .WithTimeout (_g .Background (),_fe .Second *5);defer _cg ();if _baf :=_ae .HealthCheck (_gcb );_baf !=nil {return _baf ;
};return nil ;};var _ae *_ea .Client ;
// SetPageSize sets the page default size.
func (_bcb *Document )SetPageSize (pageSize _fe .PageSize )error {if !pageSize .IsAPageSize (){return _e .New ("\u0070\u0072\u006f\u0076\u0069\u0064\u0065\u0064\u0020\u0069\u006ev\u0061\u006c\u0069\u0064\u0020\u0070\u0061\u0067\u0065\u0020s\u0069\u007a\u0065");
};_bcb ._cd =pageSize ;_bcb ._cfb =_ef .PositionAbsolute ;return nil ;};
// SetLandscapeOrientation sets document landscape page orientation.
func (_dfg *Document )SetLandscapeOrientation (){_dfg ._gd =_fe .Landscape };type margins struct{Left ,Right ,Bottom ,Top _fe .Length ;};
// SetPageHeight sets the page height for given document.
func (_baa *Document )SetPageHeight (pageHeight _fe .Length )error {_baa ._gcd =pageHeight ;_baa ._cfb =_ef .PositionAbsolute ;return nil ;};var ErrNoClient =_e .New ("\u0055n\u0069\u0048\u0054\u004d\u004c\u0020\u0063\u006c\u0069\u0065\u006et\u0020\u006e\u006f\u0074\u0020\u0066\u006f\u0075\u006e\u0064");
func (_eca *Document )SetPageSize (pageSize _gc .PageSize )error {if !pageSize .IsAPageSize (){return _dg .New ("\u0070\u0072\u006f\u0076\u0069\u0064\u0065\u0064\u0020\u0069\u006ev\u0061\u006c\u0069\u0064\u0020\u0070\u0061\u0067\u0065\u0020s\u0069\u007a\u0065");
};_eca ._dga =pageSize ;_eca ._ac =_eac .PositionAbsolute ;return nil ;};
// SetMargins sets the Document Margins.
func (_dd *Document )SetMargins (left ,right ,top ,bottom float64 ){_dd ._cc .Left =_fe .Point (left );_dd ._cc .Right =_fe .Point (right );_dd ._cc .Top =_fe .Point (top );_dd ._cc .Bottom =_fe .Point (bottom );_dd ._cfb =_ef .PositionAbsolute ;};
func (_daa *Document )SetMargins (left ,right ,top ,bottom float64 ){_daa ._ab .Left =_gc .Point (left );_daa ._ab .Right =_gc .Point (right );_daa ._ab .Top =_gc .Point (top );_daa ._ab .Bottom =_gc .Point (bottom );_daa ._ac =_eac .PositionAbsolute ;
};
// Document is HTML document wrapper that is used for extracting and converting HTML document into PDF pages.
type Document struct{_ea _g .Content ;_cc margins ;_cfb _ef .Positioning ;_eg ,_fb float64 ;_cd _fe .PageSize ;_dbb ,_gcd _fe .Length ;_gd _fe .Orientation ;_eb bool ;};var _gb *_bab .Client ;
// SetPageWidth sets the page width for given document.
func (_ede *Document )SetPageWidth (pageWidth _gc .Length )error {_ede ._ead =pageWidth ;_ede ._ac =_eac .PositionAbsolute ;return nil ;};
// SetMarginRight sets the left margin.
func (_ded *Document )SetMarginRight (margin _fe .Length ){_ded ._cc .Right =margin };func (_cfa *Document )getMargins ()margins {_afa :=_cfa ._cc ;if _cfa ._cfb .IsRelative (){_afa .Top =_fe .Millimeter (1);_afa .Left =_fe .Millimeter (1);_afa .Bottom =_fe .Millimeter (1);
_afa .Right =_fe .Millimeter (1);return _afa ;};if _afa .Top ==nil {_afa .Top =_fe .Millimeter (10);};if _afa .Bottom ==nil {_afa .Bottom =_fe .Millimeter (10);};if _afa .Left ==nil {_afa .Left =_fe .Millimeter (10);};if _afa .Right ==nil {_afa .Right =_fe .Millimeter (10);
};return _afa ;};
func (_ga *Document )SetMarginRight (margin _gc .Length ){_ga ._ab .Right =margin };func (_egc *Document )getMargins ()margins {_aec :=_egc ._ab ;if _egc ._ac .IsRelative (){_aec .Top =_gc .Millimeter (1);_aec .Left =_gc .Millimeter (1);_aec .Bottom =_gc .Millimeter (1);
_aec .Right =_gc .Millimeter (1);return _aec ;};if _aec .Top ==nil {_aec .Top =_gc .Millimeter (10);};if _aec .Bottom ==nil {_aec .Bottom =_gc .Millimeter (10);};if _aec .Left ==nil {_aec .Left =_gc .Millimeter (10);};if _aec .Right ==nil {_aec .Right =_gc .Millimeter (10);
};return _aec ;};
// Document is HTML document wrapper that is used for extracting and converting HTML document into PDF pages.
type Document struct{_gfa _c .Content ;_ab margins ;_ac _eac .Positioning ;_ebc ,_fa float64 ;_dga _gc .PageSize ;_ead ,_ggg _gc .Length ;_bba _gc .Orientation ;_ca bool ;};func _bb ()error {_dd :=_eab .GetLicenseKey ();if _dd ==nil {return _dg .New ("\u006e\u006f\u0020\u006cic\u0065\u006e\u0073\u0065\u0020\u0070\u0072\u006f\u0076\u0069\u0064\u0065\u0064");
};if !_dd .IsLicensed (){return _dg .New ("\u0069\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u006f\u0072 \u006e\u006f\u0020\u006c\u0069\u0063\u0065n\u0073\u0065\u0020\u0070\u0072\u006f\u0076\u0069\u0064\u0065\u0064");};return nil ;};
// GetPdfPages is a function that converts provided input content and
func (_ff *Document )GetPdfPages (ctx _g .Context )([]*_fb .PdfPage ,error ){if _bd :=_ff .validate ();_bd !=nil {return nil ,_bd ;};return _ff .extract (ctx ,_ff ._ead ,_ff ._ggg ,_ff .getMargins ());};
// Options are the HTML Client options used for establishing the connection.
type Options struct{
@ -68,40 +63,44 @@ Secure bool ;
// Prefix is an option setting used when the server is working with the URI prefix. Default Value: ''.
Prefix string ;};
// SetPos sets the absolute position. Changes object positioning to absolute.
func (_aeb *Document )SetPos (x ,y float64 ){_aeb ._cfb =_ef .PositionAbsolute ;_aeb ._eg =x ;_aeb ._fb =y ;};
// SetLandscapeOrientation sets document landscape page orientation.
func (_abg *Document )SetLandscapeOrientation (){_abg ._bba =_gc .Landscape };type margins struct{Left ,Right ,Bottom ,Top _gc .Length ;};var ErrContentNotDefined =_dg .New ("\u0068\u0074\u006d\u006c\u0020\u0064o\u0063\u0075\u006d\u0065\u006e\u0074\u0020\u0063\u006f\u006e\u0074\u0065\u006et\u0020\u006e\u006f\u0074\u0020\u0064\u0065f\u0069\u006e\u0065\u0064");
// SetMarginTop sets the left margin.
func (_fdg *Document )SetMarginTop (margin _fe .Length ){_fdg ._cc .Top =margin };
// SetPageWidth sets the page width for given document.
func (_bf *Document )SetPageWidth (pageWidth _fe .Length )error {_bf ._dbb =pageWidth ;_bf ._cfb =_ef .PositionAbsolute ;return nil ;};
// Connect creates UniHTML HTTP Client and tries to establish connection with the server.
func Connect (path string )error {if _caa :=_cg ();_caa !=nil {return _caa ;};_bac ,_ae :=_bab .ParseOptions (path );if _ae !=nil {return _ae ;};_gb =_bab .New (_bac );_be ,_bad :=_b .WithTimeout (_b .Background (),_dbe .Second *5);defer _bad ();if _efb :=_gb .HealthCheck (_be );
_efb !=nil {return _efb ;};return nil ;};
func (_fbg *Document )SetMarginTop (margin _gc .Length ){_fbg ._ab .Top =margin };func _ge (_eg _bf .Image )float64 {_fae :=_eg .Bounds ();var (_gce int ;_fac _a .Color ;_edb ,_fcd ,_eacb uint32 ;);_af ,_dff :=_fae .Min .X ,_fae .Max .Y -1;_dfb :=_eg .At (_af ,_dff );
_bbd ,_egd ,_fbca ,_ :=_dfb .RGBA ();_ad :=_bbd ==_f .MaxUint16 &&_egd ==_f .MaxUint16 &&_fbca ==_f .MaxUint16 ;for _dff =_fae .Max .Y -1;_dff >=_fae .Min .Y ;_dff --{var _fca bool ;for _af =_fae .Min .X ;_af < _fae .Max .X ;_af ++{_fac =_eg .At (_af ,_dff );
_edb ,_fcd ,_eacb ,_ =_fac .RGBA ();if (_ad &&!(_edb ==_bbd &&_fcd ==_egd &&_fbca ==_eacb ))||(!_ad &&(_f .Abs (float64 (_edb )-float64 (_bbd ))/float64 (_f .MaxUint16 )> 0.03||_f .Abs (float64 (_fcd )-float64 (_egd ))/float64 (_f .MaxUint16 )> 0.03||_f .Abs (float64 (_eacb )-float64 (_fbca ))/float64 (_f .MaxUint16 )> 0.03)){_fca =true ;
break ;};};if _fca {break ;};_gce =_dff ;};return float64 (_fae .Max .Y -_gce )/float64 (_fae .Max .Y );};var _ _eac .Drawable =(*Document )(nil );
// GeneratePageBlocks implements creator.Drawable interface.
func (_bb *Document )GeneratePageBlocks (ctx _ef .DrawContext )([]*_ef .Block ,_ef .DrawContext ,error ){if _beca :=_bb .validate ();_beca !=nil {return nil ,ctx ,_beca ;};var _ac []*_ef .Block ;_dcg :=_bb .getMargins ();_ebd ,_aca :=_bb ._dbb ,_bb ._gcd ;
if _bb ._cfb .IsRelative (){_ebd ,_aca =_fe .Point (ctx .Width ),_fe .Point (ctx .Height );ctx .X -=float64 (_dcg .Left .Points ());};_beb ,_bc :=_bb .extract (_b .Background (),_ebd ,_aca ,_dcg );if _bc !=nil {return nil ,_ef .DrawContext {},_bc ;};for _ffg ,_fd :=range _beb {_bae ,_gf :=_ef .NewBlockFromPage (_fd );
if _gf !=nil {return nil ,_ef .DrawContext {},_gf ;};var _ebc float64 ;if _bb ._eb &&_ffg ==len (_beb )-1{_gba :=_cf .NewImageDevice ();_fff ,_cgb :=_gba .Render (_fd );if _cgb !=nil {return nil ,_ef .DrawContext {},_cgb ;};_egf ,_cgb :=_fd .GetMediaBox ();
if _cgb !=nil {return nil ,_ef .DrawContext {},_cgb ;};_aa :=_dbe .Now ();_gg :=_fg (_fff );_ebc =_egf .Height ()*_gg ;_bd .Log .Trace ("\u0054\u0072i\u006d\u006d\u0069\u006eg\u0020\u006ca\u0073\u0074\u0020\u0064\u006f\u0063\u0075\u006de\u006e\u0074\u0020\u0070\u0061\u0067\u0065\u0020\u0074\u0061\u006b\u0065n\u003a\u0020\u0025\u0076",_dbe .Since (_aa ));
if _bb ._cc .Bottom !=nil {_ebc -=float64 (_bb ._cc .Bottom .Points ());};if _ebc < 0{_ebc =0;};_bd .Log .Trace ("C\u0072\u006f\u0070\u0070\u0069\u006e\u0067\u0020\u0064\u006f\u0063\u0075\u006d\u0065\u006e\u0074\u0027\u0073\u0020\u0070\u0061\u0067\u0065\u0020\u0025\u002e2\u0066 \u0070\u006f\u0069\u006et\u0073\u0020o\u0066\u0066\u0020\u0062\u006f\u0074\u0074\u006f\u006d\u0020\u006f\u0066\u0020\u006d\u0065\u0064\u0069\u0061\u0020\u0062\u006f\u0078\u000a",_ebc );
};_adf ,_fcc ,_gf :=_bae .GeneratePageBlocks (ctx );if _gf !=nil {return nil ,_ef .DrawContext {},_gf ;};ctx =_fcc ;ctx .Y -=_ebc ;if _ffg !=len (_beb )-1&&ctx .Y > (ctx .PageHeight -ctx .Margins .Bottom )*.95{ctx .X =ctx .Margins .Left ;ctx .Y =ctx .Margins .Top ;
ctx .Page ++;};_ac =append (_ac ,_adf ...);};return _ac ,ctx ,nil ;};var ErrContentNotDefined =_e .New ("\u0068\u0074\u006d\u006c\u0020\u0064o\u0063\u0075\u006d\u0065\u006e\u0074\u0020\u0063\u006f\u006e\u0074\u0065\u006et\u0020\u006e\u006f\u0074\u0020\u0064\u0065f\u0069\u006e\u0065\u0064");
func (_fbc *Document )GeneratePageBlocks (ctx _eac .DrawContext )([]*_eac .Block ,_eac .DrawContext ,error ){if _db :=_fbc .validate ();_db !=nil {return nil ,ctx ,_db ;};var _dad []*_eac .Block ;_aed :=_fbc .getMargins ();_fee ,_cad :=_fbc ._ead ,_fbc ._ggg ;
if _fbc ._ac .IsRelative (){_fee ,_cad =_gc .Point (ctx .Width ),_gc .Point (ctx .Height );ctx .X -=float64 (_aed .Left .Points ());};_ggf ,_bde :=_fbc .extract (_g .Background (),_fee ,_cad ,_aed );if _bde !=nil {return nil ,_eac .DrawContext {},_bde ;
};for _df ,_ebb :=range _ggf {_fba ,_fec :=_eac .NewBlockFromPage (_ebb );if _fec !=nil {return nil ,_eac .DrawContext {},_fec ;};var _fd float64 ;if _fbc ._ca &&_df ==len (_ggf )-1{_caf :=_be .NewImageDevice ();_fab ,_fdb :=_caf .Render (_ebb );if _fdb !=nil {return nil ,_eac .DrawContext {},_fdb ;
};_dc ,_fdb :=_ebb .GetMediaBox ();if _fdb !=nil {return nil ,_eac .DrawContext {},_fdb ;};_dgf :=_fe .Now ();_cgd :=_ge (_fab );_fd =_dc .Height ()*_cgd ;_ec .Log .Trace ("\u0054\u0072i\u006d\u006d\u0069\u006eg\u0020\u006ca\u0073\u0074\u0020\u0064\u006f\u0063\u0075\u006de\u006e\u0074\u0020\u0070\u0061\u0067\u0065\u0020\u0074\u0061\u006b\u0065n\u003a\u0020\u0025\u0076",_fe .Since (_dgf ));
if _fbc ._ab .Bottom !=nil {_fd -=float64 (_fbc ._ab .Bottom .Points ());};if _fd < 0{_fd =0;};_ec .Log .Trace ("C\u0072\u006f\u0070\u0070\u0069\u006e\u0067\u0020\u0064\u006f\u0063\u0075\u006d\u0065\u006e\u0074\u0027\u0073\u0020\u0070\u0061\u0067\u0065\u0020\u0025\u002e2\u0066 \u0070\u006f\u0069\u006et\u0073\u0020o\u0066\u0066\u0020\u0062\u006f\u0074\u0074\u006f\u006d\u0020\u006f\u0066\u0020\u006d\u0065\u0064\u0069\u0061\u0020\u0062\u006f\u0078\u000a",_fd );
};_fbab ,_gfef ,_fec :=_fba .GeneratePageBlocks (ctx );if _fec !=nil {return nil ,_eac .DrawContext {},_fec ;};ctx =_gfef ;ctx .Y -=_fd ;if _df !=len (_ggf )-1&&ctx .Y > (ctx .PageHeight -ctx .Margins .Bottom )*.95{ctx .X =ctx .Margins .Left ;ctx .Y =ctx .Margins .Top ;
ctx .Page ++;};_dad =append (_dad ,_fbab ...);};return _dad ,ctx ,nil ;};
// TrimLastPageContent trims the last page content so that next creator blocks are located just at the end of given block.
func (_egg *Document )TrimLastPageContent (){_egg ._eb =true };
// SetMarginBottom sets the left margin.
func (_ace *Document )SetMarginBottom (margin _fe .Length ){_ace ._cc .Bottom =margin };var _ _ef .Drawable =(*Document )(nil );
// SetPageHeight sets the page height for given document.
func (_cf *Document )SetPageHeight (pageHeight _gc .Length )error {_cf ._ggg =pageHeight ;_cf ._ac =_eac .PositionAbsolute ;return nil ;};
// NewDocument creates new HTML Document used as an input for the creator.Drawable.
func NewDocument (path string )(*Document ,error ){_eaa :=&Document {};_bec ,_aed :=_db .Parse (path );if _aed !=nil {return nil ,_aed ;};switch _bec .Scheme {case "\u0068\u0074\u0074\u0070","\u0068\u0074\u0074p\u0073":_eaa ._ea ,_aed =_g .NewWebURL (path );
if _aed !=nil {return nil ,_aed ;};return _eaa ,nil ;};_ec ,_aed :=_d .Stat (path );if _aed !=nil {return nil ,_aed ;};if !_ec .IsDir (){_eaa ._ea ,_aed =_g .NewHTMLFile (path );}else {_eaa ._ea ,_aed =_g .NewZipDirectory (path );};if _aed !=nil {return nil ,_aed ;
};return _eaa ,nil ;};
func NewDocument (path string )(*Document ,error ){_cc :=&Document {};_ccc ,_eag :=_d .Parse (path );if _eag !=nil {return nil ,_eag ;};switch _ccc .Scheme {case "\u0068\u0074\u0074\u0070","\u0068\u0074\u0074p\u0073":_cc ._gfa ,_eag =_c .NewWebURL (path );
if _eag !=nil {return nil ,_eag ;};return _cc ,nil ;};_ed ,_eag :=_e .Stat (path );if _eag !=nil {return nil ,_eag ;};if !_ed .IsDir (){_cc ._gfa ,_eag =_c .NewHTMLFile (path );}else {_cc ._gfa ,_eag =_c .NewZipDirectory (path );};if _eag !=nil {return nil ,_eag ;
};return _cc ,nil ;};
// ChapterDraw implements creator.containerElement interface.
func (_dce *Document )ContainerComponent (container _ef .Drawable )(_ef .Drawable ,error ){switch container .(type ){case *_ef .Chapter :default:return nil ,_ca .Errorf ("\u0075\u006e\u0069\u0068t\u006d\u006c\u002e\u0044\u006f\u0063\u0075\u006d\u0065n\u0074\u0020\u0063\u0061\u006e\u0027\u0074\u0020\u0062\u0065\u0020\u0061\u0020\u0063\u006f\u006d\u0070\u006fn\u0065\u006e\u0074\u0020\u006ff\u0020\u0074\u0068\u0065\u0020\u0025\u0054\u0020\u0063\u006f\u006e\u0074\u0061\u0069\u006e\u0065\u0072",container );
};return _dce ,nil ;};
// SetMarginLeft sets the left margin.
func (_ggc *Document )SetMarginLeft (margin _gc .Length ){_ggc ._ab .Left =margin };
// Connect creates UniHTML HTTP Client and tries to establish connection with the server.
func Connect (path string )error {if _eb :=_bb ();_eb !=nil {return _eb ;};_gg ,_ee :=_ea .ParseOptions (path );if _ee !=nil {return _ee ;};_ae =_ea .New (_gg );_da ,_de :=_g .WithTimeout (_g .Background (),_fe .Second *5);defer _de ();if _fc :=_ae .HealthCheck (_da );
_fc !=nil {return _fc ;};return nil ;};
// SetMarginBottom sets the left margin.
func (_faf *Document )SetMarginBottom (margin _gc .Length ){_faf ._ab .Bottom =margin };func (_dffa *Document )extract (_feg _g .Context ,_dba ,_feb _gc .Length ,_eae margins )([]*_fb .PdfPage ,error ){_cgb :=_ea .BuildHTMLQuery ().SetContent (_dffa ._gfa ).PageSize (_dffa ._dga ).PaperWidth (_dba ).PaperHeight (_feb ).Orientation (_dffa ._bba ).MarginLeft (_eae .Left ).MarginRight (_eae .Right ).MarginTop (_eae .Top ).MarginBottom (_eae .Bottom );
_ggga ,_bfc :=_cgb .Query ();if _bfc !=nil {return nil ,_bfc ;};_feg ,_ag :=_g .WithTimeout (_feg ,_fe .Second *15);defer _ag ();_gcbf ,_bfc :=_ae .ConvertHTML (_feg ,_ggga );if _bfc !=nil {return nil ,_bfc ;};_ded :=_gf .NewReader (_gcbf .Data );_fg ,_bfc :=_fb .NewPdfReader (_ded );
if _bfc !=nil {return nil ,_bfc ;};return _fg .PageList ,nil ;};
// SetPos sets the absolute position. Changes object positioning to absolute.
func (_beb *Document )SetPos (x ,y float64 ){_beb ._ac =_eac .PositionAbsolute ;_beb ._ebc =x ;_beb ._fa =y ;};