Page
Page
概述
Page 是 Aspose.PDF FOSS for Go 中的一种类型。
Page 是文档中单个页面的实时视图。
此类型为 Go 程序中处理 Page 对象提供了 58 个方法。可用的方法包括:AddFloatingBox、AddForm、AddImage、AddImageFromStream、AddInlineImage、AddInlineImageFromStream、AddMarkdown、AddSVG、AddSVGFromStream、AddSVGObject、AddStamp、AddTOC,以及另外 46 个方法。安装 Aspose.PDF FOSS for Go 包后,所有公共成员对任何 Go 应用程序均可访问。
方法
| 签名 | 描述 |
|---|---|
RenderBMP(w: io.Writer, opts: RenderOptions) → error | RenderBMP 渲染页面并将其写入未压缩的 BMP。 |
AddFloatingBox(box: *FloatingBox, rect: Rectangle) → error | AddFloatingBox 在 rect 内的绝对位置绘制盒子:它绘制背景和边框,然后在 rect 减去 padding 的区域内布局盒子内容(溢出盒子的内容将被裁剪)。 |
Forms() → []*XForm | Forms 返回页面资源中引用的 Form XObject——已经存在的可重用内容组(例如. |
AddForm(form: *XForm, rect: Rectangle) → error | AddForm 将表单放置在页面上,使其盒子映射到 rect,并保持表单在每个轴上的自身缩放。 |
ExtractImages() → ([]Image, error) | ExtractImages 返回页面上找到的所有图像。 |
ImageInfos() → ([]ImageInfo, error) | ImageInfos 返回页面上找到的所有图像的元数据,但不解码像素数据。 |
AddImage(path: string, rect: Rectangle) → error | AddImage 在给定的矩形区域内,将文件中的图像添加到页面。 |
AddImageFromStream(r: io.Reader, rect: Rectangle) → error | AddImageFromStream 在给定的矩形区域内,从读取器中将图像添加到页面。 |
AddInlineImage(path: string, rect: Rectangle) → error | AddInlineImage 将一个小图像直接绘制到页面内容流中,作为内联图像(BI … ID … EI,ISO 32000-1 §8.9.7),而不是作为 Image XObject。 |
AddInlineImageFromStream(r: io.Reader, rect: Rectangle) → error | AddInlineImageFromStream 是 AddInlineImage 的 io.Reader 变体。 |
AddMarkdown(md: string, rect: Rectangle, opts: ...MarkdownOptions) → error | AddMarkdown 在矩形内部渲染 Markdown 片段。 |
BeginLayer(layer: *Layer) → error | BeginLayer 在页面上启动一个标记内容区段并分配给图层:此调用之后绘制的内容(AddText、Draw*、AddImage,…)属于该图层,直至 EndLayer。 |
EndLayer() → error | EndLayer 关闭由 BeginLayer 打开的标记内容段。 |
Number() → int | Number 返回文档中的页码(从 1 开始)。 |
Annotations() → *AnnotationCollection | Annotations 返回页面的注释集合。 |
Size() → (PageSize, error) | Size 返回页面尺寸,来源于其 MediaBox。 |
Rotation() → RotationAngle | Rotation 返回页面的有效旋转角度(单位为度),取值为 0、90、180、270。 |
MediaBox() → (Rectangle, error) | MediaBox 返回页面的 MediaBox,以 PDF 用户空间中的 Rectangle 形式。 |
CropBox() → (Rectangle, error) | CropBox 返回页面的 crop box,形式为 Rectangle。 |
TrimBox() → (Rectangle, error) | TrimBox 返回页面的 trim box,形式为 Rectangle。 |
BleedBox() → (Rectangle, error) | BleedBox 返回页面的出血框(bleed box),类型为 Rectangle。 |
ArtBox() → (Rectangle, error) | ArtBox 返回页面的艺术框(art box),类型为 Rectangle。 |
SetMediaBox(rect: Rectangle) → error | SetMediaBox 在 PDF 用户空间中设置页面的 MediaBox(完整页面矩形)。 |
SetCropBox(rect: Rectangle) → error | SetCropBox 设置页面的 CropBox(可见区域)。 |
SetTrimBox(rect: Rectangle) → error | SetTrimBox 设置页面的 TrimBox(预期完成尺寸)。 |
SetBleedBox(rect: Rectangle) → error | SetBleedBox 设置页面的 BleedBox(生产出血区域)。 |
SetArtBox(rect: Rectangle) → error | SetArtBox 设置页面的 ArtBox(有效内容范围)。 |
SetPageSize(width: float64) → error | SetPageSize 通过将其 MediaBox 设置为 [0 0 width height](点)来调整页面大小。 |
Label() → string | Label 返回此页的格式化页标签,依据文档的 /PageLabels 编号树(PDF 规范 §12.4.2)。 |
Paragraphs() → (PageMarkup, error) | Paragraphs 返回页面的文本,按列(章节)和段落分组。 |
RenderImage(opts: RenderOptions) → (image.Image, error) | RenderImage 将页面光栅化为请求的 DPI 下的 *image.RGBA。 |
RenderPNG(w: io.Writer, opts: RenderOptions) → error | RenderPNG 渲染页面并将其写入 PNG。 |
RenderJPEG(w: io.Writer, opts: RenderOptions, quality: int) → error | RenderJPEG 渲染页面并将其写入 JPEG。 |
RenderGIF(w: io.Writer, opts: RenderOptions) → error | RenderGIF 渲染页面并将其写入 GIF(256 色,已量化)。 |
ReplaceText(old: string, opts: ...ReplaceOptions) → (int, error) | ReplaceText 在页面上将所有出现的 old 替换为 replacement,并返回所做的替换次数。 |
AddStamp(s: Stamp) → error | AddStamp 在页面上绘制印章。 |
AddSVG(path: string, rect: Rectangle) → error | AddSVG 读取 SVG 文件并将其渲染到页面上的给定矩形区域。 |
AddSVGFromStream(r: io.Reader, rect: Rectangle) → error | AddSVGFromStream 将来自任意 io.Reader 的 SVG 渲染到页面上的指定矩形区域。 |
AddSVGObject(svg: *SVG, rect: Rectangle) → error | AddSVGObject 将预解析的 SVG 渲染到页面上的指定矩形区域。 |
AddTable(t: *Table, rect: Rectangle) → (int, error) | AddTable 在给定的矩形内渲染表格。 |
TagContent(parent: *StructElement, t: StructType, draw: func() error) → (*StructElement, error) | TagContent 在标记内容序列中绘制一块页面内容(即 draw 回调产生的所有内容),并将一个对应的类型为 t 的叶结构元素作为 parent 的子元素添加进去(nil = 文档根)。 |
TagArtifact(draw: func() error) → error | TagArtifact 将页面绘图块括在 /Artifact 标记内容序列中,因此它被视为装饰并从逻辑结构树中排除。 |
AddTaggedList(tc: *TaggedContent, parent: *StructElement, items: []string, style: TextStyle, rect: Rectangle, ordered: bool) → (*StructElement, error) | AddTaggedList 在 rect 内绘制一个项目符号(ordered=false)或编号(ordered=true)列表,并构建其可访问结构:在父节点下(nil = 文档根)创建一个 /L 元素,每个项目对应一个包含 /Lbl(项目符号/编号)和 /LBody(项目文本)的 /LI。 |
AddTaggedTable(tc: *TaggedContent, parent: *StructElement, t: *Table, rect: Rectangle) → (*StructElement, int, error) | AddTaggedTable 在 rect 中像 AddTable 那样渲染 t,同时在父节点下(nil = 文档根)构建表格的逻辑结构(/Table → /TR → /TH/TD),将每个单元格的内容标记为标记内容,并将单元格背景和边框括为 /Artifact。 |
ExtractText(opts: ...TextExtractOptions) → (string, error) | ExtractText 返回页面的文本内容。 |
AddText(text: string, style: TextStyle, rect: Rectangle) → error | AddText 使用给定的样式在矩形内部绘制文本。 |
ExtractTextWithLayout() → ([]TextLine, error) | ExtractTextWithLayout 返回结构化文本行,按视觉(从上到下、从左到右)阅读顺序排序。 |
SearchText(query: string, opts: ...SearchOptions) → ([]TextMatch, error) | SearchText 在页面上查找查询的每一次出现,并按视觉阅读顺序(从上到下、从左到右)返回匹配项。 |
RenderTIFF(w: io.Writer, opts: RenderOptions) → error | RenderTIFF 渲染页面并将其保存为单页 Deflate TIFF。 |
AddTOC(entries: []TOCEntry, rect: Rectangle, opts: ...TOCOptions) → (int, error) | AddTOC 根据提供的条目列表在本页的 rect 区域渲染目录。 |
DrawLine(from: Point, style: LineStyle) → error | DrawLine 用给定的样式绘制一条从→到的单线段。 |
DrawRectangle(rect: Rectangle, style: ShapeStyle) → error | DrawRectangle 描边并/或填充一个轴对齐矩形。 |
DrawCircle(center: Point, radius: float64, style: ShapeStyle) → error | DrawCircle 描边并/或填充一个圆。 |
DrawEllipse(center: Point, rx: float64, style: ShapeStyle) → error | DrawEllipse 描边并/或填充一个轴对齐椭圆。 |
DrawPolyline(points: []Point, style: LineStyle) → error | DrawPolyline 绘制一条开放折线(首尾点不相连)。 |
DrawPath(path: *Path, style: ShapeStyle) → error | DrawPath 绘制并/或填充先前构建的路径。 |
DrawRoundedRectangle(rect: Rectangle, radius: float64, style: ShapeStyle) → error | DrawRoundedRectangle 绘制并/或填充一个轴对齐的矩形,圆角半径为给定值。 |
DrawPolygon(points: []Point, style: ShapeStyle) → error | DrawPolygon 绘制并/或填充一个闭合多边形(最后一点通过 h 与第一点相连)。 |