Page
概述
Page 是 Aspose.PDF FOSS 中用于 .NET 的类。继承自:IDisposable。
表示 PDF 文档中的一页。
此类为在 .NET 程序中处理 Page 对象提供了 58 种方法。可用的方法包括:Accept、AddContent、AddContentStream、AddExtGState、AddFloatingBox、AddGraph、AddGraphics、AddImage、AddStamp、AddTable、AsByteArray、AsXml,以及另外 28 种方法。安装 Aspose.PDF FOSS for .NET 包后,所有公共成员对任何 .NET 应用程序均可访问。属性有:Actions、Annotations、ArtBox、Artifacts、Background、BackgroundImage,以及另外 35 项。
属性
| 名称 | 类型 | 访问 | 描述 |
|---|---|---|---|
Number | int | 读取 | 以1为起始的页码。 |
FieldsInTabOrder | IList<Forms.Field> | 读取 | 在此页面上显示其小部件的表单字段,按制表顺序排序。 |
Rect | Rectangle | 读写 | 页面矩形(默认值为 MediaBox)。 |
Rectangle | Rectangle | 读写 | 页面矩形。 |
PageInfo | PageInfo | 读写 | 页面信息容器,具有宽度/高度/边距属性。 |
Background | Color? | 读写 | 页面背景颜色。 |
MediaBox | Rectangle | 读写 | 此页的媒体框(规范要求)。 |
CropBox | Rectangle | 读写 | 裁剪框(默认与媒体框相同)。 |
BleedBox | Rectangle | 读写 | 出血框(默认是裁剪框)。 |
TrimBox | Rectangle | 读写 | 修剪框(默认是裁剪框)。 |
ArtBox | Rectangle | 读写 | 艺术框(默认为裁剪框)。 |
Rotate | Rotation | 读写 | 页面旋转,使用 Rotation 枚举。 |
RotateDegrees | int | 读写 | 页面旋转(以度为单位),类型为 int,取值为 0、90、180、270。 |
RotationMatrix | Matrix | 读取 | 仿射变换,将未旋转的 PDF 坐标系映射到页面用户可见的(已旋转)坐标系。 |
Duration | double | 读写 | 演示模式下页面显示的持续时间(秒)。 |
Annotations | AnnotationCollection | 读取 | 此页面上的注释。 |
Images | XImageCollection | 读取 | 此页面上的 Image XObjects。 |
Fonts | FontCollection | 读取 | 此页面引用的字体。 |
Resources | Resources | 读取 | 页面资源(字体、图像)——通过统一的 Resources 对象提供访问。 |
Patterns | IReadOnlyDictionary<string, Pattern> | 读取 | 此页面上的模式资源(按模式名称键入)。 |
Contents | OperatorCollection | 读取 | 内容流操作符集合。 |
ContentsAppender | ContentsAppender | 读取 | 在 UpdateData 上应用的帮助程序,用于缓冲操作符以在此页面的内容流前置或追加。 |
Width | double | 读取 | 考虑旋转后的可见页面宽度。 |
Height | double | 读取 | 考虑旋转后的可见页面高度。 |
ColorType | ColorType | 读取 | 通过分析其内容流操作符和图像颜色空间来获取此页面的颜色类型。 |
Transition | PageTransition? | 读取 | 页面转换效果,如果未设置则为 null。 |
Header | HeaderFooter? | 读写 | 在此页面顶部渲染的页眉。 |
Footer | HeaderFooter? | 读写 | 在此页面底部渲染的页脚。 |
TocInfo | TocInfo? | 读写 | 此页面的目录信息。 |
Paragraphs | Paragraphs | 读写 | 要添加到此页面的段落对象集合(TextFragment、HtmlFragment、表格、标题等)。 |
NoteLineStyle | GraphInfo | 读写 | 用于绘制脚注/尾注分隔线的默认描边/填充样式。 |
Artifacts | ArtifactCollection | 读取 | 用于向此页面添加工件(如水印等)的集合。 |
OcgLayers | LayerCollection | 读取 | 获取此页面引用的图层(可选内容组)。 |
Actions | PageActionCollection | 读取 | 每页的附加操作(打开 / 关闭 / 等),由 /AA 支持。 |
UserUnit | double | 读写 | 用户单位因子(PDF 32000 §14.8.4 /UserUnit 条目)。 |
IsAddParagraphsAfterLast | bool | 读写 | 段落的添加是否在末尾追加(相对于流位置)。 |
BackgroundImage | Image? | 读写 | 页面背景图像。 |
Group | Group? | 读写 | 此页面的组 / 混合颜色空间字典。 |
TabOrder | TabOrder | 读写 | 标签顺序(PDF 32000 第12.5节 /Tabs 条目)。 |
Watermark | Watermark? | 读写 | 页面水印。 |
Layers | System.Collections.Generic.List<Layer> | 读写 | 页面的图层(Optional Content Groups)。 |
方法
| 签名 | 描述 |
|---|---|
SetRotation(degrees: int) | 以度为单位设置页面旋转(0、90、180、270)。 |
SetMediaBox(rect: Rectangle) | 为此页面设置媒体框。 |
SetCropBox(rect: Rectangle) | 为此页面设置裁剪框。 |
SetBleedBox(rect: Rectangle) | 为此页面设置出血框。 |
SetTrimBox(rect: Rectangle) | 为此页面设置裁剪框。 |
SetArtBox(rect: Rectangle) | 为此页面设置艺术框。 |
Accept(visitor: Annotations.AnnotationSelector) | 遍历此页面上的每个注释,通过 visitor;匹配项累积到 Selected 中。 |
GetResources() | 资源的方法式访问器 — public-API 等价。 |
SetPageSize(width: double, height: double) | 通过更新 MediaBox 来设置页面大小。 |
GetPageRect(considerRotation: bool) | 获取页面矩形,可选地考虑 CropBox。 |
Accept(visitor: Text.TextAbsorber) | 接受一个TextAbsorber访客(匹配公共API)。 |
GetText() | 使用TextAbsorber提取页面的所有文本。 |
Accept(visitor: Text.TextFragmentAbsorber) | 接受一个TextFragmentAbsorber访客(匹配公共API)。 |
GetTextRotationStatistic() | 统计此页面上每个旋转角度绘制的文本片段数量。 |
Accept(visitor: ImagePlacementAbsorber) | 接受一个 ImagePlacementAbsorber 访客(匹配公共的 API)。 |
SendTo(device: Devices.ImageDevice, outputFileName: string) | 在此页面添加一个印章。 |
SendTo(device: Devices.ImageDevice, output: Stream) | 使用指定的设备渲染此页面并写入流。 |
AddStamp(stamp: ImageStamp) | 将图像印章应用到此页面。 |
AddStamp(stamp: PdfPageStamp) | 将页面印章应用到此页面。 |
AddStamp(stamp: Aspose.Pdf.Stamps.Stamp) | 在此 Page 实例上调用 AddStamp(stamp)。 |
AddContentStream(contentBytes: byte[]) | 向此页面追加内容流。 |
PrependContentStream(contentBytes: byte[]) | 在现有页面内容之前预先添加内容流字节(用于背景元素)。 |
AddContent(contentStreamBytes: byte[]) | 将内容流字节追加到此页面。 |
AddTable(table: Table) | 在此页面添加表格。 |
AddGraph(graph: Drawing.Graph) | 在此页面添加图形(形状集合)。 |
AddFloatingBox(box: FloatingBox) | 在此页面添加一个浮动框。 |
AddExtGState(extGState: Content.ExtGState) | 将一个 ExtGState 字典添加到此页面的资源中,并返回资源名称。 |
AddImage(imageData: byte[], rect: Rectangle, blackWhite: bool) | 在指定的位置和尺寸向此页面添加图片。 |
AddImage(imageStream: Stream, rect: Rectangle) | 在指定的位置和尺寸,从流中向此页面添加图片。 |
AddImage(imagePath: string, rectangle: Rectangle) | 从文件路径添加图像;矩形限定图像,图像保持其自身的宽高比并居中显示。 |
AddImage(imageStream: Stream, imageRect: Rectangle, bbox: Rectangle, autoAdjustRectangle: bool) | 在 imageRect 处添加图像,并使用显式的边界框。 |
AddImage(imageStream: Stream, imageRect: Rectangle, imageWidth: int, imageHeight: int, saveImageProportions: bool) | 添加具有显式像素尺寸和比例标志的图像(bbox 默认为图像矩形)。 |
AddImage(imageStream: Stream, imageRect: Rectangle, imageWidth: int, imageHeight: int, saveImageProportions: bool, bbox: Rectangle) | 添加具有显式像素尺寸和 bbox 的图像。 |
AddImage(hocr: string, imageStream: Stream, imageRect: Rectangle) | 插入图像并叠加 HOCR(OCR)字符串作为不可见的文本层(文本渲染模式 3),因此页面显示图像,但其识别的文本可搜索/可复制粘贴。 |
AddImage(hocr: string, imageStream: Stream, imageRect: Rectangle, bbox: Rectangle) | 插入图像并叠加 HOCR(OCR)字符串作为不可见的文本层;bbox 被接受用于 API 的等价性。 |
Resize(targetSize: Aspose.Pdf.PageSize) | 通过更新 media-box 将此页面大小调整为 targetSize。 |
AsByteArray(resolution: Aspose.Pdf.Devices.Resolution) | 按请求的分辨率将此页面渲染为 PNG 字节数组。 |
Flatten() | 将此页面上的所有注释扁平化——将它们的视觉外观渲染到页面内容流中,并从注释数组中移除它们。 |
ConvertToPNGMemoryStream() | 确定页面是否为空(没有任何有意义的内容)。 |
IsBlank(fillThresholdFactor: double) | 在此 Page 实例上调用 IsBlank(fillThresholdFactor)。 |
MergeLayers(newLayerName: string) | 将此页面上的所有图层合并为具有给定名称的单个图层。 |
MergeLayers(newLayerName: string, newOptionalContentGroupId: string) | 将此页面上的所有图层合并,并为新 OCG 分配给定的 id. |
HasVectorGraphics() | 此页面是否绘制任何矢量图形,即。 |
TrySaveVectorGraphics(pathToSave: string) | 将此页面的矢量图形保存到 pathToSave。 |
AsXml() | 此页面的诊断 XML 表示。 |
GetNotifications() | 在保存之前设置 EnableNotificationLogging 时,流布局为此页面发出的换行通知。 |
MakeGrayscale() | 将此页面的颜色转换为灰度:content-stream colour operators、image XObjects、named colour-space resources 和 annotation appearances。 |
IntToRotation(rotation: int) | 将 degrees-int 旋转转换为 Rotation。 |
RotationToInt(rotation: Rotation) | 将 Rotation 转换为 degrees 整数。 |
FreeMemory() | 清除缓存数据。 |
Dispose() | 释放内存。 |
CalculateContentBBox() | 计算页面空间中包围此页所有绘制内容(文本、矢量路径、图像、内联图像,递归遍历 Form XObjects)的最小轴对齐矩形。 |
SendTo(device: PageDevice, output: Stream) | 通过 PageDevice 将此页面渲染到流中。 |
SendTo(device: PageDevice, outputFileName: string) | 通过 PageDevice 将此页面渲染到文件中。 |
AddStamp(stamp: Stamp) | 通过其 Put(Page) 覆盖来应用印章。 |
AddGraphics(elements: GraphicElementCollection) | 将给定的矢量元素(通常由 GraphicsAbsorber 生成)追加到此页的内容流中,并在页面空间中再现每个元素的几何形状。 |
AddGraphics(elements: GraphicElementCollection, rectangle: Rectangle) | 追加矢量元素;矩形为建议性(元素会完整输出,携带其自身的几何信息)。 |
DeleteGraphics(elementsToDelete: GraphicElementCollection) | 同上 — 矢量元素的删除未实现。 |