mirror of
https://github.com/unidoc/unioffice.git
synced 2025-04-27 13:48:54 +08:00
19 lines
1.1 KiB
Go
19 lines
1.1 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 utils ;import (_d "bytes";_g "github.com/unidoc/unioffice/document";_cd "github.com/unidoc/unioffice/document/convert";_c "github.com/unidoc/unipdf/v3/model";);
|
|
|
|
// GetNumPages will try to get actual document page count by converting the document to a PDF first
|
|
// and then get the actual page count from the PDF result.
|
|
//
|
|
// WARNING: This method is currently in experimental state as the PDF result might have incorrect page count.
|
|
func GetNumPages (d *_g .Document )(int ,error ){var _cf _d .Buffer ;_ee :=_cd .ConvertToPdf (d );if _f :=_ee .Write (&_cf );_f !=nil {return 0,_f ;};_ge ,_ea :=_c .NewPdfReader (_d .NewReader (_cf .Bytes ()));if _ea !=nil {return 0,_ea ;};_da ,_ea :=_ge .GetNumPages ();
|
|
if _ea !=nil {return 0,_ea ;};return _da ,nil ;}; |