diff --git a/cli/cmd/cmd.go b/cli/cmd/cmd.go index 69a2e56..ebfca2f 100644 --- a/cli/cmd/cmd.go +++ b/cli/cmd/cmd.go @@ -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 (_b "context";_d "fmt";_ge "github.com/mitchellh/go-homedir";_ff "github.com/spf13/cobra";_da "github.com/spf13/viper";_eg "github.com/unidoc/unihtml/client";_ec "github.com/unidoc/unihtml/content";_egf "github.com/unidoc/unihtml/sizes"; -_a "github.com/unidoc/unipdf/v3/common";_c "os";_g "path/filepath";_f "time";);type generateConfig struct{Port int `mapstructure:"port"`;Host string `mapstructure:"host"`;Https bool `mapstructure:"https"`;Prefix string `mapstructure:"prefix"`;};type parametersConfig struct{ +package cmd ;import (_cg "context";_e "fmt";_da "github.com/mitchellh/go-homedir";_b "github.com/spf13/cobra";_db "github.com/spf13/viper";_eb "github.com/unidoc/unihtml/client";_ce "github.com/unidoc/unihtml/content";_dg "github.com/unidoc/unihtml/sizes"; +_ee "github.com/unidoc/unipdf/v3/common";_de "os";_a "path/filepath";_d "time";); + +// 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 _dae :=_fea .Execute ();_dae !=nil {_e .Println (_dae );_de .Exit (1);};};var _fea =&_b .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"}; +func _df (){_eef :=_ee .LogLevelInfo ;if _ad {_eef =_ee .LogLevelDebug ;};if _cd {_eef =_ee .LogLevelTrace ;};_ee .Log =_ee .NewConsoleLogger (_eef );};var _ba string ;func init (){_fea .AddCommand (_g );_g .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"); +_g .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"); +_g .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"); +_g .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"); +_g .Flags ().Var (&_dc .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");_g .Flags ().Var (&_dc .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"); +_g .Flags ().Var (&_dc .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");_g .Flags ().Var (&_dc .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"); +_g .Flags ().Var (&_dc .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");_g .Flags ().Var (&_dc .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"); +_g .Flags ().Var (&_dc .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");_g .Flags ().Var (&_dc .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"); +};type generateConfig struct{Port int `mapstructure:"port"`;Host string `mapstructure:"host"`;Https bool `mapstructure:"https"`;Prefix string `mapstructure:"prefix"`;};var _g =&_b .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 :_gc ,Args :_b .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"}; +type parametersConfig struct{ // PaperWidth sets the width of the paper. -PaperWidth _egf .LengthFlag `mapstructure:"paper-width"`; +PaperWidth _dg .LengthFlag `mapstructure:"paper-width"`; // PaperHeight is the height of the output paper. -PaperHeight _egf .LengthFlag `mapstructure:"paper-height"`; +PaperHeight _dg .LengthFlag `mapstructure:"paper-height"`; // PageSize is the page size string. -PageSize _egf .PageSize `mapstructure:"page-size"`; +PageSize _dg .PageSize `mapstructure:"page-size"`; // Orientation defines if the output should be in a landscape format. -Orientation _egf .Orientation `mapstructure:"orientation"`; +Orientation _dg .Orientation `mapstructure:"orientation"`; // MarginTop sets up the Top Margin for the output. -MarginTop _egf .LengthFlag `mapstructure:"margin-top"`; +MarginTop _dg .LengthFlag `mapstructure:"margin-top"`; // MarginBottom sets up the Bottom Margin for the output. -MarginBottom _egf .LengthFlag `mapstructure:"margin-bottom"`; +MarginBottom _dg .LengthFlag `mapstructure:"margin-bottom"`; // MarginLeft sets up the Left Margin for the output. -MarginLeft _egf .LengthFlag `mapstructure:"margin-left"`; +MarginLeft _dg .LengthFlag `mapstructure:"margin-left"`; // MarginRight sets up the Right Margin for the output. -MarginRight _egf .LengthFlag `mapstructure:"margin-right"`;};func _ae (){_ac :=_a .LogLevelInfo ;if _ab {_ac =_a .LogLevelDebug ;};if _bc {_ac =_a .LogLevelTrace ;};_a .Log =_a .NewConsoleLogger (_ac );};var _dg =&_ff .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 :_cd ,Args :_ff .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 (){_ba .AddCommand (_dg );_dg .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");_dg .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"); -_dg .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"); -_dg .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"); -_dg .Flags ().Var (&_gd .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");_dg .Flags ().Var (&_gd .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"); -_dg .Flags ().Var (&_gd .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");_dg .Flags ().Var (&_gd .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"); -_dg .Flags ().Var (&_gd .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");_dg .Flags ().Var (&_gd .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"); -_dg .Flags ().Var (&_gd .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");_dg .Flags ().Var (&_gd .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 _cd (cmd *_ff .Command ,_ce []string ){_bd :=_f .Now ();if _fb :=_da .BindPFlags (cmd .Flags ());_fb !=nil {_d .Printf ("\u0045\u0072\u0072\u003a\u0020\u0025\u0076\u000a",_fb );_c .Exit (1);};if _dc :=_da .Unmarshal (&_gf );_dc !=nil {_d .Printf ("\u0045\u0072\u0072\u003a\u0020\u0025\u0076\u000a",_dc ); -_c .Exit (1);};_ae ();_ca ,_cdg :=_c .Stat (_ce [0]);if _cdg !=nil {_d .Printf ("\u0045\u0072\u0072\u003a\u0020\u0025\u0076\u000a",_cdg );_c .Exit (1);};if !_ca .IsDir (){if _g .Ext (_ca .Name ())!="\u002e\u0068\u0074m\u006c"{_d .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",_ce [0]); -_c .Exit (1);};};_cad ,_cdg :=_c .OpenFile (_ce [1],_c .O_CREATE |_c .O_WRONLY |_c .O_TRUNC ,0700);if _cdg !=nil {_d .Printf ("\u0045\u0072\u0072\u003a\u0020\u0025\u0076\u000a",_cdg );_c .Exit (1);};defer _cad .Close ();_ea :=_eg .New (_eg .Options {HTTPS :_gf .Https ,Hostname :_gf .Host ,Port :_gf .Port ,Prefix :_gf .Prefix }); -_bb ,_af :=_b .WithTimeout (_b .Background (),_f .Second *10);defer _af ();_gb :=_f .Now ();var _gbd _ec .Content ;if _ca .IsDir (){_gbd ,_cdg =_ec .NewZipDirectory (_ce [0]);}else {_gbd ,_cdg =_ec .NewHTMLFile (_ce [0]);};if _cdg !=nil {_d .Printf ("\u0045r\u0072\u003a\u0020\u0025\u0076",_cdg ); -_c .Exit (1);};_db ,_cdg :=_eg .BuildHTMLQuery ().PaperWidth (_gd .PaperWidth .Length ).PaperHeight (_gd .PaperHeight .Length ).PageSize (_gd .PageSize ).MarginTop (_gd .MarginTop .Length ).MarginBottom (_gd .MarginBottom .Length ).MarginLeft (_gd .MarginLeft .Length ).MarginRight (_gd .MarginRight .Length ).Orientation (_gd .Orientation ).SetContent (_gbd ).Query (); -if _cdg !=nil {_d .Printf ("\u0045\u0072\u0072\u003a\u0020\u0025\u0076\u000a",_cdg );_c .Exit (1);};_be ,_cdg :=_ea .ConvertHTML (_bb ,_db );if _cdg !=nil {_d .Printf ("\u0045\u0072\u0072\u003a\u0020\u0025\u0076\u000a",_cdg );_c .Exit (1);};_a .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 (_gb )); -_gb =_f .Now ();_ ,_cdg =_cad .Write (_be .Data );if _cdg !=nil {_d .Printf ("\u0045\u0072\u0072\u003a\u0020\u0025\u0076\u000a",_cdg );_c .Exit (1);};_a .Log .Trace ("\u0057\u0072\u0069\u0074in\u0067\u0020\u0066\u0069\u006c\u0065\u0020\u0074\u0061\u006b\u0065\u006e\u003a\u0020%\u0073",_f .Since (_gb )); -_d .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 (_bd ));};var (_gf =generateConfig {};_gd =parametersConfig {PaperWidth :_egf .LengthFlag {Length :_egf .Inch (8.5).Millimeters ()},PaperHeight :_egf .LengthFlag {Length :_egf .Inch (11).Millimeters ()},Orientation :_egf .Portrait ,MarginTop :_egf .LengthFlag {Length :_egf .Millimeter (10)},MarginBottom :_egf .LengthFlag {Length :_egf .Millimeter (10)},MarginLeft :_egf .LengthFlag {Length :_egf .Millimeter (10)},MarginRight :_egf .LengthFlag {Length :_egf .Millimeter (10)}}; -);var (_ab ,_bc bool ;); - -// 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 _bde :=_ba .Execute ();_bde !=nil {_d .Println (_bde );_c .Exit (1);};};var _cb string ;func init (){_ff .OnInitialize (_gg );_ba .PersistentFlags ().BoolVarP (&_ab ,"\u0064\u0065\u0062u\u0067","\u0064",false ,"\u0044e\u0066i\u006e\u0065\u0073\u0020\u0064e\u0062\u0075g\u0020\u006d\u006f\u0064\u0065"); -_ba .PersistentFlags ().BoolVarP (&_bc ,"\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"); -_ba .PersistentFlags ().StringVar (&_cb ,"\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"); -_ba .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");};func _gg (){if _cb !=""{_da .SetConfigFile (_cb ); -}else {_aa ,_ad :=_ge .Dir ();if _ad !=nil {_d .Println (_ad );_c .Exit (1);};_da .AddConfigPath (_aa );_da .SetConfigName ("\u002e\u0075\u006ei\u0068\u0074\u006d\u006c\u002d\u0073\u0072\u0063");};_da .AutomaticEnv ();if _eb :=_da .ReadInConfig ();_eb ==nil {_d .Println ("\u0055s\u0069n\u0067\u0020\u0063\u006f\u006ef\u0069\u0067 \u0066\u0069\u006c\u0065\u003a",_da .ConfigFileUsed ()); -};};var _ba =&_ff .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 _dg .LengthFlag `mapstructure:"margin-right"`;};var (_ad ,_cd bool ;);var (_f =generateConfig {};_dc =parametersConfig {PaperWidth :_dg .LengthFlag {Length :_dg .Inch (8.5).Millimeters ()},PaperHeight :_dg .LengthFlag {Length :_dg .Inch (11).Millimeters ()},Orientation :_dg .Portrait ,MarginTop :_dg .LengthFlag {Length :_dg .Millimeter (10)},MarginBottom :_dg .LengthFlag {Length :_dg .Millimeter (10)},MarginLeft :_dg .LengthFlag {Length :_dg .Millimeter (10)},MarginRight :_dg .LengthFlag {Length :_dg .Millimeter (10)}}; +);func init (){_b .OnInitialize (_fa );_fea .PersistentFlags ().BoolVarP (&_ad ,"\u0064\u0065\u0062u\u0067","\u0064",false ,"\u0044e\u0066i\u006e\u0065\u0073\u0020\u0064e\u0062\u0075g\u0020\u006d\u006f\u0064\u0065");_fea .PersistentFlags ().BoolVarP (&_cd ,"\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"); +_fea .PersistentFlags ().StringVar (&_ba ,"\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"); +_fea .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");};func _fa (){if _ba !=""{_db .SetConfigFile (_ba ); +}else {_baf ,_dd :=_da .Dir ();if _dd !=nil {_e .Println (_dd );_de .Exit (1);};_db .AddConfigPath (_baf );_db .SetConfigName ("\u002e\u0075\u006ei\u0068\u0074\u006d\u006c\u002d\u0073\u0072\u0063");};_db .AutomaticEnv ();if _bgc :=_db .ReadInConfig (); +_bgc ==nil {_e .Println ("\u0055s\u0069n\u0067\u0020\u0063\u006f\u006ef\u0069\u0067 \u0066\u0069\u006c\u0065\u003a",_db .ConfigFileUsed ());};};func _gc (cmd *_b .Command ,_be []string ){_bc :=_d .Now ();if _ag :=_db .BindPFlags (cmd .Flags ());_ag !=nil {_e .Printf ("\u0045\u0072\u0072\u003a\u0020\u0025\u0076\u000a",_ag ); +_de .Exit (1);};if _fe :=_db .Unmarshal (&_f );_fe !=nil {_e .Printf ("\u0045\u0072\u0072\u003a\u0020\u0025\u0076\u000a",_fe );_de .Exit (1);};_df ();_agb ,_bg :=_de .Stat (_be [0]);if _bg !=nil {_e .Printf ("\u0045\u0072\u0072\u003a\u0020\u0025\u0076\u000a",_bg ); +_de .Exit (1);};if !_agb .IsDir (){if _a .Ext (_agb .Name ())!="\u002e\u0068\u0074m\u006c"{_e .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",_be [0]); +_de .Exit (1);};};_fec ,_bg :=_de .OpenFile (_be [1],_de .O_CREATE |_de .O_WRONLY |_de .O_TRUNC ,0700);if _bg !=nil {_e .Printf ("\u0045\u0072\u0072\u003a\u0020\u0025\u0076\u000a",_bg );_de .Exit (1);};defer _fec .Close ();_gb :=_eb .New (_eb .Options {HTTPS :_f .Https ,Hostname :_f .Host ,Port :_f .Port ,Prefix :_f .Prefix }); +_bd ,_dcg :=_cg .WithTimeout (_cg .Background (),_d .Second *10);defer _dcg ();_bf :=_d .Now ();var _cb _ce .Content ;if _agb .IsDir (){_cb ,_bg =_ce .NewZipDirectory (_be [0]);}else {_cb ,_bg =_ce .NewHTMLFile (_be [0]);};if _bg !=nil {_e .Printf ("\u0045r\u0072\u003a\u0020\u0025\u0076",_bg ); +_de .Exit (1);};_dbb ,_bg :=_eb .BuildHTMLQuery ().PaperWidth (_dc .PaperWidth .Length ).PaperHeight (_dc .PaperHeight .Length ).PageSize (_dc .PageSize ).MarginTop (_dc .MarginTop .Length ).MarginBottom (_dc .MarginBottom .Length ).MarginLeft (_dc .MarginLeft .Length ).MarginRight (_dc .MarginRight .Length ).Orientation (_dc .Orientation ).SetContent (_cb ).Query (); +if _bg !=nil {_e .Printf ("\u0045\u0072\u0072\u003a\u0020\u0025\u0076\u000a",_bg );_de .Exit (1);};_eec ,_bg :=_gb .ConvertHTML (_bd ,_dbb );if _bg !=nil {_e .Printf ("\u0045\u0072\u0072\u003a\u0020\u0025\u0076\u000a",_bg );_de .Exit (1);};_ee .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",_d .Since (_bf )); +_bf =_d .Now ();_ ,_bg =_fec .Write (_eec .Data );if _bg !=nil {_e .Printf ("\u0045\u0072\u0072\u003a\u0020\u0025\u0076\u000a",_bg );_de .Exit (1);};_ee .Log .Trace ("\u0057\u0072\u0069\u0074in\u0067\u0020\u0066\u0069\u006c\u0065\u0020\u0074\u0061\u006b\u0065\u006e\u003a\u0020%\u0073",_d .Since (_bf )); +_e .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",_d .Since (_bc ));}; \ No newline at end of file diff --git a/cli/main.go b/cli/main.go index c33ee30..48b52ba 100644 --- a/cli/main.go +++ b/cli/main.go @@ -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 _e "github.com/unidoc/unihtml/cli/cmd";func main (){_e .Execute ()}; \ No newline at end of file +package main ;import _a "github.com/unidoc/unihtml/cli/cmd";func main (){_a .Execute ()}; \ No newline at end of file diff --git a/client/client.go b/client/client.go index 4223495..ddcf12e 100644 --- a/client/client.go +++ b/client/client.go @@ -11,202 +11,203 @@ // 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 (_db "bytes";_dac "compress/flate";_de "compress/gzip";_f "context";_da "encoding/json";_fe "errors";_dbc "fmt";_cd "github.com/unidoc/unihtml/content";_ga "github.com/unidoc/unihtml/selector";_gg "github.com/unidoc/unihtml/sizes"; -_aa "github.com/unidoc/unipdf/v3/common";_d "io";_df "net";_ab "net/http";_af "net/url";_g "strconv";_a "strings";_c "time";); +package client ;import (_a "bytes";_dd "compress/flate";_gb "compress/gzip";_g "context";_b "encoding/json";_d "errors";_ba "fmt";_bb "github.com/unidoc/unihtml/content";_be "github.com/unidoc/unihtml/selector";_f "github.com/unidoc/unihtml/sizes";_ag "github.com/unidoc/unipdf/v3/common"; +_ge "io";_gd "net";_eb "net/http";_bg "net/url";_e "strconv";_ac "strings";_bd "time";); -// ParseOptions parses options for the Client. -func ParseOptions (connectPath string )(Options ,error ){if !_a .HasPrefix (connectPath ,"\u0068\u0074\u0074\u0070"){connectPath ="\u0068t\u0074\u0070\u003a\u002f\u002f"+connectPath ;};_aag ,_b :=_af .Parse (connectPath );if _b !=nil {return Options {},_dbc .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 _fc int ;if _aag .Port ()!=""{_fc ,_b =_g .Atoi (_aag .Port ());if _b !=nil {return Options {},_dbc .Errorf ("\u0070\u0061\u0072si\u006e\u0067\u0020\u0070\u006f\u0072\u0074\u0020\u0066\u0061\u0069\u006c\u0065\u0064\u003a\u0020\u0025\u0077",_b );}; -};return Options {Hostname :_aag .Hostname (),Port :_fc ,HTTPS :_aag .Scheme =="\u0068\u0074\u0074p\u0073",Prefix :_aag .Path },nil ;}; +// WaitVisible waits for the selector to get visible. +func (_bfg *QueryBuilder )WaitVisible (selector string ,by _be .ByType )*QueryBuilder {_bfg ._fd .RenderParameters .WaitVisible =append (_bfg ._fd .RenderParameters .WaitVisible ,BySelector {Selector :selector ,By :by });return _bfg ;};var (ErrNotFound =_d .New ("\u006eo\u0074\u0020\u0066\u006f\u0075\u006ed"); +ErrBadRequest =_d .New ("b\u0061\u0064\u0020\u0072\u0065\u0071\u0075\u0065\u0073\u0074");ErrNotImplemented =_d .New ("\u006eo\u0074 \u0069\u006d\u0070\u006c\u0065\u006d\u0065\u006e\u0074\u0065\u0064");ErrInternalError =_d .New ("i\u006e\u0074\u0065\u0072na\u006c \u0073\u0065\u0072\u0076\u0065r\u0020\u0065\u0072\u0072\u006f\u0072"); +ErrBadGateway =_d .New ("b\u0061\u0064\u0020\u0067\u0061\u0074\u0065\u0077\u0061\u0079");ErrUnauthorized =_d .New ("\u0075\u006e\u0061u\u0074\u0068\u006f\u0072\u0069\u007a\u0065\u0064");ErrTimedOut =_d .New ("\u0072\u0065\u0071\u0075\u0065\u0073\u0074\u0020\u0074\u0069\u006d\u0065d\u0020\u006f\u0075\u0074"); +); // Query is a structure that contains query parameters and the content used for the HTMLConverter conversion process. -type Query struct{Content []byte ;ContentType string ;URL string ;Method string ;PageParameters PageParameters ;RenderParameters RenderParameters ;TimeoutDuration _c .Duration ;}; +type Query struct{Content []byte ;ContentType string ;URL string ;Method string ;PageParameters PageParameters ;RenderParameters RenderParameters ;TimeoutDuration _bd .Duration ;};func (_ec *Client )setQueryValues (_gbb *_eb .Request ,_eg *Query ){_cdg :=_gbb .URL .Query (); +_egc :=_eg .PageParameters ;if _egc .PageSize !=nil {_cdg .Set ("\u0070a\u0067\u0065\u002d\u0073\u0069\u007ae",_egc .PageSize .String ());};if _egc .PaperHeight !=nil {_cdg .Set ("\u0070\u0061\u0070e\u0072\u002d\u0068\u0065\u0069\u0067\u0068\u0074",_egc .PaperHeight .String ()); +};if _egc .PaperWidth !=nil {_cdg .Set ("p\u0061\u0070\u0065\u0072\u002d\u0077\u0069\u0064\u0074\u0068",_egc .PaperWidth .String ());};if _egc .MarginTop !=nil {_cdg .Set ("\u006d\u0061\u0072\u0067\u0069\u006e\u002d\u0074\u006f\u0070",_egc .MarginTop .String ()); +};if _egc .MarginBottom !=nil {_cdg .Set ("\u006d\u0061\u0072\u0067\u0069\u006e\u002d\u0062\u006f\u0074\u0074\u006f\u006d",_egc .MarginBottom .String ());};if _egc .MarginRight !=nil {_cdg .Set ("\u006d\u0061\u0072g\u0069\u006e\u002d\u0072\u0069\u0067\u0068\u0074",_egc .MarginRight .String ()); +};if _egc .MarginLeft !=nil {_cdg .Set ("m\u0061\u0072\u0067\u0069\u006e\u002d\u006c\u0065\u0066\u0074",_egc .MarginLeft .String ());};if _egc .Orientation ==_f .Landscape {_cdg .Set ("o\u0072\u0069\u0065\u006e\u0074\u0061\u0074\u0069\u006f\u006e",_egc .Orientation .String ()); +};if _eg .RenderParameters .WaitTime !=0{_cdg .Set ("\u006d\u0069\u006e\u0069\u006d\u0075\u006d\u002d\u006c\u006f\u0061\u0064-\u0074\u0069\u006d\u0065",_e .FormatInt (int64 (_eg .RenderParameters .WaitTime /_bd .Millisecond ),10));};_gbb .URL .RawQuery =_cdg .Encode (); +}; -// Addr gets the HTTP address URI used by the http.Client. -func (_dacf *Options )Addr ()string {_cbc :=_a .Builder {};_cbc .WriteString ("\u0068\u0074\u0074\u0070");if _dacf .HTTPS {_cbc .WriteRune ('s');};_cbc .WriteString ("\u003a\u002f\u002f");_cbc .WriteString (_dacf .Hostname );_cbc .WriteRune (':');_cbc .WriteString (_g .Itoa (_dacf .Port )); -if _dacf .Prefix !=""{_cbc .WriteString (_dacf .Prefix );};return _cbc .String ();}; +// WithDefaultTimeout sets the DefaultTimeout option for the client options. +func WithDefaultTimeout (option _bd .Duration )Option {return func (_ed *Options ){_ed .DefaultTimeout =option };}; -// BuildHTMLQuery creates a Query builder that is supposed to create valid -func BuildHTMLQuery ()*QueryBuilder {return &QueryBuilder {}}; +// SetContent sets custom data with it's content type. +func (_aebg *QueryBuilder )SetContent (content _bb .Content )*QueryBuilder {if _aebg ._ece !=nil {return _aebg ;};switch content .Method (){case "\u0064\u0069\u0072","\u0068\u0074\u006d\u006c":if _aebg ._fd .ContentType !=""{_aebg ._ece =ErrContentTypeDeclared ; +return _aebg ;};if content .ContentType ()==""{_aebg ._ece =_ba .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 _aebg ; +};_aebg ._fd .Content =content .Data ();_aebg ._fd .ContentType =content .ContentType ();case "\u0077\u0065\u0062":if _aebg ._fd .ContentType !=""{_aebg ._ece =ErrContentTypeDeclared ;return _aebg ;};_aebg ._fd .URL =string (content .Data ());_aebg ._fd .ContentType =content .ContentType (); +default:_aebg ._ece =_ba .Errorf ("\u0069\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u0063\u006f\u006et\u0065\u006e\u0074\u0020\u006d\u0065\u0074\u0068\u006f\u0064:\u0020\u0025\u0073",content .Method ());return _aebg ;};_aebg ._fd .Method =content .Method (); +return _aebg ;}; -// MarginLeft sets up the MarginLeft parameter for the query. -func (_cdd *QueryBuilder )MarginLeft (marginLeft _gg .Length )*QueryBuilder {_cdd ._bade .PageParameters .MarginLeft =marginLeft ;return _cdd ;}; +// Options are the client options used by the HTTP client. +type Options struct{HTTPS bool ;Hostname string ;Port int ;DefaultTimeout _bd .Duration ;Prefix string ;}; -// BySelector is a structure that defines a selector with it's query 'by' type. -type BySelector struct{Selector string `json:"selector"`;By _ga .ByType `json:"by"`;}; +// Validate checks if the parameters are valid. +func (_ege *PageParameters )Validate ()error {if _ege .PaperWidth !=nil {if _ege .PaperWidth .Millimeters ()< 0{return _d .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 _ege .PaperHeight !=nil {if _ege .PaperHeight .Millimeters ()< 0{return _d .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 _ege .MarginTop !=nil {if _ege .MarginTop .Millimeters ()< 0{return _d .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 _ege .MarginBottom !=nil {if _ege .MarginBottom .Millimeters ()< 0{return _d .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 _ege .MarginLeft !=nil {if _ege .MarginLeft .Millimeters ()< 0{return _d .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 _ege .MarginRight !=nil {if _ege .MarginRight .Millimeters ()< 0{return _d .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 _ege .PageSize !=nil &&!_ege .PageSize .IsAPageSize (){return _d .New ("\u0069\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u0070\u0061\u0067\u0065 \u0073\u0069\u007a\u0065");};return nil ;}; -// WithDefaultTimeout sets the DefaultTimeout option for the client options. -func WithDefaultTimeout (option _c .Duration )Option {return func (_cbb *Options ){_cbb .DefaultTimeout =option };}; +// Portrait sets up the portrait page orientation. +func (_cdd *QueryBuilder )Portrait ()*QueryBuilder {_cdd ._fd .PageParameters .Orientation =_f .Portrait ;return _cdd ;}; -// Option is a function that changes client options. -type Option func (_aad *Options );var (ErrNotFound =_fe .New ("\u006eo\u0074\u0020\u0066\u006f\u0075\u006ed");ErrBadRequest =_fe .New ("b\u0061\u0064\u0020\u0072\u0065\u0071\u0075\u0065\u0073\u0074");ErrNotImplemented =_fe .New ("\u006eo\u0074 \u0069\u006d\u0070\u006c\u0065\u006d\u0065\u006e\u0074\u0065\u0064"); -ErrInternalError =_fe .New ("i\u006e\u0074\u0065\u0072na\u006c \u0073\u0065\u0072\u0076\u0065r\u0020\u0065\u0072\u0072\u006f\u0072");ErrBadGateway =_fe .New ("b\u0061\u0064\u0020\u0067\u0061\u0074\u0065\u0077\u0061\u0079");ErrUnauthorized =_fe .New ("\u0075\u006e\u0061u\u0074\u0068\u006f\u0072\u0069\u007a\u0065\u0064"); -ErrTimedOut =_fe .New ("\u0072\u0065\u0071\u0075\u0065\u0073\u0074\u0020\u0074\u0069\u006d\u0065d\u0020\u006f\u0075\u0074");); +// PageSize sets up the PageSize parameter for the query. +func (_ccd *QueryBuilder )PageSize (pageSize _f .PageSize )*QueryBuilder {if pageSize !=_f .Undefined {_ccd ._fd .PageParameters .PageSize =&pageSize ;};return _ccd ;}; // MarginBottom sets up the MarginBottom parameter for the query. -func (_ae *QueryBuilder )MarginBottom (marginBottom _gg .Length )*QueryBuilder {_ae ._bade .PageParameters .MarginBottom =marginBottom ;return _ae ;}; +func (_aa *QueryBuilder )MarginBottom (marginBottom _f .Length )*QueryBuilder {_aa ._fd .PageParameters .MarginBottom =marginBottom ;return _aa ;}; // WaitTime sets the minimum load time parameter for the page rendering. -func (_ggd *QueryBuilder )WaitTime (d _c .Duration )*QueryBuilder {_ggd ._bade .RenderParameters .WaitTime =d ;return _ggd ;}; +func (_deg *QueryBuilder )WaitTime (d _bd .Duration )*QueryBuilder {_deg ._fd .RenderParameters .WaitTime =d ;return _deg ;}; -// Portrait sets up the portrait page orientation. -func (_cbg *QueryBuilder )Portrait ()*QueryBuilder {_cbg ._bade .PageParameters .Orientation =_gg .Portrait ;return _cbg ;};type generatePDFRequestV1 struct{Content []byte `json:"content"`;ContentType string `json:"contentType"`;ContentURL string `json:"contentURL"`; -Method string `json:"method"`;ExpiresAt int64 `json:"expiresAt"`;TimeoutDuration int64 `json:"timeoutDuration,omitempty"`;PageParameters ;RenderParameters ;}; +// RenderParameters are the parameters related with the rendering. +type RenderParameters struct{WaitTime _bd .Duration `schema:"minimum-load-time" json:"waitTime"`;WaitReady []BySelector `json:"waitReady"`;WaitVisible []BySelector `json:"waitVisible"`;}; -// WithPrefix sets the client prefix. -func WithPrefix (prefix string )Option {return func (_ce *Options ){_ce .Prefix =prefix }}; +// ConvertHTML converts provided Query input into PDF file data. +// Implements creator.HTMLConverter interface. +func (_cc *Client )ConvertHTML (ctx _g .Context ,q *Query )(*PDFResponse ,error ){if _fc :=q .Validate ();_fc !=nil {return nil ,_fc ;};_gec ,_ccg :=_cc .getGenerateRequest (ctx ,q );if _ccg !=nil {return nil ,_ccg ;};_ag .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",_gec .Method ,_gec .URL .Hostname (),_gec .URL .Path ,_gec .Header ,_gec .URL .Query ()); +_df :=*_cc .Client ;if q .TimeoutDuration !=0{_df .Timeout =q .TimeoutDuration ;};_bf ,_ccg :=_df .Do (_gec );if _ccg !=nil {return nil ,_ccg ;};var _ebc error ;switch _bf .StatusCode {case _eb .StatusNotFound :_ebc =ErrNotFound ;case _eb .StatusBadRequest :_ebc =ErrBadRequest ; +case _eb .StatusNotImplemented :_ebc =ErrNotImplemented ;case _eb .StatusUnauthorized :_ebc =ErrUnauthorized ;case _eb .StatusRequestTimeout :_ebc =ErrTimedOut ;case _eb .StatusCreated :default:_ebc =ErrInternalError ;};_dc :=_bf .Body ;switch _bf .Header .Get ("\u0043\u006fn\u0074\u0065\u006et\u002d\u0045\u006e\u0063\u006f\u0064\u0069\u006e\u0067"){case "\u0067\u007a\u0069\u0070":_dc ,_ccg =_gb .NewReader (_bf .Body ); +if _ccg !=nil {return nil ,_ccg ;};case "\u0064e\u0066\u006c\u0061\u0074\u0065":_dc =_dd .NewReader (_bf .Body );case "":default:return nil ,_ba .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",_bf .Header .Get ("\u0043\u006fn\u0074\u0065\u006et\u002d\u0045\u006e\u0063\u006f\u0064\u0069\u006e\u0067")); +};_af ,_ccg :=_ge .ReadAll (_dc );if _ccg !=nil &&_ebc ==nil {return nil ,_ba .Errorf ("\u0055\u006e\u0069HT\u004d\u004c\u0020\u0073\u0065\u0072\u0076\u0065\u0072\u0020\u0065\u0072\u0072\u006f\u0072\u0020\u0025\u0073",_ccg );};_ag .Log .Trace ("\u005b\u0025\u0064]\u0020\u0025\u0073\u0020\u0025\u0073\u0025\u0073",_bf .StatusCode ,_gec .Method ,_gec .URL .Host ,_gec .URL .Path ); +if _ebc !=nil {return nil ,_ba .Errorf ("\u0025\u0073\u0020%\u0077",string (_af ),_ebc );};_aea :=_bf .Header .Get ("\u0058\u002d\u004a\u006f\u0062\u002d\u0049\u0044");_ag .Log .Trace ("\u0052\u0065\u0073\u0070\u006f\u006e\u0073\u0065\u0020I\u0044\u0020\u0025\u0073",_aea ); +return &PDFResponse {ID :_aea ,Data :_af },nil ;}; -// PDFResponse is the response used by the HTMLConverter. -type PDFResponse struct{ID string `json:"id"`;Data []byte `json:"data"`;}; +// Validate checks if provided Query is valid. +func (_agb *Query )Validate ()error {switch _agb .Method {case "\u0077\u0065\u0062":if _agb .URL ==""{return ErrMissingData ;};case "\u0064\u0069\u0072","\u0068\u0074\u006d\u006c":if len (_agb .Content )==0{return ErrMissingData ;};if _agb .ContentType ==""{return ErrContentType ; +};default:return _ba .Errorf ("\u0075\u006e\u0064ef\u0069\u006e\u0065\u0064\u0020\u0063\u006f\u006e\u0074e\u006et\u0020q\u0075e\u0072\u0079\u0020\u006d\u0065\u0074\u0068\u006f\u0072\u003a\u0020\u0025\u0073",_agb .Method );};if _afa :=_agb .PageParameters .Validate (); +_afa !=nil {return _afa ;};if _geg :=_agb .RenderParameters .Validate ();_geg !=nil {return _geg ;};return nil ;};var (ErrMissingData =_d .New ("\u006di\u0073s\u0069\u006e\u0067\u0020\u0069n\u0070\u0075t\u0020\u0064\u0061\u0074\u0061");ErrContentType =_d .New ("i\u006ev\u0061\u006c\u0069\u0064\u0020\u0063\u006f\u006et\u0065\u006e\u0074\u0020ty\u0070\u0065"); +ErrContentTypeDeclared =_d .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");); -// QueryBuilder is the query that converts HTMLConverter defined data -type QueryBuilder struct{_bade Query ;_afb error ;}; +// PaperWidth sets up the PaperWidth (in cm) parameter for the query. +func (_dbc *QueryBuilder )PaperWidth (paperWidth _f .Length )*QueryBuilder {_dbc ._fd .PageParameters .PaperWidth =paperWidth ;return _dbc ;}; // PageParameters are the query parameters used in the PDF generation. type PageParameters struct{ // PaperWidth sets the width of the paper. -PaperWidth _gg .Length `schema:"paper-width" json:"paperWidth"`; +PaperWidth _f .Length `schema:"paper-width" json:"paperWidth"`; // PaperHeight is the height of the output paper. -PaperHeight _gg .Length `schema:"paper-height" json:"paperHeight"`; +PaperHeight _f .Length `schema:"paper-height" json:"paperHeight"`; // PageSize is the page size string. -PageSize *_gg .PageSize `schema:"page-size" json:"pageSize"`; +PageSize *_f .PageSize `schema:"page-size" json:"pageSize"`; // Orientation defines if the output should be in a landscape format. -Orientation _gg .Orientation `schema:"orientation" json:"orientation"`; +Orientation _f .Orientation `schema:"orientation" json:"orientation"`; // MarginTop sets up the Top Margin for the output. -MarginTop _gg .Length `schema:"margin-top" json:"marginTop"`; +MarginTop _f .Length `schema:"margin-top" json:"marginTop"`; // MarginBottom sets up the Bottom Margin for the output. -MarginBottom _gg .Length `schema:"margin-bottom" json:"marginBottom"`; +MarginBottom _f .Length `schema:"margin-bottom" json:"marginBottom"`; // MarginLeft sets up the Left Margin for the output. -MarginLeft _gg .Length `schema:"margin-left" json:"marginLeft"`; +MarginLeft _f .Length `schema:"margin-left" json:"marginLeft"`; // MarginRight sets up the Right Margin for the output. -MarginRight _gg .Length `schema:"margin-right" json:"marginRight"`;}; +MarginRight _f .Length `schema:"margin-right" json:"marginRight"`;}; -// Client is a structure that is a HTTP client for the unihtml server. -type Client struct{Options Options ;Client *_ab .Client ;};func (_ffgf *Client )setQueryValues (_fae *_ab .Request ,_dbe *Query ){_ffb :=_fae .URL .Query ();_ggcf :=_dbe .PageParameters ;if _ggcf .PageSize !=nil {_ffb .Set ("\u0070a\u0067\u0065\u002d\u0073\u0069\u007ae",_ggcf .PageSize .String ()); -};if _ggcf .PaperHeight !=nil {_ffb .Set ("\u0070\u0061\u0070e\u0072\u002d\u0068\u0065\u0069\u0067\u0068\u0074",_ggcf .PaperHeight .String ());};if _ggcf .PaperWidth !=nil {_ffb .Set ("p\u0061\u0070\u0065\u0072\u002d\u0077\u0069\u0064\u0074\u0068",_ggcf .PaperWidth .String ()); -};if _ggcf .MarginTop !=nil {_ffb .Set ("\u006d\u0061\u0072\u0067\u0069\u006e\u002d\u0074\u006f\u0070",_ggcf .MarginTop .String ());};if _ggcf .MarginBottom !=nil {_ffb .Set ("\u006d\u0061\u0072\u0067\u0069\u006e\u002d\u0062\u006f\u0074\u0074\u006f\u006d",_ggcf .MarginBottom .String ()); -};if _ggcf .MarginRight !=nil {_ffb .Set ("\u006d\u0061\u0072g\u0069\u006e\u002d\u0072\u0069\u0067\u0068\u0074",_ggcf .MarginRight .String ());};if _ggcf .MarginLeft !=nil {_ffb .Set ("m\u0061\u0072\u0067\u0069\u006e\u002d\u006c\u0065\u0066\u0074",_ggcf .MarginLeft .String ()); -};if _ggcf .Orientation ==_gg .Landscape {_ffb .Set ("o\u0072\u0069\u0065\u006e\u0074\u0061\u0074\u0069\u006f\u006e",_ggcf .Orientation .String ());};if _dbe .RenderParameters .WaitTime !=0{_ffb .Set ("\u006d\u0069\u006e\u0069\u006d\u0075\u006d\u002d\u006c\u006f\u0061\u0064-\u0074\u0069\u006d\u0065",_g .FormatInt (int64 (_dbe .RenderParameters .WaitTime /_c .Millisecond ),10)); -};_fae .URL .RawQuery =_ffb .Encode ();}; - -// SetContent sets custom data with it's content type. -func (_fg *QueryBuilder )SetContent (content _cd .Content )*QueryBuilder {if _fg ._afb !=nil {return _fg ;};switch content .Method (){case "\u0064\u0069\u0072","\u0068\u0074\u006d\u006c":if _fg ._bade .ContentType !=""{_fg ._afb =ErrContentTypeDeclared ; -return _fg ;};if content .ContentType ()==""{_fg ._afb =_dbc .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 _fg ;}; -_fg ._bade .Content =content .Data ();_fg ._bade .ContentType =content .ContentType ();case "\u0077\u0065\u0062":if _fg ._bade .ContentType !=""{_fg ._afb =ErrContentTypeDeclared ;return _fg ;};_fg ._bade .URL =string (content .Data ());_fg ._bade .ContentType =content .ContentType (); -default:_fg ._afb =_dbc .Errorf ("\u0069\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u0063\u006f\u006et\u0065\u006e\u0074\u0020\u006d\u0065\u0074\u0068\u006f\u0064:\u0020\u0025\u0073",content .Method ());return _fg ;};_fg ._bade .Method =content .Method (); -return _fg ;}; +// ParseOptions parses options for the Client. +func ParseOptions (connectPath string )(Options ,error ){if !_ac .HasPrefix (connectPath ,"\u0068\u0074\u0074\u0070"){connectPath ="\u0068t\u0074\u0070\u003a\u002f\u002f"+connectPath ;};_fa ,_ad :=_bg .Parse (connectPath );if _ad !=nil {return Options {},_ba .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 _ga int ;if _fa .Port ()!=""{_ga ,_ad =_e .Atoi (_fa .Port ());if _ad !=nil {return Options {},_ba .Errorf ("\u0070\u0061\u0072si\u006e\u0067\u0020\u0070\u006f\u0072\u0074\u0020\u0066\u0061\u0069\u006c\u0065\u0064\u003a\u0020\u0025\u0077",_ad );}; +};return Options {Hostname :_fa .Hostname (),Port :_ga ,HTTPS :_fa .Scheme =="\u0068\u0074\u0074p\u0073",Prefix :_fa .Path },nil ;}; // New creates new client with provided options. -func New (o Options )*Client {o .DefaultTimeout =_c .Second *30;if o .Port <=0{o .Port =8080;};if o .Hostname ==""{o .Hostname ="\u00312\u0037\u002e\u0030\u002e\u0030\u002e1";};var _bc =&_ab .Transport {DialContext :(&_df .Dialer {Timeout :5*_c .Second }).DialContext ,TLSHandshakeTimeout :5*_c .Second }; -_aa .Log .Info ("\u0043l\u0069e\u006e\u0074\u0020\u0041\u0064\u0064\u0072\u003a\u0020\u0025\u0073",o .Addr ());return &Client {Options :o ,Client :&_ab .Client {Transport :_bc ,Timeout :o .DefaultTimeout }};}; +func New (o Options )*Client {o .DefaultTimeout =_bd .Second *30;if o .Port <=0{o .Port =8080;};if o .Hostname ==""{o .Hostname ="\u00312\u0037\u002e\u0030\u002e\u0030\u002e1";};var _ddg =&_eb .Transport {DialContext :(&_gd .Dialer {Timeout :5*_bd .Second }).DialContext ,TLSHandshakeTimeout :5*_bd .Second }; +_ag .Log .Info ("\u0043l\u0069e\u006e\u0074\u0020\u0041\u0064\u0064\u0072\u003a\u0020\u0025\u0073",o .Addr ());return &Client {Options :o ,Client :&_eb .Client {Transport :_ddg ,Timeout :o .DefaultTimeout }};}; -// WaitReady waits for the selector to get ready - 'loaded'. -func (_bf *QueryBuilder )WaitReady (selector string ,by _ga .ByType )*QueryBuilder {_bf ._bade .RenderParameters .WaitReady =append (_bf ._bade .RenderParameters .WaitReady ,BySelector {Selector :selector ,By :by });return _bf ;}; +// Orientation sets the page orientation for the Query. +func (_gff *QueryBuilder )Orientation (orientation _f .Orientation )*QueryBuilder {_gff ._fd .PageParameters .Orientation =orientation ;return _gff ;}; -// DefaultPageParameters creates default parameters. -func DefaultPageParameters ()PageParameters {return PageParameters {Orientation :_gg .Portrait }}; +// Validate checks the validity of the RenderParameters. +func (_bga *RenderParameters )Validate ()error {if _bga .WaitTime > _bd .Minute *3{return _d .New ("\u0074\u006f\u006f\u0020\u006c\u006f\u006e\u0067 \u006d\u0069\u006eim\u0075\u006d\u0020\u006c\u006f\u0061d\u0020\u0074\u0069\u006d\u0065\u002e\u0020\u004d\u0061\u0078\u0069\u006d\u0075\u006d\u0020i\u0073\u0020\u0033\u0020\u006d\u0069\u006e\u0075t\u0065\u0073"); +};for _ ,_aee :=range _bga .WaitReady {if _ebe :=_aee .Validate ();_ebe !=nil {return _ba .Errorf ("\u006f\u006e\u0065\u0020\u006f\u0066\u0020w\u0061\u0069\u0074 \u0072\u0065\u0061\u0064y\u0020\u0073\u0065\u006c\u0065\u0063\u0074\u006f\u0072\u0020\u0069\u0073\u0020\u006e\u006f\u0074\u0020\u0076\u0061\u006c\u0069\u0064\u003a\u0020\u0025\u0077",_ebe ); +};};return nil ;}; -// Validate checks if the parameters are valid. -func (_bab *PageParameters )Validate ()error {if _bab .PaperWidth !=nil {if _bab .PaperWidth .Millimeters ()< 0{return _fe .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 _bab .PaperHeight !=nil {if _bab .PaperHeight .Millimeters ()< 0{return _fe .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 _bab .MarginTop !=nil {if _bab .MarginTop .Millimeters ()< 0{return _fe .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 _bab .MarginBottom !=nil {if _bab .MarginBottom .Millimeters ()< 0{return _fe .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 _bab .MarginLeft !=nil {if _bab .MarginLeft .Millimeters ()< 0{return _fe .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 _bab .MarginRight !=nil {if _bab .MarginRight .Millimeters ()< 0{return _fe .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 _bab .PageSize !=nil &&!_bab .PageSize .IsAPageSize (){return _fe .New ("\u0069\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u0070\u0061\u0067\u0065 \u0073\u0069\u007a\u0065");};return nil ;};var (ErrMissingData =_fe .New ("\u006di\u0073s\u0069\u006e\u0067\u0020\u0069n\u0070\u0075t\u0020\u0064\u0061\u0074\u0061"); -ErrContentType =_fe .New ("i\u006ev\u0061\u006c\u0069\u0064\u0020\u0063\u006f\u006et\u0065\u006e\u0074\u0020ty\u0070\u0065");ErrContentTypeDeclared =_fe .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"); -); +// WithPort sets the Port option for the client options. +func WithPort (option int )Option {return func (_cdf *Options ){_cdf .Port =option }};func (_bag *Client )getGenerateRequest (_beg _g .Context ,_ab *Query )(*_eb .Request ,error ){_ddf :=generatePDFRequestV1 {Method :_ab .Method ,PageParameters :_ab .PageParameters ,RenderParameters :_ab .RenderParameters ,TimeoutDuration :int64 (_ab .TimeoutDuration )}; +switch _ab .Method {case "\u0077\u0065\u0062":_ddf .ContentURL =_ab .URL ;case "\u0064\u0069\u0072","\u0068\u0074\u006d\u006c":_ddf .ContentType =_ab .ContentType ;_ddf .Content =_ab .Content ;};_cb :=new (_a .Buffer );if _gf :=_b .NewEncoder (_cb ).Encode (&_ddf ); +_gf !=nil {return nil ,_ba .Errorf ("e\u006e\u0063\u006f\u0064\u0069\u006eg\u0020\u0072\u0065\u0071\u0075\u0065\u0073\u0074\u0020f\u0061\u0069\u006ce\u0064:\u0020\u0025\u0076",_gf );};_bgf :=_bag .Options .Addr ();_bgf =_ba .Sprintf ("\u0025s\u002f\u0076\u0031\u002f\u0070\u0064f",_bgf ); +_cd ,_bfe :=_eb .NewRequest ("\u0050\u004f\u0053\u0054",_bgf ,_cb );if _bfe !=nil {return nil ,_bfe ;};_cd .Header .Set ("\u0043\u006f\u006et\u0065\u006e\u0074\u002d\u0054\u0079\u0070\u0065","\u0061\u0070p\u006c\u0069\u0063a\u0074\u0069\u006f\u006e\u002f\u006a\u0073\u006f\u006e"); +_cd .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"); +_cd =_cd .WithContext (_beg );return _cd ,nil ;}; -// PageSize sets up the PageSize parameter for the query. -func (_cga *QueryBuilder )PageSize (pageSize _gg .PageSize )*QueryBuilder {if pageSize !=_gg .Undefined {_cga ._bade .PageParameters .PageSize =&pageSize ;};return _cga ;}; +// Addr gets the HTTP address URI used by the http.Client. +func (_ddd *Options )Addr ()string {_aeb :=_ac .Builder {};_aeb .WriteString ("\u0068\u0074\u0074\u0070");if _ddd .HTTPS {_aeb .WriteRune ('s');};_aeb .WriteString ("\u003a\u002f\u002f");_aeb .WriteString (_ddd .Hostname );_aeb .WriteRune (':');_aeb .WriteString (_e .Itoa (_ddd .Port )); +if _ddd .Prefix !=""{_aeb .WriteString (_ddd .Prefix );};return _aeb .String ();}; -// PaperWidth sets up the PaperWidth (in cm) parameter for the query. -func (_aagg *QueryBuilder )PaperWidth (paperWidth _gg .Length )*QueryBuilder {_aagg ._bade .PageParameters .PaperWidth =paperWidth ;return _aagg ;}; +// MarginTop sets up the MarginTop parameter for the query. +func (_ce *QueryBuilder )MarginTop (marginTop _f .Length )*QueryBuilder {_ce ._fd .PageParameters .MarginTop =marginTop ;return _ce ;}; -// Validate checks if the QueryBuilder had no errors during composition and creation. -func (_eg *QueryBuilder )Validate ()error {if _eg ._afb !=nil {return _eg ._afb ;};return _eg ._bade .Validate ();}; +// Landscape sets up the landscape portrait orientation. +func (_gdg *QueryBuilder )Landscape ()*QueryBuilder {_gdg ._fd .PageParameters .Orientation =_f .Landscape ;return _gdg ;}; + +// WithPrefix sets the client prefix. +func WithPrefix (prefix string )Option {return func (_ada *Options ){_ada .Prefix =prefix }}; + +// PaperHeight sets up the PaperHeight (in cm) parameter for the query. +func (_aga *QueryBuilder )PaperHeight (paperHeight _f .Length )*QueryBuilder {_aga ._fd .PageParameters .PaperHeight =paperHeight ;return _aga ;}; // Validate checks validity of the selector. -func (_dgd BySelector )Validate ()error {if _dgd .Selector ==""{return _fe .New ("\u0070\u0072\u006fvi\u0064\u0065\u0064\u0020\u0065\u006d\u0070\u0074\u0079\u0020\u0073\u0065\u006c\u0065\u0063\u0074\u006f\u0072");};if _geb :=_dgd .By .Validate ();_geb !=nil {return _geb ; +func (_cdfg BySelector )Validate ()error {if _cdfg .Selector ==""{return _d .New ("\u0070\u0072\u006fvi\u0064\u0065\u0064\u0020\u0065\u006d\u0070\u0074\u0079\u0020\u0073\u0065\u006c\u0065\u0063\u0074\u006f\u0072");};if _ebd :=_cdfg .By .Validate ();_ebd !=nil {return _ebd ; };return nil ;}; -// Err gets the error which could occur in the query. -func (_edb *QueryBuilder )Err ()error {return _edb ._afb }; +// Option is a function that changes client options. +type Option func (_bfb *Options ); -// Validate checks the validity of the RenderParameters. -func (_ad *RenderParameters )Validate ()error {if _ad .WaitTime > _c .Minute *3{return _fe .New ("\u0074\u006f\u006f\u0020\u006c\u006f\u006e\u0067 \u006d\u0069\u006eim\u0075\u006d\u0020\u006c\u006f\u0061d\u0020\u0074\u0069\u006d\u0065\u002e\u0020\u004d\u0061\u0078\u0069\u006d\u0075\u006d\u0020i\u0073\u0020\u0033\u0020\u006d\u0069\u006e\u0075t\u0065\u0073"); -};for _ ,_cc :=range _ad .WaitReady {if _cec :=_cc .Validate ();_cec !=nil {return _dbc .Errorf ("\u006f\u006e\u0065\u0020\u006f\u0066\u0020w\u0061\u0069\u0074 \u0072\u0065\u0061\u0064y\u0020\u0073\u0065\u006c\u0065\u0063\u0074\u006f\u0072\u0020\u0069\u0073\u0020\u006e\u006f\u0074\u0020\u0076\u0061\u006c\u0069\u0064\u003a\u0020\u0025\u0077",_cec ); -};};return nil ;}; +// QueryBuilder is the query that converts HTMLConverter defined data +type QueryBuilder struct{_fd Query ;_ece error ;}; -// HealthCheck connects to the server and check the health status of the server. -func (_bb *Client )HealthCheck (ctx _f .Context )error {_cf :=_bb .Options .Addr ();_cf =_dbc .Sprintf ("\u0025s\u002f\u0068\u0065\u0061\u006c\u0074h",_cf );_ed ,_ea :=_ab .NewRequest ("\u0047\u0045\u0054",_cf ,nil );if _ea !=nil {return _ea ;};_ed =_ed .WithContext (ctx ); -_deb ,_ea :=_bb .Client .Do (_ed );if _ea !=nil {return _ea ;};switch _deb .StatusCode {case _ab .StatusOK :return nil ;case _ab .StatusNotFound :return ErrNotFound ;case _ab .StatusInternalServerError :return ErrInternalError ;case _ab .StatusBadGateway :return ErrBadGateway ; -default:return ErrNotImplemented ;};}; +// WithHTTPS sets the TLS option for the client options. +func WithHTTPS (useHTTPS bool )Option {return func (_acd *Options ){_acd .HTTPS =useHTTPS }}; -// ConvertHTML converts provided Query input into PDF file data. -// Implements creator.HTMLConverter interface. -func (_cdg *Client )ConvertHTML (ctx _f .Context ,q *Query )(*PDFResponse ,error ){if _fca :=q .Validate ();_fca !=nil {return nil ,_fca ;};_ff ,_dg :=_cdg .getGenerateRequest (ctx ,q );if _dg !=nil {return nil ,_dg ;};_aa .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",_ff .Method ,_ff .URL .Hostname (),_ff .URL .Path ,_ff .Header ,_ff .URL .Query ()); -_ede :=*_cdg .Client ;if q .TimeoutDuration !=0{_ede .Timeout =q .TimeoutDuration ;};_ffg ,_dg :=_ede .Do (_ff );if _dg !=nil {return nil ,_dg ;};var _dc error ;switch _ffg .StatusCode {case _ab .StatusNotFound :_dc =ErrNotFound ;case _ab .StatusBadRequest :_dc =ErrBadRequest ; -case _ab .StatusNotImplemented :_dc =ErrNotImplemented ;case _ab .StatusUnauthorized :_dc =ErrUnauthorized ;case _ab .StatusRequestTimeout :_dc =ErrTimedOut ;case _ab .StatusCreated :default:_dc =ErrInternalError ;};_gc :=_ffg .Body ;switch _ffg .Header .Get ("\u0043\u006fn\u0074\u0065\u006et\u002d\u0045\u006e\u0063\u006f\u0064\u0069\u006e\u0067"){case "\u0067\u007a\u0069\u0070":_gc ,_dg =_de .NewReader (_ffg .Body ); -if _dg !=nil {return nil ,_dg ;};case "\u0064e\u0066\u006c\u0061\u0074\u0065":_gc =_dac .NewReader (_ffg .Body );case "":default:return nil ,_dbc .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",_ffg .Header .Get ("\u0043\u006fn\u0074\u0065\u006et\u002d\u0045\u006e\u0063\u006f\u0064\u0069\u006e\u0067")); -};_ggc ,_dg :=_d .ReadAll (_gc );if _dg !=nil &&_dc ==nil {return nil ,_dbc .Errorf ("\u0055\u006e\u0069HT\u004d\u004c\u0020\u0073\u0065\u0072\u0076\u0065\u0072\u0020\u0065\u0072\u0072\u006f\u0072\u0020\u0025\u0073",_dg );};_aa .Log .Trace ("\u005b\u0025\u0064]\u0020\u0025\u0073\u0020\u0025\u0073\u0025\u0073",_ffg .StatusCode ,_ff .Method ,_ff .URL .Host ,_ff .URL .Path ); -if _dc !=nil {return nil ,_dbc .Errorf ("\u0025\u0073\u0020%\u0077",string (_ggc ),_dc );};_cb :=_ffg .Header .Get ("\u0058\u002d\u004a\u006f\u0062\u002d\u0049\u0044");_aa .Log .Trace ("\u0052\u0065\u0073\u0070\u006f\u006e\u0073\u0065\u0020I\u0044\u0020\u0025\u0073",_cb ); -return &PDFResponse {ID :_cb ,Data :_ggc },nil ;}; +// TimeoutDuration sets the server query duration timeout. +// Once the timeout is reached the server will return an error. +func (_adaf *QueryBuilder )TimeoutDuration (d _bd .Duration )*QueryBuilder {_adaf ._fd .TimeoutDuration =d ;return _adaf ;}; -// Orientation sets the page orientation for the Query. -func (_ecd *QueryBuilder )Orientation (orientation _gg .Orientation )*QueryBuilder {_ecd ._bade .PageParameters .Orientation =orientation ;return _ecd ;}; +// WaitReady waits for the selector to get ready - 'loaded'. +func (_ea *QueryBuilder )WaitReady (selector string ,by _be .ByType )*QueryBuilder {_ea ._fd .RenderParameters .WaitReady =append (_ea ._fd .RenderParameters .WaitReady ,BySelector {Selector :selector ,By :by });return _ea ;}; -// WithPort sets the Port option for the client options. -func WithPort (option int )Option {return func (_fb *Options ){_fb .Port =option }}; +// Client is a structure that is a HTTP client for the unihtml server. +type Client struct{Options Options ;Client *_eb .Client ;}; -// Landscape sets up the landscape portrait orientation. -func (_ggb *QueryBuilder )Landscape ()*QueryBuilder {_ggb ._bade .PageParameters .Orientation =_gg .Landscape ;return _ggb ;}; +// WithHostname sets the Hostname option for the client options. +func WithHostname (option string )Option {return func (_baa *Options ){_baa .Hostname =option }}; -// WithHTTPS sets the TLS option for the client options. -func WithHTTPS (useHTTPS bool )Option {return func (_bad *Options ){_bad .HTTPS =useHTTPS }}; +// BySelector is a structure that defines a selector with it's query 'by' type. +type BySelector struct{Selector string `json:"selector"`;By _be .ByType `json:"by"`;};type generatePDFRequestV1 struct{Content []byte `json:"content"`;ContentType string `json:"contentType"`;ContentURL string `json:"contentURL"`;Method string `json:"method"`; +ExpiresAt int64 `json:"expiresAt"`;TimeoutDuration int64 `json:"timeoutDuration,omitempty"`;PageParameters ;RenderParameters ;}; -// PaperHeight sets up the PaperHeight (in cm) parameter for the query. -func (_aadb *QueryBuilder )PaperHeight (paperHeight _gg .Length )*QueryBuilder {_aadb ._bade .PageParameters .PaperHeight =paperHeight ;return _aadb ;}; +// DefaultPageParameters creates default parameters. +func DefaultPageParameters ()PageParameters {return PageParameters {Orientation :_f .Portrait }}; -// MarginTop sets up the MarginTop parameter for the query. -func (_ee *QueryBuilder )MarginTop (marginTop _gg .Length )*QueryBuilder {_ee ._bade .PageParameters .MarginTop =marginTop ;return _ee ;}; +// Err gets the error which could occur in the query. +func (_db *QueryBuilder )Err ()error {return _db ._ece }; // MarginRight sets up the MarginRight parameter for the query. -func (_cge *QueryBuilder )MarginRight (marginRight _gg .Length )*QueryBuilder {_cge ._bade .PageParameters .MarginRight =marginRight ;return _cge ;}; +func (_fgb *QueryBuilder )MarginRight (marginRight _f .Length )*QueryBuilder {_fgb ._fd .PageParameters .MarginRight =marginRight ;return _fgb ;}; -// WaitVisible waits for the selector to get visible. -func (_ef *QueryBuilder )WaitVisible (selector string ,by _ga .ByType )*QueryBuilder {_ef ._bade .RenderParameters .WaitVisible =append (_ef ._bade .RenderParameters .WaitVisible ,BySelector {Selector :selector ,By :by });return _ef ;}; - -// WithHostname sets the Hostname option for the client options. -func WithHostname (option string )Option {return func (_dcb *Options ){_dcb .Hostname =option }}; +// MarginLeft sets up the MarginLeft parameter for the query. +func (_de *QueryBuilder )MarginLeft (marginLeft _f .Length )*QueryBuilder {_de ._fd .PageParameters .MarginLeft =marginLeft ;return _de ;}; // 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 (_cg *QueryBuilder )Query ()(*Query ,error ){if _bd :=_cg .Validate ();_bd !=nil {return nil ,_bd ;};return &_cg ._bade ,nil ;}; +func (_ca *QueryBuilder )Query ()(*Query ,error ){if _bbc :=_ca .Validate ();_bbc !=nil {return nil ,_bbc ;};return &_ca ._fd ,nil ;}; -// Validate checks if provided Query is valid. -func (_gb *Query )Validate ()error {switch _gb .Method {case "\u0077\u0065\u0062":if _gb .URL ==""{return ErrMissingData ;};case "\u0064\u0069\u0072","\u0068\u0074\u006d\u006c":if len (_gb .Content )==0{return ErrMissingData ;};if _gb .ContentType ==""{return ErrContentType ; -};default:return _dbc .Errorf ("\u0075\u006e\u0064ef\u0069\u006e\u0065\u0064\u0020\u0063\u006f\u006e\u0074e\u006et\u0020q\u0075e\u0072\u0079\u0020\u006d\u0065\u0074\u0068\u006f\u0072\u003a\u0020\u0025\u0073",_gb .Method );};if _dd :=_gb .PageParameters .Validate (); -_dd !=nil {return _dd ;};if _gcc :=_gb .RenderParameters .Validate ();_gcc !=nil {return _gcc ;};return nil ;}; +// HealthCheck connects to the server and check the health status of the server. +func (_ae *Client )HealthCheck (ctx _g .Context )error {_fg :=_ae .Options .Addr ();_fg =_ba .Sprintf ("\u0025s\u002f\u0068\u0065\u0061\u006c\u0074h",_fg );_cf ,_da :=_eb .NewRequest ("\u0047\u0045\u0054",_fg ,nil );if _da !=nil {return _da ;};_cf =_cf .WithContext (ctx ); +_ebg ,_da :=_ae .Client .Do (_cf );if _da !=nil {return _da ;};switch _ebg .StatusCode {case _eb .StatusOK :return nil ;case _eb .StatusNotFound :return ErrNotFound ;case _eb .StatusInternalServerError :return ErrInternalError ;case _eb .StatusBadGateway :return ErrBadGateway ; +default:return ErrNotImplemented ;};}; -// RenderParameters are the parameters related with the rendering. -type RenderParameters struct{WaitTime _c .Duration `schema:"minimum-load-time" json:"waitTime"`;WaitReady []BySelector `json:"waitReady"`;WaitVisible []BySelector `json:"waitVisible"`;}; +// Validate checks if the QueryBuilder had no errors during composition and creation. +func (_fdb *QueryBuilder )Validate ()error {if _fdb ._ece !=nil {return _fdb ._ece ;};return _fdb ._fd .Validate ();}; -// TimeoutDuration sets the server query duration timeout. -// Once the timeout is reached the server will return an error. -func (_eea *QueryBuilder )TimeoutDuration (d _c .Duration )*QueryBuilder {_eea ._bade .TimeoutDuration =d ;return _eea ;}; +// BuildHTMLQuery creates a Query builder that is supposed to create valid +func BuildHTMLQuery ()*QueryBuilder {return &QueryBuilder {}}; -// Options are the client options used by the HTTP client. -type Options struct{HTTPS bool ;Hostname string ;Port int ;DefaultTimeout _c .Duration ;Prefix string ;};func (_ge *Client )getGenerateRequest (_ba _f .Context ,_ec *Query )(*_ab .Request ,error ){_ggce :=generatePDFRequestV1 {Method :_ec .Method ,PageParameters :_ec .PageParameters ,RenderParameters :_ec .RenderParameters ,TimeoutDuration :int64 (_ec .TimeoutDuration )}; -switch _ec .Method {case "\u0077\u0065\u0062":_ggce .ContentURL =_ec .URL ;case "\u0064\u0069\u0072","\u0068\u0074\u006d\u006c":_ggce .ContentType =_ec .ContentType ;_ggce .Content =_ec .Content ;};_gec :=new (_db .Buffer );if _fa :=_da .NewEncoder (_gec ).Encode (&_ggce ); -_fa !=nil {return nil ,_dbc .Errorf ("e\u006e\u0063\u006f\u0064\u0069\u006eg\u0020\u0072\u0065\u0071\u0075\u0065\u0073\u0074\u0020f\u0061\u0069\u006ce\u0064:\u0020\u0025\u0076",_fa );};_bbe :=_ge .Options .Addr ();_bbe =_dbc .Sprintf ("\u0025s\u002f\u0076\u0031\u002f\u0070\u0064f",_bbe ); -_eb ,_bbc :=_ab .NewRequest ("\u0050\u004f\u0053\u0054",_bbe ,_gec );if _bbc !=nil {return nil ,_bbc ;};_eb .Header .Set ("\u0043\u006f\u006et\u0065\u006e\u0074\u002d\u0054\u0079\u0070\u0065","\u0061\u0070p\u006c\u0069\u0063a\u0074\u0069\u006f\u006e\u002f\u006a\u0073\u006f\u006e"); -_eb .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"); -_eb =_eb .WithContext (_ba );return _eb ,nil ;}; \ No newline at end of file +// PDFResponse is the response used by the HTMLConverter. +type PDFResponse struct{ID string `json:"id"`;Data []byte `json:"data"`;}; \ No newline at end of file diff --git a/common/common.go b/common/common.go index a52f214..e8fbe84 100644 --- a/common/common.go +++ b/common/common.go @@ -10,8 +10,7 @@ // 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 =2024;const Version ="\u0030\u002e\u0039.\u0030"; +package common ;import _gc "time";const Version ="\u0030\u002e\u0031\u0030\u002e\u0030";const _d ="\u0032\u0020\u004aan\u0075\u0061\u0072\u0079\u0020\u0032\u0030\u0030\u0036\u0020\u0061\u0074\u0020\u0031\u0035\u003a\u0030\u0034";const _e =20; // UtcTimeFormat returns a formatted string describing a UTC timestamp. -func UtcTimeFormat (t _e .Time )string {return t .Format (_ca )+"\u0020\u0055\u0054\u0043"};const _ef =20;const _ca ="\u0032\u0020\u004aan\u0075\u0061\u0072\u0079\u0020\u0032\u0030\u0030\u0036\u0020\u0061\u0074\u0020\u0031\u0035\u003a\u0030\u0034";const _cd =12; -var ReleasedAt =_e .Date (_f ,_cd ,_d ,_fc ,_ef ,0,0,_e .UTC );const _d =22;const _fc =12; \ No newline at end of file +func UtcTimeFormat (t _gc .Time )string {return t .Format (_d )+"\u0020\u0055\u0054\u0043"};const _b =2025;var ReleasedAt =_gc .Date (_b ,_c ,_gb ,_gf ,_e ,0,0,_gc .UTC );const _gb =25;const _gf =12;const _c =3; \ No newline at end of file diff --git a/content/content.go b/content/content.go index 3740d9b..e15806f 100644 --- a/content/content.go +++ b/content/content.go @@ -9,64 +9,64 @@ // 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 (_b "archive/zip";_ab "bytes";_bd "fmt";_a "net/url";_d "os";_bc "strings";); +package content ;import (_e "archive/zip";_fd "bytes";_b "fmt";_f "net/url";_df "os";_a "strings";);type webURL struct{_gd string }; -// Method gets the query method. -func (_bg *htmlFile )Method ()string {return "\u0068\u0074\u006d\u006c"};type htmlFile struct{_c _ab .Buffer }; +// Data implements Content interface. +func (_fc *webURL )Data ()[]byte {return []byte (_fc ._gd )}; -// Content is an interface used for putting the content into Client Query. -type Content interface{ContentType ()string ;Method ()string ;Data ()[]byte ;};type webURL struct{_cd string }; +// ContentType implements Content interface. +func (_db *zipDirectory )ContentType ()string {return "\u0061p\u0070l\u0069\u0063\u0061\u0074\u0069\u006f\u006e\u002f\u007a\u0069\u0070";}; // Data implements Content interface. -func (_bee *StringContent )Data ()[]byte {return []byte (_bee ._aca )}; +func (_ef *zipDirectory )Data ()[]byte {return _ef ._dff .Bytes ()}; + +// NewWebURL creates new Content webURL for provided input URL path. +func NewWebURL (path string )(Content ,error ){if _ ,_faa :=_f .Parse (path );_faa !=nil {return nil ,_faa ;};return &webURL {_gd :path },nil ;}; // ContentType implements Content interface. -func (_bad *StringContent )ContentType ()string {return "\u0074e\u0078\u0074\u002f\u0068\u0074\u006dl";}; +func (_bea *StringContent )ContentType ()string {return "\u0074e\u0078\u0074\u002f\u0068\u0074\u006dl";}; // Data implements Content interface. -func (_bgb *webURL )Data ()[]byte {return []byte (_bgb ._cd )};func (_af *zipDirectory )zipPath (_dcd ,_fa string )error {_abc ,_agf :=_d .ReadDir (_dcd );if _agf !=nil {return _bd .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",_dcd ,_agf ); -};_de :=&_bc .Builder {};for _ ,_bae :=range _abc {_cc ,_faf :=_bae .Info ();if _faf !=nil {return _faf ;};_ee ,_eg :=_af .zipBasePaths (_cc ,_dcd ,_fa ,_bae .IsDir (),_de );if _bae .IsDir (){if _aag :=_af .zipPath (_ee ,_eg );_aag !=nil {return _aag ; -};continue ;};_gf ,_faf :=_d .ReadFile (_ee );if _faf !=nil {return _faf ;};_be ,_faf :=_af ._g .Create (_eg );if _faf !=nil {return _faf ;};if _ ,_faf =_be .Write (_gf );_faf !=nil {return _faf ;};};return nil ;}; - -// Method gets the zip directory method. -func (_ba *zipDirectory )Method ()string {return "\u0064\u0069\u0072"}; +func (_dbe *StringContent )Data ()[]byte {return []byte (_dbe ._fe )}; -// NewWebURL creates new Content webURL for provided input URL path. -func NewWebURL (path string )(Content ,error ){if _ ,_cg :=_a .Parse (path );_cg !=nil {return nil ,_cg ;};return &webURL {_cd :path },nil ;};func (_dfe *zipDirectory )zipBasePaths (_gfa _d .FileInfo ,_gg ,_ffe string ,_ffed bool ,_gd *_bc .Builder )(string ,string ){_gd .WriteString (_gg ); -if !_bc .HasSuffix (_gg ,"\u002f"){_gd .WriteRune ('/');};_gd .WriteString (_gfa .Name ());if _ffed {_gd .WriteRune ('/');};_ca :=_gd .String ();_gd .Reset ();_gd .WriteString (_ffe );_gd .WriteString (_gfa .Name ());if _ffed {_gd .WriteRune ('/');};_gbd :=_gd .String (); -_gd .Reset ();return _ca ,_gbd ;}; +// StringContent implements Content interface for an HTML string. +type StringContent struct{_fe string };func (_aaa *zipDirectory )zipBasePaths (_ab _df .FileInfo ,_gc ,_de string ,_da bool ,_fdf *_a .Builder )(string ,string ){_fdf .WriteString (_gc );if !_a .HasSuffix (_gc ,"\u002f"){_fdf .WriteRune ('/');};_fdf .WriteString (_ab .Name ()); +if _da {_fdf .WriteRune ('/');};_bfe :=_fdf .String ();_fdf .Reset ();_fdf .WriteString (_de );_fdf .WriteString (_ab .Name ());if _da {_fdf .WriteRune ('/');};_gf :=_fdf .String ();_fdf .Reset ();return _bfe ,_gf ;};type zipDirectory struct{_dff _fd .Buffer ; +_ce *_e .Writer ;}; -// Method gets the web url query method. -func (_ag *webURL )Method ()string {return "\u0077\u0065\u0062"}; +// 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 ){_dfc :=&zipDirectory {_dff :_fd .Buffer {}};_dfc ._ce =_e .NewWriter (&_dfc ._dff );if _cea :=_dfc .zipPath (dirPath ,"");_cea !=nil {return nil ,_cea ;};if _ec :=_dfc ._ce .Close ();_ec !=nil {return nil ,_ec ; +};return _dfc ,nil ;};func (_ga *zipDirectory )zipPath (_gb ,_ge string )error {_fac ,_ac :=_df .ReadDir (_gb );if _ac !=nil {return _b .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",_gb ,_ac ); +};_cg :=&_a .Builder {};for _ ,_fca :=range _fac {_bd ,_acb :=_fca .Info ();if _acb !=nil {return _acb ;};_dd ,_ee :=_ga .zipBasePaths (_bd ,_gb ,_ge ,_fca .IsDir (),_cg );if _fca .IsDir (){if _ae :=_ga .zipPath (_dd ,_ee );_ae !=nil {return _ae ;};continue ; +};_dc ,_acb :=_df .ReadFile (_dd );if _acb !=nil {return _acb ;};_cb ,_acb :=_ga ._ce .Create (_ee );if _acb !=nil {return _acb ;};if _ ,_acb =_cb .Write (_dc );_acb !=nil {return _acb ;};};return nil ;}; -// NewHTMLFile creates new Content htmFile for provided input path. -func NewHTMLFile (path string )(Content ,error ){_f ,_ff :=_d .Open (path );if _ff !=nil {return nil ,_ff ;};_bce :=&htmlFile {_c :_ab .Buffer {}};if _ ,_ff =_bce ._c .ReadFrom (_f );_ff !=nil {return nil ,_ff ;};return _bce ,nil ;}; +// Data implements Content interface. +func (_fg *htmlFile )Data ()[]byte {return _fg ._c .Bytes ()}; -// ContentType implements Content interface. -func (_aa *webURL )ContentType ()string {return "\u0074\u0065\u0078\u0074\u002f\u0070\u006c\u0061\u0069\u006e";}; +// NewStringContent creates a new StringContent. +func NewStringContent (html string )(*StringContent ,error ){return &StringContent {_fe :html },nil }; -// StringContent implements Content interface for an HTML string. -type StringContent struct{_aca string }; +// Method implements Content interface. +func (_adg *StringContent )Method ()string {return "\u0068\u0074\u006d\u006c"}; // ContentType implements Content interface. -func (_fg *zipDirectory )ContentType ()string {return "\u0061p\u0070l\u0069\u0063\u0061\u0074\u0069\u006f\u006e\u002f\u007a\u0069\u0070";}; +func (_bg *webURL )ContentType ()string {return "\u0074\u0065\u0078\u0074\u002f\u0070\u006c\u0061\u0069\u006e";}; -// NewStringContent creates a new StringContent. -func NewStringContent (html string )(*StringContent ,error ){return &StringContent {_aca :html },nil }; +// Method gets the query method. +func (_be *htmlFile )Method ()string {return "\u0068\u0074\u006d\u006c"}; -// Data implements Content interface. -func (_ac *zipDirectory )Data ()[]byte {return _ac ._cbb .Bytes ()}; +// Content is an interface used for putting the content into Client Query. +type Content interface{ContentType ()string ;Method ()string ;Data ()[]byte ;}; // ContentType implements Content interface. -func (_dc *htmlFile )ContentType ()string {return "\u0074e\u0078\u0074\u002f\u0068\u0074\u006dl"}; +func (_fag *htmlFile )ContentType ()string {return "\u0074e\u0078\u0074\u002f\u0068\u0074\u006dl"};type htmlFile struct{_c _fd .Buffer }; -// 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 ){_df :=&zipDirectory {_cbb :_ab .Buffer {}};_df ._g =_b .NewWriter (&_df ._cbb );if _dca :=_df .zipPath (dirPath ,"");_dca !=nil {return nil ,_dca ;};if _cgd :=_df ._g .Close ();_cgd !=nil {return nil ,_cgd ; -};return _df ,nil ;}; +// Method gets the zip directory method. +func (_aa *zipDirectory )Method ()string {return "\u0064\u0069\u0072"}; -// Data implements Content interface. -func (_cb *htmlFile )Data ()[]byte {return _cb ._c .Bytes ()}; +// NewHTMLFile creates new Content htmFile for provided input path. +func NewHTMLFile (path string )(Content ,error ){_fa ,_cc :=_df .Open (path );if _cc !=nil {return nil ,_cc ;};_g :=&htmlFile {_c :_fd .Buffer {}};if _ ,_cc =_g ._c .ReadFrom (_fa );_cc !=nil {return nil ,_cc ;};return _g ,nil ;}; -// Method implements Content interface. -func (_ga *StringContent )Method ()string {return "\u0068\u0074\u006d\u006c"};type zipDirectory struct{_cbb _ab .Buffer ;_g *_b .Writer ;}; \ No newline at end of file +// Method gets the web url query method. +func (_ca *webURL )Method ()string {return "\u0077\u0065\u0062"}; \ No newline at end of file diff --git a/go.mod b/go.mod index 8c52edc..d125340 100644 --- a/go.mod +++ b/go.mod @@ -6,17 +6,17 @@ require ( github.com/mitchellh/go-homedir v1.1.0 github.com/spf13/cobra v1.8.0 github.com/spf13/viper v1.16.0 - github.com/stretchr/testify v1.9.0 - github.com/unidoc/unipdf/v3 v3.64.0 + github.com/stretchr/testify v1.10.0 + github.com/unidoc/unipdf/v3 v3.68.0 ) require ( github.com/adrg/strutil v0.3.1 // indirect github.com/adrg/sysfont v0.1.2 // indirect - github.com/adrg/xdg v0.4.0 // indirect + github.com/adrg/xdg v0.5.3 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect - github.com/gabriel-vasile/mimetype v1.4.3 // indirect + github.com/gabriel-vasile/mimetype v1.4.8 // indirect github.com/gorilla/i18n v0.0.0-20150820051429-8b358169da46 // indirect github.com/hashicorp/hcl v1.0.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect @@ -33,14 +33,14 @@ require ( github.com/unidoc/freetype v0.2.3 // indirect github.com/unidoc/pkcs7 v0.2.0 // indirect github.com/unidoc/timestamp v0.0.0-20200412005513-91597fd3793a // indirect - github.com/unidoc/unichart v0.3.0 // indirect - github.com/unidoc/unitype v0.4.0 // indirect - golang.org/x/crypto v0.31.0 // indirect - golang.org/x/image v0.18.0 // indirect - golang.org/x/net v0.33.0 // indirect - golang.org/x/sys v0.28.0 // indirect - golang.org/x/text v0.21.0 // indirect - golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect + github.com/unidoc/unichart v0.4.0 // indirect + github.com/unidoc/unitype v0.5.1 // indirect + golang.org/x/crypto v0.33.0 // indirect + golang.org/x/image v0.24.0 // indirect + golang.org/x/net v0.35.0 // indirect + golang.org/x/sys v0.30.0 // indirect + golang.org/x/text v0.22.0 // indirect + golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da // indirect gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/go.sum b/go.sum index 76ea277..0938820 100644 --- a/go.sum +++ b/go.sum @@ -4,8 +4,8 @@ github.com/adrg/strutil v0.3.1/go.mod h1:8h90y18QLrs11IBffcGX3NW/GFBXCMcNg4M7H6M github.com/adrg/sysfont v0.1.2 h1:MSU3KREM4RhsQ+7QgH7wPEPTgAgBIz0Hw6Nd4u7QgjE= github.com/adrg/sysfont v0.1.2/go.mod h1:6d3l7/BSjX9VaeXWJt9fcrftFaD/t7l11xgSywCPZGk= github.com/adrg/xdg v0.3.0/go.mod h1:7I2hH/IT30IsupOpKZ5ue7/qNi3CoKzD6tL3HwpaRMQ= -github.com/adrg/xdg v0.4.0 h1:RzRqFcjH4nE5C6oTAxhBtoE2IRyjBSa62SCbyPidvls= -github.com/adrg/xdg v0.4.0/go.mod h1:N6ag73EX4wyxeaoeHctc1mas01KZgsj5tYiAIwqJE/E= +github.com/adrg/xdg v0.5.3 h1:xRnxJXne7+oWDatRhR1JLnvuccuIeCoBu2rtuLqQB78= +github.com/adrg/xdg v0.5.3/go.mod h1:nlTsY+NNiCBGCK2tpm09vRqfVzrc2fLmXGpBLF0zlTQ= github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -14,8 +14,8 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8Yc github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= -github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0= -github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk= +github.com/gabriel-vasile/mimetype v1.4.8 h1:FfZ3gj38NjllZIeJAmMhr+qKL8Wu+nOoI3GqacKw1NM= +github.com/gabriel-vasile/mimetype v1.4.8/go.mod h1:ByKUIKGjh1ODkGM1asKUbQZOLGrPjydw3hYPU2YU9t8= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/gorilla/i18n v0.0.0-20150820051429-8b358169da46 h1:N+R2A3fGIr5GucoRMu2xpqyQWQlfY31orbofBCdjMz8= github.com/gorilla/i18n v0.0.0-20150820051429-8b358169da46/go.mod h1:2Yoiy15Cf7Q3NFwfaJquh7Mk1uGI09ytcD7CUhn8j7s= @@ -23,9 +23,6 @@ github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= -github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= @@ -44,7 +41,6 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRI github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/sirupsen/logrus v1.5.0/go.mod h1:+F7Ogzej0PZc/94MaYx/nvG9jOFMD2osvC3s+Squfpo= github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8= @@ -64,14 +60,14 @@ github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSS github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= github.com/unidoc/freetype v0.2.3 h1:uPqW+AY0vXN6K2tvtg8dMAtHTEvvHTN52b72XpZU+3I= @@ -81,39 +77,33 @@ github.com/unidoc/pkcs7 v0.2.0 h1:0Y0RJR5Zu7OuD+/l7bODXARn6b8Ev2G4A8lI4rzy9kg= github.com/unidoc/pkcs7 v0.2.0/go.mod h1:UEzOZUEpJfDpywVJMUT8QiugqEZC29pDq7kdIZhWCr8= github.com/unidoc/timestamp v0.0.0-20200412005513-91597fd3793a h1:RLtvUhe4DsUDl66m7MJ8OqBjq8jpWBXPK6/RKtqeTkc= github.com/unidoc/timestamp v0.0.0-20200412005513-91597fd3793a/go.mod h1:j+qMWZVpZFTvDey3zxUkSgPJZEX33tDgU/QIA0IzCUw= -github.com/unidoc/unichart v0.3.0 h1:VX1j5yzhjrR3f2flC03Yat6/WF3h7Z+DLEvJLoTGhoc= -github.com/unidoc/unichart v0.3.0/go.mod h1:8JnLNKSOl8yQt1jXewNgYFHhFm5M6/ZiaydncFDpakA= -github.com/unidoc/unipdf/v3 v3.64.0 h1:6qP8Q7lprY+LIgEz43Ni8mM+q7dCydRp3uwnf9LxzTU= -github.com/unidoc/unipdf/v3 v3.64.0/go.mod h1:0OIzSHHno23Y8WzaK+852abK8d3AxUZ1GQkMqpyCzu8= -github.com/unidoc/unitype v0.4.0 h1:/TMZ3wgwfWWX64mU5x2O9no9UmoBqYCB089LYYqHyQQ= -github.com/unidoc/unitype v0.4.0/go.mod h1:HV5zuUeqMKA4QgYQq3KDlJY/P96XF90BQB+6czK6LVA= -golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U= -golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= +github.com/unidoc/unichart v0.4.0 h1:uXk9ZjbqzKb8Lt2Qv2oM9D2ftNRXvezPevgxQhsTQys= +github.com/unidoc/unichart v0.4.0/go.mod h1:9QsE8RbS0fE7ndHNroeCEFkRPqqk47Qsoj6QSAtcwN0= +github.com/unidoc/unipdf/v3 v3.68.0 h1:AM1wKukv75hvCtTbiPb3HSIdHS5RbmR6aYTCE0jiO+A= +github.com/unidoc/unipdf/v3 v3.68.0/go.mod h1:4mQ4E8niuY+30TGxT1e/8aVoSk/nn0yCKfi+kYw98+I= +github.com/unidoc/unitype v0.5.1 h1:UwTX15K6bktwKocWVvLoijIeu4JAVEAIeFqMOjvxqQs= +github.com/unidoc/unitype v0.5.1/go.mod h1:3dxbRL+f1otNqFQIRHho8fxdg3CcUKrqS8w1SXTsqcI= +golang.org/x/crypto v0.33.0 h1:IOBPskki6Lysi0lo9qQvbxiQ+FvsCC/YWOecCHAixus= +golang.org/x/crypto v0.33.0/go.mod h1:bVdXmD7IV/4GdElGPozy6U7lWdRXA4qyRVGJV57uQ5M= golang.org/x/image v0.0.0-20211028202545-6944b10bf410/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM= -golang.org/x/image v0.18.0 h1:jGzIakQa/ZXI1I0Fxvaa9W7yP25TqT6cHIHn+6CqvSQ= -golang.org/x/image v0.18.0/go.mod h1:4yyo5vMFQjVjUcVk4jEQcU9MGy/rulF5WvUILseCM2E= -golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= -golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= -golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/image v0.24.0 h1:AN7zRgVsbvmTfNyqIbbOraYL8mSwcKncEj8ofjgzcMQ= +golang.org/x/image v0.24.0/go.mod h1:4b/ITuLfqYq1hqZcjofwctIhi7sZh2WaCjvsBNjjya8= +golang.org/x/net v0.35.0 h1:T5GQRQb2y08kTAByq9L4/bz8cipCdA8FbRTXewonqY8= +golang.org/x/net v0.35.0/go.mod h1:EglIi67kWsHKlRzzVMUD93VMSWGFOMSZgxFjparz1Qk= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220731174439-a90be440212d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= -golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc= +golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= -golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= +golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM= +golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 h1:+cNy6SZtPcJQH3LJVLOSmiC7MMxXNOb3PU/VUEz+EhU= -golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028/go.mod h1:NDW/Ps6MPRej6fsCIbMTohpP40sJ/P/vI1MoTEGwX90= +golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da h1:noIWHXmPHxILtqtCOPIhSt0ABwskkZKjD3bXGnZGpNY= +golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da/go.mod h1:NDW/Ps6MPRej6fsCIbMTohpP40sJ/P/vI1MoTEGwX90= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/selector/selector.go b/selector/selector.go index c2986e7..4d5b7c7 100644 --- a/selector/selector.go +++ b/selector/selector.go @@ -9,10 +9,10 @@ // 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 selector ;import _b "errors"; - -// ByType is a 'By' selector type enumerator. -type ByType uint ;const (ByUndefined ByType =iota ;ByID ;ByQueryAll ;ByQuery ;ByNodeID ;ByJSPath ;BySearch ;); +package selector ;import _f "errors"; // Validate checks validity of the ByType. -func (_dd ByType )Validate ()error {if _dd >=ByID &&_dd <=BySearch {return nil ;};return _b .New ("\u0069\u006e\u0076\u0061li\u0064\u0020\u0062\u0079\u0020\u0073\u0065\u006c\u0065\u0063\u0074\u006f\u0072");}; \ No newline at end of file +func (_e ByType )Validate ()error {if _e >=ByID &&_e <=BySearch {return nil ;};return _f .New ("\u0069\u006e\u0076\u0061li\u0064\u0020\u0062\u0079\u0020\u0073\u0065\u006c\u0065\u0063\u0074\u006f\u0072");}; + +// ByType is a 'By' selector type enumerator. +type ByType uint ;const (ByUndefined ByType =iota ;ByID ;ByQueryAll ;ByQuery ;ByNodeID ;ByJSPath ;BySearch ;); \ No newline at end of file diff --git a/sizes/sizes.go b/sizes/sizes.go index bbac2a7..fe84dcc 100644 --- a/sizes/sizes.go +++ b/sizes/sizes.go @@ -12,190 +12,190 @@ // Package sizes defines basic types that determines the size units i.e. lengths. // // -package sizes ;import (_d "encoding/json";_a "flag";_bd "fmt";_c "strconv";_b "strings";);const _ece ="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"; +package sizes ;import (_g "encoding/json";_ae "flag";_e "fmt";_ce "strconv";_c "strings";);const (_cd =float64 (1)/float64 (25.4);_b =25.4;_d =0.0139;_ac =0.3528;_cb =1.0/64;_bc =1.0/_ac ;); +// MarshalPageSize marshals the page size into string. +func MarshalPageSize (p PageSize )(string ,error ){_cgg ,_ab :=p .MarshalText ();if _ab !=nil {return "",_ab ;};return string (_cgg ),nil ;}; -// Inches gets the inches equivalent from provided millimeter value. -func (_ebb Millimeter )Inches ()Inch {return Inch (float64 (_ebb )*_cb )}; +// Name implements viper.FlagValue interface. +func (_bab Point )Name ()string {return "\u0070\u006f\u0069n\u0074"};var _ Length =Inch (0);var _ccc =[]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};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 ;); -// ValueString implements viper.FlagValue interface. -func (_fgc Point )ValueString ()string {return _fgc .String ()};var _ Length =Inch (0); +// String implements fmt.Stringer interface. +func (_fc Inch )String ()string {_aa :=_c .Builder {};_aa .WriteString (_ce .FormatFloat (float64 (_fc ),'f',1,64));_aa .WriteString ("\u0069\u006e");return _aa .String ();};func _eaa (_fbb string )(Point ,error ){_fbb =_c .TrimSpace (_c .Trim (_fbb ,"\u0070\u0074")); +_bbe ,_gdf :=_ce .ParseFloat (_fbb ,64);if _gdf !=nil {return 0,_gdf ;};return Point (_bbe ),nil ;}; -// String gets the string value for given flag. -func (_db *LengthFlag )String ()string {if _db .Length ==nil {return "\u0075n\u0064\u0065\u0066\u0069\u006e\u0065d";};return _db .Length .String ();}; +// Orientation is the page orientation type wrapper. +type Orientation bool ; -// ValueType implements pflag.Value interface. -func (_aa Inch )ValueType ()string {return _aa .Type ()}; +// Points implements Length interface. +func (_dcc Inch )Points ()Point {return Point (float64 (_dcc )*_cb )}; -// ValueType implements viper.FlagValue interface. -func (_dbb Point )ValueType ()string {return _dbb .Type ()}; +// Set implements pflag.Value interface. +func (_ecd *PageSize )Set (s string )error {_bdf ,_fgb :=UnmarshalPageSize (s );if _fgb !=nil {return _fgb ;};*_ecd =_bdf ;return nil ;}; -// Set sets the unit value. -// Implements pflag.Value interface. -func (_ga *LengthFlag )Set (s string )error {if s =="\u0075n\u0064\u0065\u0066\u0069\u006e\u0065d"{_ga .Length =nil ;return nil ;};_ae ,_bc :=UnmarshalLength (s );if _bc !=nil {return _bc ;};_ga .Length =_ae ;return nil ;}; +// PageSizeValues returns all values of the enum +func PageSizeValues ()[]PageSize {return _ccc };const (Portrait =Orientation (false );Landscape =Orientation (true );); -// Inches gets the inch value. Implements Length interface. -func (_ccf Inch )Inches ()Inch {return _ccf }; +// Points implements Length interface. +func (_aef Millimeter )Points ()Point {return Point (_aef *_bc )}; -// MarshalJSON implements the json.Marshaler interface for PageSize -func (_gd PageSize )MarshalJSON ()([]byte ,error ){return _d .Marshal (_gd .String ())}; +// 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 _afb ,_bbfe :=_gde [s ];_bbfe {return _afb ,nil ;};return 0,_e .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 ); +}; -// UnmarshalLength unmarshalls string value into Length. -func UnmarshalLength (length string )(Length ,error ){if _b .HasSuffix (length ,"\u006d\u006d"){return _dcg (length );};if _b .HasSuffix (length ,"\u0069\u006e"){return _cbfe (length );};if _b .HasSuffix (length ,"\u0070\u0074"){return _ccb (length );}; -return nil ,_bd .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 _eca =[...]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}; -func _ccb (_gf string )(Point ,error ){_gf =_b .TrimSpace (_b .Trim (_gf ,"\u0070\u0074"));_dgb ,_abe :=_c .ParseFloat (_gf ,64);if _abe !=nil {return 0,_abe ;};return Point (_dgb ),nil ;}; +// Dimensions gets the dimensions of the given page size. +// If provided page size is not valid than the function returns 0 values. +func (_bae PageSize )Dimensions ()(_ga ,_bdfc Millimeter ){switch _bae {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 _ga ,_bdfc ;};var _fdg =[...]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}; -// Set implements flag.Value interface. -func (_fce *Point )Set (s string )error {_fg ,_bef :=_c .ParseFloat (s ,64);if _bef !=nil {return _bd .Errorf ("\u0069\u006e\u0076\u0061li\u0064\u0020\u0069\u006e\u0063\u0068\u0020\u0076\u0061\u006c\u0075\u0065\u003a\u0020%\u0077",_bef );};*_fce =Point (_fg ); -return nil ;}; +// HasChanged implements pflag.Value interface. +func (_fcd *Inch )HasChanged ()bool {return _fcd !=nil }; -// ValueString implements pflag.Value interface. -func (_de Inch )ValueString ()string {return _de .String ()}; +// Type implements pflag.Value interface. +func (_bd *LengthFlag )Type ()string {return "\u0075\u006e\u0069\u0074"}; // String implements fmt.Stringer interface. -func (_dbe Inch )String ()string {_bg :=_b .Builder {};_bg .WriteString (_c .FormatFloat (float64 (_dbe ),'f',1,64));_bg .WriteString ("\u0069\u006e");return _bg .String ();}; - -// Inch is a unit that -type Inch 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 ;);var _add =map[string ]PageSize {_ece [0:9]:0,_ece [9:11]:1,_ece [11:13]:2,_ece [13:15]:3,_ece [15:17]:4,_ece [17:19]:5,_ece [19:21]:6,_ece [21:23]:7,_ece [23:25]:8,_ece [25:27]:9,_ece [27:29]:10,_ece [29:32]:11,_ece [32:34]:12,_ece [34:36]:13,_ece [36:38]:14,_ece [38:40]:15,_ece [40:42]:16,_ece [42:44]:17,_ece [44:46]:18,_ece [46:48]:19,_ece [48:50]:20,_ece [50:52]:21,_ece [52:55]:22,_ece [55:61]:23}; +func (_cg Point )String ()string {_da :=_c .Builder {};_da .WriteString (_ce .FormatFloat (float64 (_cg ),'f',1,64));_da .WriteString ("\u0070\u0074");return _da .String ();}; +// UnmarshalLength unmarshalls string value into Length. +func UnmarshalLength (length string )(Length ,error ){if _c .HasSuffix (length ,"\u006d\u006d"){return _dbf (length );};if _c .HasSuffix (length ,"\u0069\u006e"){return _fg (length );};if _c .HasSuffix (length ,"\u0070\u0074"){return _eaa (length );};return nil ,_e .Errorf ("\u0069n\u0076\u0061\u006c\u0069\u0064\u0020\u006c\u0065\u006e\u0067\u0074h\u0020\u0069\u006e\u0070\u0075\u0074\u003a\u0020\u0025\u0073",length ); +}; -// HasChanged implements pflag.Value interface. -func (_df *Inch )HasChanged ()bool {return _df !=nil }; - -// Name implements viper.FlagValue interface. -func (_cce Point )Name ()string {return "\u0070\u006f\u0069n\u0074"};var _ _a .Value =(*Point )(nil ); - -// MarshalText implements the encoding.TextMarshaler interface for PageSize -func (_bae PageSize )MarshalText ()([]byte ,error ){return []byte (_bae .String ()),nil }; +// MarshalJSON implements json.Marshaler interface +func (_cda Millimeter )MarshalJSON ()([]byte ,error ){return _cff (_cda )}; // Type implements pflag.Value interface. -func (_cda Orientation )Type ()string {return "o\u0072\u0069\u0065\u006e\u0074\u0061\u0074\u0069\u006f\u006e";}; +func (_aaf Point )Type ()string {return "\u0070\u006f\u0069n\u0074"}; -// MarshalUnit marshals the unit into the string. -func MarshalUnit (unit Length )(string ,error ){switch _fe :=unit .(type ){case Millimeter :return _bd .Sprintf ("\u0025\u002e\u0030\u0066\u006d\u006d",_fe ),nil ;case Inch :return _bd .Sprintf ("\u0025\u002e\u0030\u0066\u0069\u006e",_fe ),nil ;case Point :return _bd .Sprintf ("\u0025\u002e\u0030\u0066\u0070\u0074",_fe ),nil ; -default:return "",_bd .Errorf ("i\u006e\u0076\u0061\u006cid\u0020u\u006e\u0069\u0074\u0020\u0074y\u0070\u0065\u003a\u0020\u0025\u0054",unit );};}; - -// String implements fmt.Stringer interface. -func (_aab Orientation )String ()string {if _aab ==Portrait {return "\u0070\u006f\u0072\u0074\u0072\u0061\u0069\u0074";};return "\u006ca\u006e\u0064\u0073\u0063\u0061\u0070e";}; +// MarshalJSON implements json.Marshaler interface +func (_dce Inch )MarshalJSON ()([]byte ,error ){return _cff (_dce )}; -// Point is a unit of Length commonly used to measure the height of fonts. -type Point float64 ; +// MarshalJSON implements the json.Marshaler interface for PageSize +func (_gdff PageSize )MarshalJSON ()([]byte ,error ){return _g .Marshal (_gdff .String ())}; -// Type implements pflag.Value interface. -func (_fc Inch )Type ()string {return "\u0069\u006e\u0063\u0068"}; +// Millimeter is the dimension unit that defines a millimeter. +type Millimeter float64 ; -// Set implements pflag.Value interface. -func (_aaa *PageSize )Set (s string )error {_fed ,_acf :=UnmarshalPageSize (s );if _acf !=nil {return _acf ;};*_aaa =_fed ;return nil ;}; +// UnmarshalPageSize unmarshals the page size from the string. +func UnmarshalPageSize (pageSize string )(PageSize ,error ){var _fd PageSize ;if _gce :=(&_fd ).UnmarshalText ([]byte (pageSize ));_gce !=nil {return 0,_e .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",_gce ); +};return _fd ,nil ;};func _dbf (_beaf string )(Millimeter ,error ){_beaf =_c .TrimSpace (_c .TrimSuffix (_beaf ,"\u006d\u006d"));_agg ,_fa :=_ce .ParseFloat (_beaf ,64);if _fa !=nil {return 0,_e .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",_fa ); +};return Millimeter (_agg ),nil ;}; -// Set implements flag.Value interface. -func (_cde *Orientation )Set (s string )error {switch s {case "\u0070\u006f\u0072\u0074\u0072\u0061\u0069\u0074":*_cde =Portrait ;case "\u006ca\u006e\u0064\u0073\u0063\u0061\u0070e":*_cde =Landscape ;default:return _bd .Errorf ("\u0069n\u0076\u0061\u006c\u0069d\u0020\u006f\u0072\u0069\u0065n\u0074a\u0074i\u006f\u006e\u003a\u0020\u0027\u0025\u0073'",s ); -};return nil ;}; +// MarshalText implements the encoding.TextMarshaler interface for PageSize +func (_ggb PageSize )MarshalText ()([]byte ,error ){return []byte (_ggb .String ()),nil }; -// PageSize is the enum used for defining the page size. -type PageSize int ;func _dcg (_dbg string )(Millimeter ,error ){_dbg =_b .TrimSpace (_b .TrimSuffix (_dbg ,"\u006d\u006d"));_fd ,_egag :=_c .ParseFloat (_dbg ,64);if _egag !=nil {return 0,_bd .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",_egag ); -};return Millimeter (_fd ),nil ;}; +// Type implements pflag.Value interface. +func (_ee Orientation )Type ()string {return "o\u0072\u0069\u0065\u006e\u0074\u0061\u0074\u0069\u006f\u006e";};const _fdf ="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"; -// Millimeters converts the inches value to the millimeters. -func (_gab Point )Millimeters ()Millimeter {return Millimeter (float64 (_gab )*_g )}; -// String implements fmt.Stringer interface. -func (_gac Point )String ()string {_ebe :=_b .Builder {};_ebe .WriteString (_c .FormatFloat (float64 (_gac ),'f',1,64));_ebe .WriteString ("\u0070\u0074");return _ebe .String ();};func (_cad PageSize )String ()string {if _cad < 0||_cad >=PageSize (len (_eca )-1){return _bd .Sprintf ("\u0050\u0061\u0067e\u0053\u0069\u007a\u0065\u0028\u0025\u0064\u0029",_cad ); -};return _ece [_eca [_cad ]:_eca [_cad +1]];}; +// Inch is a unit that +type Inch float64 ; -// UnmarshalJSON implements the json.Unmarshaler interface for PageSize -func (_acg *PageSize )UnmarshalJSON (data []byte )error {var _bgg string ;if _bag :=_d .Unmarshal (data ,&_bgg );_bag !=nil {return _bd .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 _ege error ;*_acg ,_ege =PageSizeString (_bgg );return _ege ;}; +// Set sets the unit value. +// Implements pflag.Value interface. +func (_cf *LengthFlag )Set (s string )error {if s =="\u0075n\u0064\u0065\u0066\u0069\u006e\u0065d"{_cf .Length =nil ;return nil ;};_bg ,_f :=UnmarshalLength (s );if _f !=nil {return _f ;};_cf .Length =_bg ;return nil ;}; -// PageSizeValues returns all values of the enum -func PageSizeValues ()[]PageSize {return _fef };var _fef =[]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}; +// Points implements Length interface. +func (_bea Point )Points ()Point {return _bea }; // String implements fmt.Stringer interface. -func (_ff Millimeter )String ()string {_gag :=_b .Builder {};_gag .WriteString (_c .FormatFloat (float64 (_ff ),'f',1,64));_gag .WriteString ("\u006d\u006d");return _gag .String ();};var _ _a .Value =(*Orientation )(nil ); - -// Name implements pflag.Value interface. -func (_gae Inch )Name ()string {return "\u0069\u006e\u0063\u0068"}; - -// Millimeters converts the inches value to the millimeters. -func (_dfa Inch )Millimeters ()Millimeter {return Millimeter (float64 (_dfa )*_ba )}; +func (_df Millimeter )String ()string {_cea :=_c .Builder {};_cea .WriteString (_ce .FormatFloat (float64 (_df ),'f',1,64));_cea .WriteString ("\u006d\u006d");return _cea .String ();}; -// Millimeter is the dimension unit that defines a millimeter. -type Millimeter float64 ; +// Type implements pflag.Value interface. +func (_ea Inch )Type ()string {return "\u0069\u006e\u0063\u0068"}; -// Orientation is the page orientation type wrapper. -type Orientation bool ; +// ValueString implements pflag.Value interface. +func (_ba Inch )ValueString ()string {return _ba .String ()}; -// MarshalJSON implements json.Marshaler interface -func (_ab Millimeter )MarshalJSON ()([]byte ,error ){return _bff (_ab )}; +// UnmarshalText implements the encoding.TextUnmarshaler interface for PageSize +func (_gdfa *PageSize )UnmarshalText (text []byte )error {var _gad error ;*_gdfa ,_gad =PageSizeString (string (text ));return _gad ;};func _cff (_cgd Length )([]byte ,error ){if _cgd ==nil {return nil ,nil ;};_ccd ,_cfb :=MarshalUnit (_cgd );if _cfb !=nil {return nil ,_cfb ; +};return []byte ("\u0022"+_ccd +"\u0022"),nil ;}; -// UnmarshalInch unmarshalls provided string into unit. -func UnmarshalInch (unit string )(Inch ,error ){if _b .HasSuffix (unit ,"\u006d\u006d"){_dg ,_af :=_dcg (unit );if _af !=nil {return 0,_af ;};return _dg .Inches (),nil ;};if _b .HasSuffix (unit ,"\u0069\u006e"){return _cbfe (unit );};return 0,_bd .Errorf ("\u0069\u006e\u0076\u0061li\u0064\u0020\u0069\u006e\u0063\u0068\u0020\u0069\u006e\u0070\u0075\u0074\u003a\u0020%\u0073",unit ); -}; +// Point is a unit of Length commonly used to measure the height of fonts. +type Point float64 ; -// MarshalJSON implements json.Marshaler interface -func (_ac Inch )MarshalJSON ()([]byte ,error ){return _bff (_ac )};const (Portrait =Orientation (false );Landscape =Orientation (true ););func _bff (_aba Length )([]byte ,error ){if _aba ==nil {return nil ,nil ;};_ad ,_fdd :=MarshalUnit (_aba );if _fdd !=nil {return nil ,_fdd ; -};return []byte ("\u0022"+_ad +"\u0022"),nil ;}; +// ValueType implements viper.FlagValue interface. +func (_ag Point )ValueType ()string {return _ag .Type ()}; // Set implements pflag.Value interface. -func (_ega *Inch )Set (s string )error {_dc ,_cc :=_c .ParseFloat (s ,64);if _cc !=nil {return _bd .Errorf ("\u0069\u006e\u0076\u0061li\u0064\u0020\u0069\u006e\u0063\u0068\u0020\u0076\u0061\u006c\u0075\u0065\u003a\u0020%\u0077",_cc );};*_ega =Inch (_dc ); -return nil ;}; +func (_dg *Inch )Set (s string )error {_dgc ,_db :=_ce .ParseFloat (s ,64);if _db !=nil {return _e .Errorf ("\u0069\u006e\u0076\u0061li\u0064\u0020\u0069\u006e\u0063\u0068\u0020\u0076\u0061\u006c\u0075\u0065\u003a\u0020%\u0077",_db );};*_dg =Inch (_dgc ); +return nil ;};func (_af PageSize )String ()string {if _af < 0||_af >=PageSize (len (_fdg )-1){return _e .Sprintf ("\u0050\u0061\u0067e\u0053\u0069\u007a\u0065\u0028\u0025\u0064\u0029",_af );};return _fdf [_fdg [_af ]:_fdg [_af +1]];}; // Type implements pflag.Value interface. -func (_fa Point )Type ()string {return "\u0070\u006f\u0069n\u0074"}; +func (_ddf PageSize )Type ()string {return "\u0070a\u0067\u0065\u002d\u0073\u0069\u007ae"}; -// 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 _ccfc ,_bec :=_add [s ];_bec {return _ccfc ,nil ;};return 0,_bd .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 ); -}; +// ValueType implements pflag.Value interface. +func (_gg Inch )ValueType ()string {return _gg .Type ()}; -// Points implements Length interface. -func (_ec Inch )Points ()Point {return Point (float64 (_ec )*_f )}; +// String implements fmt.Stringer interface. +func (_gbc Orientation )String ()string {if _gbc ==Portrait {return "\u0070\u006f\u0072\u0074\u0072\u0061\u0069\u0074";};return "\u006ca\u006e\u0064\u0073\u0063\u0061\u0070e";}; + +// IsAPageSize returns "true" if the value is listed in the enum definition. "false" otherwise +func (_gaa PageSize )IsAPageSize ()bool {for _ ,_gf :=range _ccc {if _gaa ==_gf {return true ;};};return false ;}; + +// MarshalJSON implements json.Marshaler interface. +func (_eb Point )MarshalJSON ()([]byte ,error ){return _cff (_eb )}; // HasChanged implements viper.FlagValue interface. -func (_ag *Point )HasChanged ()bool {return _ag !=nil };func _cbfe (_dbbc string )(Inch ,error ){_dbbc =_b .TrimSpace (_b .Trim (_dbbc ,"\u0069\u006e"));_dee ,_aca :=_c .ParseFloat (_dbbc ,64);if _aca !=nil {return 0,_bd .Errorf ("\u0069\u006e\u0076\u0061li\u0064\u0020\u0069\u006e\u0063\u0068\u0020\u0076\u0061\u006c\u0075\u0065\u003a\u0020%\u0077",_aca ); -};return Inch (_dee ),nil ;};const (_cb =float64 (1)/float64 (25.4);_ba =25.4;_be =0.0139;_g =0.3528;_f =1.0/64;_cg =1.0/_g ;); +func (_cga *Point )HasChanged ()bool {return _cga !=nil }; -// Type implements pflag.Value interface. -func (_bab *LengthFlag )Type ()string {return "\u0075\u006e\u0069\u0074"}; +// PageSize is the enum used for defining the page size. +type PageSize int ; -// UnmarshalPageSize unmarshals the page size from the string. -func UnmarshalPageSize (pageSize string )(PageSize ,error ){var _dcb PageSize ;if _bb :=(&_dcb ).UnmarshalText ([]byte (pageSize ));_bb !=nil {return 0,_bd .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",_bb ); -};return _dcb ,nil ;}; +// Millimeters gets the float64 millimeter value. +func (_eg Millimeter )Millimeters ()Millimeter {return _eg }; -// MarshalJSON implements json.Marshaler interface. -func (_cd Point )MarshalJSON ()([]byte ,error ){return _bff (_cd )}; +// Millimeters converts the inches value to the millimeters. +func (_dgd Inch )Millimeters ()Millimeter {return Millimeter (float64 (_dgd )*_b )}; -// Points implements Length interface. -func (_cbf Point )Points ()Point {return _cbf }; +// MarshalUnit marshals the unit into the string. +func MarshalUnit (unit Length )(string ,error ){switch _bbf :=unit .(type ){case Millimeter :return _e .Sprintf ("\u0025\u002e\u0030\u0066\u006d\u006d",_bbf ),nil ;case Inch :return _e .Sprintf ("\u0025\u002e\u0030\u0066\u0069\u006e",_bbf ),nil ;case Point :return _e .Sprintf ("\u0025\u002e\u0030\u0066\u0070\u0074",_bbf ),nil ; +default:return "",_e .Errorf ("i\u006e\u0076\u0061\u006cid\u0020u\u006e\u0069\u0074\u0020\u0074y\u0070\u0065\u003a\u0020\u0025\u0054",unit );};}; // Inches gets the inch value. Implements Length interface. -func (_dbc Point )Inches ()Inch {return Inch (float64 (_dbc )*_be )};var (_ Length =Millimeter (0);); +func (_gb Point )Inches ()Inch {return Inch (float64 (_gb )*_d )}; -// LengthFlag is a pflag wrapper for the Length value. -type LengthFlag struct{Length Length ;}; +// Name implements pflag.Value interface. +func (_dc Inch )Name ()string {return "\u0069\u006e\u0063\u0068"}; -// Millimeters gets the float64 millimeter value. -func (_eb Millimeter )Millimeters ()Millimeter {return _eb }; +// Set implements flag.Value interface. +func (_dcg *Point )Set (s string )error {_cc ,_bad :=_ce .ParseFloat (s ,64);if _bad !=nil {return _e .Errorf ("\u0069\u006e\u0076\u0061li\u0064\u0020\u0069\u006e\u0063\u0068\u0020\u0076\u0061\u006c\u0075\u0065\u003a\u0020%\u0077",_bad );};*_dcg =Point (_cc ); +return nil ;}; -// Dimensions gets the dimensions of the given page size. -// If provided page size is not valid than the function returns 0 values. -func (_ge PageSize )Dimensions ()(_ca ,_dca Millimeter ){switch _ge {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 _ca ,_dca ;}; +// Millimeters converts the inches value to the millimeters. +func (_fb Point )Millimeters ()Millimeter {return Millimeter (float64 (_fb )*_ac )}; -// UnmarshalText implements the encoding.TextUnmarshaler interface for PageSize -func (_gdd *PageSize )UnmarshalText (text []byte )error {var _gb error ;*_gdd ,_gb =PageSizeString (string (text ));return _gb ;}; +// String gets the string value for given flag. +func (_bb *LengthFlag )String ()string {if _bb .Length ==nil {return "\u0075n\u0064\u0065\u0066\u0069\u006e\u0065d";};return _bb .Length .String ();}; -// Type implements pflag.Value interface. -func (_ed PageSize )Type ()string {return "\u0070a\u0067\u0065\u002d\u0073\u0069\u007ae"}; +// LengthFlag is a pflag wrapper for the Length value. +type LengthFlag struct{Length Length ;};var _gde =map[string ]PageSize {_fdf [0:9]:0,_fdf [9:11]:1,_fdf [11:13]:2,_fdf [13:15]:3,_fdf [15:17]:4,_fdf [17:19]:5,_fdf [19:21]:6,_fdf [21:23]:7,_fdf [23:25]:8,_fdf [25:27]:9,_fdf [27:29]:10,_fdf [29:32]:11,_fdf [32:34]:12,_fdf [34:36]:13,_fdf [36:38]:14,_fdf [38:40]:15,_fdf [40:42]:16,_fdf [42:44]:17,_fdf [44:46]:18,_fdf [46:48]:19,_fdf [48:50]:20,_fdf [50:52]:21,_fdf [52:55]:22,_fdf [55:61]:23}; +var (_ Length =Millimeter (0);); -// Points implements Length interface. -func (_gc Millimeter )Points ()Point {return Point (_gc *_cg )}; +// UnmarshalInch unmarshalls provided string into unit. +func UnmarshalInch (unit string )(Inch ,error ){if _c .HasSuffix (unit ,"\u006d\u006d"){_bf ,_fcf :=_dbf (unit );if _fcf !=nil {return 0,_fcf ;};return _bf .Inches (),nil ;};if _c .HasSuffix (unit ,"\u0069\u006e"){return _fg (unit );};return 0,_e .Errorf ("\u0069\u006e\u0076\u0061li\u0064\u0020\u0069\u006e\u0063\u0068\u0020\u0069\u006e\u0070\u0075\u0074\u003a\u0020%\u0073",unit ); +};func _fg (_ec string )(Inch ,error ){_ec =_c .TrimSpace (_c .Trim (_ec ,"\u0069\u006e"));_dbe ,_dag :=_ce .ParseFloat (_ec ,64);if _dag !=nil {return 0,_e .Errorf ("\u0069\u006e\u0076\u0061li\u0064\u0020\u0069\u006e\u0063\u0068\u0020\u0076\u0061\u006c\u0075\u0065\u003a\u0020%\u0077",_dag ); +};return Inch (_dbe ),nil ;};var _ _ae .Value =(*Point )(nil ); -// IsAPageSize returns "true" if the value is listed in the enum definition. "false" otherwise -func (_bcc PageSize )IsAPageSize ()bool {for _ ,_ee :=range _fef {if _bcc ==_ee {return true ;};};return false ;}; +// UnmarshalJSON implements the json.Unmarshaler interface for PageSize +func (_ggg *PageSize )UnmarshalJSON (data []byte )error {var _dad string ;if _afc :=_g .Unmarshal (data ,&_dad );_afc !=nil {return _e .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 _beae error ;*_ggg ,_beae =PageSizeString (_dad );return _beae ;}; // Length is it the default dimension unit. type Length interface{Millimeters ()Millimeter ;Inches ()Inch ;Points ()Point ;String ()string ;}; -// MarshalPageSize marshals the page size into string. -func MarshalPageSize (p PageSize )(string ,error ){_acb ,_aabg :=p .MarshalText ();if _aabg !=nil {return "",_aabg ;};return string (_acb ),nil ;}; \ No newline at end of file +// Set implements flag.Value interface. +func (_acf *Orientation )Set (s string )error {switch s {case "\u0070\u006f\u0072\u0074\u0072\u0061\u0069\u0074":*_acf =Portrait ;case "\u006ca\u006e\u0064\u0073\u0063\u0061\u0070e":*_acf =Landscape ;default:return _e .Errorf ("\u0069n\u0076\u0061\u006c\u0069d\u0020\u006f\u0072\u0069\u0065n\u0074a\u0074i\u006f\u006e\u003a\u0020\u0027\u0025\u0073'",s ); +};return nil ;};var _ _ae .Value =(*Orientation )(nil ); + +// Inches gets the inch value. Implements Length interface. +func (_gd Inch )Inches ()Inch {return _gd }; + +// ValueString implements viper.FlagValue interface. +func (_be Point )ValueString ()string {return _be .String ()}; + +// Inches gets the inches equivalent from provided millimeter value. +func (_gc Millimeter )Inches ()Inch {return Inch (float64 (_gc )*_cd )}; \ No newline at end of file diff --git a/unihtml.go b/unihtml.go index a112f8d..d840751 100644 --- a/unihtml.go +++ b/unihtml.go @@ -10,126 +10,126 @@ // terms that can be accessed at https://unidoc.io/eula/ // Package unihtml contains a plugin for the UniDoc. -package unihtml ;import (_ee "bytes";_f "context";_a "errors";_ea "fmt";_fde "github.com/unidoc/unihtml/client";_fb "github.com/unidoc/unihtml/content";_eea "github.com/unidoc/unihtml/selector";_g "github.com/unidoc/unihtml/sizes";_eac "github.com/unidoc/unipdf/v3/common"; -_fdd "github.com/unidoc/unipdf/v3/common/license";_cb "github.com/unidoc/unipdf/v3/creator";_ed "github.com/unidoc/unipdf/v3/model";_ab "github.com/unidoc/unipdf/v3/render";_b "image";_eg "image/color";_d "math";_e "net/url";_ff "os";_fd "time";); +package unihtml ;import (_gc "bytes";_d "context";_cg "errors";_e "fmt";_f "github.com/unidoc/unihtml/client";_ef "github.com/unidoc/unihtml/content";_ea "github.com/unidoc/unihtml/selector";_gf "github.com/unidoc/unihtml/sizes";_fa "github.com/unidoc/unipdf/v3/common"; +_a "github.com/unidoc/unipdf/v3/common/license";_ac "github.com/unidoc/unipdf/v3/creator";_cd "github.com/unidoc/unipdf/v3/model";_dff "github.com/unidoc/unipdf/v3/render";_dd "image";_g "image/color";_cb "math";_c "net/url";_de "os";_df "time";); -// Options are the HTML Client options used for establishing the connection. -type Options struct{ +// SetMarginTop sets the left margin. +func (_eaag *Document )SetMarginTop (margin _gf .Length ){_eaag ._daf .Top =margin }; -// Hostname defines the hostname for the client. Default value: 'localhost'. -Hostname string ; +// SetMarginLeft sets the left margin. +func (_fgd *Document )SetMarginLeft (margin _gf .Length ){_fgd ._daf .Left =margin }; -// Port defines the port at which the server works. Default value: '8080' -Port int ; +// GeneratePageBlocks implements creator.Drawable interface. +func (_dbe *Document )GeneratePageBlocks (ctx _ac .DrawContext )([]*_ac .Block ,_ac .DrawContext ,error ){if _fc :=_dbe .validate ();_fc !=nil {return nil ,ctx ,_fc ;};var _ecg []*_ac .Block ;_ca :=_dbe .getMargins ();_fcb ,_cac :=_dbe ._db ,_dbe ._dbf ; +if _dbe ._dgg .IsRelative (){_fcb ,_cac =_gf .Point (ctx .Width ),_gf .Point (ctx .Height );ctx .X -=float64 (_ca .Left .Points ());}else {ctx .X =_dbe ._ag ;ctx .Y =_dbe ._ddb ;};_geg ,_bb :=_dbe .extract (_d .Background (),_fcb ,_cac ,_ca );if _bb !=nil {return nil ,_ac .DrawContext {},_bb ; +};for _ecd ,_dea :=range _geg {_ce ,_ff :=_ac .NewBlockFromPage (_dea );if _ff !=nil {return nil ,_ac .DrawContext {},_ff ;};var _bc float64 ;if _dbe ._ace &&_ecd ==len (_geg )-1{_gd :=_dff .NewImageDevice ();_af ,_fg :=_gd .Render (_dea );if _fg !=nil {return nil ,_ac .DrawContext {},_fg ; +};_aff ,_fg :=_dea .GetMediaBox ();if _fg !=nil {return nil ,_ac .DrawContext {},_fg ;};_bbd :=_df .Now ();_fab :=_fcg (_af );_bc =_aff .Height ()*_fab ;_fa .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",_df .Since (_bbd )); +if _dbe ._daf .Bottom !=nil {_bc -=float64 (_dbe ._daf .Bottom .Points ());};if _bc < 0{_bc =0;};_fa .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",_bc ); +};_ccd ,_def ,_ff :=_ce .GeneratePageBlocks (ctx );if _ff !=nil {return nil ,_ac .DrawContext {},_ff ;};ctx =_def ;ctx .Y -=_bc ;if _ecd !=len (_geg )-1&&ctx .Y > (ctx .PageHeight -ctx .Margins .Bottom )*.95{ctx .X =ctx .Margins .Left ;ctx .Y =ctx .Margins .Top ; +ctx .Page ++;};_ecg =append (_ecg ,_ccd ...);};return _ecg ,ctx ,nil ;}; -// Secure is the flag that states if the connection uses HTTPS protocol. Default Value: 'false'. -Secure bool ; +// WriteToFile writes the document to a file defined by the output path. +func (_cfe *Document )WriteToFile (outputPath string )error {if _dee :=_cfe .validate ();_dee !=nil {return _dee ;};_eac :=_df .Second *20+_cfe ._gg ;_ffg ,_eaab :=_d .WithTimeout (_d .Background (),_eac );defer _eaab ();_bf ,_bd :=_cfe .extract (_ffg ,_cfe ._db ,_cfe ._dbf ,_cfe .getMargins ()); +if _bd !=nil {return _bd ;};_cfb :=_ac .New ();for _ ,_feg :=range _bf {if _bd =_cfb .AddPage (_feg );_bd !=nil {return _bd ;};};return _cfb .WriteToFile (outputPath );}; -// Prefix is an option setting used when the server is working with the URI prefix. Default Value: ''. -Prefix string ;}; +// ContainerComponent implements creator.containerElement interface. +func (_cdg *Document )ContainerComponent (container _ac .Drawable )(_ac .Drawable ,error ){switch container .(type ){case *_ac .Chapter :default:return nil ,_e .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 _cdg ,nil ;}; -// ConnectOptions creates UniHTML HTTP Client and tries to establish connection with the server. -func ConnectOptions (o Options )error {_dd =_fde .New (_fde .Options {Hostname :o .Hostname ,Port :o .Port ,HTTPS :o .Secure });_ad ,_fe :=_f .WithTimeout (_f .Background (),_fd .Second *5);defer _fe ();if _gb :=_dd .HealthCheck (_ad );_gb !=nil {return _gb ; -};return nil ;}; +// Document is HTML document wrapper that is used for extracting and converting HTML document into PDF pages. +type Document struct{_dg _ef .Content ;_daf margins ;_dgg _ac .Positioning ;_ag ,_ddb float64 ;_eaa _gf .PageSize ;_db ,_dbf _gf .Length ;_ed _gf .Orientation ;_ace bool ;_gg _df .Duration ;_dab []_f .BySelector ;_faf []_f .BySelector ;_dde *_df .Duration ; +}; -// SetMarkedContentID sets the marked content id for the document. -func (_dcc *Document )SetMarkedContentID (id int64 )*_ed .KDict {return nil }; +// TrimLastPageContent trims the last page content so that next creator blocks are located just at the end of given block. +func (_agg *Document )TrimLastPageContent (){_agg ._ace =true };func (_gb *Document )extract (_gde _d .Context ,_aad ,_ccb _gf .Length ,_be margins )([]*_cd .PdfPage ,error ){_deg :=_f .BuildHTMLQuery ().SetContent (_gb ._dg ).PageSize (_gb ._eaa ).PaperWidth (_aad ).PaperHeight (_ccb ).Orientation (_gb ._ed ).MarginLeft (_be .Left ).MarginRight (_be .Right ).MarginTop (_be .Top ).MarginBottom (_be .Bottom ).TimeoutDuration (_gb .getTimeoutDuration ()).WaitTime (_gb ._gg ); +for _ ,_fec :=range _gb ._dab {_deg .WaitReady (_fec .Selector ,_fec .By );};for _ ,_dgd :=range _gb ._faf {_deg .WaitVisible (_dgd .Selector ,_dgd .By );};_gda ,_ddg :=_deg .Query ();if _ddg !=nil {return nil ,_ddg ;};var _aee _d .CancelFunc ;if _gb ._dde !=nil {_gde ,_aee =_d .WithTimeout (_gde ,*_gb ._dde ); +}else {_gde ,_aee =_d .WithTimeout (_gde ,_df .Second *15);};defer _aee ();_ade ,_ddg :=_ge .ConvertHTML (_gde ,_gda );if _ddg !=nil {return nil ,_ddg ;};_bad :=_gc .NewReader (_ade .Data );_cad ,_ddg :=_cd .NewPdfReader (_bad );if _ddg !=nil {return nil ,_ddg ; +};return _cad .PageList ,nil ;}; -// SetPageSize sets the page default size. -func (_egg *Document )SetPageSize (pageSize _g .PageSize )error {if !pageSize .IsAPageSize (){return _a .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"); -};_egg ._ffa =pageSize ;_egg ._bg =_cb .PositionAbsolute ;return nil ;}; +// NewDocument creates new HTML Document used as an input for the creator.Drawable. +func NewDocument (path string )(*Document ,error ){_ad :=&Document {};_cgg ,_fb :=_c .Parse (path );if _fb !=nil {return nil ,_fb ;};switch _cgg .Scheme {case "\u0068\u0074\u0074\u0070","\u0068\u0074\u0074p\u0073":_ad ._dg ,_fb =_ef .NewWebURL (path ); +if _fb !=nil {return nil ,_fb ;};return _ad ,nil ;};_gcd ,_fb :=_de .Stat (path );if _fb !=nil {return nil ,_fb ;};if !_gcd .IsDir (){_ad ._dg ,_fb =_ef .NewHTMLFile (path );}else {_ad ._dg ,_fb =_ef .NewZipDirectory (path );};if _fb !=nil {return nil ,_fb ; +};return _ad ,nil ;}; // SetLandscapeOrientation sets document landscape page orientation. -func (_bffb *Document )SetLandscapeOrientation (){_bffb ._ced =_g .Landscape }; +func (_fbf *Document )SetLandscapeOrientation (){_fbf ._ed =_gf .Landscape };func (_gac *Document )validate ()error {if _ge ==nil {return ErrNoClient ;};if _gac ._dg ==nil {return ErrContentNotDefined ;};return nil ;}; -// NewDocumentFromString creates a new Document from the provided HTML string. -func NewDocumentFromString (html string )(*Document ,error ){_adc ,_cd :=_fb .NewStringContent (html );if _cd !=nil {return nil ,_cd ;};_ef :=&Document {};_ef ._bf =_adc ;return _ef ,nil ;}; +// SetTimeoutDuration sets the timeout duration +// the default timeout is 15 seconds. +func (_gfce *Document )SetTimeoutDuration (duration _df .Duration ){_gfce ._dde =&duration }; -// SetPos sets the absolute position. Changes object positioning to absolute. -func (_fgb *Document )SetPos (x ,y float64 ){_fgb ._bg =_cb .PositionAbsolute ;_fgb ._fbd =x ;_fgb ._fba =y ;}; +// SetMarkedContentID sets the marked content id for the document. +func (_dbec *Document )SetMarkedContentID (id int64 )*_cd .KDict {return nil }; -// TrimLastPageContent trims the last page content so that next creator blocks are located just at the end of given block. -func (_acd *Document )TrimLastPageContent (){_acd ._fdg =true }; +// SetPageHeight sets the page height for given document. +func (_aef *Document )SetPageHeight (pageHeight _gf .Length )error {_aef ._dbf =pageHeight ;_aef ._dgg =_ac .PositionAbsolute ;return nil ;}; -// GetPdfPages is a function that converts provided input content and -func (_fac *Document )GetPdfPages (ctx _f .Context )([]*_ed .PdfPage ,error ){if _gf :=_fac .validate ();_gf !=nil {return nil ,_gf ;};return _fac .extract (ctx ,_fac ._db ,_fac ._eb ,_fac .getMargins ());}; +// Options are the HTML Client options used for establishing the connection. +type Options struct{ -// SetPageWidth sets the page width for given document. -func (_abg *Document )SetPageWidth (pageWidth _g .Length )error {_abg ._db =pageWidth ;_abg ._bg =_cb .PositionAbsolute ;return nil ;};var _ _cb .Drawable =(*Document )(nil ); +// Hostname defines the hostname for the client. Default value: 'localhost'. +Hostname string ; -// SetMarginLeft sets the left margin. -func (_fgf *Document )SetMarginLeft (margin _g .Length ){_fgf ._fdb .Left =margin }; +// Port defines the port at which the server works. Default value: '8080' +Port int ; + +// Secure is the flag that states if the connection uses HTTPS protocol. Default Value: 'false'. +Secure bool ; + +// Prefix is an option setting used when the server is working with the URI prefix. Default Value: ''. +Prefix string ;};func (_cbed *Document )getMargins ()margins {_gcf :=_cbed ._daf ;if _cbed ._dgg .IsRelative (){_gcf .Top =_gf .Millimeter (1);_gcf .Left =_gf .Millimeter (1);_gcf .Bottom =_gf .Millimeter (1);_gcf .Right =_gf .Millimeter (1);return _gcf ; +};if _gcf .Top ==nil {_gcf .Top =_gf .Millimeter (10);};if _gcf .Bottom ==nil {_gcf .Bottom =_gf .Millimeter (10);};if _gcf .Left ==nil {_gcf .Left =_gf .Millimeter (10);};if _gcf .Right ==nil {_gcf .Right =_gf .Millimeter (10);};return _gcf ;}; // SetMarginRight sets the left margin. -func (_ddbf *Document )SetMarginRight (margin _g .Length ){_ddbf ._fdb .Right =margin }; +func (_gfc *Document )SetMarginRight (margin _gf .Length ){_gfc ._daf .Right =margin }; -// WriteToFile writes the document to a file defined by the output path. -func (_ga *Document )WriteToFile (outputPath string )error {if _bc :=_ga .validate ();_bc !=nil {return _bc ;};_abd :=_fd .Second *20+_ga ._age ;_cf ,_fdbf :=_f .WithTimeout (_f .Background (),_abd );defer _fdbf ();_gc ,_agea :=_ga .extract (_cf ,_ga ._db ,_ga ._eb ,_ga .getMargins ()); -if _agea !=nil {return _agea ;};_ece :=_cb .New ();for _ ,_ebf :=range _gc {if _agea =_ece .AddPage (_ebf );_agea !=nil {return _agea ;};};return _ece .WriteToFile (outputPath );};func _cg (_fda _b .Image )float64 {_cde :=_fda .Bounds ();var (_gef int ; -_abc _eg .Color ;_fbc ,_aeb ,_gdc uint32 ;);_af ,_dad :=_cde .Min .X ,_cde .Max .Y -1;_gfc :=_fda .At (_af ,_dad );_def ,_bca ,_ebg ,_ :=_gfc .RGBA ();_dbg :=_def ==_d .MaxUint16 &&_bca ==_d .MaxUint16 &&_ebg ==_d .MaxUint16 ;for _dad =_cde .Max .Y -1; -_dad >=_cde .Min .Y ;_dad --{var _fae bool ;for _af =_cde .Min .X ;_af < _cde .Max .X ;_af ++{_abc =_fda .At (_af ,_dad );_fbc ,_aeb ,_gdc ,_ =_abc .RGBA ();if (_dbg &&!(_fbc ==_def &&_aeb ==_bca &&_ebg ==_gdc ))||(!_dbg &&(_d .Abs (float64 (_fbc )-float64 (_def ))/float64 (_d .MaxUint16 )> 0.03||_d .Abs (float64 (_aeb )-float64 (_bca ))/float64 (_d .MaxUint16 )> 0.03||_d .Abs (float64 (_gdc )-float64 (_ebg ))/float64 (_d .MaxUint16 )> 0.03)){_fae =true ; -break ;};};if _fae {break ;};_gef =_dad ;};return float64 (_cde .Max .Y -_gef )/float64 (_cde .Max .Y );};type margins struct{Left ,Right ,Bottom ,Top _g .Length ;};var ErrNoClient =_a .New ("\u0055n\u0069\u0048\u0054\u004d\u004c\u0020\u0063\u006c\u0069\u0065\u006et\u0020\u006e\u006f\u0074\u0020\u0066\u006f\u0075\u006e\u0064"); +// SetMargins sets the Document Margins. +func (_efd *Document )SetMargins (left ,right ,top ,bottom float64 ){_efd ._daf .Left =_gf .Point (left );_efd ._daf .Right =_gf .Point (right );_efd ._daf .Top =_gf .Point (top );_efd ._daf .Bottom =_gf .Point (bottom );_efd ._dgg =_ac .PositionAbsolute ; +};func _fcg (_bcb _dd .Image )float64 {_gfd :=_bcb .Bounds ();var (_eg int ;_aa _g .Color ;_aceg ,_egb ,_dc uint32 ;);_ffe ,_fea :=_gfd .Min .X ,_gfd .Max .Y -1;_fcd :=_bcb .At (_ffe ,_fea );_cbe ,_fbd ,_afa ,_ :=_fcd .RGBA ();_dga :=_cbe ==_cb .MaxUint16 &&_fbd ==_cb .MaxUint16 &&_afa ==_cb .MaxUint16 ; +for _fea =_gfd .Max .Y -1;_fea >=_gfd .Min .Y ;_fea --{var _ggg bool ;for _ffe =_gfd .Min .X ;_ffe < _gfd .Max .X ;_ffe ++{_aa =_bcb .At (_ffe ,_fea );_aceg ,_egb ,_dc ,_ =_aa .RGBA ();if (_dga &&!(_aceg ==_cbe &&_egb ==_fbd &&_afa ==_dc ))||(!_dga &&(_cb .Abs (float64 (_aceg )-float64 (_cbe ))/float64 (_cb .MaxUint16 )> 0.03||_cb .Abs (float64 (_egb )-float64 (_fbd ))/float64 (_cb .MaxUint16 )> 0.03||_cb .Abs (float64 (_dc )-float64 (_afa ))/float64 (_cb .MaxUint16 )> 0.03)){_ggg =true ; +break ;};};if _ggg {break ;};_eg =_fea ;};return float64 (_gfd .Max .Y -_eg )/float64 (_gfd .Max .Y );}; +// SetPos sets the absolute position. Changes object positioning to absolute. +func (_baf *Document )SetPos (x ,y float64 ){_baf ._dgg =_ac .PositionAbsolute ;_baf ._ag =x ;_baf ._ddb =y ;};func _cc ()error {_ae :=_a .GetLicenseKey ();if _ae ==nil {return _cg .New ("\u006e\u006f\u0020\u006cic\u0065\u006e\u0073\u0065\u0020\u0070\u0072\u006f\u0076\u0069\u0064\u0065\u0064"); +};if !_ae .IsLicensed (){return _cg .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 ;}; // WaitTime sets the waiting time before the webpage is rendered to PDF. -func (_bce *Document )WaitTime (duration _fd .Duration ){_bce ._age =duration };func (_baa *Document )validate ()error {if _dd ==nil {return ErrNoClient ;};if _baa ._bf ==nil {return ErrContentNotDefined ;};return nil ;}; +func (_eae *Document )WaitTime (duration _df .Duration ){_eae ._gg =duration }; -// WaitVisible waits for the provided selector to be ready. -// A selector might be i.e. `#example` for id and `.example` for classes. The second parameter defines how to match given selector. -func (_gcg *Document )WaitVisible (sel string ,by ..._eea .ByType ){_gaf :=_eea .BySearch ;if len (by )> 0{_gaf =by [0];};_gcg ._da =append (_gcg ._da ,_fde .BySelector {Selector :sel ,By :_gaf });}; +// NewDocumentFromString creates a new Document from the provided HTML string. +func NewDocumentFromString (html string )(*Document ,error ){_cba ,_ec :=_ef .NewStringContent (html );if _ec !=nil {return nil ,_ec ;};_dfc :=&Document {};_dfc ._dg =_cba ;return _dfc ,nil ;};func (_feaa *Document )getTimeoutDuration ()_df .Duration {if _feaa ._dde !=nil {return *_feaa ._dde ; +};return 0;};var _ge *_f .Client ;type margins struct{Left ,Right ,Bottom ,Top _gf .Length ;}; -// Connect creates UniHTML HTTP Client and tries to establish connection with the server. -func Connect (path string )error {if _ddg :=_aa ();_ddg !=nil {return _ddg ;};_eda ,_ae :=_fde .ParseOptions (path );if _ae !=nil {return _ae ;};_dd =_fde .New (_eda );_ag ,_ce :=_f .WithTimeout (_f .Background (),_fd .Second *5);defer _ce ();if _ge :=_dd .HealthCheck (_ag ); -_ge !=nil {return _ge ;};return nil ;}; +// ConnectOptions creates UniHTML HTTP Client and tries to establish connection with the server. +func ConnectOptions (o Options )error {_ge =_f .New (_f .Options {Hostname :o .Hostname ,Port :o .Port ,HTTPS :o .Secure });_bgg ,_cf :=_d .WithTimeout (_d .Background (),_df .Second *5);defer _cf ();if _ab :=_ge .HealthCheck (_bgg );_ab !=nil {return _ab ; +};return nil ;}; -// WaitReady waits for the provided selector to be ready. -// A selector might be i.e. `#example` for id and `.example` for classes. The second parameter defines how to match given selector. -func (_dfb *Document )WaitReady (sel string ,by ..._eea .ByType ){_dc :=_eea .BySearch ;if len (by )> 0{_dc =by [0];};_dfb ._ac =append (_dfb ._ac ,_fde .BySelector {Selector :sel ,By :_dc });}; +// GetPdfPages is a function that converts provided input content and +func (_aca *Document )GetPdfPages (ctx _d .Context )([]*_cd .PdfPage ,error ){if _eda :=_aca .validate ();_eda !=nil {return nil ,_eda ;};return _aca .extract (ctx ,_aca ._db ,_aca ._dbf ,_aca .getMargins ());};var ErrNoClient =_cg .New ("\u0055n\u0069\u0048\u0054\u004d\u004c\u0020\u0063\u006c\u0069\u0065\u006et\u0020\u006e\u006f\u0074\u0020\u0066\u006f\u0075\u006e\u0064"); -// NewDocument creates new HTML Document used as an input for the creator.Drawable. -func NewDocument (path string )(*Document ,error ){_gd :=&Document {};_fa ,_eebf :=_e .Parse (path );if _eebf !=nil {return nil ,_eebf ;};switch _fa .Scheme {case "\u0068\u0074\u0074\u0070","\u0068\u0074\u0074p\u0073":_gd ._bf ,_eebf =_fb .NewWebURL (path ); -if _eebf !=nil {return nil ,_eebf ;};return _gd ,nil ;};_cac ,_eebf :=_ff .Stat (path );if _eebf !=nil {return nil ,_eebf ;};if !_cac .IsDir (){_gd ._bf ,_eebf =_fb .NewHTMLFile (path );}else {_gd ._bf ,_eebf =_fb .NewZipDirectory (path );};if _eebf !=nil {return nil ,_eebf ; -};return _gd ,nil ;};var _dd *_fde .Client ; -// GeneratePageBlocks implements creator.Drawable interface. -func (_fcc *Document )GeneratePageBlocks (ctx _cb .DrawContext )([]*_cb .Block ,_cb .DrawContext ,error ){if _cec :=_fcc .validate ();_cec !=nil {return nil ,ctx ,_cec ;};var _eab []*_cb .Block ;_aae :=_fcc .getMargins ();_de ,_ec :=_fcc ._db ,_fcc ._eb ; -if _fcc ._bg .IsRelative (){_de ,_ec =_g .Point (ctx .Width ),_g .Point (ctx .Height );ctx .X -=float64 (_aae .Left .Points ());}else {ctx .X =_fcc ._fbd ;ctx .Y =_fcc ._fba ;};_ffd ,_faf :=_fcc .extract (_f .Background (),_de ,_ec ,_aae );if _faf !=nil {return nil ,_cb .DrawContext {},_faf ; -};for _df ,_ceg :=range _ffd {_efd ,_cab :=_cb .NewBlockFromPage (_ceg );if _cab !=nil {return nil ,_cb .DrawContext {},_cab ;};var _fed float64 ;if _fcc ._fdg &&_df ==len (_ffd )-1{_ba :=_ab .NewImageDevice ();_cbe ,_aac :=_ba .Render (_ceg );if _aac !=nil {return nil ,_cb .DrawContext {},_aac ; -};_cdg ,_aac :=_ceg .GetMediaBox ();if _aac !=nil {return nil ,_cb .DrawContext {},_aac ;};_ffda :=_fd .Now ();_bff :=_cg (_cbe );_fed =_cdg .Height ()*_bff ;_eac .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",_fd .Since (_ffda )); -if _fcc ._fdb .Bottom !=nil {_fed -=float64 (_fcc ._fdb .Bottom .Points ());};if _fed < 0{_fed =0;};_eac .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",_fed ); -};_fg ,_be ,_cab :=_efd .GeneratePageBlocks (ctx );if _cab !=nil {return nil ,_cb .DrawContext {},_cab ;};ctx =_be ;ctx .Y -=_fed ;if _df !=len (_ffd )-1&&ctx .Y > (ctx .PageHeight -ctx .Margins .Bottom )*.95{ctx .X =ctx .Margins .Left ;ctx .Y =ctx .Margins .Top ; -ctx .Page ++;};_eab =append (_eab ,_fg ...);};return _eab ,ctx ,nil ;};func (_gfb *Document )getMargins ()margins {_daf :=_gfb ._fdb ;if _gfb ._bg .IsRelative (){_daf .Top =_g .Millimeter (1);_daf .Left =_g .Millimeter (1);_daf .Bottom =_g .Millimeter (1); -_daf .Right =_g .Millimeter (1);return _daf ;};if _daf .Top ==nil {_daf .Top =_g .Millimeter (10);};if _daf .Bottom ==nil {_daf .Bottom =_g .Millimeter (10);};if _daf .Left ==nil {_daf .Left =_g .Millimeter (10);};if _daf .Right ==nil {_daf .Right =_g .Millimeter (10); -};return _daf ;};func (_aed *Document )getTimeoutDuration ()_fd .Duration {if _aed ._fc !=nil {return *_aed ._fc ;};return 0;}; +// Connect creates UniHTML HTTP Client and tries to establish connection with the server. +func Connect (path string )error {if _ga :=_cc ();_ga !=nil {return _ga ;};_dfe ,_fe :=_f .ParseOptions (path );if _fe !=nil {return _fe ;};_ge =_f .New (_dfe );_da ,_ba :=_d .WithTimeout (_d .Background (),_df .Second *5);defer _ba ();if _bg :=_ge .HealthCheck (_da ); +_bg !=nil {return _bg ;};return nil ;}; // GetContent returns the content of the document. -func (_eaf *Document )GetContent ()_fb .Content {return _eaf ._bf }; +func (_dec *Document )GetContent ()_ef .Content {return _dec ._dg };var _ _ac .Drawable =(*Document )(nil ); -// SetTimeoutDuration sets the timeout duration -// the default timeout is 15 seconds. -func (_ggb *Document )SetTimeoutDuration (duration _fd .Duration ){_ggb ._fc =&duration }; - -// SetPageHeight sets the page height for given document. -func (_bgc *Document )SetPageHeight (pageHeight _g .Length )error {_bgc ._eb =pageHeight ;_bgc ._bg =_cb .PositionAbsolute ;return nil ;}; - -// Document is HTML document wrapper that is used for extracting and converting HTML document into PDF pages. -type Document struct{_bf _fb .Content ;_fdb margins ;_bg _cb .Positioning ;_fbd ,_fba float64 ;_ffa _g .PageSize ;_db ,_eb _g .Length ;_ced _g .Orientation ;_fdg bool ;_age _fd .Duration ;_ac []_fde .BySelector ;_da []_fde .BySelector ;_fc *_fd .Duration ; -};func (_edf *Document )extract (_gff _f .Context ,_fag ,_gaa _g .Length ,_feg margins )([]*_ed .PdfPage ,error ){_dbb :=_fde .BuildHTMLQuery ().SetContent (_edf ._bf ).PageSize (_edf ._ffa ).PaperWidth (_fag ).PaperHeight (_gaa ).Orientation (_edf ._ced ).MarginLeft (_feg .Left ).MarginRight (_feg .Right ).MarginTop (_feg .Top ).MarginBottom (_feg .Bottom ).TimeoutDuration (_edf .getTimeoutDuration ()).WaitTime (_edf ._age ); -for _ ,_ade :=range _edf ._ac {_dbb .WaitReady (_ade .Selector ,_ade .By );};for _ ,_edb :=range _edf ._da {_dbb .WaitVisible (_edb .Selector ,_edb .By );};_fad ,_aag :=_dbb .Query ();if _aag !=nil {return nil ,_aag ;};var _ace _f .CancelFunc ;if _edf ._fc !=nil {_gff ,_ace =_f .WithTimeout (_gff ,*_edf ._fc ); -}else {_gff ,_ace =_f .WithTimeout (_gff ,_fd .Second *15);};defer _ace ();_eff ,_aag :=_dd .ConvertHTML (_gff ,_fad );if _aag !=nil {return nil ,_aag ;};_fbf :=_ee .NewReader (_eff .Data );_dba ,_aag :=_ed .NewPdfReader (_fbf );if _aag !=nil {return nil ,_aag ; -};return _dba .PageList ,nil ;}; +// SetPageWidth sets the page width for given document. +func (_caa *Document )SetPageWidth (pageWidth _gf .Length )error {_caa ._db =pageWidth ;_caa ._dgg =_ac .PositionAbsolute ;return nil ;}; -// ContainerComponent implements creator.containerElement interface. -func (_bd *Document )ContainerComponent (container _cb .Drawable )(_cb .Drawable ,error ){switch container .(type ){case *_cb .Chapter :default:return nil ,_ea .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 _bd ,nil ;};func _aa ()error {_ca :=_fdd .GetLicenseKey ();if _ca ==nil {return _a .New ("\u006e\u006f\u0020\u006cic\u0065\u006e\u0073\u0065\u0020\u0070\u0072\u006f\u0076\u0069\u0064\u0065\u0064");};if !_ca .IsLicensed (){return _a .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 ;}; +// SetPageSize sets the page default size. +func (_dfd *Document )SetPageSize (pageSize _gf .PageSize )error {if !pageSize .IsAPageSize (){return _cg .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"); +};_dfd ._eaa =pageSize ;_dfd ._dgg =_ac .PositionAbsolute ;return nil ;}; -// SetMarginTop sets the left margin. -func (_gbe *Document )SetMarginTop (margin _g .Length ){_gbe ._fdb .Top =margin }; +// SetMarginBottom sets the left margin. +func (_ffc *Document )SetMarginBottom (margin _gf .Length ){_ffc ._daf .Bottom =margin }; -// SetMargins sets the Document Margins. -func (_aca *Document )SetMargins (left ,right ,top ,bottom float64 ){_aca ._fdb .Left =_g .Point (left );_aca ._fdb .Right =_g .Point (right );_aca ._fdb .Top =_g .Point (top );_aca ._fdb .Bottom =_g .Point (bottom );_aca ._bg =_cb .PositionAbsolute ;}; +// WaitReady waits for the provided selector to be ready. +// A selector might be i.e. `#example` for id and `.example` for classes. The second parameter defines how to match given selector. +func (_efc *Document )WaitReady (sel string ,by ..._ea .ByType ){_abc :=_ea .BySearch ;if len (by )> 0{_abc =by [0];};_efc ._dab =append (_efc ._dab ,_f .BySelector {Selector :sel ,By :_abc });};var ErrContentNotDefined =_cg .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"); -// SetMarginBottom sets the left margin. -func (_gg *Document )SetMarginBottom (margin _g .Length ){_gg ._fdb .Bottom =margin };var ErrContentNotDefined =_a .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"); +// WaitVisible waits for the provided selector to be ready. +// A selector might be i.e. `#example` for id and `.example` for classes. The second parameter defines how to match given selector. +func (_gdf *Document )WaitVisible (sel string ,by ..._ea .ByType ){_gcda :=_ea .BySearch ;if len (by )> 0{_gcda =by [0];};_gdf ._faf =append (_gdf ._faf ,_f .BySelector {Selector :sel ,By :_gcda });}; \ No newline at end of file