prepare release

This commit is contained in:
UniDoc Build 2024-12-22 09:15:36 +00:00
parent 558c4097b7
commit 3757adb7e8
10 changed files with 553 additions and 547 deletions

View File

@ -9,55 +9,54 @@
// 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 (_a "context";_c "fmt";_f "github.com/mitchellh/go-homedir";_ca "github.com/spf13/cobra";_cg "github.com/spf13/viper";_e "github.com/unidoc/unihtml/client";_cd "github.com/unidoc/unihtml/content";_bb "github.com/unidoc/unihtml/sizes";
_bc "github.com/unidoc/unipdf/v3/common";_db "os";_g "path/filepath";_b "time";);func _ae (){_ba :=_bc .LogLevelInfo ;if _dfc {_ba =_bc .LogLevelDebug ;};if _dgd {_ba =_bc .LogLevelTrace ;};_bc .Log =_bc .NewConsoleLogger (_ba );};var _ebf =&_ca .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"};
var _da =&_ca .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 :_gf ,Args :_ca .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 _gf (cmd *_ca .Command ,_ff []string ){_ec :=_b .Now ();if _bbg :=_cg .BindPFlags (cmd .Flags ());_bbg !=nil {_c .Printf ("\u0045\u0072\u0072\u003a\u0020\u0025\u0076\u000a",_bbg );_db .Exit (1);};if _ed :=_cg .Unmarshal (&_df );_ed !=nil {_c .Printf ("\u0045\u0072\u0072\u003a\u0020\u0025\u0076\u000a",_ed );
_db .Exit (1);};_ae ();_ga ,_dg :=_db .Stat (_ff [0]);if _dg !=nil {_c .Printf ("\u0045\u0072\u0072\u003a\u0020\u0025\u0076\u000a",_dg );_db .Exit (1);};if !_ga .IsDir (){if _g .Ext (_ga .Name ())!="\u002e\u0068\u0074m\u006c"{_c .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",_ff [0]);
_db .Exit (1);};};_fb ,_dg :=_db .OpenFile (_ff [1],_db .O_CREATE |_db .O_WRONLY |_db .O_TRUNC ,0700);if _dg !=nil {_c .Printf ("\u0045\u0072\u0072\u003a\u0020\u0025\u0076\u000a",_dg );_db .Exit (1);};defer _fb .Close ();_bg :=_e .New (_e .Options {HTTPS :_df .Https ,Hostname :_df .Host ,Port :_df .Port ,Prefix :_df .Prefix });
_cde ,_eeb :=_a .WithTimeout (_a .Background (),_b .Second *10);defer _eeb ();_dgc :=_b .Now ();var _eb _cd .Content ;if _ga .IsDir (){_eb ,_dg =_cd .NewZipDirectory (_ff [0]);}else {_eb ,_dg =_cd .NewHTMLFile (_ff [0]);};if _dg !=nil {_c .Printf ("\u0045r\u0072\u003a\u0020\u0025\u0076",_dg );
_db .Exit (1);};_ad ,_dg :=_e .BuildHTMLQuery ().PaperWidth (_ag .PaperWidth .Length ).PaperHeight (_ag .PaperHeight .Length ).PageSize (_ag .PageSize ).MarginTop (_ag .MarginTop .Length ).MarginBottom (_ag .MarginBottom .Length ).MarginLeft (_ag .MarginLeft .Length ).MarginRight (_ag .MarginRight .Length ).Orientation (_ag .Orientation ).SetContent (_eb ).Query ();
if _dg !=nil {_c .Printf ("\u0045\u0072\u0072\u003a\u0020\u0025\u0076\u000a",_dg );_db .Exit (1);};_dc ,_dg :=_bg .ConvertHTML (_cde ,_ad );if _dg !=nil {_c .Printf ("\u0045\u0072\u0072\u003a\u0020\u0025\u0076\u000a",_dg );_db .Exit (1);};_bc .Log .Trace ("\u0045\u0078\u0065cu\u0074\u0069\u006e\u0067\u0020\u0067\u0065\u006e\u0065r\u0061t\u0065 \u0071u\u0065\u0072\u0079\u0020\u0074\u0061\u006b\u0065\u006e\u003a\u0020\u0025\u0073",_b .Since (_dgc ));
_dgc =_b .Now ();_ ,_dg =_fb .Write (_dc .Data );if _dg !=nil {_c .Printf ("\u0045\u0072\u0072\u003a\u0020\u0025\u0076\u000a",_dg );_db .Exit (1);};_bc .Log .Trace ("\u0057\u0072\u0069\u0074in\u0067\u0020\u0066\u0069\u006c\u0065\u0020\u0074\u0061\u006b\u0065\u006e\u003a\u0020%\u0073",_b .Since (_dgc ));
_c .Printf ("\u0047\u0065n\u0065\u0072\u0061\u0074\u0065\u0064\u0020\u0077\u0069\u0074\u0068\u0020\u0073\u0075\u0063\u0063\u0065\u0073\u0073\u0020\u0069\u006e %\u0073\u000a",_b .Since (_ec ));};func init (){_ebf .AddCommand (_da );_da .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");
_da .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");
_da .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");
_da .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");
_da .Flags ().Var (&_ag .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");_da .Flags ().Var (&_ag .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");
_da .Flags ().Var (&_ag .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");_da .Flags ().Var (&_ag .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");
_da .Flags ().Var (&_ag .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");_da .Flags ().Var (&_ag .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");
_da .Flags ().Var (&_ag .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");_da .Flags ().Var (&_ag .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 _fbf (){if _bcc !=""{_cg .SetConfigFile (_bcc );}else {_cdac ,_aa :=_f .Dir ();if _aa !=nil {_c .Println (_aa );_db .Exit (1);};_cg .AddConfigPath (_cdac );_cg .SetConfigName ("\u002e\u0075\u006ei\u0068\u0074\u006d\u006c\u002d\u0073\u0072\u0063");
};_cg .AutomaticEnv ();if _af :=_cg .ReadInConfig ();_af ==nil {_c .Println ("\u0055s\u0069n\u0067\u0020\u0063\u006f\u006ef\u0069\u0067 \u0066\u0069\u006c\u0065\u003a",_cg .ConfigFileUsed ());};};var (_dfc ,_dgd bool ;);type generateConfig struct{Port int `mapstructure:"port"`;
Host string `mapstructure:"host"`;Https bool `mapstructure:"https"`;Prefix string `mapstructure:"prefix"`;};
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{
// PaperWidth sets the width of the paper.
PaperWidth _egf .LengthFlag `mapstructure:"paper-width"`;
// PaperHeight is the height of the output paper.
PaperHeight _egf .LengthFlag `mapstructure:"paper-height"`;
// PageSize is the page size string.
PageSize _egf .PageSize `mapstructure:"page-size"`;
// Orientation defines if the output should be in a landscape format.
Orientation _egf .Orientation `mapstructure:"orientation"`;
// MarginTop sets up the Top Margin for the output.
MarginTop _egf .LengthFlag `mapstructure:"margin-top"`;
// MarginBottom sets up the Bottom Margin for the output.
MarginBottom _egf .LengthFlag `mapstructure:"margin-bottom"`;
// MarginLeft sets up the Left Margin for the output.
MarginLeft _egf .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 _ebg :=_ebf .Execute ();_ebg !=nil {_c .Println (_ebg );_db .Exit (1);};};var (_df =generateConfig {};_ag =parametersConfig {PaperWidth :_bb .LengthFlag {Length :_bb .Inch (8.5).Millimeters ()},PaperHeight :_bb .LengthFlag {Length :_bb .Inch (11).Millimeters ()},Orientation :_bb .Portrait ,MarginTop :_bb .LengthFlag {Length :_bb .Millimeter (10)},MarginBottom :_bb .LengthFlag {Length :_bb .Millimeter (10)},MarginLeft :_bb .LengthFlag {Length :_bb .Millimeter (10)},MarginRight :_bb .LengthFlag {Length :_bb .Millimeter (10)}};
);func init (){_ca .OnInitialize (_fbf );_ebf .PersistentFlags ().BoolVarP (&_dfc ,"\u0064\u0065\u0062u\u0067","\u0064",false ,"\u0044e\u0066i\u006e\u0065\u0073\u0020\u0064e\u0062\u0075g\u0020\u006d\u006f\u0064\u0065");_ebf .PersistentFlags ().BoolVarP (&_dgd ,"\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");
_ebf .PersistentFlags ().StringVar (&_bcc ,"\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");
_ebf .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");};type parametersConfig struct{
// PaperWidth sets the width of the paper.
PaperWidth _bb .LengthFlag `mapstructure:"paper-width"`;
// PaperHeight is the height of the output paper.
PaperHeight _bb .LengthFlag `mapstructure:"paper-height"`;
// PageSize is the page size string.
PageSize _bb .PageSize `mapstructure:"page-size"`;
// Orientation defines if the output should be in a landscape format.
Orientation _bb .Orientation `mapstructure:"orientation"`;
// MarginTop sets up the Top Margin for the output.
MarginTop _bb .LengthFlag `mapstructure:"margin-top"`;
// MarginBottom sets up the Bottom Margin for the output.
MarginBottom _bb .LengthFlag `mapstructure:"margin-bottom"`;
// MarginLeft sets up the Left Margin for the output.
MarginLeft _bb .LengthFlag `mapstructure:"margin-left"`;
// MarginRight sets up the Right Margin for the output.
MarginRight _bb .LengthFlag `mapstructure:"margin-right"`;};var _bcc string ;
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"};

View File

@ -9,4 +9,4 @@
// Use of this source code is governed by the UniDoc End User License Agreement
// terms that can be accessed at https://unidoc.io/eula/
package main ;import _g "github.com/unidoc/unihtml/cli/cmd";func main (){_g .Execute ()};
package main ;import _e "github.com/unidoc/unihtml/cli/cmd";func main (){_e .Execute ()};

View File

@ -11,202 +11,202 @@
// 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 (_aa "bytes";_de "compress/flate";_a "compress/gzip";_df "context";_c "encoding/json";_g "errors";_ac "fmt";_fa "github.com/unidoc/unihtml/content";_dbe "github.com/unidoc/unihtml/selector";_b "github.com/unidoc/unihtml/sizes";_da "github.com/unidoc/unipdf/v3/common";
_e "io/ioutil";_af "net";_dee "net/http";_db "net/url";_eb "strconv";_ca "strings";_f "time";);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 ;};
// WithPrefix sets the client prefix.
func WithPrefix (prefix string )Option {return func (_fae *Options ){_fae .Prefix =prefix }};
// PaperWidth sets up the PaperWidth (in cm) parameter for the query.
func (_gce *QueryBuilder )PaperWidth (paperWidth _b .Length )*QueryBuilder {_gce ._agg .PageParameters .PaperWidth =paperWidth ;return _gce ;};
// ConvertHTML converts provided Query input into PDF file data.
// Implements creator.HTMLConverter interface.
func (_ag *Client )ConvertHTML (ctx _df .Context ,q *Query )(*PDFResponse ,error ){if _gg :=q .Validate ();_gg !=nil {return nil ,_gg ;};_gde ,_eg :=_ag .getGenerateRequest (ctx ,q );if _eg !=nil {return nil ,_eg ;};_da .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",_gde .Method ,_gde .URL .Hostname (),_gde .URL .Path ,_gde .Header ,_gde .URL .Query ());
_cd :=*_ag .Client ;if q .TimeoutDuration !=0{_cd .Timeout =q .TimeoutDuration ;};_cf ,_eg :=_cd .Do (_gde );if _eg !=nil {return nil ,_eg ;};var _gc error ;switch _cf .StatusCode {case _dee .StatusNotFound :_gc =ErrNotFound ;case _dee .StatusBadRequest :_gc =ErrBadRequest ;
case _dee .StatusNotImplemented :_gc =ErrNotImplemented ;case _dee .StatusUnauthorized :_gc =ErrUnauthorized ;case _dee .StatusRequestTimeout :_gc =ErrTimedOut ;case _dee .StatusCreated :default:_gc =ErrInternalError ;};_ee :=_cf .Body ;switch _cf .Header .Get ("\u0043\u006fn\u0074\u0065\u006et\u002d\u0045\u006e\u0063\u006f\u0064\u0069\u006e\u0067"){case "\u0067\u007a\u0069\u0070":_ee ,_eg =_a .NewReader (_cf .Body );
if _eg !=nil {return nil ,_eg ;};case "\u0064e\u0066\u006c\u0061\u0074\u0065":_ee =_de .NewReader (_cf .Body );case "":default:return nil ,_ac .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",_cf .Header .Get ("\u0043\u006fn\u0074\u0065\u006et\u002d\u0045\u006e\u0063\u006f\u0064\u0069\u006e\u0067"));
};_bc ,_eg :=_e .ReadAll (_ee );if _eg !=nil &&_gc ==nil {return nil ,_ac .Errorf ("\u0055\u006e\u0069HT\u004d\u004c\u0020\u0073\u0065\u0072\u0076\u0065\u0072\u0020\u0065\u0072\u0072\u006f\u0072\u0020\u0025\u0073",_eg );};_da .Log .Trace ("\u005b\u0025\u0064]\u0020\u0025\u0073\u0020\u0025\u0073\u0025\u0073",_cf .StatusCode ,_gde .Method ,_gde .URL .Host ,_gde .URL .Path );
if _gc !=nil {return nil ,_ac .Errorf ("\u0025\u0073\u0020%\u0077",string (_bc ),_gc );};_dfd :=_cf .Header .Get ("\u0058\u002d\u004a\u006f\u0062\u002d\u0049\u0044");_da .Log .Trace ("\u0052\u0065\u0073\u0070\u006f\u006e\u0073\u0065\u0020I\u0044\u0020\u0025\u0073",_dfd );
return &PDFResponse {ID :_dfd ,Data :_bc },nil ;};
// Portrait sets up the portrait page orientation.
func (_gcd *QueryBuilder )Portrait ()*QueryBuilder {_gcd ._agg .PageParameters .Orientation =_b .Portrait ;return _gcd ;};
// WithHostname sets the Hostname option for the client options.
func WithHostname (option string )Option {return func (_ec *Options ){_ec .Hostname =option }};
// Validate checks if provided Query is valid.
func (_ddd *Query )Validate ()error {switch _ddd .Method {case "\u0077\u0065\u0062":if _ddd .URL ==""{return ErrMissingData ;};case "\u0064\u0069\u0072","\u0068\u0074\u006d\u006c":if len (_ddd .Content )==0{return ErrMissingData ;};if _ddd .ContentType ==""{return ErrContentType ;
};default:return _ac .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",_ddd .Method );};if _bg :=_ddd .PageParameters .Validate ();
_bg !=nil {return _bg ;};if _gba :=_ddd .RenderParameters .Validate ();_gba !=nil {return _gba ;};return nil ;};
// Option is a function that changes client options.
type Option func (_dd *Options );
// Validate checks the validity of the RenderParameters.
func (_acg *RenderParameters )Validate ()error {if _acg .WaitTime > _f .Minute *3{return _g .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 _ ,_gb :=range _acg .WaitReady {if _fbb :=_gb .Validate ();_fbb !=nil {return _ac .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",_fbb );
};};return nil ;};func (_cfc *Client )setQueryValues (_ffe *_dee .Request ,_ce *Query ){_caf :=_ffe .URL .Query ();_cc :=_ce .PageParameters ;if _cc .PageSize !=nil {_caf .Set ("\u0070a\u0067\u0065\u002d\u0073\u0069\u007ae",_cc .PageSize .String ());};
if _cc .PaperHeight !=nil {_caf .Set ("\u0070\u0061\u0070e\u0072\u002d\u0068\u0065\u0069\u0067\u0068\u0074",_cc .PaperHeight .String ());};if _cc .PaperWidth !=nil {_caf .Set ("p\u0061\u0070\u0065\u0072\u002d\u0077\u0069\u0064\u0074\u0068",_cc .PaperWidth .String ());
};if _cc .MarginTop !=nil {_caf .Set ("\u006d\u0061\u0072\u0067\u0069\u006e\u002d\u0074\u006f\u0070",_cc .MarginTop .String ());};if _cc .MarginBottom !=nil {_caf .Set ("\u006d\u0061\u0072\u0067\u0069\u006e\u002d\u0062\u006f\u0074\u0074\u006f\u006d",_cc .MarginBottom .String ());
};if _cc .MarginRight !=nil {_caf .Set ("\u006d\u0061\u0072g\u0069\u006e\u002d\u0072\u0069\u0067\u0068\u0074",_cc .MarginRight .String ());};if _cc .MarginLeft !=nil {_caf .Set ("m\u0061\u0072\u0067\u0069\u006e\u002d\u006c\u0065\u0066\u0074",_cc .MarginLeft .String ());
};if _cc .Orientation ==_b .Landscape {_caf .Set ("o\u0072\u0069\u0065\u006e\u0074\u0061\u0074\u0069\u006f\u006e",_cc .Orientation .String ());};if _ce .RenderParameters .WaitTime !=0{_caf .Set ("\u006d\u0069\u006e\u0069\u006d\u0075\u006d\u002d\u006c\u006f\u0061\u0064-\u0074\u0069\u006d\u0065",_eb .FormatInt (int64 (_ce .RenderParameters .WaitTime /_f .Millisecond ),10));
};_ffe .URL .RawQuery =_caf .Encode ();};
// HealthCheck connects to the server and check the health status of the server.
func (_fg *Client )HealthCheck (ctx _df .Context )error {_ad :=_fg .Options .Addr ();_ad =_ac .Sprintf ("\u0025s\u002f\u0068\u0065\u0061\u006c\u0074h",_ad );_fe ,_fb :=_dee .NewRequest ("\u0047\u0045\u0054",_ad ,nil );if _fb !=nil {return _fb ;};_fe =_fe .WithContext (ctx );
_feb ,_fb :=_fg .Client .Do (_fe );if _fb !=nil {return _fb ;};switch _feb .StatusCode {case _dee .StatusOK :return nil ;case _dee .StatusNotFound :return ErrNotFound ;case _dee .StatusInternalServerError :return ErrInternalError ;case _dee .StatusBadGateway :return ErrBadGateway ;
default:return ErrNotImplemented ;};};
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";);
// ParseOptions parses options for the Client.
func ParseOptions (connectPath string )(Options ,error ){if !_ca .HasPrefix (connectPath ,"\u0068\u0074\u0074\u0070"){connectPath ="\u0068t\u0074\u0070\u003a\u002f\u002f"+connectPath ;};_gd ,_ebd :=_db .Parse (connectPath );if _ebd !=nil {return Options {},_ac .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 _bb int ;if _gd .Port ()!=""{_bb ,_ebd =_eb .Atoi (_gd .Port ());if _ebd !=nil {return Options {},_ac .Errorf ("\u0070\u0061\u0072si\u006e\u0067\u0020\u0070\u006f\u0072\u0074\u0020\u0066\u0061\u0069\u006c\u0065\u0064\u003a\u0020\u0025\u0077",_ebd );
};};return Options {Hostname :_gd .Hostname (),Port :_bb ,HTTPS :_gd .Scheme =="\u0068\u0074\u0074p\u0073",Prefix :_gd .Path },nil ;};
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 ;};
// RenderParameters are the parameters related with the rendering.
type RenderParameters struct{WaitTime _f .Duration `schema:"minimum-load-time" json:"waitTime"`;WaitReady []BySelector `json:"waitReady"`;WaitVisible []BySelector `json:"waitVisible"`;};
// 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 ;};
// SetContent sets custom data with it's content type.
func (_febbf *QueryBuilder )SetContent (content _fa .Content )*QueryBuilder {if _febbf ._fgb !=nil {return _febbf ;};switch content .Method (){case "\u0064\u0069\u0072","\u0068\u0074\u006d\u006c":if _febbf ._agg .ContentType !=""{_febbf ._fgb =ErrContentTypeDeclared ;
return _febbf ;};if content .ContentType ()==""{_febbf ._fgb =_ac .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 _febbf ;
};_febbf ._agg .Content =content .Data ();_febbf ._agg .ContentType =content .ContentType ();case "\u0077\u0065\u0062":if _febbf ._agg .ContentType !=""{_febbf ._fgb =ErrContentTypeDeclared ;return _febbf ;};_febbf ._agg .URL =string (content .Data ());
_febbf ._agg .ContentType =content .ContentType ();default:_febbf ._fgb =_ac .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 _febbf ;};_febbf ._agg .Method =content .Method ();return _febbf ;};
// 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 ();};
// MarginTop sets up the MarginTop parameter for the query.
func (_ea *QueryBuilder )MarginTop (marginTop _b .Length )*QueryBuilder {_ea ._agg .PageParameters .MarginTop =marginTop ;return _ea ;};
// BuildHTMLQuery creates a Query builder that is supposed to create valid
func BuildHTMLQuery ()*QueryBuilder {return &QueryBuilder {}};
// MarginLeft sets up the MarginLeft parameter for the query.
func (_cdd *QueryBuilder )MarginLeft (marginLeft _gg .Length )*QueryBuilder {_cdd ._bade .PageParameters .MarginLeft =marginLeft ;return _cdd ;};
// BySelector is a structure that defines a selector with it's query 'by' type.
type BySelector struct{Selector string `json:"selector"`;By _dbe .ByType `json:"by"`;};
type BySelector struct{Selector string `json:"selector"`;By _ga .ByType `json:"by"`;};
// WithDefaultTimeout sets the DefaultTimeout option for the client options.
func WithDefaultTimeout (option _c .Duration )Option {return func (_cbb *Options ){_cbb .DefaultTimeout =option };};
// 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"););
// MarginBottom sets up the MarginBottom parameter for the query.
func (_ae *QueryBuilder )MarginBottom (marginBottom _gg .Length )*QueryBuilder {_ae ._bade .PageParameters .MarginBottom =marginBottom ;return _ae ;};
// 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 ;};
// 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 ;};
// WithPrefix sets the client prefix.
func WithPrefix (prefix string )Option {return func (_ce *Options ){_ce .Prefix =prefix }};
// PDFResponse is the response used by the HTMLConverter.
type PDFResponse struct{ID string `json:"id"`;Data []byte `json:"data"`;};
// QueryBuilder is the query that converts HTMLConverter defined data
type QueryBuilder struct{_agg Query ;_fgb error ;};
type QueryBuilder struct{_bade Query ;_afb error ;};
// PageParameters are the query parameters used in the PDF generation.
type PageParameters struct{
// PaperWidth sets the width of the paper.
PaperWidth _b .Length `schema:"paper-width" json:"paperWidth"`;
PaperWidth _gg .Length `schema:"paper-width" json:"paperWidth"`;
// PaperHeight is the height of the output paper.
PaperHeight _b .Length `schema:"paper-height" json:"paperHeight"`;
PaperHeight _gg .Length `schema:"paper-height" json:"paperHeight"`;
// PageSize is the page size string.
PageSize *_b .PageSize `schema:"page-size" json:"pageSize"`;
PageSize *_gg .PageSize `schema:"page-size" json:"pageSize"`;
// Orientation defines if the output should be in a landscape format.
Orientation _b .Orientation `schema:"orientation" json:"orientation"`;
Orientation _gg .Orientation `schema:"orientation" json:"orientation"`;
// MarginTop sets up the Top Margin for the output.
MarginTop _b .Length `schema:"margin-top" json:"marginTop"`;
MarginTop _gg .Length `schema:"margin-top" json:"marginTop"`;
// MarginBottom sets up the Bottom Margin for the output.
MarginBottom _b .Length `schema:"margin-bottom" json:"marginBottom"`;
MarginBottom _gg .Length `schema:"margin-bottom" json:"marginBottom"`;
// MarginLeft sets up the Left Margin for the output.
MarginLeft _b .Length `schema:"margin-left" json:"marginLeft"`;
MarginLeft _gg .Length `schema:"margin-left" json:"marginLeft"`;
// MarginRight sets up the Right Margin for the output.
MarginRight _b .Length `schema:"margin-right" json:"marginRight"`;};
// Validate checks validity of the selector.
func (_ecg BySelector )Validate ()error {if _ecg .Selector ==""{return _g .New ("\u0070\u0072\u006fvi\u0064\u0065\u0064\u0020\u0065\u006d\u0070\u0074\u0079\u0020\u0073\u0065\u006c\u0065\u0063\u0074\u006f\u0072");};if _ega :=_ecg .By .Validate ();_ega !=nil {return _ega ;
};return nil ;};
// 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 _f .Duration ;};
// WaitReady waits for the selector to get ready - 'loaded'.
func (_aae *QueryBuilder )WaitReady (selector string ,by _dbe .ByType )*QueryBuilder {_aae ._agg .RenderParameters .WaitReady =append (_aae ._agg .RenderParameters .WaitReady ,BySelector {Selector :selector ,By :by });return _aae ;};
// TimeoutDuration sets the server query duration timeout.
// Once the timeout is reached the server will return an error.
func (_eedb *QueryBuilder )TimeoutDuration (d _f .Duration )*QueryBuilder {_eedb ._agg .TimeoutDuration =d ;return _eedb ;};
// PaperHeight sets up the PaperHeight (in cm) parameter for the query.
func (_aac *QueryBuilder )PaperHeight (paperHeight _b .Length )*QueryBuilder {_aac ._agg .PageParameters .PaperHeight =paperHeight ;return _aac ;};
// MarginLeft sets up the MarginLeft parameter for the query.
func (_agf *QueryBuilder )MarginLeft (marginLeft _b .Length )*QueryBuilder {_agf ._agg .PageParameters .MarginLeft =marginLeft ;return _agf ;};
// Options are the client options used by the HTTP client.
type Options struct{HTTPS bool ;Hostname string ;Port int ;DefaultTimeout _f .Duration ;Prefix string ;};
MarginRight _gg .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 *_dee .Client ;};
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 ();};
// WithHTTPS sets the TLS option for the client options.
func WithHTTPS (useHTTPS bool )Option {return func (_cee *Options ){_cee .HTTPS =useHTTPS }};
// WithPort sets the Port option for the client options.
func WithPort (option int )Option {return func (_cce *Options ){_cce .Port =option }};
// DefaultPageParameters creates default parameters.
func DefaultPageParameters ()PageParameters {return PageParameters {Orientation :_b .Portrait }};
// Validate checks if the parameters are valid.
func (_eed *PageParameters )Validate ()error {if _eed .PaperWidth !=nil {if _eed .PaperWidth .Millimeters ()< 0{return _g .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 _eed .PaperHeight !=nil {if _eed .PaperHeight .Millimeters ()< 0{return _g .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 _eed .MarginTop !=nil {if _eed .MarginTop .Millimeters ()< 0{return _g .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 _eed .MarginBottom !=nil {if _eed .MarginBottom .Millimeters ()< 0{return _g .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 _eed .MarginLeft !=nil {if _eed .MarginLeft .Millimeters ()< 0{return _g .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 _eed .MarginRight !=nil {if _eed .MarginRight .Millimeters ()< 0{return _g .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 _eed .PageSize !=nil &&!_eed .PageSize .IsAPageSize (){return _g .New ("\u0069\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u0070\u0061\u0067\u0065 \u0073\u0069\u007a\u0065");};return nil ;};
// Addr gets the HTTP address URI used by the http.Client.
func (_eeg *Options )Addr ()string {_afc :=_ca .Builder {};_afc .WriteString ("\u0068\u0074\u0074\u0070");if _eeg .HTTPS {_afc .WriteRune ('s');};_afc .WriteString ("\u003a\u002f\u002f");_afc .WriteString (_eeg .Hostname );_afc .WriteRune (':');_afc .WriteString (_eb .Itoa (_eeg .Port ));
if _eeg .Prefix !=""{_afc .WriteString (_eeg .Prefix );};return _afc .String ();};
// PageSize sets up the PageSize parameter for the query.
func (_bfcb *QueryBuilder )PageSize (pageSize _b .PageSize )*QueryBuilder {if pageSize !=_b .Undefined {_bfcb ._agg .PageParameters .PageSize =&pageSize ;};return _bfcb ;};
// BuildHTMLQuery creates a Query builder that is supposed to create valid
func BuildHTMLQuery ()*QueryBuilder {return &QueryBuilder {}};
// WithDefaultTimeout sets the DefaultTimeout option for the client options.
func WithDefaultTimeout (option _f .Duration )Option {return func (_be *Options ){_be .DefaultTimeout =option };};var (ErrNotFound =_g .New ("\u006eo\u0074\u0020\u0066\u006f\u0075\u006ed");ErrBadRequest =_g .New ("b\u0061\u0064\u0020\u0072\u0065\u0071\u0075\u0065\u0073\u0074");
ErrNotImplemented =_g .New ("\u006eo\u0074 \u0069\u006d\u0070\u006c\u0065\u006d\u0065\u006e\u0074\u0065\u0064");ErrInternalError =_g .New ("i\u006e\u0074\u0065\u0072na\u006c \u0073\u0065\u0072\u0076\u0065r\u0020\u0065\u0072\u0072\u006f\u0072");ErrBadGateway =_g .New ("b\u0061\u0064\u0020\u0067\u0061\u0074\u0065\u0077\u0061\u0079");
ErrUnauthorized =_g .New ("\u0075\u006e\u0061u\u0074\u0068\u006f\u0072\u0069\u007a\u0065\u0064");ErrTimedOut =_g .New ("\u0072\u0065\u0071\u0075\u0065\u0073\u0074\u0020\u0074\u0069\u006d\u0065d\u0020\u006f\u0075\u0074"););
// 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 ;};
// New creates new client with provided options.
func New (o Options )*Client {o .DefaultTimeout =_f .Second *30;if o .Port <=0{o .Port =8080;};if o .Hostname ==""{o .Hostname ="\u00312\u0037\u002e\u0030\u002e\u0030\u002e1";};var _acb =&_dee .Transport {DialContext :(&_af .Dialer {Timeout :5*_f .Second }).DialContext ,TLSHandshakeTimeout :5*_f .Second };
_da .Log .Info ("\u0043l\u0069e\u006e\u0074\u0020\u0041\u0064\u0064\u0072\u003a\u0020\u0025\u0073",o .Addr ());return &Client {Options :o ,Client :&_dee .Client {Transport :_acb ,Timeout :o .DefaultTimeout }};};
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 }};};
// MarginRight sets up the MarginRight parameter for the query.
func (_aaa *QueryBuilder )MarginRight (marginRight _b .Length )*QueryBuilder {_aaa ._agg .PageParameters .MarginRight =marginRight ;return _aaa ;};
// 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 ;};
// WaitTime sets the minimum load time parameter for the page rendering.
func (_bcc *QueryBuilder )WaitTime (d _f .Duration )*QueryBuilder {_bcc ._agg .RenderParameters .WaitTime =d ;return _bcc ;};
// DefaultPageParameters creates default parameters.
func DefaultPageParameters ()PageParameters {return PageParameters {Orientation :_gg .Portrait }};
// 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");
);
// 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 ;};
// 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 ;};
// 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 ();};
// 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 ;
};return nil ;};
// Err gets the error which could occur in the query.
func (_fbg *QueryBuilder )Err ()error {return _fbg ._fgb };func (_dc *Client )getGenerateRequest (_dfb _df .Context ,_gded *Query )(*_dee .Request ,error ){_bf :=generatePDFRequestV1 {Method :_gded .Method ,PageParameters :_gded .PageParameters ,RenderParameters :_gded .RenderParameters ,TimeoutDuration :int64 (_gded .TimeoutDuration )};
switch _gded .Method {case "\u0077\u0065\u0062":_bf .ContentURL =_gded .URL ;case "\u0064\u0069\u0072","\u0068\u0074\u006d\u006c":_bf .ContentType =_gded .ContentType ;_bf .Content =_gded .Content ;};_ff :=new (_aa .Buffer );if _acbd :=_c .NewEncoder (_ff ).Encode (&_bf );
_acbd !=nil {return nil ,_ac .Errorf ("e\u006e\u0063\u006f\u0064\u0069\u006eg\u0020\u0072\u0065\u0071\u0075\u0065\u0073\u0074\u0020f\u0061\u0069\u006ce\u0064:\u0020\u0025\u0076",_acbd );};_ffd :=_dc .Options .Addr ();_ffd =_ac .Sprintf ("%\u0073\u002f\u0062\u0065\u0074\u0061\u002f\u0070\u0064\u0066",_ffd );
_bd ,_fed :=_dee .NewRequest ("\u0050\u004f\u0053\u0054",_ffd ,_ff );if _fed !=nil {return nil ,_fed ;};_bd .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");
_bd .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");
_bd =_bd .WithContext (_dfb );return _bd ,nil ;};
func (_edb *QueryBuilder )Err ()error {return _edb ._afb };
// PDFResponse is the response used by the HTMLConverter.
type PDFResponse struct{ID string `json:"id"`;Data []byte `json:"data"`;};
// 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 ;};
// 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 ;};};
// 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 ;};
// Orientation sets the page orientation for the Query.
func (_ecd *QueryBuilder )Orientation (orientation _gg .Orientation )*QueryBuilder {_ecd ._bade .PageParameters .Orientation =orientation ;return _ecd ;};
// WithPort sets the Port option for the client options.
func WithPort (option int )Option {return func (_fb *Options ){_fb .Port =option }};
// Landscape sets up the landscape portrait orientation.
func (_dcd *QueryBuilder )Landscape ()*QueryBuilder {_dcd ._agg .PageParameters .Orientation =_b .Landscape ;return _dcd ;};
func (_ggb *QueryBuilder )Landscape ()*QueryBuilder {_ggb ._bade .PageParameters .Orientation =_gg .Landscape ;return _ggb ;};
// MarginBottom sets up the MarginBottom parameter for the query.
func (_febb *QueryBuilder )MarginBottom (marginBottom _b .Length )*QueryBuilder {_febb ._agg .PageParameters .MarginBottom =marginBottom ;return _febb ;};
// WithHTTPS sets the TLS option for the client options.
func WithHTTPS (useHTTPS bool )Option {return func (_bad *Options ){_bad .HTTPS =useHTTPS }};
// 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 ;};
// MarginTop sets up the MarginTop parameter for the query.
func (_ee *QueryBuilder )MarginTop (marginTop _gg .Length )*QueryBuilder {_ee ._bade .PageParameters .MarginTop =marginTop ;return _ee ;};
// MarginRight sets up the MarginRight parameter for the query.
func (_cge *QueryBuilder )MarginRight (marginRight _gg .Length )*QueryBuilder {_cge ._bade .PageParameters .MarginRight =marginRight ;return _cge ;};
// 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 }};
// 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 (_gbf *QueryBuilder )Query ()(*Query ,error ){if _bfc :=_gbf .Validate ();_bfc !=nil {return nil ,_bfc ;};return &_gbf ._agg ,nil ;};var (ErrMissingData =_g .New ("\u006di\u0073s\u0069\u006e\u0067\u0020\u0069n\u0070\u0075t\u0020\u0064\u0061\u0074\u0061");
ErrContentType =_g .New ("i\u006ev\u0061\u006c\u0069\u0064\u0020\u0063\u006f\u006et\u0065\u006e\u0074\u0020ty\u0070\u0065");ErrContentTypeDeclared =_g .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");
);
func (_cg *QueryBuilder )Query ()(*Query ,error ){if _bd :=_cg .Validate ();_bd !=nil {return nil ,_bd ;};return &_cg ._bade ,nil ;};
// Validate checks if the QueryBuilder had no errors during composition and creation.
func (_gbd *QueryBuilder )Validate ()error {if _gbd ._fgb !=nil {return _gbd ._fgb ;};return _gbd ._agg .Validate ();};
// 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 ;};
// WaitVisible waits for the selector to get visible.
func (_ceea *QueryBuilder )WaitVisible (selector string ,by _dbe .ByType )*QueryBuilder {_ceea ._agg .RenderParameters .WaitVisible =append (_ceea ._agg .RenderParameters .WaitVisible ,BySelector {Selector :selector ,By :by });return _ceea ;};
// 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"`;};
// Orientation sets the page orientation for the Query.
func (_dbb *QueryBuilder )Orientation (orientation _b .Orientation )*QueryBuilder {_dbb ._agg .PageParameters .Orientation =orientation ;return _dbb ;};
// 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 ;};
// 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 ;};

View File

@ -10,8 +10,8 @@
// terms that can be accessed at https://unidoc.io/eula/
// Package common contains common properties used by the subpackages.
package common ;import _bb "time";
package common ;import _e "time";const _f =2024;const Version ="\u0030\u002e\u0039.\u0030";
// UtcTimeFormat returns a formatted string describing a UTC timestamp.
func UtcTimeFormat (t _bb .Time )string {return t .Format (_a )+"\u0020\u0055\u0054\u0043"};const _e =26;const _a ="\u0032\u0020\u004aan\u0075\u0061\u0072\u0079\u0020\u0032\u0030\u0030\u0036\u0020\u0061\u0074\u0020\u0031\u0035\u003a\u0030\u0034";const _c =2024;
const _g =1;const _ea =12;var ReleasedAt =_bb .Date (_c ,_g ,_e ,_ea ,_d ,0,0,_bb .UTC );const _d =20;const Version ="\u0030\u002e\u0038.\u0030";
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;

View File

@ -9,65 +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 (_ff "archive/zip";_d "bytes";_e "fmt";_g "io/ioutil";_c "net/url";_be "os";_b "strings";);
// ContentType implements Content interface.
func (_cff *zipDirectory )ContentType ()string {return "\u0061p\u0070l\u0069\u0063\u0061\u0074\u0069\u006f\u006e\u002f\u007a\u0069\u0070";};
// StringContent implements Content interface for an HTML string.
type StringContent struct{_aag string };type htmlFile struct{_fe _d .Buffer };
// NewHTMLFile creates new Content htmFile for provided input path.
func NewHTMLFile (path string )(Content ,error ){_ge ,_fb :=_be .Open (path );if _fb !=nil {return nil ,_fb ;};_a :=&htmlFile {_fe :_d .Buffer {}};if _ ,_fb =_a ._fe .ReadFrom (_ge );_fb !=nil {return nil ,_fb ;};return _a ,nil ;};type webURL struct{_bf string };
type zipDirectory struct{_bc _d .Buffer ;_ad *_ff .Writer ;};
// Method gets the web url query method.
func (_aa *webURL )Method ()string {return "\u0077\u0065\u0062"};
// Content is an interface used for putting the content into Client Query.
type Content interface{ContentType ()string ;Method ()string ;Data ()[]byte ;};func (_adg *zipDirectory )zipPath (_aaa ,_aaf string )error {_ac ,_fa :=_g .ReadDir (_aaa );if _fa !=nil {return _e .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",_aaa ,_fa );
};_df :=&_b .Builder {};for _ ,_ag :=range _ac {_bgb ,_dc :=_adg .zipBasePaths (_ag ,_aaa ,_aaf ,_ag .IsDir (),_df );if _ag .IsDir (){if _dg :=_adg .zipPath (_bgb ,_dc );_dg !=nil {return _dg ;};continue ;};_gg ,_fc :=_g .ReadFile (_bgb );if _fc !=nil {return _fc ;
};_def ,_fc :=_adg ._ad .Create (_dc );if _fc !=nil {return _fc ;};if _ ,_fc =_def .Write (_gg );_fc !=nil {return _fc ;};};return nil ;};
// Method implements Content interface.
func (_faa *StringContent )Method ()string {return "\u0068\u0074\u006d\u006c"};
// Data implements Content interface.
func (_cd *StringContent )Data ()[]byte {return []byte (_cd ._aag )};
// Data implements Content interface.
func (_de *htmlFile )Data ()[]byte {return _de ._fe .Bytes ()};
// Data implements Content interface.
func (_gef *zipDirectory )Data ()[]byte {return _gef ._bc .Bytes ()};
// ContentType implements Content interface.
func (_bce *StringContent )ContentType ()string {return "\u0074e\u0078\u0074\u002f\u0068\u0074\u006dl";};
// NewStringContent creates a new StringContent.
func NewStringContent (html string )(*StringContent ,error ){return &StringContent {_aag :html },nil };
// ContentType implements Content interface.
func (_ab *htmlFile )ContentType ()string {return "\u0074e\u0078\u0074\u002f\u0068\u0074\u006dl"};
// NewWebURL creates new Content webURL for provided input URL path.
func NewWebURL (path string )(Content ,error ){if _ ,_ec :=_c .Parse (path );_ec !=nil {return nil ,_ec ;};return &webURL {_bf :path },nil ;};
// ContentType implements Content interface.
func (_cg *webURL )ContentType ()string {return "\u0074\u0065\u0078\u0074\u002f\u0070\u006c\u0061\u0069\u006e";};
package content ;import (_b "archive/zip";_ab "bytes";_bd "fmt";_a "net/url";_d "os";_bc "strings";);
// Method gets the query method.
func (_ee *htmlFile )Method ()string {return "\u0068\u0074\u006d\u006c"};
func (_bg *htmlFile )Method ()string {return "\u0068\u0074\u006d\u006c"};type htmlFile struct{_c _ab .Buffer };
// 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 };
// Data implements Content interface.
func (_cf *webURL )Data ()[]byte {return []byte (_cf ._bf )};func (_gda *zipDirectory )zipBasePaths (_bd _be .FileInfo ,_fd ,_ea string ,_eaa bool ,_ggf *_b .Builder )(string ,string ){_ggf .WriteString (_fd );if !_b .HasSuffix (_fd ,"\u002f"){_ggf .WriteRune ('/');
};_ggf .WriteString (_bd .Name ());if _eaa {_ggf .WriteRune ('/');};_fef :=_ggf .String ();_ggf .Reset ();_ggf .WriteString (_ea );_ggf .WriteString (_bd .Name ());if _eaa {_ggf .WriteRune ('/');};_bb :=_ggf .String ();_ggf .Reset ();return _fef ,_bb ;
};
func (_bee *StringContent )Data ()[]byte {return []byte (_bee ._aca )};
// ContentType implements Content interface.
func (_bad *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 (_ecf *zipDirectory )Method ()string {return "\u0064\u0069\u0072"};
func (_ba *zipDirectory )Method ()string {return "\u0064\u0069\u0072"};
// 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 ;};
// Method gets the web url query method.
func (_ag *webURL )Method ()string {return "\u0077\u0065\u0062"};
// 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 ;};
// ContentType implements Content interface.
func (_aa *webURL )ContentType ()string {return "\u0074\u0065\u0078\u0074\u002f\u0070\u006c\u0061\u0069\u006e";};
// StringContent implements Content interface for an HTML string.
type StringContent struct{_aca string };
// ContentType implements Content interface.
func (_fg *zipDirectory )ContentType ()string {return "\u0061p\u0070l\u0069\u0063\u0061\u0074\u0069\u006f\u006e\u002f\u007a\u0069\u0070";};
// NewStringContent creates a new StringContent.
func NewStringContent (html string )(*StringContent ,error ){return &StringContent {_aca :html },nil };
// Data implements Content interface.
func (_ac *zipDirectory )Data ()[]byte {return _ac ._cbb .Bytes ()};
// ContentType implements Content interface.
func (_dc *htmlFile )ContentType ()string {return "\u0074e\u0078\u0074\u002f\u0068\u0074\u006dl"};
// 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 ){_ae :=&zipDirectory {_bc :_d .Buffer {}};_ae ._ad =_ff .NewWriter (&_ae ._bc );if _gd :=_ae .zipPath (dirPath ,"");_gd !=nil {return nil ,_gd ;};if _eg :=_ae ._ad .Close ();_eg !=nil {return nil ,_eg ;
};return _ae ,nil ;};
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 ;};
// Data implements Content interface.
func (_cb *htmlFile )Data ()[]byte {return _cb ._c .Bytes ()};
// Method implements Content interface.
func (_ga *StringContent )Method ()string {return "\u0068\u0074\u006d\u006c"};type zipDirectory struct{_cbb _ab .Buffer ;_g *_b .Writer ;};

21
go.mod
View File

@ -1,13 +1,13 @@
module github.com/unidoc/unihtml
go 1.17
go 1.18
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.8.4
github.com/unidoc/unipdf/v3 v3.53.0
github.com/stretchr/testify v1.9.0
github.com/unidoc/unipdf/v3 v3.64.0
)
require (
@ -16,12 +16,13 @@ require (
github.com/adrg/xdg v0.4.0 // 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/gorilla/i18n v0.0.0-20150820051429-8b358169da46 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/pelletier/go-toml/v2 v2.1.1 // indirect
github.com/pelletier/go-toml/v2 v2.2.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/spf13/afero v1.11.0 // indirect
@ -34,13 +35,13 @@ require (
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.18.0 // indirect
golang.org/x/image v0.15.0 // indirect
golang.org/x/net v0.20.0 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/text v0.14.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
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // 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
)

39
go.sum
View File

@ -14,6 +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/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=
@ -24,6 +26,7 @@ github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLf
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=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
@ -34,8 +37,8 @@ github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/pelletier/go-toml/v2 v2.1.1 h1:LWAJwfNvjQZCFIDKWYQaM62NcYeYViCmWIwmOStowAI=
github.com/pelletier/go-toml/v2 v2.1.1/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc=
github.com/pelletier/go-toml/v2 v2.2.1 h1:9TA9+T8+8CUCO2+WYnDLCgrYi9+omqKXyjDtosvtEhg=
github.com/pelletier/go-toml/v2 v2.2.1/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
@ -59,14 +62,16 @@ github.com/spf13/viper v1.16.0/go.mod h1:yg78JgCJcbrQOvV9YLXgkLaZqUidkY9K+Dd1Fof
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
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 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
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/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=
@ -78,34 +83,34 @@ github.com/unidoc/timestamp v0.0.0-20200412005513-91597fd3793a h1:RLtvUhe4DsUDl6
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.53.0 h1:xUgG/MH2iUHaar554w6OrL0qTKNy4AWzb19z0RyIExs=
github.com/unidoc/unipdf/v3 v3.53.0/go.mod h1:sEXO/chguUL1RAtyPnGos2BbCBGjL9dusmdT5b13eBg=
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.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc=
golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg=
golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U=
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
golang.org/x/image v0.0.0-20211028202545-6944b10bf410/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM=
golang.org/x/image v0.15.0 h1:kOELfmgrmJlw4Cdb7g/QGuB3CvDrXbqEIww/pNtNBm8=
golang.org/x/image v0.15.0/go.mod h1:HUYqC05R2ZcZ3ejNQsIHQDQiwWM4JBqmm6MKANTp4LE=
golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo=
golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY=
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/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.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU=
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
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/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
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/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=
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-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/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=

View File

@ -9,11 +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 _g "errors";
package selector ;import _b "errors";
// ByType is a 'By' selector type enumerator.
type ByType uint ;
type ByType uint ;const (ByUndefined ByType =iota ;ByID ;ByQueryAll ;ByQuery ;ByNodeID ;ByJSPath ;BySearch ;);
// Validate checks validity of the ByType.
func (_cg ByType )Validate ()error {if _cg >=ByID &&_cg <=BySearch {return nil ;};return _g .New ("\u0069\u006e\u0076\u0061li\u0064\u0020\u0062\u0079\u0020\u0073\u0065\u006c\u0065\u0063\u0074\u006f\u0072");};const (ByUndefined ByType =iota ;ByID ;ByQueryAll ;
ByQuery ;ByNodeID ;ByJSPath ;BySearch ;);
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");};

View File

@ -12,191 +12,190 @@
// Package sizes defines basic types that determines the size units i.e. lengths.
//
//
package sizes ;import (_b "encoding/json";_g "flag";_ea "fmt";_c "strconv";_be "strings";);
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";
// Inches gets the inches equivalent from provided millimeter value.
func (_ebb Millimeter )Inches ()Inch {return Inch (float64 (_ebb )*_cb )};
// ValueString implements viper.FlagValue interface.
func (_fgc Point )ValueString ()string {return _fgc .String ()};var _ Length =Inch (0);
// String gets the string value for given flag.
func (_ga *LengthFlag )String ()string {if _ga .Length ==nil {return "\u0075n\u0064\u0065\u0066\u0069\u006e\u0065d";};return _ga .Length .String ();};
// Points implements Length interface.
func (_dc Inch )Points ()Point {return Point (float64 (_dc )*_af )};
// UnmarshalPageSize unmarshals the page size from the string.
func UnmarshalPageSize (pageSize string )(PageSize ,error ){var _deea PageSize ;if _cca :=(&_deea ).UnmarshalText ([]byte (pageSize ));_cca !=nil {return 0,_ea .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",_cca );
};return _deea ,nil ;};var _ _g .Value =(*Orientation )(nil );
// Type implements pflag.Value interface.
func (_fcc Orientation )Type ()string {return "o\u0072\u0069\u0065\u006e\u0074\u0061\u0074\u0069\u006f\u006e";};
// String implements fmt.Stringer interface.
func (_ef Orientation )String ()string {if _ef ==Portrait {return "\u0070\u006f\u0072\u0074\u0072\u0061\u0069\u0074";};return "\u006ca\u006e\u0064\u0073\u0063\u0061\u0070e";};
// PageSize is the enum used for defining the page size.
type PageSize int ;
// Type implements pflag.Value interface.
func (_ag *LengthFlag )Type ()string {return "\u0075\u006e\u0069\u0074"};
// Type implements pflag.Value interface.
func (_ega Point )Type ()string {return "\u0070\u006f\u0069n\u0074"};
func (_db *LengthFlag )String ()string {if _db .Length ==nil {return "\u0075n\u0064\u0065\u0066\u0069\u006e\u0065d";};return _db .Length .String ();};
// ValueType implements pflag.Value interface.
func (_dg Inch )ValueType ()string {return _dg .Type ()};
func (_aa Inch )ValueType ()string {return _aa .Type ()};
// MarshalJSON implements json.Marshaler interface.
func (_ggb Point )MarshalJSON ()([]byte ,error ){return _bee (_ggb )};func _bc (_fed string )(Inch ,error ){_fed =_be .TrimSpace (_be .Trim (_fed ,"\u0069\u006e"));_bcc ,_gaf :=_c .ParseFloat (_fed ,64);if _gaf !=nil {return 0,_ea .Errorf ("\u0069\u006e\u0076\u0061li\u0064\u0020\u0069\u006e\u0063\u0068\u0020\u0076\u0061\u006c\u0075\u0065\u003a\u0020%\u0077",_gaf );
};return Inch (_bcc ),nil ;};
// String implements fmt.Stringer interface.
func (_ffe Point )String ()string {_fcb :=_be .Builder {};_fcb .WriteString (_c .FormatFloat (float64 (_ffe ),'f',1,64));_fcb .WriteString ("\u0070\u0074");return _fcb .String ();};
// Millimeters converts the inches value to the millimeters.
func (_ba Inch )Millimeters ()Millimeter {return Millimeter (float64 (_ba )*_ee )};
// UnmarshalJSON implements the json.Unmarshaler interface for PageSize
func (_bcf *PageSize )UnmarshalJSON (data []byte )error {var _bge string ;if _ae :=_b .Unmarshal (data ,&_bge );_ae !=nil {return _ea .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 _baed error ;*_bcf ,_baed =PageSizeString (_bge );return _baed ;};
// Length is it the default dimension unit.
type Length interface{Millimeters ()Millimeter ;Inches ()Inch ;Points ()Point ;String ()string ;};const (_f =float64 (1)/float64 (25.4);_ee =25.4;_a =0.0139;_gd =0.3528;_af =1.0/64;_ff =1.0/_gd ;);const _fbe ="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";
// Type implements pflag.Value interface.
func (_bbg 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 _dbf =[]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};var _cg =map[string ]PageSize {_fbe [0:9]:0,_fbe [9:11]:1,_fbe [11:13]:2,_fbe [13:15]:3,_fbe [15:17]:4,_fbe [17:19]:5,_fbe [19:21]:6,_fbe [21:23]:7,_fbe [23:25]:8,_fbe [25:27]:9,_fbe [27:29]:10,_fbe [29:32]:11,_fbe [32:34]:12,_fbe [34:36]:13,_fbe [36:38]:14,_fbe [38:40]:15,_fbe [40:42]:16,_fbe [42:44]:17,_fbe [44:46]:18,_fbe [46:48]:19,_fbe [48:50]:20,_fbe [50:52]:21,_fbe [52:55]:22,_fbe [55:61]:23};
// IsAPageSize returns "true" if the value is listed in the enum definition. "false" otherwise
func (_bg PageSize )IsAPageSize ()bool {for _ ,_ca :=range _dbf {if _bg ==_ca {return true ;};};return false ;};
// ValueType implements viper.FlagValue interface.
func (_dbb Point )ValueType ()string {return _dbb .Type ()};
// Set sets the unit value.
// Implements pflag.Value interface.
func (_fg *LengthFlag )Set (s string )error {if s =="\u0075n\u0064\u0065\u0066\u0069\u006e\u0065d"{_fg .Length =nil ;return nil ;};_d ,_fc :=UnmarshalLength (s );if _fc !=nil {return _fc ;};_fg .Length =_d ;return nil ;};
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 ;};
// Dimensions gets the dimensions of the given page size.
// If provided page size is not valid than the function returns 0 values.
func (_dbg PageSize )Dimensions ()(_gdef ,_cc Millimeter ){switch _dbg {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 _gdef ,_cc ;};
// ValueType implements viper.FlagValue interface.
func (_cd Point )ValueType ()string {return _cd .Type ()};
// ValueString implements viper.FlagValue interface.
func (_cb Point )ValueString ()string {return _cb .String ()};
// Points implements Length interface.
func (_bae Point )Points ()Point {return _bae };func (_gee PageSize )String ()string {if _gee < 0||_gee >=PageSize (len (_eba )-1){return _ea .Sprintf ("\u0050\u0061\u0067e\u0053\u0069\u007a\u0065\u0028\u0025\u0064\u0029",_gee );};return _fbe [_eba [_gee ]:_eba [_gee +1]];
};
// UnmarshalInch unmarshalls provided string into unit.
func UnmarshalInch (unit string )(Inch ,error ){if _be .HasSuffix (unit ,"\u006d\u006d"){_gc ,_gde :=_fca (unit );if _gde !=nil {return 0,_gde ;};return _gc .Inches (),nil ;};if _be .HasSuffix (unit ,"\u0069\u006e"){return _bc (unit );};return 0,_ea .Errorf ("\u0069\u006e\u0076\u0061li\u0064\u0020\u0069\u006e\u0063\u0068\u0020\u0069\u006e\u0070\u0075\u0074\u003a\u0020%\u0073",unit );
};var _eba =[...]uint8 {0,9,11,13,15,17,19,21,23,25,27,29,32,34,36,38,40,42,44,46,48,50,52,55,61};
// Orientation is the page orientation type wrapper.
type Orientation bool ;
// Type implements pflag.Value interface.
func (_bb Inch )Type ()string {return "\u0069\u006e\u0063\u0068"};
// Name implements viper.FlagValue interface.
func (_dgg Point )Name ()string {return "\u0070\u006f\u0069n\u0074"};
// Set implements flag.Value interface.
func (_eeg *Point )Set (s string )error {_baf ,_fbg :=_c .ParseFloat (s ,64);if _fbg !=nil {return _ea .Errorf ("\u0069\u006e\u0076\u0061li\u0064\u0020\u0069\u006e\u0063\u0068\u0020\u0076\u0061\u006c\u0075\u0065\u003a\u0020%\u0077",_fbg );};*_eeg =Point (_baf );
return nil ;};
// Set implements flag.Value interface.
func (_bf *Orientation )Set (s string )error {switch s {case "\u0070\u006f\u0072\u0074\u0072\u0061\u0069\u0074":*_bf =Portrait ;case "\u006ca\u006e\u0064\u0073\u0063\u0061\u0070e":*_bf =Landscape ;default:return _ea .Errorf ("\u0069n\u0076\u0061\u006c\u0069d\u0020\u006f\u0072\u0069\u0065n\u0074a\u0074i\u006f\u006e\u003a\u0020\u0027\u0025\u0073'",s );
};return nil ;};
// Millimeter is the dimension unit that defines a millimeter.
type Millimeter 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 ;);func _fca (_deg string )(Millimeter ,error ){_deg =_be .TrimSpace (_be .TrimSuffix (_deg ,"\u006d\u006d"));
_ebf ,_fd :=_c .ParseFloat (_deg ,64);if _fd !=nil {return 0,_ea .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",_fd );};return Millimeter (_ebf ),nil ;
};
// Inch is a unit that
type Inch float64 ;
// HasChanged implements viper.FlagValue interface.
func (_aad *Point )HasChanged ()bool {return _aad !=nil };
// MarshalUnit marshals the unit into the string.
func MarshalUnit (unit Length )(string ,error ){switch _gfd :=unit .(type ){case Millimeter :return _ea .Sprintf ("\u0025\u002e\u0030\u0066\u006d\u006d",_gfd ),nil ;case Inch :return _ea .Sprintf ("\u0025\u002e\u0030\u0066\u0069\u006e",_gfd ),nil ;case Point :return _ea .Sprintf ("\u0025\u002e\u0030\u0066\u0070\u0074",_gfd ),nil ;
default:return "",_ea .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 (_ec Millimeter )String ()string {_gff :=_be .Builder {};_gff .WriteString (_c .FormatFloat (float64 (_ec ),'f',1,64));_gff .WriteString ("\u006d\u006d");return _gff .String ();};
// Inches gets the inch value. Implements Length interface.
func (_ccf Inch )Inches ()Inch {return _ccf };
// MarshalJSON implements the json.Marshaler interface for PageSize
func (_dde PageSize )MarshalJSON ()([]byte ,error ){return _b .Marshal (_dde .String ())};var (_ Length =Millimeter (0););var _ _g .Value =(*Point )(nil );
func (_gd PageSize )MarshalJSON ()([]byte ,error ){return _d .Marshal (_gd .String ())};
// MarshalText implements the encoding.TextMarshaler interface for PageSize
func (_fbgb PageSize )MarshalText ()([]byte ,error ){return []byte (_fbgb .String ()),nil };
// 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 ;};
// Set implements pflag.Value interface.
func (_eg *Inch )Set (s string )error {_de ,_fb :=_c .ParseFloat (s ,64);if _fb !=nil {return _ea .Errorf ("\u0069\u006e\u0076\u0061li\u0064\u0020\u0069\u006e\u0063\u0068\u0020\u0076\u0061\u006c\u0075\u0065\u003a\u0020%\u0077",_fb );};*_eg =Inch (_de );
// 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 ;};
// Millimeters gets the float64 millimeter value.
func (_agg Millimeter )Millimeters ()Millimeter {return _agg };
// Name implements pflag.Value interface.
func (_ge Inch )Name ()string {return "\u0069\u006e\u0063\u0068"};
// 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 _dgbf ,_eff :=_cg [s ];_eff {return _dgbf ,nil ;};return 0,_ea .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 );
};var _ Length =Inch (0);
// Inches gets the inches equivalent from provided millimeter value.
func (_bef Millimeter )Inches ()Inch {return Inch (float64 (_bef )*_f )};
// PageSizeValues returns all values of the enum
func PageSizeValues ()[]PageSize {return _dbf };
// MarshalPageSize marshals the page size into string.
func MarshalPageSize (p PageSize )(string ,error ){_ad ,_egg :=p .MarshalText ();if _egg !=nil {return "",_egg ;};return string (_ad ),nil ;};
// Points implements Length interface.
func (_aga Millimeter )Points ()Point {return Point (_aga *_ff )};
// ValueString implements pflag.Value interface.
func (_de Inch )ValueString ()string {return _de .String ()};
// String implements fmt.Stringer interface.
func (_aa Inch )String ()string {_gg :=_be .Builder {};_gg .WriteString (_c .FormatFloat (float64 (_aa ),'f',1,64));_gg .WriteString ("\u0069\u006e");return _gg .String ();};
func (_dbe Inch )String ()string {_bg :=_b .Builder {};_bg .WriteString (_c .FormatFloat (float64 (_dbe ),'f',1,64));_bg .WriteString ("\u0069\u006e");return _bg .String ();};
// Inches gets the inch value. Implements Length interface.
func (_eb Point )Inches ()Inch {return Inch (float64 (_eb )*_a )};func _gbe (_gffe string )(Point ,error ){_gffe =_be .TrimSpace (_be .Trim (_gffe ,"\u0070\u0074"));_agd ,_bd :=_c .ParseFloat (_gffe ,64);if _bd !=nil {return 0,_bd ;};return Point (_agd ),nil ;
};func _bee (_cde Length )([]byte ,error ){if _cde ==nil {return nil ,nil ;};_db ,_abd :=MarshalUnit (_cde );if _abd !=nil {return nil ,_abd ;};return []byte ("\u0022"+_db +"\u0022"),nil ;};const (Portrait =Orientation (false );Landscape =Orientation (true );
);
// 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};
// UnmarshalText implements the encoding.TextUnmarshaler interface for PageSize
func (_ac *PageSize )UnmarshalText (text []byte )error {var _dgd error ;*_ac ,_dgd =PageSizeString (string (text ));return _dgd ;};
// Set implements pflag.Value interface.
func (_dd *PageSize )Set (s string )error {_afc ,_fcaf :=UnmarshalPageSize (s );if _fcaf !=nil {return _fcaf ;};*_dd =_afc ;return nil ;};
// Inches gets the inch value. Implements Length interface.
func (_fbb Inch )Inches ()Inch {return _fbb };
// HasChanged implements pflag.Value interface.
func (_fcf *Inch )HasChanged ()bool {return _fcf !=nil };
func (_df *Inch )HasChanged ()bool {return _df !=nil };
// ValueString implements pflag.Value interface.
func (_fe Inch )ValueString ()string {return _fe .String ()};
// Name implements viper.FlagValue interface.
func (_cce Point )Name ()string {return "\u0070\u006f\u0069n\u0074"};var _ _a .Value =(*Point )(nil );
// MarshalJSON implements json.Marshaler interface
func (_ed Inch )MarshalJSON ()([]byte ,error ){return _bee (_ed )};
// MarshalText implements the encoding.TextMarshaler interface for PageSize
func (_bae PageSize )MarshalText ()([]byte ,error ){return []byte (_bae .String ()),nil };
// Type implements pflag.Value interface.
func (_cda Orientation )Type ()string {return "o\u0072\u0069\u0065\u006e\u0074\u0061\u0074\u0069\u006f\u006e";};
// 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";};
// Point is a unit of Length commonly used to measure the height of fonts.
type Point float64 ;
// Millimeters converts the inches value to the millimeters.
func (_dee Point )Millimeters ()Millimeter {return Millimeter (float64 (_dee )*_gd )};
// Type implements pflag.Value interface.
func (_fc Inch )Type ()string {return "\u0069\u006e\u0063\u0068"};
// UnmarshalLength unmarshalls string value into Length.
func UnmarshalLength (length string )(Length ,error ){if _be .HasSuffix (length ,"\u006d\u006d"){return _fca (length );};if _be .HasSuffix (length ,"\u0069\u006e"){return _bc (length );};if _be .HasSuffix (length ,"\u0070\u0074"){return _gbe (length );
};return nil ,_ea .Errorf ("\u0069n\u0076\u0061\u006c\u0069\u0064\u0020\u006c\u0065\u006e\u0067\u0074h\u0020\u0069\u006e\u0070\u0075\u0074\u003a\u0020\u0025\u0073",length );};
// 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 ;};
// 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 ;};
// 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 ;};
// 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]];};
// 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 ;};
// 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};
// 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 )};
// Millimeter is the dimension unit that defines a millimeter.
type Millimeter float64 ;
// Orientation is the page orientation type wrapper.
type Orientation bool ;
// MarshalJSON implements json.Marshaler interface
func (_ab Millimeter )MarshalJSON ()([]byte ,error ){return _bee (_ab )};
func (_ab Millimeter )MarshalJSON ()([]byte ,error ){return _bff (_ab )};
// 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 );
};
// 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 ;};
// 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 ;};
// Type implements pflag.Value interface.
func (_fa Point )Type ()string {return "\u0070\u006f\u0069n\u0074"};
// 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 );
};
// Points implements Length interface.
func (_ec Inch )Points ()Point {return Point (float64 (_ec )*_f )};
// 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 ;);
// Type implements pflag.Value interface.
func (_bab *LengthFlag )Type ()string {return "\u0075\u006e\u0069\u0074"};
// 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 ;};
// MarshalJSON implements json.Marshaler interface.
func (_cd Point )MarshalJSON ()([]byte ,error ){return _bff (_cd )};
// Points implements Length interface.
func (_cbf Point )Points ()Point {return _cbf };
// Inches gets the inch value. Implements Length interface.
func (_dbc Point )Inches ()Inch {return Inch (float64 (_dbc )*_be )};var (_ Length =Millimeter (0););
// LengthFlag is a pflag wrapper for the Length value.
type LengthFlag struct{Length Length ;};
// Millimeters gets the float64 millimeter value.
func (_eb Millimeter )Millimeters ()Millimeter {return _eb };
// 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 ;};
// 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 ;};
// Type implements pflag.Value interface.
func (_ed PageSize )Type ()string {return "\u0070a\u0067\u0065\u002d\u0073\u0069\u007ae"};
// Points implements Length interface.
func (_gc Millimeter )Points ()Point {return Point (_gc *_cg )};
// 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 ;};
// 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 ;};

View File

@ -10,95 +10,8 @@
// terms that can be accessed at https://unidoc.io/eula/
// Package unihtml contains a plugin for the UniDoc.
package unihtml ;import (_gg "bytes";_g "context";_bg "errors";_af "fmt";_cc "github.com/unidoc/unihtml/client";_bad "github.com/unidoc/unihtml/content";_ac "github.com/unidoc/unihtml/selector";_ag "github.com/unidoc/unihtml/sizes";_d "github.com/unidoc/unipdf/v3/common";
_ee "github.com/unidoc/unipdf/v3/common/license";_gc "github.com/unidoc/unipdf/v3/creator";_ga "github.com/unidoc/unipdf/v3/model";_ad "github.com/unidoc/unipdf/v3/render";_ba "image";_e "image/color";_a "math";_f "net/url";_b "os";_ce "time";);
// WriteToFile writes the document to a file defined by the output path.
func (_ccd *Document )WriteToFile (outputPath string )error {if _ccdb :=_ccd .validate ();_ccdb !=nil {return _ccdb ;};_fge :=_ce .Second *20+_ccd ._ae ;_fb ,_abf :=_g .WithTimeout (_g .Background (),_fge );defer _abf ();_gce ,_badc :=_ccd .extract (_fb ,_ccd ._dda ,_ccd ._dcb ,_ccd .getMargins ());
if _badc !=nil {return _badc ;};_fa :=_gc .New ();for _ ,_acd :=range _gce {if _badc =_fa .AddPage (_acd );_badc !=nil {return _badc ;};};return _fa .WriteToFile (outputPath );};
// SetMarginBottom sets the left margin.
func (_fe *Document )SetMarginBottom (margin _ag .Length ){_fe ._gaa .Bottom =margin };
// 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 (_fgf *Document )WaitVisible (sel string ,by ..._ac .ByType ){_cdg :=_ac .BySearch ;if len (by )> 0{_cdg =by [0];};_fgf ._bag =append (_fgf ._bag ,_cc .BySelector {Selector :sel ,By :_cdg });};
// TrimLastPageContent trims the last page content so that next creator blocks are located just at the end of given block.
func (_eef *Document )TrimLastPageContent (){_eef ._cd =true };type margins struct{Left ,Right ,Bottom ,Top _ag .Length ;};
// SetPageSize sets the page default size.
func (_add *Document )SetPageSize (pageSize _ag .PageSize )error {if !pageSize .IsAPageSize (){return _bg .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");
};_add ._ace =pageSize ;_add ._ebf =_gc .PositionAbsolute ;return nil ;};
// SetMarginLeft sets the left margin.
func (_ff *Document )SetMarginLeft (margin _ag .Length ){_ff ._gaa .Left =margin };
// ContainerComponent implements creator.containerElement interface.
func (_dag *Document )ContainerComponent (container _gc .Drawable )(_gc .Drawable ,error ){switch container .(type ){case *_gc .Chapter :default:return nil ,_af .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 _dag ,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 (_ccb *Document )WaitReady (sel string ,by ..._ac .ByType ){_fd :=_ac .BySearch ;if len (by )> 0{_fd =by [0];};_ccb ._gf =append (_ccb ._gf ,_cc .BySelector {Selector :sel ,By :_fd });};
// SetMarginRight sets the left margin.
func (_cccb *Document )SetMarginRight (margin _ag .Length ){_cccb ._gaa .Right =margin };
// SetTimeoutDuration sets the timeout duration
// the default timeout is 15 seconds.
func (_edg *Document )SetTimeoutDuration (duration _ce .Duration ){_edg ._bf =&duration };var ErrContentNotDefined =_bg .New ("\u0068\u0074\u006d\u006c\u0020\u0064o\u0063\u0075\u006d\u0065\u006e\u0074\u0020\u0063\u006f\u006e\u0074\u0065\u006et\u0020\u006e\u006f\u0074\u0020\u0064\u0065f\u0069\u006e\u0065\u0064");
func _de (_badd _ba .Image )float64 {_ceg :=_badd .Bounds ();var (_db int ;_adc _e .Color ;_beef ,_ca ,_gab uint32 ;);_aa ,_ebb :=_ceg .Min .X ,_ceg .Max .Y -1;_fad :=_badd .At (_aa ,_ebb );_bd ,_cga ,_abfg ,_ :=_fad .RGBA ();_ddc :=_bd ==_a .MaxUint16 &&_cga ==_a .MaxUint16 &&_abfg ==_a .MaxUint16 ;
for _ebb =_ceg .Max .Y -1;_ebb >=_ceg .Min .Y ;_ebb --{var _cgae bool ;for _aa =_ceg .Min .X ;_aa < _ceg .Max .X ;_aa ++{_adc =_badd .At (_aa ,_ebb );_beef ,_ca ,_gab ,_ =_adc .RGBA ();if (_ddc &&!(_beef ==_bd &&_ca ==_cga &&_abfg ==_gab ))||(!_ddc &&(_a .Abs (float64 (_beef )-float64 (_bd ))/float64 (_a .MaxUint16 )> 0.03||_a .Abs (float64 (_ca )-float64 (_cga ))/float64 (_a .MaxUint16 )> 0.03||_a .Abs (float64 (_gab )-float64 (_abfg ))/float64 (_a .MaxUint16 )> 0.03)){_cgae =true ;
break ;};};if _cgae {break ;};_db =_ebb ;};return float64 (_ceg .Max .Y -_db )/float64 (_ceg .Max .Y );};func _fg ()error {_cg :=_ee .GetLicenseKey ();if _cg ==nil {return _bg .New ("\u006e\u006f\u0020\u006cic\u0065\u006e\u0073\u0065\u0020\u0070\u0072\u006f\u0076\u0069\u0064\u0065\u0064");
};if !_cg .IsLicensed (){return _bg .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 ;};func (_cfb *Document )validate ()error {if _bgd ==nil {return ErrNoClient ;
};if _cfb ._dde ==nil {return ErrContentNotDefined ;};return nil ;};func (_dcc *Document )getTimeoutDuration ()_ce .Duration {if _dcc ._bf !=nil {return *_dcc ._bf ;};return 0;};
// Connect creates UniHTML HTTP Client and tries to establish connection with the server.
func Connect (path string )error {if _cb :=_fg ();_cb !=nil {return _cb ;};_eb ,_dc :=_cc .ParseOptions (path );if _dc !=nil {return _dc ;};_bgd =_cc .New (_eb );_ge ,_fc :=_g .WithTimeout (_g .Background (),_ce .Second *5);defer _fc ();if _dg :=_bgd .HealthCheck (_ge );
_dg !=nil {return _dg ;};return nil ;};
// SetLandscapeOrientation sets document landscape page orientation.
func (_dgc *Document )SetLandscapeOrientation (){_dgc ._bed =_ag .Landscape };var ErrNoClient =_bg .New ("\u0055n\u0069\u0048\u0054\u004d\u004c\u0020\u0063\u006c\u0069\u0065\u006et\u0020\u006e\u006f\u0074\u0020\u0066\u006f\u0075\u006e\u0064");
// SetPageHeight sets the page height for given document.
func (_dcg *Document )SetPageHeight (pageHeight _ag .Length )error {_dcg ._dcb =pageHeight ;_dcg ._ebf =_gc .PositionAbsolute ;return nil ;};var _ _gc .Drawable =(*Document )(nil );
// SetMargins sets the Document Margins.
func (_ed *Document )SetMargins (left ,right ,top ,bottom float64 ){_ed ._gaa .Left =_ag .Point (left );_ed ._gaa .Right =_ag .Point (right );_ed ._gaa .Top =_ag .Point (top );_ed ._gaa .Bottom =_ag .Point (bottom );_ed ._ebf =_gc .PositionAbsolute ;};
func (_cgg *Document )extract (_dge _g .Context ,_cde ,_dgea _ag .Length ,_cec margins )([]*_ga .PdfPage ,error ){_ebc :=_cc .BuildHTMLQuery ().SetContent (_cgg ._dde ).PageSize (_cgg ._ace ).PaperWidth (_cde ).PaperHeight (_dgea ).Orientation (_cgg ._bed ).MarginLeft (_cec .Left ).MarginRight (_cec .Right ).MarginTop (_cec .Top ).MarginBottom (_cec .Bottom ).TimeoutDuration (_cgg .getTimeoutDuration ()).WaitTime (_cgg ._ae );
for _ ,_gee :=range _cgg ._gf {_ebc .WaitReady (_gee .Selector ,_gee .By );};for _ ,_bbb :=range _cgg ._bag {_ebc .WaitVisible (_bbb .Selector ,_bbb .By );};_fgec ,_efc :=_ebc .Query ();if _efc !=nil {return nil ,_efc ;};var _df _g .CancelFunc ;if _cgg ._bf !=nil {_dge ,_df =_g .WithTimeout (_dge ,*_cgg ._bf );
}else {_dge ,_df =_g .WithTimeout (_dge ,_ce .Second *15);};defer _df ();_cdgg ,_efc :=_bgd .ConvertHTML (_dge ,_fgec );if _efc !=nil {return nil ,_efc ;};_gbd :=_gg .NewReader (_cdgg .Data );_abc ,_efc :=_ga .NewPdfReader (_gbd );if _efc !=nil {return nil ,_efc ;
};return _abc .PageList ,nil ;};
// Document is HTML document wrapper that is used for extracting and converting HTML document into PDF pages.
type Document struct{_dde _bad .Content ;_gaa margins ;_ebf _gc .Positioning ;_be ,_bee float64 ;_ace _ag .PageSize ;_dda ,_dcb _ag .Length ;_bed _ag .Orientation ;_cd bool ;_ae _ce .Duration ;_gf []_cc .BySelector ;_bag []_cc .BySelector ;_bf *_ce .Duration ;
};
// ConnectOptions creates UniHTML HTTP Client and tries to establish connection with the server.
func ConnectOptions (o Options )error {_bgd =_cc .New (_cc .Options {Hostname :o .Hostname ,Port :o .Port ,HTTPS :o .Secure });_da ,_ef :=_g .WithTimeout (_g .Background (),_ce .Second *5);defer _ef ();if _dd :=_bgd .HealthCheck (_da );_dd !=nil {return _dd ;
};return nil ;};
// NewDocumentFromString creates a new Document from the provided HTML string.
func NewDocumentFromString (html string )(*Document ,error ){_acf ,_ea :=_bad .NewStringContent (html );if _ea !=nil {return nil ,_ea ;};_bb :=&Document {};_bb ._dde =_acf ;return _bb ,nil ;};
// SetPos sets the absolute position. Changes object positioning to absolute.
func (_gced *Document )SetPos (x ,y float64 ){_gced ._ebf =_gc .PositionAbsolute ;_gced ._be =x ;_gced ._bee =y ;};
// WaitTime sets the waiting time before the webpage is rendered to PDF.
func (_fadd *Document )WaitTime (duration _ce .Duration ){_fadd ._ae =duration };
// GeneratePageBlocks implements creator.Drawable interface.
func (_afb *Document )GeneratePageBlocks (ctx _gc .DrawContext )([]*_gc .Block ,_gc .DrawContext ,error ){if _badg :=_afb .validate ();_badg !=nil {return nil ,ctx ,_badg ;};var _gb []*_gc .Block ;_ec :=_afb .getMargins ();_fgc ,_ade :=_afb ._dda ,_afb ._dcb ;
if _afb ._ebf .IsRelative (){_fgc ,_ade =_ag .Point (ctx .Width ),_ag .Point (ctx .Height );ctx .X -=float64 (_ec .Left .Points ());}else {ctx .X =_afb ._be ;ctx .Y =_afb ._bee ;};_cdf ,_ebfe :=_afb .extract (_g .Background (),_fgc ,_ade ,_ec );if _ebfe !=nil {return nil ,_gc .DrawContext {},_ebfe ;
};for _bff ,_cbc :=range _cdf {_ggg ,_ab :=_gc .NewBlockFromPage (_cbc );if _ab !=nil {return nil ,_gc .DrawContext {},_ab ;};var _agg float64 ;if _afb ._cd &&_bff ==len (_cdf )-1{_beg :=_ad .NewImageDevice ();_fca ,_acec :=_beg .Render (_cbc );if _acec !=nil {return nil ,_gc .DrawContext {},_acec ;
};_cdd ,_acec :=_cbc .GetMediaBox ();if _acec !=nil {return nil ,_gc .DrawContext {},_acec ;};_gd :=_ce .Now ();_ccc :=_de (_fca );_agg =_cdd .Height ()*_ccc ;_d .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",_ce .Since (_gd ));
if _afb ._gaa .Bottom !=nil {_agg -=float64 (_afb ._gaa .Bottom .Points ());};if _agg < 0{_agg =0;};_d .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",_agg );
};_cfc ,_gggc ,_ab :=_ggg .GeneratePageBlocks (ctx );if _ab !=nil {return nil ,_gc .DrawContext {},_ab ;};ctx =_gggc ;ctx .Y -=_agg ;if _bff !=len (_cdf )-1&&ctx .Y > (ctx .PageHeight -ctx .Margins .Bottom )*.95{ctx .X =ctx .Margins .Left ;ctx .Y =ctx .Margins .Top ;
ctx .Page ++;};_gb =append (_gb ,_cfc ...);};return _gb ,ctx ,nil ;};
// GetContent returns the content of the document.
func (_afg *Document )GetContent ()_bad .Content {return _afg ._dde };var _bgd *_cc .Client ;
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";);
// Options are the HTML Client options used for establishing the connection.
type Options struct{
@ -113,19 +26,110 @@ Port int ;
Secure bool ;
// Prefix is an option setting used when the server is working with the URI prefix. Default Value: ''.
Prefix string ;};func (_deg *Document )getMargins ()margins {_gea :=_deg ._gaa ;if _deg ._ebf .IsRelative (){_gea .Top =_ag .Millimeter (1);_gea .Left =_ag .Millimeter (1);_gea .Bottom =_ag .Millimeter (1);_gea .Right =_ag .Millimeter (1);return _gea ;
};if _gea .Top ==nil {_gea .Top =_ag .Millimeter (10);};if _gea .Bottom ==nil {_gea .Bottom =_ag .Millimeter (10);};if _gea .Left ==nil {_gea .Left =_ag .Millimeter (10);};if _gea .Right ==nil {_gea .Right =_ag .Millimeter (10);};return _gea ;};
Prefix string ;};
// NewDocument creates new HTML Document used as an input for the creator.Drawable.
func NewDocument (path string )(*Document ,error ){_efe :=&Document {};_bfg ,_acb :=_f .Parse (path );if _acb !=nil {return nil ,_acb ;};switch _bfg .Scheme {case "\u0068\u0074\u0074\u0070","\u0068\u0074\u0074p\u0073":_efe ._dde ,_acb =_bad .NewWebURL (path );
if _acb !=nil {return nil ,_acb ;};return _efe ,nil ;};_ebd ,_acb :=_b .Stat (path );if _acb !=nil {return nil ,_acb ;};if !_ebd .IsDir (){_efe ._dde ,_acb =_bad .NewHTMLFile (path );}else {_efe ._dde ,_acb =_bad .NewZipDirectory (path );};if _acb !=nil {return nil ,_acb ;
};return _efe ,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 ;};
// SetPageWidth sets the page width for given document.
func (_ege *Document )SetPageWidth (pageWidth _ag .Length )error {_ege ._dda =pageWidth ;_ege ._ebf =_gc .PositionAbsolute ;return nil ;};
// SetMarkedContentID sets the marked content id for the document.
func (_dcc *Document )SetMarkedContentID (id int64 )*_ed .KDict {return nil };
// SetMarginTop sets the left margin.
func (_cef *Document )SetMarginTop (margin _ag .Length ){_cef ._gaa .Top =margin };
// 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 ;};
// SetLandscapeOrientation sets document landscape page orientation.
func (_bffb *Document )SetLandscapeOrientation (){_bffb ._ced =_g .Landscape };
// 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 ;};
// 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 ;};
// 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 };
// GetPdfPages is a function that converts provided input content and
func (_ddd *Document )GetPdfPages (ctx _g .Context )([]*_ga .PdfPage ,error ){if _cf :=_ddd .validate ();_cf !=nil {return nil ,_cf ;};return _ddd .extract (ctx ,_ddd ._dda ,_ddd ._dcb ,_ddd .getMargins ());};
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 ());};
// 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 );
// SetMarginLeft sets the left margin.
func (_fgf *Document )SetMarginLeft (margin _g .Length ){_fgf ._fdb .Left =margin };
// SetMarginRight sets the left margin.
func (_ddbf *Document )SetMarginRight (margin _g .Length ){_ddbf ._fdb .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");
// 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 ;};
// 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 });};
// 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 ;};
// 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 });};
// 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;};
// GetContent returns the content of the document.
func (_eaf *Document )GetContent ()_fb .Content {return _eaf ._bf };
// 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 ;};
// 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 ;};
// SetMarginTop sets the left margin.
func (_gbe *Document )SetMarginTop (margin _g .Length ){_gbe ._fdb .Top =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 ;};
// 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");