Files
ofdgo/ofdgo_pdf_halftone.go
T
2026-09-30 21:15:14 +08:00

46 lines
1.5 KiB
Go

// Copyright 2025-2026 肖其顿 (XIAO QI DUN)
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package ofdgo
import "github.com/xiaoqidun/pdfgo"
// halftone 检查连续色调转换及不可忽略的传递函数,避免将打印网屏误用于屏幕显示
// 入参: style 图形状态
// 返回: error 严格模式或非恒等传递函数无法表达
func (p *pdfImporter) halftone(style pdfgo.Style) error {
h := style.Halftone
if h == nil {
return nil
}
identity, err := h.IdentityTransfer(p.reader)
if err != nil {
return err
}
if !identity {
return &pdfgo.UnsupportedError{Feature: "halftone transfer function conversion"}
}
if p.warning == nil {
return &pdfgo.UnsupportedError{Feature: "device halftone conversion"}
}
if p.halftoneWarnings == nil {
p.halftoneWarnings = make(map[*pdfgo.Halftone]bool)
}
if !p.halftoneWarnings[h] {
p.halftoneWarnings[h] = true
p.warning(pdfgo.Diagnostic{Message: "PDF continuous-tone appearance retained; device halftone not transferred to OFD"})
}
return nil
}