mirror of
https://github.com/unidoc/unipdf.git
synced 2025-04-27 13:48:51 +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 (_e "github.com/unidoc/unipdf/v3/internal/bitwise";_ef "github.com/unidoc/unipdf/v3/internal/jbig2/bitmap";_ec "github.com/unidoc/unipdf/v3/internal/jbig2/document";_be "github.com/unidoc/unipdf/v3/internal/jbig2/errors";_a "image";);func (_ab *Decoder )DecodeNextPage ()([]byte ,error ){_ab ._g ++;_cc :=_ab ._g ;return _ab .decodePage (_cc );};func (_d *Decoder )decodePage (_gf int )([]byte ,error ){const _dd ="\u0064\u0065\u0063\u006f\u0064\u0065\u0050\u0061\u0067\u0065";if _gf < 0{return nil ,_be .Errorf (_dd ,"\u0069n\u0076\u0061\u006c\u0069d\u0020\u0070\u0061\u0067\u0065 \u006eu\u006db\u0065\u0072\u003a\u0020\u0027\u0025\u0064'",_gf );};if _gf > int (_d ._bf .NumberOfPages ){return nil ,_be .Errorf (_dd ,"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",_gf );};_ae ,_ea :=_d ._bf .GetPage (_gf );if _ea !=nil {return nil ,_be .Wrap (_ea ,_dd ,"");};_dc ,_ea :=_ae .GetBitmap ();if _ea !=nil {return nil ,_be .Wrap (_ea ,_dd ,"");};_dc .InverseData ();if !_d ._c .UnpaddedData {return _dc .Data ,nil ;};return _dc .GetUnpaddedData ();};func (_cf *Decoder )PageNumber ()(int ,error ){const _ag ="\u0044e\u0063o\u0064\u0065\u0072\u002e\u0050a\u0067\u0065N\u0075\u006d\u0062\u0065\u0072";if _cf ._bf ==nil {return 0,_be .Error (_ag ,"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 (_cf ._bf .NumberOfPages ),nil ;};func Decode (input []byte ,parameters Parameters ,globals *_ec .Globals )(*Decoder ,error ){_abb :=_e .NewReader (input );_aeg ,_eff :=_ec .DecodeDocument (_abb ,globals );if _eff !=nil {return nil ,_eff ;};return &Decoder {_ed :_abb ,_bf :_aeg ,_c :parameters },nil ;};func (_efb *Decoder )DecodePage (pageNumber int )([]byte ,error ){return _efb .decodePage (pageNumber )};func (_af *Decoder )decodePageImage (_dcf int )(_a .Image ,error ){const _agb ="\u0064e\u0063o\u0064\u0065\u0050\u0061\u0067\u0065\u0049\u006d\u0061\u0067\u0065";if _dcf < 0{return nil ,_be .Errorf (_agb ,"\u0069n\u0076\u0061\u006c\u0069d\u0020\u0070\u0061\u0067\u0065 \u006eu\u006db\u0065\u0072\u003a\u0020\u0027\u0025\u0064'",_dcf );};if _dcf > int (_af ._bf .NumberOfPages ){return nil ,_be .Errorf (_agb ,"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",_dcf );};_fac ,_bb :=_af ._bf .GetPage (_dcf );if _bb !=nil {return nil ,_be .Wrap (_bb ,_agb ,"");};_abd ,_bb :=_fac .GetBitmap ();if _bb !=nil {return nil ,_be .Wrap (_bb ,_agb ,"");};return _abd .ToImage (),nil ;};type Decoder struct{_ed _e .StreamReader ;_bf *_ec .Document ;_g int ;_c Parameters ;};func (_f *Decoder )DecodePageImage (pageNumber int )(_a .Image ,error ){const _bc ="\u0064\u0065\u0063od\u0065\u0072\u002e\u0044\u0065\u0063\u006f\u0064\u0065\u0050\u0061\u0067\u0065\u0049\u006d\u0061\u0067\u0065";_fa ,_bg :=_f .decodePageImage (pageNumber );if _bg !=nil {return nil ,_be .Wrap (_bg ,_bc ,"");};return _fa ,nil ;};type Parameters struct{UnpaddedData bool ;Color _ef .Color ;}; |