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 45 methods for working with Page objects in Go programs. Available methods include: AddImage, AddImageFromStream, AddSVG, AddSVGFromStream, AddSVGObject, AddStamp, AddTOC, AddTable, AddText, Annotations, ArtBox, BleedBox, and 33 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.
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.
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).
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.
ExtractText()(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