代码拉取完成,页面将自动刷新
//
// 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 redactor
import (
_bb "errors"
_b "fmt"
_a "gitee.com/zhaobingss/unipdf/v3/common"
_ag "gitee.com/zhaobingss/unipdf/v3/contentstream"
_abf "gitee.com/zhaobingss/unipdf/v3/core"
_dd "gitee.com/zhaobingss/unipdf/v3/creator"
_g "gitee.com/zhaobingss/unipdf/v3/extractor"
_ab "gitee.com/zhaobingss/unipdf/v3/model"
_fa "io"
_f "regexp"
_d "sort"
_e "strings"
)
// Redact executes the redact operation on a pdf file and updates the content streams of all pages of the file.
func (_bfga *Redactor) Redact() error {
_bbc, _bbca := _bfga._afb.GetNumPages()
if _bbca != nil {
return _b.Errorf("\u0066\u0061\u0069\u006c\u0065\u0064 \u0074\u006f\u0020\u0067\u0065\u0074\u0020\u0074\u0068\u0065\u0020\u006e\u0075m\u0062\u0065\u0072\u0020\u006f\u0066\u0020P\u0061\u0067\u0065\u0073")
}
_badd := _bfga._gfe.FillColor
_egb := _bfga._gfe.BorderWidth
_aca := _bfga._gfe.FillOpacity
for _dfb := 1; _dfb <= _bbc; _dfb++ {
_agea, _cffa := _bfga._afb.GetPage(_dfb)
if _cffa != nil {
return _cffa
}
_bgfd, _cffa := _g.New(_agea)
if _cffa != nil {
return _cffa
}
_bbde, _, _, _cffa := _bgfd.ExtractPageText()
if _cffa != nil {
return _cffa
}
_cdg := _bbde.GetContentStreamOps()
_gbd, _agb, _cffa := _bfga.redactPage(_cdg, _agea.Resources)
if _agb == nil {
_a.Log.Info("N\u006f\u0020\u006d\u0061\u0074\u0063\u0068\u0020\u0066\u006f\u0075\u006e\u0064\u0020\u0066\u006f\u0072\u0020t\u0068\u0065\u0020\u0070\u0072\u006f\u0076\u0069\u0064\u0065d \u0070\u0061\u0074t\u0061r\u006e\u002e")
_agb = _cdg
}
_agea.SetContentStreams([]string{_agb.String()}, _abf.NewFlateEncoder())
if _cffa != nil {
return _cffa
}
_gdcg, _cffa := _agea.GetMediaBox()
if _cffa != nil {
return _cffa
}
if _agea.MediaBox == nil {
_agea.MediaBox = _gdcg
}
if _add := _bfga._dgfb.AddPage(_agea); _add != nil {
return _add
}
_dbd := _gdcg.Ury
for _, _aab := range _gbd {
_dbdf := _aab._ead
_gea := _bfga._dgfb.NewRectangle(_dbdf.Llx, _dbd-_dbdf.Lly, _dbdf.Urx-_dbdf.Llx, -(_dbdf.Ury - _dbdf.Lly))
_gea.SetFillColor(_badd)
_gea.SetBorderWidth(_egb)
_gea.SetFillOpacity(_aca)
if _bec := _bfga._dgfb.Draw(_gea); _bec != nil {
return nil
}
}
}
_bfga._dgfb.SetOutlineTree(_bfga._afb.GetOutlineTree())
return nil
}
func _ebf(_aa *_ag.ContentStreamOperation, _ceca _abf.PdfObject, _ec []localSpanMarks) error {
_ffa, _cb := _abf.GetArray(_aa.Params[0])
_acc := []_abf.PdfObject{}
if !_cb {
_a.Log.Debug("\u0045\u0052\u0052OR\u003a\u0020\u0054\u004a\u0020\u006f\u0070\u003d\u0025s\u0020G\u0065t\u0041r\u0072\u0061\u0079\u0056\u0061\u006c\u0020\u0066\u0061\u0069\u006c\u0065\u0064", _aa)
return _b.Errorf("\u0073\u0070\u0061\u006e\u004d\u0061\u0072\u006bs\u002e\u0042\u0042ox\u0020\u0068\u0061\u0073\u0020\u006eo\u0020\u0062\u006f\u0075\u006e\u0064\u0069\u006e\u0067\u0020\u0062\u006f\u0078\u002e\u0020s\u0070\u0061\u006e\u004d\u0061\u0072\u006b\u0073=\u0025\u0073", _aa)
}
_gf, _gg := _aaa(_ec)
if len(_gg) == 1 {
_ggc := _gg[0]
_bbe := _gf[_ggc]
if len(_bbe) == 1 {
_cg := _bbe[0]
_ddf := _cg._ebd
_fdd := _gcf(_ddf)
_ebb, _cag := _aed(_ceca, _fdd)
if _cag != nil {
return _cag
}
_ebe, _cag := _dab(_cg, _ddf, _fdd, _ebb, _ggc)
if _cag != nil {
return _cag
}
for _, _gdf := range _ffa.Elements() {
if _gdf == _ceca {
_acc = append(_acc, _ebe...)
} else {
_acc = append(_acc, _gdf)
}
}
} else {
_cdc := _bbe[0]._ebd
_dfe := _gcf(_cdc)
_cc, _ga := _aed(_ceca, _dfe)
if _ga != nil {
return _ga
}
_cge, _ga := _eec(_cc, _bbe)
if _ga != nil {
return _ga
}
_bbb := _bea(_cge)
_ba := _bab(_cc, _bbb, _dfe)
for _, _eba := range _ffa.Elements() {
if _eba == _ceca {
_acc = append(_acc, _ba...)
} else {
_acc = append(_acc, _eba)
}
}
}
_aa.Params[0] = _abf.MakeArray(_acc...)
} else if len(_gg) > 1 {
_bba := _ec[0]
_dda := _bba._ebd
_, _feb := _da(_dda)
_dfeb := _dda.Elements()[_feb]
_fde := _dfeb.Font
_gdfb, _aaea := _aed(_ceca, _fde)
if _aaea != nil {
return _aaea
}
_bf, _aaea := _eec(_gdfb, _ec)
if _aaea != nil {
return _aaea
}
_ebfe := _bea(_bf)
_aaf := _bab(_gdfb, _ebfe, _fde)
for _, _ggf := range _ffa.Elements() {
if _ggf == _ceca {
_acc = append(_acc, _aaf...)
} else {
_acc = append(_acc, _ggf)
}
}
_aa.Params[0] = _abf.MakeArray(_acc...)
}
return nil
}
func _bad(_bdc *_ab.PdfFont, _baf _g.TextMark) float64 {
_bdg := 0.001
_cged := _baf.Th / 100
if _bdc.Subtype() == "\u0054\u0079\u0070e\u0033" {
_bdg = 1
}
_bcc, _gdc := _bdc.GetRuneMetrics(' ')
if !_gdc {
_bcc, _gdc = _bdc.GetCharMetrics(32)
}
if !_gdc {
_bcc, _ = _ab.DefaultFont().GetRuneMetrics(' ')
}
_eea := _bdg * ((_bcc.Wx*_baf.FontSize + _baf.Tc + _baf.Tw) / _cged)
return _eea
}
func (_cbab *regexMatcher) match(_dec string) ([]*matchedIndex, error) {
_fgef := _cbab._aede.Pattern
if _fgef == nil {
return nil, _bb.New("\u006e\u006f\u0020\u0070at\u0074\u0065\u0072\u006e\u0020\u0063\u006f\u006d\u0070\u0069\u006c\u0065\u0064")
}
var (
_facb = _fgef.FindAllStringIndex(_dec, -1)
_ecb []*matchedIndex
)
for _, _gga := range _facb {
_ecb = append(_ecb, &matchedIndex{_eaf: _gga[0], _adec: _gga[1], _dad: _dec[_gga[0]:_gga[1]]})
}
return _ecb, nil
}
func _cecg(_abd []int, _bfgd *_g.TextMarkArray, _bbcd string) (*_g.TextMarkArray, matchedBBox, error) {
_bfa := matchedBBox{}
_aeda := _abd[0]
_ccc := _abd[1]
_fbe := len(_bbcd) - len(_e.TrimLeft(_bbcd, "\u0020"))
_bagg := len(_bbcd) - len(_e.TrimRight(_bbcd, "\u0020\u000a"))
_aeda = _aeda + _fbe
_ccc = _ccc - _bagg
_bbcd = _e.Trim(_bbcd, "\u0020\u000a")
_ddc, _fadb := _bfgd.RangeOffset(_aeda, _ccc)
if _fadb != nil {
return nil, _bfa, _fadb
}
_dbfc, _aga := _ddc.BBox()
if !_aga {
return nil, _bfa, _b.Errorf("\u0073\u0070\u0061\u006e\u004d\u0061\u0072\u006bs\u002e\u0042\u0042ox\u0020\u0068\u0061\u0073\u0020\u006eo\u0020\u0062\u006f\u0075\u006e\u0064\u0069\u006e\u0067\u0020\u0062\u006f\u0078\u002e\u0020s\u0070\u0061\u006e\u004d\u0061\u0072\u006b\u0073=\u0025\u0073", _ddc)
}
_bfa = matchedBBox{_fad: _bbcd, _ead: _dbfc}
return _ddc, _bfa, nil
}
func _ffg(_bcfe *_g.TextMarkArray) (float64, error) {
_efa, _bddg := _bcfe.BBox()
if !_bddg {
return 0.0, _b.Errorf("\u0073\u0070\u0061\u006e\u004d\u0061\u0072\u006bs\u002e\u0042\u0042ox\u0020\u0068\u0061\u0073\u0020\u006eo\u0020\u0062\u006f\u0075\u006e\u0064\u0069\u006e\u0067\u0020\u0062\u006f\u0078\u002e\u0020s\u0070\u0061\u006e\u004d\u0061\u0072\u006b\u0073=\u0025\u0073", _bcfe)
}
_bdf := _cec(_bcfe)
_gae := 0.0
_, _eca := _da(_bcfe)
_bbbg := _bcfe.Elements()[_eca]
_gcc := _bbbg.Font
if _bdf > 0 {
_gae = _bad(_gcc, _bbbg)
}
_bbad := (_efa.Urx - _efa.Llx)
_bbad = _bbad + _gae*float64(_bdf)
Tj := _gbgf(_bbad, _bbbg.FontSize, _bbbg.Th)
return Tj, nil
}
func _da(_fg *_g.TextMarkArray) (_abf.PdfObject, int) {
var _be _abf.PdfObject
_bc := -1
for _af, _daf := range _fg.Elements() {
_be = _daf.DirectObject
_bc = _af
if _be != nil {
break
}
}
return _be, _bc
}
func _aed(_dga _abf.PdfObject, _bbd *_ab.PdfFont) (string, error) {
_bca, _dce := _abf.GetStringBytes(_dga)
if !_dce {
return "", _abf.ErrTypeError
}
_cbf := _bbd.BytesToCharcodes(_bca)
_eaca, _efad, _ceb := _bbd.CharcodesToStrings(_cbf)
if _ceb > 0 {
_a.Log.Debug("\u0072\u0065nd\u0065\u0072\u0054e\u0078\u0074\u003a\u0020num\u0043ha\u0072\u0073\u003d\u0025\u0064\u0020\u006eum\u004d\u0069\u0073\u0073\u0065\u0073\u003d%\u0064", _efad, _ceb)
}
_dag := _e.Join(_eaca, "")
return _dag, nil
}
type localSpanMarks struct {
_ebd *_g.TextMarkArray
_ffgf int
_dddd string
}
func _abg(_faae *_g.TextMarkArray) []*_g.TextMarkArray {
_ebdf := _faae.Elements()
_caad := len(_ebdf)
var _beae _abf.PdfObject
_gaac := []*_g.TextMarkArray{}
_ggd := &_g.TextMarkArray{}
_fed := -1
for _dbgf, _dbgb := range _ebdf {
_gce := _dbgb.DirectObject
_fed = _dbgb.Index
if _gce == nil {
_cbbag := _bddge(_faae, _dbgf, _fed)
if _beae != nil {
if _cbbag == -1 || _cbbag > _dbgf {
_gaac = append(_gaac, _ggd)
_ggd = &_g.TextMarkArray{}
}
}
} else if _gce != nil && _beae == nil {
if _fed == 0 && _dbgf > 0 {
_gaac = append(_gaac, _ggd)
_ggd = &_g.TextMarkArray{}
}
} else if _gce != nil && _beae != nil {
if _gce != _beae {
_gaac = append(_gaac, _ggd)
_ggd = &_g.TextMarkArray{}
}
}
_beae = _gce
_ggd.Append(_dbgb)
if _dbgf == (_caad - 1) {
_gaac = append(_gaac, _ggd)
}
}
return _gaac
}
func _dab(_cfe localSpanMarks, _eeac *_g.TextMarkArray, _ed *_ab.PdfFont, _bfe, _fbd string) ([]_abf.PdfObject, error) {
_ade := _fdf(_eeac)
Tj, _bag := _ffg(_eeac)
if _bag != nil {
return nil, _bag
}
_eac := len(_bfe)
_faf := len(_ade)
_fbde := -1
_cfeb := _abf.MakeFloat(Tj)
if _ade != _fbd {
_gaa := _cfe._ffgf
if _gaa == 0 {
_fbde = _e.LastIndex(_bfe, _ade)
} else {
_fbde = _e.Index(_bfe, _ade)
}
} else {
_fbde = _e.Index(_bfe, _ade)
}
_gfc := _fbde + _faf
_ccg := []_abf.PdfObject{}
if _fbde == 0 && _gfc == _eac {
_ccg = append(_ccg, _cfeb)
} else if _fbde == 0 && _gfc < _eac {
_cbba := _dbgd(_bfe[_gfc:], _ed)
_abbb := _abf.MakeStringFromBytes(_cbba)
_ccg = append(_ccg, _cfeb, _abbb)
} else if _fbde > 0 && _gfc >= _eac {
_dbb := _dbgd(_bfe[:_fbde], _ed)
_fbg := _abf.MakeStringFromBytes(_dbb)
_ccg = append(_ccg, _fbg, _cfeb)
} else if _fbde > 0 && _gfc < _eac {
_cgc := _dbgd(_bfe[:_fbde], _ed)
_gaad := _dbgd(_bfe[_gfc:], _ed)
_caa := _abf.MakeStringFromBytes(_cgc)
_adf := _abf.MakeString(string(_gaad))
_ccg = append(_ccg, _caa, _cfeb, _adf)
}
return _ccg, nil
}
// New instantiates a Redactor object with given PdfReader and `regex` pattern.
func New(reader *_ab.PdfReader, opts *RedactionOptions, rectProps *RectangleProps) *Redactor {
if rectProps == nil {
rectProps = RedactRectanglePropsNew()
}
return &Redactor{_afb: reader, _aee: opts, _dgfb: _dd.New(), _gfe: rectProps}
}
func _bab(_acgg string, _agd []replacement, _eag *_ab.PdfFont) []_abf.PdfObject {
_ecc := []_abf.PdfObject{}
_fcdc := 0
_gedd := _acgg
for _dg, _aded := range _agd {
_gb := _aded._fag
_adg := _aded._bd
_ggcc := _aded._agg
_bcf := _abf.MakeFloat(_adg)
_cgcg := _acgg[_fcdc:_gb]
_acgb := _dbgd(_cgcg, _eag)
_eae := _abf.MakeStringFromBytes(_acgb)
_ecc = append(_ecc, _eae)
_ecc = append(_ecc, _bcf)
_ebae := _gb + len(_ggcc)
_gedd = _acgg[_ebae:]
_fcdc = _ebae
if _dg == len(_agd)-1 {
_acgb = _dbgd(_gedd, _eag)
_eae = _abf.MakeStringFromBytes(_acgb)
_ecc = append(_ecc, _eae)
}
}
return _ecc
}
// RedactionTerm holds the regexp pattern and the replacement string for the redaction process.
type RedactionTerm struct{ Pattern *_f.Regexp }
// Redactor represtents a Redactor object.
type Redactor struct {
_afb *_ab.PdfReader
_aee *RedactionOptions
_dgfb *_dd.Creator
_gfe *RectangleProps
}
func _dbgd(_ge string, _cf *_ab.PdfFont) []byte {
_fdda, _afg := _cf.StringToCharcodeBytes(_ge)
if _afg != 0 {
_a.Log.Debug("\u0057\u0041\u0052\u004e\u003a\u0020\u0073\u006fm\u0065\u0020\u0072un\u0065\u0073\u0020\u0063\u006f\u0075l\u0064\u0020\u006e\u006f\u0074\u0020\u0062\u0065\u0020\u0065\u006e\u0063\u006f\u0064\u0065d\u002e\u000a\u0009\u0025\u0073\u0020\u002d\u003e \u0025\u0076", _ge, _fdda)
}
return _fdda
}
func _eec(_cbac string, _ged []localSpanMarks) ([]placeHolders, error) {
_eee := ""
_dbf := []placeHolders{}
for _ffcb, _gec := range _ged {
_edg := _gec._ebd
_gca := _gec._dddd
_cbae := _fdf(_edg)
_daa, _cfff := _ffg(_edg)
if _cfff != nil {
return nil, _cfff
}
if _cbae != _eee {
var _bae []int
if _ffcb == 0 && _gca != _cbae {
_acg := _e.Index(_cbac, _cbae)
_bae = []int{_acg}
} else if _ffcb == len(_ged)-1 {
_bgc := _e.LastIndex(_cbac, _cbae)
_bae = []int{_bgc}
} else {
_bae = _deag(_cbac, _cbae)
}
_gff := placeHolders{_ca: _bae, _fb: _cbae, _fe: _daa}
_dbf = append(_dbf, _gff)
}
_eee = _cbae
}
return _dbf, nil
}
// RectangleProps defines properties of the redaction rectangle to be drawn.
type RectangleProps struct {
FillColor _dd.Color
BorderWidth float64
FillOpacity float64
}
type matchedIndex struct {
_eaf int
_adec int
_dad string
}
func (_gcd *Redactor) redactPage(_ddag *_ag.ContentStreamOperations, _geae *_ab.PdfPageResources) ([]matchedBBox, *_ag.ContentStreamOperations, error) {
_fge, _fgd := _g.NewFromContents(_ddag.String(), _geae)
if _fgd != nil {
return nil, nil, _fgd
}
_ffe, _, _, _fgd := _fge.ExtractPageText()
_ddag = _ffe.GetContentStreamOps()
if _fgd != nil {
return nil, nil, _fgd
}
_cagc := _ffe.Marks()
_eagf := _ffe.Text()
_bcff := []matchedBBox{}
_bgd := make(map[_abf.PdfObject][]localSpanMarks)
for _, _ada := range _gcd._aee.Terms {
_cgg, _fff := _fcc(_ada)
if _fff != nil {
return nil, nil, _fff
}
_beab, _fff := _cgg.match(_eagf)
if _fff != nil {
return nil, nil, _fff
}
_ede := _adgd(_beab)
for _gfca, _eaa := range _ede {
_afe := []matchedBBox{}
for _, _efab := range _eaa {
_cbg, _dde, _ceg := _cecg(_efab, _cagc, _gfca)
if _ceg != nil {
return nil, nil, _ceg
}
_beb := _abg(_cbg)
for _ddb, _becc := range _beb {
_cceb := localSpanMarks{_ebd: _becc, _ffgf: _ddb, _dddd: _gfca}
_gfg, _ := _da(_becc)
if _dceg, _afgg := _bgd[_gfg]; _afgg {
_bgd[_gfg] = append(_dceg, _cceb)
} else {
_bgd[_gfg] = []localSpanMarks{_cceb}
}
}
_afe = append(_afe, _dde)
}
_bcff = append(_bcff, _afe...)
}
}
_fgd = _abb(_ddag, _bgd)
if _fgd != nil {
return nil, nil, _fgd
}
return _bcff, _ddag, nil
}
func _deag(_ebfc, _egdc string) []int {
if len(_egdc) == 0 {
return nil
}
var _dgf []int
for _dcd := 0; _dcd < len(_ebfc); {
_egc := _e.Index(_ebfc[_dcd:], _egdc)
if _egc < 0 {
return _dgf
}
_dgf = append(_dgf, _dcd+_egc)
_dcd += _egc + len(_egdc)
}
return _dgf
}
// Write writes the content of `re.creator` to writer of type io.Writer interface.
func (_cbd *Redactor) Write(writer _fa.Writer) error { return _cbd._dgfb.Write(writer) }
// RedactRectanglePropsNew return a new pointer to a default RectangleProps object.
func RedactRectanglePropsNew() *RectangleProps {
return &RectangleProps{FillColor: _dd.ColorBlack, BorderWidth: 0.0, FillOpacity: 1.0}
}
func _fdb(_afd *_ag.ContentStreamOperation, _dea _abf.PdfObject, _aea []localSpanMarks) error {
var _ddfa *_abf.PdfObjectArray
_bcca, _dbe := _aaa(_aea)
if len(_dbe) == 1 {
_ffc := _dbe[0]
_gda := _bcca[_ffc]
if len(_gda) == 1 {
_bdcg := _gda[0]
_bac := _bdcg._ebd
_aag := _gcf(_bac)
_ad, _cab := _aed(_dea, _aag)
if _cab != nil {
return _cab
}
_gge, _cab := _dab(_bdcg, _bac, _aag, _ad, _ffc)
if _cab != nil {
return _cab
}
_ddfa = _abf.MakeArray(_gge...)
} else {
_bfg := _gda[0]._ebd
_ccf := _gcf(_bfg)
_gdfd, _fdg := _aed(_dea, _ccf)
if _fdg != nil {
return _fdg
}
_bed, _fdg := _eec(_gdfd, _gda)
if _fdg != nil {
return _fdg
}
_age := _bea(_bed)
_dfea := _bab(_gdfd, _age, _ccf)
_ddfa = _abf.MakeArray(_dfea...)
}
} else if len(_dbe) > 1 {
_ef := _aea[0]
_dafa := _ef._ebd
_, _fcb := _da(_dafa)
_aafg := _dafa.Elements()[_fcb]
_fdge := _aafg.Font
_eeg, _ddd := _aed(_dea, _fdge)
if _ddd != nil {
return _ddd
}
_egd, _ddd := _eec(_eeg, _aea)
if _ddd != nil {
return _ddd
}
_fagf := _bea(_egd)
_dfc := _bab(_eeg, _fagf, _fdge)
_ddfa = _abf.MakeArray(_dfc...)
}
_afd.Params[0] = _ddfa
_afd.Operand = "\u0054\u004a"
return nil
}
func _bddge(_efaa *_g.TextMarkArray, _acad int, _gcdc int) int {
_cfec := _efaa.Elements()
_cda := _acad - 1
_dbfg := _acad + 1
_aggg := -1
if _cda >= 0 {
_fdgd := _cfec[_cda]
_bfab := _fdgd.ObjString
_eadc := len(_bfab)
_bgca := _fdgd.Index
if _bgca+1 < _eadc {
_aggg = _cda
return _aggg
}
}
if _dbfg < len(_cfec) {
_acgbe := _cfec[_dbfg]
_fca := _acgbe.ObjString
if _fca[0] != _acgbe.Text {
_aggg = _dbfg
return _aggg
}
}
return _aggg
}
// RedactionOptions is a collection of RedactionTerm objects.
type RedactionOptions struct{ Terms []RedactionTerm }
func _deac(_bdcf *_ag.ContentStreamOperations, PdfObj _abf.PdfObject) (*_ag.ContentStreamOperation, int, bool) {
for _gfcg, _dead := range *_bdcf {
_gbg := _dead.Operand
if _gbg == "\u0054\u006a" {
_aef := _abf.TraceToDirectObject(_dead.Params[0])
if _aef == PdfObj {
return _dead, _gfcg, true
}
} else if _gbg == "\u0054\u004a" {
_ced, _adgc := _abf.GetArray(_dead.Params[0])
if !_adgc {
return nil, _gfcg, _adgc
}
for _, _fdc := range _ced.Elements() {
if _fdc == PdfObj {
return _dead, _gfcg, true
}
}
} else if _gbg == "\u0022" {
_dbba := _abf.TraceToDirectObject(_dead.Params[2])
if _dbba == PdfObj {
return _dead, _gfcg, true
}
} else if _gbg == "\u0027" {
_caf := _abf.TraceToDirectObject(_dead.Params[0])
if _caf == PdfObj {
return _dead, _gfcg, true
}
}
}
return nil, -1, false
}
func _gbgf(_bff, _fce, _cfee float64) float64 {
_cfee = _cfee / 100
_ebfa := (-1000 * _bff) / (_fce * _cfee)
return _ebfa
}
type regexMatcher struct{ _aede RedactionTerm }
func _adgd(_bfcc []*matchedIndex) map[string][][]int {
_fcg := make(map[string][][]int)
for _, _bee := range _bfcc {
_cae := _bee._dad
_bdgg := []int{_bee._eaf, _bee._adec}
if _afa, _fafb := _fcg[_cae]; _fafb {
_fcg[_cae] = append(_afa, _bdgg)
} else {
_fcg[_cae] = [][]int{_bdgg}
}
}
return _fcg
}
type replacement struct {
_agg string
_bd float64
_fag int
}
func _fcc(_fba RedactionTerm) (*regexMatcher, error) { return ®exMatcher{_aede: _fba}, nil }
type placeHolders struct {
_ca []int
_fb string
_fe float64
}
// WriteToFile writes the redacted document to file specified by `outputPath`.
func (_ceba *Redactor) WriteToFile(outputPath string) error {
if _bacd := _ceba._dgfb.WriteToFile(outputPath); _bacd != nil {
return _b.Errorf("\u0066\u0061\u0069l\u0065\u0064\u0020\u0074o\u0020\u0077\u0072\u0069\u0074\u0065\u0020t\u0068\u0065\u0020\u006f\u0075\u0074\u0070\u0075\u0074\u0020\u0066\u0069\u006c\u0065")
}
return nil
}
func _fdf(_gcaa *_g.TextMarkArray) string {
_cagd := ""
for _, _bce := range _gcaa.Elements() {
_cagd += _bce.Text
}
return _cagd
}
func _bea(_bedd []placeHolders) []replacement {
_fdbd := []replacement{}
for _, _gaab := range _bedd {
_cce := _gaab._ca
_faa := _gaab._fb
_gdg := _gaab._fe
for _, _dfd := range _cce {
_bda := replacement{_agg: _faa, _bd: _gdg, _fag: _dfd}
_fdbd = append(_fdbd, _bda)
}
}
_d.Slice(_fdbd, func(_cbbc, _fec int) bool { return _fdbd[_cbbc]._fag < _fdbd[_fec]._fag })
return _fdbd
}
func _ea(_cdd *_ag.ContentStreamOperations, _eb string, _ce int) error {
_dcc := _ag.ContentStreamOperations{}
var _fd _ag.ContentStreamOperation
for _eg, _db := range *_cdd {
if _eg == _ce {
if _eb == "\u0027" {
_gd := _ag.ContentStreamOperation{Operand: "\u0054\u002a"}
_dcc = append(_dcc, &_gd)
_fd.Params = _db.Params
_fd.Operand = "\u0054\u006a"
_dcc = append(_dcc, &_fd)
} else if _eb == "\u0022" {
_bdd := _db.Params[:2]
Tc, Tw := _bdd[0], _bdd[1]
_ff := _ag.ContentStreamOperation{Params: []_abf.PdfObject{Tc}, Operand: "\u0054\u0063"}
_dcc = append(_dcc, &_ff)
_ff = _ag.ContentStreamOperation{Params: []_abf.PdfObject{Tw}, Operand: "\u0054\u0077"}
_dcc = append(_dcc, &_ff)
_fd.Params = []_abf.PdfObject{_db.Params[2]}
_fd.Operand = "\u0054\u006a"
_dcc = append(_dcc, &_fd)
}
}
_dcc = append(_dcc, _db)
}
*_cdd = _dcc
return nil
}
type matchedBBox struct {
_ead _ab.PdfRectangle
_fad string
}
func _aaa(_gfa []localSpanMarks) (map[string][]localSpanMarks, []string) {
_fac := make(map[string][]localSpanMarks)
_dcb := []string{}
for _, _cbc := range _gfa {
_beg := _cbc._dddd
if _fcd, _cba := _fac[_beg]; _cba {
_fac[_beg] = append(_fcd, _cbc)
} else {
_fac[_beg] = []localSpanMarks{_cbc}
_dcb = append(_dcb, _beg)
}
}
return _fac, _dcb
}
func _cec(_df *_g.TextMarkArray) int {
_abef := 0
_dbg := _df.Elements()
if _dbg[0].Text == "\u0020" {
_abef++
}
if _dbg[_df.Len()-1].Text == "\u0020" {
_abef++
}
return _abef
}
func _abb(_ee *_ag.ContentStreamOperations, _bg map[_abf.PdfObject][]localSpanMarks) error {
for _dc, _fbf := range _bg {
if _dc == nil {
continue
}
_ac, _cd, _abe := _deac(_ee, _dc)
if !_abe {
_a.Log.Debug("Pd\u0066\u004fb\u006a\u0065\u0063\u0074\u0020\u0025\u0073\u006e\u006ft\u0020\u0066\u006f\u0075\u006e\u0064\u0020\u0069\u006e\u0020\u0073\u0069\u0064\u0065\u0020\u0074\u0068\u0065\u0020\u0063\u006f\u006e\u0074\u0065\u006e\u0074\u0073\u0074r\u0065a\u006d\u0020\u006f\u0070\u0065\u0072\u0061\u0074i\u006fn\u0020\u0025s", _dc, _ee)
return nil
}
if _ac.Operand == "\u0054\u006a" {
_fc := _fdb(_ac, _dc, _fbf)
if _fc != nil {
return _fc
}
} else if _ac.Operand == "\u0054\u004a" {
_ae := _ebf(_ac, _dc, _fbf)
if _ae != nil {
return _ae
}
} else if _ac.Operand == "\u0027" || _ac.Operand == "\u0022" {
_fbb := _ea(_ee, _ac.Operand, _cd)
if _fbb != nil {
return _fbb
}
_fbb = _fdb(_ac, _dc, _fbf)
if _fbb != nil {
return _fbb
}
}
}
return nil
}
func _gcf(_ecf *_g.TextMarkArray) *_ab.PdfFont {
_, _de := _da(_ecf)
_dee := _ecf.Elements()[_de]
_bcg := _dee.Font
return _bcg
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。