Form Preview

This module contains functions to create a preview image of a form.

class ndr_core.form_preview.PreviewImage

This class provides functions to create a preview image of a form.

col_width = 60
create_result_card_image_from_raw_data(data)

This function creates a result card preview image

create_search_form_image_from_raw_data(data)

This function creates a form preview image from a list of dictionaries.

draw_field_type_indicator(draw, coords, field_type, extra_label=None)

This function draws a small indicator of a field. The indicator indicates the type of the field. The field type is passed as an argument.

static draw_triangle(draw, side_length, middle_point, direction, fill_color)

This function draws a triangle. The triangle is used to indicate the direction of a field. The direction is passed as an argument. The direction can be either ‘up’ or ‘down’.

field_color = '#FFFFFF'
get_coordinates(row, start_col, colspan, rowspan, offset=0)

A form is organized in rows and columns. This function returns the coordinates of a rectangle that represents a field in the form. The coordinates are returned as a list of tuples. The first tuple contains the coordinates of the top left corner of the rectangle. The second tuple contains the bottom right corner of the rectangle. The coordinates are in pixels.

static get_highest_row(data)

This function returns the highest row number including rowspan

image_background_color = '#D3D3D3'
indicator_color = '#666666'
margin = 5
row_height = 50
shadow_color = '#444444'
text_color = '#000000'