GT.save
GT.save(self, file, selector='table', scale=1.0, expand=5, web_driver='chrome', window_size=(6000, 6000), debug_port=None, _debug_dump=None)
Produce a high-resolution image file or PDF of the table.
The output file is created by taking a screenshot of the table using a headless browser.
Parameters
Name | Type | Description | Default |
---|---|---|---|
file |
str |
The name of the file to save the image to. Accepts names ending with .png, .bmp, and other image extensions. Also accepts the extension .pdf. | required |
selector |
str |
(NOT IMPLEMENTED) The HTML element name used to select table. Defaults to the whole table. | 'table' |
scale |
float |
The scaling factor that will be used when generating the image. Lower values decrease resolution. A scale of 2 is equivalent to doubling the width of the table in pixels. Note that higher resolution results in larger file sizes. | 1.0 |
expand |
int |
(NOT IMPLEMENTED) The number of pixels to expand the screenshot by. This can be increased to capture more of the surrounding area, or decreased to capture less. | 5 |
web_driver |
WebDrivers |
The webdriver to use when taking the screenshot. By default, uses Google Chrome. Supports "firefox" (Mozilla Firefox), "safari" (Apple Safari), and "edge" (Microsoft Edge). Specified browser must be installed. |
'chrome' |
window_size |
tuple [int , int ] |
The size of the browser window to use when laying out the table. This shouldn’t be necessary to capture a table, but may affect the tables appearance. | (6000, 6000) |
debug_port |
None | int |
Port number to use for debugging. By default no debugging port is opened. | None |
_debug_dump |
DebugDumpOptions | None |
Whether the saved image should be a big browser window, with key elements outlined. This is helpful for debugging this function’s resizing, cropping heuristics. This is an internal parameter and subject to change. | None |
Returns
Type | Description |
---|---|
None | This function does not return anything; it simply saves the image to the specified file path. |
Details
We create the output file based on the HTML version of the table.
This process is facilitated by two libraries:
selenium
, which is used to control the Chrome browser and take a screenshot of the table.PIL
, which is used to crop the screenshot to only include the table element of the page.
Both of these packages needs to be installed before attempting to save any table as an image file. The selenium
package also requires the Chrome browser to be installed on the system.
A pip-based reinstallation of Great Tables through the following command will install these required packages:
pip install great_tables[extra]