mirror of
https://github.com/unidoc/unipdf.git
synced 2025-05-05 19:30:30 +08:00
12 lines
3.6 KiB
Go
12 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 (_ce "github.com/unidoc/unipdf/v3/internal/bitwise";_f "github.com/unidoc/unipdf/v3/internal/jbig2/bitmap";_a "github.com/unidoc/unipdf/v3/internal/jbig2/document";_b "github.com/unidoc/unipdf/v3/internal/jbig2/errors";_d "image";);type Parameters struct{UnpaddedData bool ;Color _f .Color ;};func (_fd *Decoder )DecodeNextPage ()([]byte ,error ){_fd ._bf ++;_gg :=_fd ._bf ;return _fd .decodePage (_gg );};type Decoder struct{_dd _ce .StreamReader ;_fa *_a .Document ;_bf int ;_cef Parameters ;};func (_fg *Decoder )decodePageImage (_eg int )(_d .Image ,error ){const _efe ="\u0064e\u0063o\u0064\u0065\u0050\u0061\u0067\u0065\u0049\u006d\u0061\u0067\u0065";if _eg < 0{return nil ,_b .Errorf (_efe ,"\u0069n\u0076\u0061\u006c\u0069d\u0020\u0070\u0061\u0067\u0065 \u006eu\u006db\u0065\u0072\u003a\u0020\u0027\u0025\u0064'",_eg );};if _eg > int (_fg ._fa .NumberOfPages ){return nil ,_b .Errorf (_efe ,"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",_eg );};_ec ,_ac :=_fg ._fa .GetPage (_eg );if _ac !=nil {return nil ,_b .Wrap (_ac ,_efe ,"");};_egc ,_ac :=_ec .GetBitmap ();if _ac !=nil {return nil ,_b .Wrap (_ac ,_efe ,"");};return _egc .ToImage (),nil ;};func Decode (input []byte ,parameters Parameters ,globals *_a .Globals )(*Decoder ,error ){_ae :=_ce .NewReader (input );_bfc ,_bfa :=_a .DecodeDocument (_ae ,globals );if _bfa !=nil {return nil ,_bfa ;};return &Decoder {_dd :_ae ,_fa :_bfc ,_cef :parameters },nil ;};func (_g *Decoder )DecodePage (pageNumber int )([]byte ,error ){return _g .decodePage (pageNumber )};func (_e *Decoder )PageNumber ()(int ,error ){const _aa ="\u0044e\u0063o\u0064\u0065\u0072\u002e\u0050a\u0067\u0065N\u0075\u006d\u0062\u0065\u0072";if _e ._fa ==nil {return 0,_b .Error (_aa ,"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 (_e ._fa .NumberOfPages ),nil ;};func (_ef *Decoder )decodePage (_df int )([]byte ,error ){const _bfe ="\u0064\u0065\u0063\u006f\u0064\u0065\u0050\u0061\u0067\u0065";if _df < 0{return nil ,_b .Errorf (_bfe ,"\u0069n\u0076\u0061\u006c\u0069d\u0020\u0070\u0061\u0067\u0065 \u006eu\u006db\u0065\u0072\u003a\u0020\u0027\u0025\u0064'",_df );};if _df > int (_ef ._fa .NumberOfPages ){return nil ,_b .Errorf (_bfe ,"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",_df );};_aab ,_faa :=_ef ._fa .GetPage (_df );if _faa !=nil {return nil ,_b .Wrap (_faa ,_bfe ,"");};_aae ,_faa :=_aab .GetBitmap ();if _faa !=nil {return nil ,_b .Wrap (_faa ,_bfe ,"");};_aae .InverseData ();if !_ef ._cef .UnpaddedData {return _aae .Data ,nil ;};return _aae .GetUnpaddedData ();};func (_cf *Decoder )DecodePageImage (pageNumber int )(_d .Image ,error ){const _be ="\u0064\u0065\u0063od\u0065\u0072\u002e\u0044\u0065\u0063\u006f\u0064\u0065\u0050\u0061\u0067\u0065\u0049\u006d\u0061\u0067\u0065";_ad ,_fe :=_cf .decodePageImage (pageNumber );if _fe !=nil {return nil ,_b .Wrap (_fe ,_be ,"");};return _ad ,nil ;}; |