1 Star 0 Fork 1

gzlwz/golang-pdfcpu

forked from Deeao/golang-pdfcpu 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
destination.go 3.01 KB
一键复制 编辑 原始数据 按行查看 历史
liuweizhi 提交于 2024-12-10 16:33 +08:00 . fix: 全局替换module名称
/*
Copyright 2023 The pdfcpu Authors.
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 model
import "gitee.com/gzlwz/golang-pdfcpu/pkg/pdfcpu/types"
// DestinationType represents the various PDF destination types.
type DestinationType int
// See table 151
const (
DestXYZ DestinationType = iota // [page /XYZ left top zoom]
DestFit // [page /Fit]
DestFitH // [page /FitH top]
DestFitV // [page /FitV left]
DestFitR // [page /FitR left bottom right top]
DestFitB // [page /FitB]
DestFitBH // [page /FitBH top]
DestFitBV // [page /FitBV left]
)
// DestinationTypeStrings manages string representations for destination types.
var DestinationTypeStrings = map[DestinationType]string{
DestXYZ: "XYZ", // Position (left, top) at upper-left corner of window.
DestFit: "Fit", // Fit entire page within window.
DestFitH: "FitH", // Position with (top) at top edge of window.
DestFitV: "FitV", // Position with (left) positioned at left edge of window.
DestFitR: "FitR", // Fit (left, bottom, right, top) entirely within window.
DestFitB: "FitB", // Magnify content just enough to fit its bounding box entirely within window.
DestFitBH: "FitBH", // Position with (top) at top edge of window and contents fit bounding box width within window.
DestFitBV: "FitBV", // Position with (left) at left edge of window and contents fit bounding box height within window.
}
// Destination represents a PDF destination.
type Destination struct {
Typ DestinationType
PageNr int
Left, Bottom, Right, Top int
Zoom float32
}
func (dest Destination) String() string {
return DestinationTypeStrings[dest.Typ]
}
func (dest Destination) Name() types.Name {
return types.Name(DestinationTypeStrings[dest.Typ])
}
func (dest Destination) Array(indRef types.IndirectRef) types.Array {
arr := types.Array{indRef, dest.Name()}
switch dest.Typ {
case DestXYZ:
arr = append(arr, types.Integer(dest.Left), types.Integer(dest.Top), types.Float(dest.Zoom))
case DestFitH:
arr = append(arr, types.Integer(dest.Top))
case DestFitV:
arr = append(arr, types.Integer(dest.Left))
case DestFitR:
arr = append(arr, types.Integer(dest.Left), types.Integer(dest.Bottom), types.Integer(dest.Right), types.Integer(dest.Top))
case DestFitBH:
arr = append(arr, types.Integer(dest.Top))
case DestFitBV:
arr = append(arr, types.Integer(dest.Left))
}
return arr
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/gzlwz/golang-pdfcpu.git
git@gitee.com:gzlwz/golang-pdfcpu.git
gzlwz
golang-pdfcpu
golang-pdfcpu
v0.0.2

搜索帮助