unioffice/utils/utils.go
Alip Sulistio 36d084b3c4
prepare release (#510)
Co-authored-by: UniDoc Build <build@unidoc.io>
2024-04-02 17:10:23 +00:00

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 (_b "bytes";_d "github.com/unidoc/unioffice/document";_f "github.com/unidoc/unioffice/document/convert";_g "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 *_d .Document )(int ,error ){var _dd _b .Buffer ;_e :=_f .ConvertToPdf (d );if _af :=_e .Write (&_dd );_af !=nil {return 0,_af ;};_ge ,_bf :=_g .NewPdfReader (_b .NewReader (_dd .Bytes ()));if _bf !=nil {return 0,_bf ;};_dc ,_bf :=_ge .GetNumPages ();
if _bf !=nil {return 0,_bf ;};return _dc ,nil ;};