Class RemotePage

java.lang.Object
org.nordstjernen.RemotePage
All Implemented Interfaces:
AutoCloseable

public final class RemotePage extends Object implements 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 Type
    Method
    Description
    void
     
    static RemotePage
    open(String url, int viewportWidthCss, int viewportHeightCss, int settleMs)
    Open url in a fresh renderer process at the given CSS viewport, letting scripts settle for settleMs before reading the result.
    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) at scale.
    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).
    The page <title>.
    url()
    The final URL after redirects.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • open

      public static RemotePage open(String url, int viewportWidthCss, int viewportHeightCss, int settleMs)
      Open url in a fresh renderer process at the given CSS viewport, letting scripts settle for settleMs before reading the result.
    • title

      public String title()
      The page <title>.
    • url

      public String url()
      The final URL after redirects.
    • pageSize

      public Size 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

      public BufferedImage render(int scrollX, int scrollY, int width, int height, double scale)
      Render a viewport region to a premultiplied-ARGB image.
    • renderFullPage

      public BufferedImage renderFullPage(double scale)
      Render the whole page (top to bottom, full width) at scale.
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable