mirror of
https://github.com/unidoc/unipdf.git
synced 2025-05-04 22:17:22 +08:00
22 lines
3.6 KiB
Go
22 lines
3.6 KiB
Go
//
|
|
// Copyright 2020 FoxyUtils ehf. All rights reserved.
|
|
//
|
|
// This is a commercial product and requires a license to operate.
|
|
// A trial license can be obtained at https://unidoc.io
|
|
//
|
|
// DO NOT EDIT: generated by unitwist Go source code obfuscator.
|
|
//
|
|
// Use of this source code is governed by the UniDoc End User License Agreement
|
|
// terms that can be accessed at https://unidoc.io/eula/
|
|
|
|
package decoder ;import (_da "github.com/unidoc/unipdf/v3/internal/bitwise";_b "github.com/unidoc/unipdf/v3/internal/jbig2/bitmap";_bb "github.com/unidoc/unipdf/v3/internal/jbig2/document";_a "github.com/unidoc/unipdf/v3/internal/jbig2/errors";_d "image";
|
|
);func (_bc *Decoder )DecodeNextPage ()([]byte ,error ){_bc ._de ++;_ga :=_bc ._de ;return _bc .decodePage (_ga );};type Decoder struct{_c _da .StreamReader ;_g *_bb .Document ;_de int ;_af Parameters ;};type Parameters struct{UnpaddedData bool ;Color _b .Color ;
|
|
};func (_e *Decoder )DecodePage (pageNumber int )([]byte ,error ){return _e .decodePage (pageNumber )};func (_fd *Decoder )PageNumber ()(int ,error ){const _fa ="\u0044e\u0063o\u0064\u0065\u0072\u002e\u0050a\u0067\u0065N\u0075\u006d\u0062\u0065\u0072";
|
|
if _fd ._g ==nil {return 0,_a .Error (_fa ,"d\u0065\u0063\u006f\u0064\u0065\u0072 \u006e\u006f\u0074\u0020\u0069\u006e\u0069\u0074\u0069a\u006c\u0069\u007ae\u0064 \u0079\u0065\u0074");};return int (_fd ._g .NumberOfPages ),nil ;};func (_ae *Decoder )DecodePageImage (pageNumber int )(_d .Image ,error ){const _bba ="\u0064\u0065\u0063od\u0065\u0072\u002e\u0044\u0065\u0063\u006f\u0064\u0065\u0050\u0061\u0067\u0065\u0049\u006d\u0061\u0067\u0065";
|
|
_gg ,_ab :=_ae .decodePageImage (pageNumber );if _ab !=nil {return nil ,_a .Wrap (_ab ,_bba ,"");};return _gg ,nil ;};func Decode (input []byte ,parameters Parameters ,globals *_bb .Globals )(*Decoder ,error ){_ca :=_da .NewReader (input );_ff ,_fc :=_bb .DecodeDocument (_ca ,globals );
|
|
if _fc !=nil {return nil ,_fc ;};return &Decoder {_c :_ca ,_g :_ff ,_af :parameters },nil ;};func (_be *Decoder )decodePage (_aeb int )([]byte ,error ){const _bcc ="\u0064\u0065\u0063\u006f\u0064\u0065\u0050\u0061\u0067\u0065";if _aeb < 0{return nil ,_a .Errorf (_bcc ,"\u0069n\u0076\u0061\u006c\u0069d\u0020\u0070\u0061\u0067\u0065 \u006eu\u006db\u0065\u0072\u003a\u0020\u0027\u0025\u0064'",_aeb );
|
|
};if _aeb > int (_be ._g .NumberOfPages ){return nil ,_a .Errorf (_bcc ,"p\u0061\u0067\u0065\u003a\u0020\u0027%\u0064\u0027\u0020\u006e\u006f\u0074 \u0066\u006f\u0075\u006e\u0064\u0020\u0069n\u0020\u0074\u0068\u0065\u0020\u0064\u0065\u0063\u006f\u0064e\u0072",_aeb );
|
|
};_beb ,_dd :=_be ._g .GetPage (_aeb );if _dd !=nil {return nil ,_a .Wrap (_dd ,_bcc ,"");};_ac ,_dd :=_beb .GetBitmap ();if _dd !=nil {return nil ,_a .Wrap (_dd ,_bcc ,"");};_ac .InverseData ();if !_be ._af .UnpaddedData {return _ac .Data ,nil ;};return _ac .GetUnpaddedData ();
|
|
};func (_eb *Decoder )decodePageImage (_fe int )(_d .Image ,error ){const _df ="\u0064e\u0063o\u0064\u0065\u0050\u0061\u0067\u0065\u0049\u006d\u0061\u0067\u0065";if _fe < 0{return nil ,_a .Errorf (_df ,"\u0069n\u0076\u0061\u006c\u0069d\u0020\u0070\u0061\u0067\u0065 \u006eu\u006db\u0065\u0072\u003a\u0020\u0027\u0025\u0064'",_fe );
|
|
};if _fe > int (_eb ._g .NumberOfPages ){return nil ,_a .Errorf (_df ,"p\u0061\u0067\u0065\u003a\u0020\u0027%\u0064\u0027\u0020\u006e\u006f\u0074 \u0066\u006f\u0075\u006e\u0064\u0020\u0069n\u0020\u0074\u0068\u0065\u0020\u0064\u0065\u0063\u006f\u0064e\u0072",_fe );
|
|
};_afc ,_acb :=_eb ._g .GetPage (_fe );if _acb !=nil {return nil ,_a .Wrap (_acb ,_df ,"");};_ef ,_acb :=_afc .GetBitmap ();if _acb !=nil {return nil ,_a .Wrap (_acb ,_df ,"");};_ef .InverseData ();return _ef .ToImage (),nil ;}; |