Package org.nordstjernen
Class RemotePage
java.lang.Object
org.nordstjernen.RemotePage
- All Implemented Interfaces:
AutoCloseable
A web page driven through a separate
nordstjernen-renderer process,
mirroring the in-process Page API without loading the native engine
into the JVM. The engine runs in the child process; this class is a thin
client of its HTTP/JSON control protocol.
try (RemotePage page = RemotePage.open("https://example.com", 1000, 700, 800)) {
System.out.println(page.title());
ImageIO.write(page.renderFullPage(1.0), "png", new File("out.png"));
}
Not thread-safe.
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()static RemotePageOpenurlin a fresh renderer process at the given CSS viewport, letting scripts settle forsettleMsbefore reading the result.pageSize()The laid-out page size in CSS pixels.render(int scrollX, int scrollY, int width, int height, double scale) Render a viewport region to a premultiplied-ARGB image.renderFullPage(double scale) Render the whole page (top to bottom, full width) atscale.byte[]renderRgba(int scrollX, int scrollY, int width, int height, double scale) Render a viewport region to premultiplied RGBA8888 bytes (row-major, 4 bytes per pixel, R,G,B,A).title()The page<title>.url()The final URL after redirects.
-
Method Details
-
open
public static RemotePage open(String url, int viewportWidthCss, int viewportHeightCss, int settleMs) Openurlin a fresh renderer process at the given CSS viewport, letting scripts settle forsettleMsbefore reading the result. -
title
The page<title>. -
url
The final URL after redirects. -
pageSize
The laid-out page size in CSS pixels. -
renderRgba
public byte[] renderRgba(int scrollX, int scrollY, int width, int height, double scale) Render a viewport region to premultiplied RGBA8888 bytes (row-major, 4 bytes per pixel, R,G,B,A). -
render
Render a viewport region to a premultiplied-ARGB image. -
renderFullPage
Render the whole page (top to bottom, full width) atscale. -
close
public void close()- Specified by:
closein interfaceAutoCloseable
-