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
| Signature | Description |
|---|---|
RenderBMP(w: io.Writer, opts: RenderOptions) → error | RenderBMP 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) → 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. |
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). |
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. |
ExtractText() → (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). |