Class PlaywrightCarbonService

  • All Implemented Interfaces:
    CarbonService

    public class PlaywrightCarbonService
    extends java.lang.Object
    implements CarbonService
    Interacts with Carbon using Microsoft's Playwright library.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      byte[] getImage​(java.io.File file)
      Loads Carbon using Playwright, then screenshots the image created with the specified file's contents and default options.
      byte[] getImage​(java.io.File file, ImageOptions options)
      Loads Carbon using Playwright, then screenshots the image created with the specified file's contents and options.
      byte[] getImage​(java.lang.String code)
      Loads Carbon using Playwright, then screenshots the image created with the specified code and default options.
      byte[] getImage​(java.lang.String code, ImageOptions options)
      Loads Carbon using Playwright, then screenshots the image created with the specified code and options.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PlaywrightCarbonService

        public PlaywrightCarbonService()
    • Method Detail

      • getImage

        public byte[] getImage​(java.lang.String code)
        Loads Carbon using Playwright, then screenshots the image created with the specified code and default options.
        Specified by:
        getImage in interface CarbonService
        Parameters:
        code - code to get an image of
        Returns:
        the image as a byte array
      • getImage

        public byte[] getImage​(java.lang.String code,
                               ImageOptions options)
        Loads Carbon using Playwright, then screenshots the image created with the specified code and options.
        Specified by:
        getImage in interface CarbonService
        Parameters:
        code - code to get an image of
        options - an ImageOptions instance
        Returns:
        the image as a byte array
      • getImage

        public byte[] getImage​(java.io.File file)
                        throws java.io.IOException
        Loads Carbon using Playwright, then screenshots the image created with the specified file's contents and default options.
        Specified by:
        getImage in interface CarbonService
        Parameters:
        file - a File instance to read the contents of
        Returns:
        the image as a byte array
        Throws:
        java.io.IOException - if the file cannot be read
      • getImage

        public byte[] getImage​(java.io.File file,
                               ImageOptions options)
                        throws java.io.IOException
        Loads Carbon using Playwright, then screenshots the image created with the specified file's contents and options.
        Specified by:
        getImage in interface CarbonService
        Parameters:
        file - a File instance to read the contents of
        options - an ImageOptions instance
        Returns:
        the image as a byte array
        Throws:
        java.io.IOException - if the file cannot be read