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

SignatureDescription
RenderBMP(w: io.Writer, opts: RenderOptions)errorRenderBMP renders the page and writes it as an uncompressed BMP.
AddFloatingBox(box: *FloatingBox, rect: Rectangle)errorAddFloatingBox 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()[]*XFormForms returns the Form XObjects referenced by the page’s resources — the reusable content groups already present (e.g.
AddForm(form: *XForm, rect: Rectangle)errorAddForm 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)errorAddImage adds an image from a file to the page within the given rectangle.
AddImageFromStream(r: io.Reader, rect: Rectangle)errorAddImageFromStream adds an image from a reader to the page within the given rectangle.
AddInlineImage(path: string, rect: Rectangle)errorAddInlineImage 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)errorAddInlineImageFromStream is the io.Reader variant of AddInlineImage.
AddMarkdown(md: string, rect: Rectangle, opts: ...MarkdownOptions)errorAddMarkdown renders a Markdown fragment inside the rectangle.
BeginLayer(layer: *Layer)errorBeginLayer 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()errorEndLayer closes the marked-content section opened by BeginLayer.
Number()intNumber returns the 1-based page number within the document.
Annotations()*AnnotationCollectionAnnotations returns the page’s annotation collection.
Size()(PageSize, error)Size returns the page dimensions from its MediaBox.
Rotation()RotationAngleRotation 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)errorSetMediaBox sets the page’s MediaBox (the full page rectangle) in PDF user space.
SetCropBox(rect: Rectangle)errorSetCropBox sets the page’s CropBox (the visible region).
SetTrimBox(rect: Rectangle)errorSetTrimBox sets the page’s TrimBox (intended finished dimensions).
SetBleedBox(rect: Rectangle)errorSetBleedBox sets the page’s BleedBox (production bleed region).
SetArtBox(rect: Rectangle)errorSetArtBox sets the page’s ArtBox (meaningful content extent).
SetPageSize(width: float64)errorSetPageSize resizes the page by setting its MediaBox to [0 0 width height] (points).
Label()stringLabel 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)errorRenderPNG renders the page and writes it as PNG.
RenderJPEG(w: io.Writer, opts: RenderOptions, quality: int)errorRenderJPEG renders the page and writes it as JPEG.
RenderGIF(w: io.Writer, opts: RenderOptions)errorRenderGIF 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)errorAddStamp draws a stamp onto the page.
AddSVG(path: string, rect: Rectangle)errorAddSVG reads an SVG file and renders it into the given rectangle on the page.
AddSVGFromStream(r: io.Reader, rect: Rectangle)errorAddSVGFromStream renders an SVG from any io.Reader into the given rectangle on the page.
AddSVGObject(svg: *SVG, rect: Rectangle)errorAddSVGObject 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)errorTagArtifact 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)errorAddText 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)errorRenderTIFF 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)errorDrawLine strokes a single line segment from→to with the given style.
DrawRectangle(rect: Rectangle, style: ShapeStyle)errorDrawRectangle strokes and/or fills an axis-aligned rectangle.
DrawCircle(center: Point, radius: float64, style: ShapeStyle)errorDrawCircle strokes and/or fills a circle.
DrawEllipse(center: Point, rx: float64, style: ShapeStyle)errorDrawEllipse strokes and/or fills an axis-aligned ellipse.
DrawPolyline(points: []Point, style: LineStyle)errorDrawPolyline strokes an open polyline (first and last points are NOT connected).
DrawPath(path: *Path, style: ShapeStyle)errorDrawPath strokes and/or fills the previously-built path.
DrawRoundedRectangle(rect: Rectangle, radius: float64, style: ShapeStyle)errorDrawRoundedRectangle strokes and/or fills an axis-aligned rectangle with rounded corners of the given radius.
DrawPolygon(points: []Point, style: ShapeStyle)errorDrawPolygon strokes and/or fills a closed polygon (last point connects back to the first via h).

See Also

 English