Page
Overview
Page is a type in Aspose.PDF FOSS for Go.
Page is a live view of a single page within a Document.
This type provides 58 methods for working with Page objects in Go programs.
Available methods include: AddFloatingBox, AddForm, AddImage, AddImageFromStream, AddInlineImage, AddInlineImageFromStream, AddMarkdown, AddSVG, AddSVGFromStream, AddSVGObject, AddStamp, AddTOC, and 46 additional methods.
All public members are accessible to any Go application after installing the Aspose.PDF FOSS for Go package.
Methods
| Signature | Description |
|---|---|
RenderBMP(w: io.Writer, opts: RenderOptions) → error | RenderBMP renders the page and writes it as an uncompressed BMP. |
AddFloatingBox(box: *FloatingBox, rect: Rectangle) → error | AddFloatingBox draws box at an absolute position inside rect: it paints the background and border, then lays out the box content within rect minus padding (content that overflows the box is clipped). |
Forms() → []*XForm | Forms returns the Form XObjects referenced by the page’s resources — the reusable content groups already present (e.g. |
AddForm(form: *XForm, rect: Rectangle) → error | AddForm places the form on the page so its box maps onto rect, preserving the form’s own scale per axis. |
ExtractImages() → ([]Image, error) | ExtractImages returns all images found on the page. |
ImageInfos() → ([]ImageInfo, error) | ImageInfos returns metadata for all images found on the page without decoding pixel data. |
AddImage(path: string, rect: Rectangle) → error | AddImage adds an image from a file to the page within the given rectangle. |
AddImageFromStream(r: io.Reader, rect: Rectangle) → error | AddImageFromStream adds an image from a reader to the page within the given rectangle. |
AddInlineImage(path: string, rect: Rectangle) → error | AddInlineImage draws a small image directly into the page content stream as an inline image (BI … ID … EI, ISO 32000-1 §8.9.7) rather than an Image XObject. |
AddInlineImageFromStream(r: io.Reader, rect: Rectangle) → error | AddInlineImageFromStream is the io.Reader variant of AddInlineImage. |
AddMarkdown(md: string, rect: Rectangle, opts: ...MarkdownOptions) → error | AddMarkdown renders a Markdown fragment inside the rectangle. |
BeginLayer(layer: *Layer) → error | BeginLayer starts a marked-content section on the page assigned to layer: content drawn after this call (AddText, Draw*, AddImage, …) belongs to the layer until EndLayer. |
EndLayer() → error | EndLayer closes the marked-content section opened by BeginLayer. |
Number() → int | Number returns the 1-based page number within the document. |
Annotations() → *AnnotationCollection | Annotations returns the page’s annotation collection. |
Size() → (PageSize, error) | Size returns the page dimensions from its MediaBox. |
Rotation() → RotationAngle | Rotation returns the effective rotation of the page in degrees (0, 90, 180, 270). |
MediaBox() → (Rectangle, error) | MediaBox returns the page’s MediaBox as a Rectangle in PDF user space. |
CropBox() → (Rectangle, error) | CropBox returns the crop box of the page as a Rectangle. |
TrimBox() → (Rectangle, error) | TrimBox returns the trim box of the page as a Rectangle. |
BleedBox() → (Rectangle, error) | BleedBox returns the bleed box of the page as a Rectangle. |
ArtBox() → (Rectangle, error) | ArtBox returns the art box of the page as a Rectangle. |
SetMediaBox(rect: Rectangle) → error | SetMediaBox sets the page’s MediaBox (the full page rectangle) in PDF user space. |
SetCropBox(rect: Rectangle) → error | SetCropBox sets the page’s CropBox (the visible region). |
SetTrimBox(rect: Rectangle) → error | SetTrimBox sets the page’s TrimBox (intended finished dimensions). |
SetBleedBox(rect: Rectangle) → error | SetBleedBox sets the page’s BleedBox (production bleed region). |
SetArtBox(rect: Rectangle) → error | SetArtBox sets the page’s ArtBox (meaningful content extent). |
SetPageSize(width: float64) → error | SetPageSize resizes the page by setting its MediaBox to [0 0 width height] (points). |
Label() → string | Label returns the formatted page label for this page as defined by the document’s /PageLabels number tree (PDF spec §12.4.2). |
Paragraphs() → (PageMarkup, error) | Paragraphs returns the page’s text grouped into columns (sections) and paragraphs. |
RenderImage(opts: RenderOptions) → (image.Image, error) | RenderImage rasterizes the page to an *image.RGBA at the requested DPI. |
RenderPNG(w: io.Writer, opts: RenderOptions) → error | RenderPNG renders the page and writes it as PNG. |
RenderJPEG(w: io.Writer, opts: RenderOptions, quality: int) → error | RenderJPEG renders the page and writes it as JPEG. |
RenderGIF(w: io.Writer, opts: RenderOptions) → error | RenderGIF renders the page and writes it as GIF (256 colours, quantized). |
ReplaceText(old: string, opts: ...ReplaceOptions) → (int, error) | ReplaceText replaces every occurrence of old with replacement on the page and returns the number of replacements made. |
AddStamp(s: Stamp) → error | AddStamp draws a stamp onto the page. |
AddSVG(path: string, rect: Rectangle) → error | AddSVG reads an SVG file and renders it into the given rectangle on the page. |
AddSVGFromStream(r: io.Reader, rect: Rectangle) → error | AddSVGFromStream renders an SVG from any io.Reader into the given rectangle on the page. |
AddSVGObject(svg: *SVG, rect: Rectangle) → error | AddSVGObject renders a pre-parsed SVG into the given rectangle on the page. |
AddTable(t: *Table, rect: Rectangle) → (int, error) | AddTable renders the table inside the given rectangle. |
TagContent(parent: *StructElement, t: StructType, draw: func() error) → (*StructElement, error) | TagContent draws a block of page content (everything the draw callback emits) inside a marked-content sequence and adds a corresponding leaf structure element of type t as a child of parent (nil = the document root). |
TagArtifact(draw: func() error) → error | TagArtifact brackets a block of page drawing as an /Artifact marked-content sequence, so it is treated as decoration and excluded from the logical structure tree. |
AddTaggedList(tc: *TaggedContent, parent: *StructElement, items: []string, style: TextStyle, rect: Rectangle, ordered: bool) → (*StructElement, error) | AddTaggedList draws a bulleted (ordered=false) or numbered (ordered=true) list of items inside rect and builds its accessible structure: an /L element under parent (nil = the document root), with an /LI per item containing an /Lbl (the bullet/number) and an /LBody (the item text). |
AddTaggedTable(tc: *TaggedContent, parent: *StructElement, t: *Table, rect: Rectangle) → (*StructElement, int, error) | AddTaggedTable renders t inside rect like AddTable, and at the same time builds the table’s logical structure (/Table → /TR → /TH/TD) under parent (nil = the document root), tagging each cell’s content as marked content and bracketing cell backgrounds and borders as /Artifact. |
ExtractText(opts: ...TextExtractOptions) → (string, error) | ExtractText returns the text content of the page. |
AddText(text: string, style: TextStyle, rect: Rectangle) → error | AddText draws text inside the rectangle using the given style. |
ExtractTextWithLayout() → ([]TextLine, error) | ExtractTextWithLayout returns structured text lines sorted in visual (top-to-bottom, left-to-right) reading order. |
SearchText(query: string, opts: ...SearchOptions) → ([]TextMatch, error) | SearchText finds every occurrence of query on the page and returns the matches in visual reading order (top-to-bottom, left-to-right). |
RenderTIFF(w: io.Writer, opts: RenderOptions) → error | RenderTIFF renders the page and writes it as a single-page Deflate TIFF. |
AddTOC(entries: []TOCEntry, rect: Rectangle, opts: ...TOCOptions) → (int, error) | AddTOC renders a table of contents from a supplied list of entries into rect on this page. |
DrawLine(from: Point, style: LineStyle) → error | DrawLine strokes a single line segment from→to with the given style. |
DrawRectangle(rect: Rectangle, style: ShapeStyle) → error | DrawRectangle strokes and/or fills an axis-aligned rectangle. |
DrawCircle(center: Point, radius: float64, style: ShapeStyle) → error | DrawCircle strokes and/or fills a circle. |
DrawEllipse(center: Point, rx: float64, style: ShapeStyle) → error | DrawEllipse strokes and/or fills an axis-aligned ellipse. |
DrawPolyline(points: []Point, style: LineStyle) → error | DrawPolyline strokes an open polyline (first and last points are NOT connected). |
DrawPath(path: *Path, style: ShapeStyle) → error | DrawPath strokes and/or fills the previously-built path. |
DrawRoundedRectangle(rect: Rectangle, radius: float64, style: ShapeStyle) → error | DrawRoundedRectangle strokes and/or fills an axis-aligned rectangle with rounded corners of the given radius. |
DrawPolygon(points: []Point, style: ShapeStyle) → error | DrawPolygon strokes and/or fills a closed polygon (last point connects back to the first via h). |