o
    @@i*                    @   sn  d Z ddlZddlZddlZddlmZ ddlZddlmZ ddl	m
Z
 ddl	mZ ddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlm Z  ddl!m"Z" ddl#m$Z$ ddl%m&Z& ddl%m'Z' ddl(m)Z) ddl*m+Z+ ddl,m-Z- ddl.m/Z/ ddl0m1Z1 ddl2m3Z3 ddl4m5Z5 G dd dZ6dS )z\
This class represents an easy way to manipulate a PDF document
that looks like a slideshow
    N)Decimal)Shapes)Color)HexColor)	Rectangle)MapOfEurope)MapOfTheUnitedStates)MapOfTheWorld)Barcode)BarcodeType)Chart)Image)	Alignment)OrderedList)UnorderedList)ConnectedShape)FixedColumnWidthTable)Table)	TableCell)	TableUtil)CodeBlockWithSyntaxHighlighting)	Paragraph)LineArtFactory)Document)Page)PDFc                   @   s  e Zd ZU dZedZeed< edZeed< edZ	eed< dZ
eed	< d
Zeed< dZeed< dZeed< d
Zeed< dZeed< dZeed< dZeed< dZeed< dZeed< dZeed< d
Zeed< dd Zddd Zdefd!d"Zd#eje d$eje d%eje defd&d'Z				dd(eje  d)eje d#eje d$eje d%eje d*eje dd fd+d,Z!	dd(eje  d)eje d*eje dd fd-d.Z"			dd/ed#eje d$eje d%eje dd f
d0d1Z#d/edd fd2d3Z$	4dd5edd fd6d7Z%			dd8ed#eje d$eje d%eje fd9d:Z&d8edd fd;d<Z'			dd=ed#eje d$eje d%eje dd f
d>d?Z(d=edd fd@dAZ)					dd(ejeje   dBejeje   d)eje dCeje d*eje d#eje d$eje d%eje dd fdDdEZ*		dd(ejeje   dBejeje   d)eje dCeje d*eje dd fdFdGZ+g dddfdHeje d#eje d$eje d%eje dd f
dIdJZ,g fdHeje dd fdKdLZ-g dddfdMeje d#eje d$eje d%eje dd f
dNdOZ.g fdMeje dd fdPdQZ/g dddfdMeje d#eje d$eje d%eje dd f
dRdSZ0g fdMeje dd fdTdUZ1g dddfdHeje d#eje d$eje d%eje dd f
dVdWZ2g fdHeje dd fdXdYZ3g dddfdZeje d#eje d$eje d%eje dd f
d[d\Z4g fdZeje dd fd]d^Z5			dd(eje  d)ejeje  d#eje d$eje d%eje dd fd_d`Z6d(eje  d)ejeje  dd fdadbZ7			ddced#eje d$eje d%eje dd f
dddeZ8dcedd fdfdgZ9			ddhedied#eje d$eje d%eje dd fdjdkZ:dhediedd fdldmZ;dned#ed%edd fdodpZ<		dd$ed#eje d%eje dd fdqdrZ=	s	t			dduejejej>  dve?dwe?d#eje d$eje d%eje dd fdxdyZ@	s	tdduejejej>  dve?dwe?dd fdzd{ZAd|ed}ed#ed%ed~edd fddZB		ddeded#eje d%eje dd f
ddZCg dddfdZeje d#eje d$eje d%eje dd f
ddZDg fdZeje dd fddZEdeFfddZFdejGeeHjIf dd fddZJdS )SlideTemplatezh
    This class represents an easy way to manipulate a PDF document
    that looks like a slideshow
    z#0b3954ACCENT_COLORz#eeeeeeLIGHT_GRAY_COLORz#595959DARK_GRAY_COLORi,  BIG_NUMBER_TEXT_FONTSIZE_MAX   BIG_NUMBER_TEXT_FONTSIZE_MIN
   BIG_NUMBER_TEXT_FONTSIZE_STEPQUOTE_TEXT_FONTSIZE_MAXQUOTE_TEXT_FONTSIZE_MINQUOTE_TEXT_FONTSIZE_STEPd   TABLE_TEXT_FONTSIZE_MAX   TABLE_TEXT_FONTSIZE_MIN   TABLE_TEXT_FONTSIZE_STEP   SUBTITLE_FONTSIZETEXT_FONTSIZETITLE_FONTSIZEc                 C   s   t  | _g | _d S N)r   	_document_slides_to_be_numbered)self r6   ^/home/ubuntu/transcripts/venv/lib/python3.10/site-packages/borb/pdf/template/slide_template.py__init__K   s   
zSlideTemplate.__init__returnNc              	   C   sb   | j D ]+}| j|}t|d  tdtjtjtj	dj
|ttdtdtdtdd qd S )N   r#   )	font_size
font_colorhorizontal_alignmentvertical_alignment  r   /   pageavailable_space)r4   r3   get_pager   r   r   r   r   CENTEREDMIDDLEpaintr   )r5   isr6   r6   r7   _add_page_numbersS   s    
zSlideTemplate._add_page_numbersc                 C   s$   t tdtdd}| j| |S )N    widthheight)r   r   r3   add_page)r5   pr6   r6   r7   _blank_slidec   s   zSlideTemplate._blank_slidesubtitletexttitlec              	   C   sv  |   }ttttdtdtdtdtjtjdj|ttdtdtdtdd ttttdtdtdtdtj	tj	dj|ttdtdtdtdd d }t
| j  pgtd}td|D ]}| j||kr||} nqn|d usJ | j| td}d}	|d urt|ttjtd	td	td	d
}
|
j|ttdtdtdtdd |
 }|d usJ | }d}	|d urt|tjttj|	rtd	ntdtd	td	d}
|
j|ttdtdtd|d |
 }|d usJ | }d}	|d ur9t|ttj|	rtd	ntdtd	td	d
j|ttdtdtd|d |S )N  r   rL   stroke_color
fill_colorrA   r?   r@   T6   r;   padding_toppadding_rightpadding_leftFr<   r;   r\   r]   r^   )rR   r   r   	rectangler   r   r   r   rG   r   intr3   get_document_infoget_number_of_pagesrangerD   r4   appendr   r1   get_previous_paint_boxget_yr   r/   r0   )r5   rS   rT   rU   rI   page_nrnumber_of_pagesrH   prev_bottom_ymust_have_top_paddingp0p0_prev_paint_boxr6   r6   r7   _split_in_half_slideh   s   

z"SlideTemplate._split_in_half_slidexslabelsy_labelc              	   C   s   | j |||d}ddl}|j \}	}
|
|| |dur"|
| t|jtdtdtdtdtdtddj|t	tdtdtdtd	d
 | S )a  
        This function adds a slide to this SlideTemplate containing a barchart (on the left side)
        and a title, subtitle and text (on the right side)
        :param xs           the x-data series
        :param labels       the labels of the series
        :param subtitle:    the subtitle
        :param text:        the title
        :param title:       the text
        :param y_label      the label on the y-axis
        :return:            self
        rS   rT   rU   r   NrZ   o    r\   r]   padding_bottomr^   rN   rO   rV   rL   rA   )
rn   matplotlib.pyplotpyplotsubplotsbar
set_ylabelr   r   rG   r   )r5   ro   rp   rS   rT   rU   rq   rI   
matplotlibfigaxr6   r6   r7   add_barchart_and_text_slide   s,   
z)SlideTemplate.add_barchart_and_text_slidec              	   C   s   |   }ddl}|j \}}||| |dur|| t|jtdtdtdtdtdtddj|t	tdtdtdtdd	 | S )
a^  
        This function adds a slide to this SlideTemplate containing a barchart
        as big as it can be, centered horizontally and vertically on the page
        :param xs           the x-data series
        :param labels       the labels of the series
        :param y_label      the label on the y-axis
        :return:            self
        r   NrZ   J  rt   ru   rK   rL   rA   )
rR   rw   rx   ry   rz   r{   r   r   rG   r   )r5   ro   rp   rq   rI   r|   r}   r~   r6   r6   r7   add_barchart_slide  s,   
z SlideTemplate.add_barchart_slide
big_numberc                 C   s   | j |||d}ttjtjtj D ]8}z1t|tjtj	dt
dt
dt
dt
dt
|tjd
j|tt
dt
dt
dt
dd W  | S    Y q| S )	a  
        This function adds a slide to this SlideTemplate containing a large number (on the left side)
        and a title, subtitle and text (on the right side)
        :param big_number:  the big number to be added (e.g. "84%")
        :param subtitle:    the subtitle
        :param text:        the title
        :param title:       the text
        :return:            self
        rr   Helvetica-BoldrZ   	r=   r>   fontr\   r]   rv   r^   r;   r<   r   rV   rL   rA   )rn   rd   r   r    r"   r$   r   r   rE   rF   r   r   rG   r   )r5   r   rS   rT   rU   rI   r;   r6   r6   r7   add_big_number_and_text_slide>  s<   z+SlideTemplate.add_big_number_and_text_slidec                 C   s   |   }ttjtjtj D ]8}z1t|tjtj	dt
dt
dt
dt
dt
|tjd
j|tt
dt
dt
dt
dd W  | S    Y q| S )a  
        This function adds a slide to this SlideTemplate containing a large number
        as big as it can be, centered horizontally and vertically on the page
        :param big_number:  the big number to be added (e.g. "84%")
        :return:            self
        r   rZ   r   r   rK   rL   rA   )rR   rd   r   r    r"   r$   r   r   rE   rF   r   r   rG   r   )r5   r   rI   r;   r6   r6   r7   add_big_number_slideq  s<   	z"SlideTemplate.add_big_number_slide$This slide intentionally left blank.disclaimer_textc                 C   sR   |   }t|tjtjttjd tjdj	|t
tdtdtdtdd | S )a  
        This function adds a blank slide to this SlideTemplate, possibly containing a disclaimer as to why this slide is blank.
        Such as "Slide intentionally left blank"
        :param disclaimer_text  the disclaimer text
        :return:                self
        r,   )r=   r>   r;   r<   r   rK   rL   rA   )rR   r   r   rE   BOTTOMr   r   r0   r   rG   r   )r5   r   rI   r6   r6   r7   add_blank_slide  s   	zSlideTemplate.add_blank_slidecodec                 C   s   | j |||d}ttjtjtj D ]7}z0t|tjtjt	dt	dt	dt	dt	|tj
d	j|tt	dt	dt	dt	dd W  | S    Y q| S )au  
        This function adds a slide to this SlideTemplate containing a block of code (on the left side)
        and a title, subtitle and text (on the right side)
        :param code         the code to be displayed
        :param subtitle:    the subtitle
        :param text:        the title
        :param title:       the text
        :return:            self
        rr   rZ   r=   r>   r\   r]   rv   r^   r;   r<   r   rV   rL   rA   )rn   rd   r   r    r$   r   r   rE   rF   r   r   rG   r   )r5   r   rS   rT   rU   rI   r;   r6   r6   r7   add_code_and_text_slide  s:   
z%SlideTemplate.add_code_and_text_slidec                 C   s   |   }ttjtjtj D ]7}z0t|tjtjt	dt	dt	dt	dt	|tj
d	j|tt	dt	dt	dt	dd W  | S    Y q| S )z
        This function adds a slide to this SlideTemplate containing a block of code
        as big as it can be, centered horizontally and vertically on the page
        :param big_number:  the code to be added
        :return:            self
        rZ   r   r   rK   rL   rA   )rR   rd   r   r    r$   r   r   rE   rF   r   r   rG   r   )r5   r   rI   r;   r6   r6   r7   add_code_slide  s:   	
zSlideTemplate.add_code_slide	image_urlc              	   C   sf   | j |||d}t|tdtdtdtdtdtddj|ttdtdtdtdd	 | S )
a{  
        This function adds a slide to this SlideTemplate containing an image (on the left side)
        and a title, subtitle and text (on the right side)
        :param image_url    the URL for the image being displayed
        :param subtitle:    the subtitle
        :param text:        the title
        :param title:       the text
        :return:            self
        rr   rs   rt   rZ   )rN   rO   r\   r]   rv   r^   r   rK   rL   rA   )rn   r   r   rG   r   )r5   r   rS   rT   rU   rI   r6   r6   r7   add_image_and_text_slide  s"   z&SlideTemplate.add_image_and_text_slidec                 C   sF   |   }t|tdtddj|ttdtdtdtdd | S )a  
        This function adds a slide to this SlideTemplate containing an image
        as big as it can be, centered horizontally and vertically on the page
        :param image_url    the URL of the image to be added
        :return:            self
        rK   rL   rM   r   rA   )rR   r   r   rG   r   )r5   r   rI   r6   r6   r7   add_image_slide5  s   zSlideTemplate.add_image_slideysx_labelc	              	   C   s   | j |||d}	ddl}
|
jjdd\}}|j|pd|pddd t|||D ]\}}}|j|||d q'|jd	d
 t|
jt	dt	dt	dt	dt	dt	ddj
|	tt	dt	dt	dt	dd | S )a7  
        This function adds a slide to this SlideTemplate containing a linechart (on the left side)
        and a title, subtitle and text (on the right side)
        :param xs           the x-data series
        :param ys           the y-data series
        :param labels       the labels of the series
        :param x_label      the label for the x-axis
        :param y_label      the label for the y-axis
        :param subtitle:    the subtitle
        :param text:        the title
        :param title:       the text
        :return:            self
        rr   r   Nconstrainedlayout xlabelylabelrU   labeloutside lower centerlocrZ   rs   rt   ru   rV   rL   rA   )rn   rw   rx   ry   setzipplotlegendr   r   rG   r   )r5   ro   r   rp   r   rq   rS   rT   rU   rI   r|   r}   r~   xyr   r6   r6   r7   add_linechart_and_text_slideJ  s.   z*SlideTemplate.add_linechart_and_text_slidec                 C   s   |   }ddl}|jjdd\}}	|	j|pd|pddd t|||D ]\}
}}|	j|
||d q#|jdd	 t|jt	j
t	jtd
td
td
td
tdtdd	j|ttdtdtdtdd | S )a  
        This function adds a slide to this SlideTemplate containing a linechart
        as big as it can be, centered horizontally and vertically on the page
        :param xs           the x-data series
        :param ys           the y-data series
        :param labels       the labels of the series
        :param x_label      the label for the x-axis
        :param y_label      the label for the y-axis
        :return:            self
        r   Nr   r   r   r   r   r   r   rZ   r   rt   )r=   r>   r\   r]   rv   r^   rN   rO   rK   rL   rA   )rR   rw   rx   ry   r   r   r   r   r   r   rE   rF   r   rG   r   )r5   ro   r   rp   r   rq   rI   r|   r}   r~   r   r   r   r6   r6   r7   add_linechart_slide  s2   
z!SlideTemplate.add_linechart_slidemarked_countriesc                 C   s   | j |||d}ttjtjtjtdtdd}|j	tdtdd |D ]
}|j
tj|d q%|j|ttd	td	td
tdd | S )a  
        This function adds a slide to this SlideTemplate containing a map of Europe (on the left side)
        and a title, subtitle and text (on the right side)
        :param marked_countries:    the countries to be marked
        :param subtitle:            the subtitle
        :param text:                the text
        :param title:               the title
        :return:                    self
        rr   #ffffff皙?r=   r>   rY   rX   
line_widthrs   rt   	max_width
max_heightrY   keyr   rV   rL   rA   )rn   r   r   rE   rF   r   r   r   r   scale_upset_fill_colorr   rG   r   r5   r   rS   rT   rU   rI   mcr6   r6   r7    add_map_of_europe_and_text_slide  s*   z.SlideTemplate.add_map_of_europe_and_text_slidec                 C      |   }ttjtjtjtdtdtdtdtdtdd	}|j	tdtdd |D ]
}|j
tj|d q-|j|ttd	td	td
tdd | S )a  
        This function adds a slide to this SlideTemplate containing a map of Europe
        as big as it can be, centered horizontally and vertically on the page
        :param marked_countries:    the countries that ought to be marked
        :return:                    self
        r   r   rZ   	r=   r>   rY   rX   r   r\   r]   rv   r^   r   rt   r   r   r   rK   rL   rA   )rR   r   r   rE   rF   r   r   r   r   r   r   r   rG   r   r5   r   rI   r   r   r6   r6   r7   add_map_of_europe_slide  2   	z%SlideTemplate.add_map_of_europe_slidemarked_statesc                 C   s   | j |||d}ttjtjtjtdtdd}|	d |	d |	d |	d |	d	 |	d
 |	d |	d |j
tdtdd |D ]
}|jtj|d qM|j|ttdtdtdtdd | S )a  
        This function adds a slide to this SlideTemplate containing a map of the (contiguous) United States (on the left side)
        and a title, subtitle and text (on the right side)
        :param marked_states    the states that ought to be marked
        :param subtitle:        the subtitle
        :param text:            the title
        :param title:           the text
        :return:                self
        rr   r   r   r   AlaskaAmerican Samoa,Commonwealth of the Northern Mariana IslandsDistrict of ColumbiaGuamHawaiiPuerto RicoUnited States Virgin Islandsrs   rt   r   r   r   rV   rL   rA   )rn   r   r   rE   rF   r   r   r   r   popr   r   r   rG   r   r5   r   rS   rT   rU   rI   r   r   r6   r6   r7   6add_map_of_the_contiguous_united_states_and_text_slide  s:   







zDSlideTemplate.add_map_of_the_contiguous_united_states_and_text_slidec                 C   s   |   }ttjtjtjtdtdtdtdtdtdd	}|	d |	d |	d |	d |	d	 |	d
 |	d |	d |j
tdtdd |D ]
}|jtj|d qU|j|ttdtdtdtdd | S )a+  
        This function adds a slide to this SlideTemplate containing a map of the (contiguous) United States
        as big as it can be, centered horizontally and vertically on the page
        :param marked_states    the states that ought to be marked
        :return:                self
        r   r   rZ   r   r   r   r   r   r   r   r   r   r   rt   r   r   r   rK   rL   rA   )rR   r   r   rE   rF   r   r   r   r   r   r   r   r   rG   r   r5   r   rI   r   r   r6   r6   r7   -add_map_of_the_contiguous_united_states_slide:  sB   	







z;SlideTemplate.add_map_of_the_contiguous_united_states_slidec                 C   v   | j |||d}ttjtjtjtdtdd}|D ]
}|j	tj
|d q|j|ttdtdtdtdd	 | S )
a  
        This function adds a slide to this SlideTemplate containing a map of the United States (on the left side)
        and a title, subtitle and text (on the right side)
        :param marked_states    the states that ought to be marked
        :param subtitle:        the subtitle
        :param text:            the title
        :param title:           the text
        :return:                self
        rr   r   r   r   r   r   rV   rL   rA   )rn   r   r   rE   rF   r   r   r   r   r   r   rG   r   r   r6   r6   r7   +add_map_of_the_united_states_and_text_slidef  "   z9SlideTemplate.add_map_of_the_united_states_and_text_slidec                 C   r   )a  
        This function adds a slide to this SlideTemplate containing a map of the United States
        as big as it can be, centered horizontally and vertically on the page
        :param marked_states    the states that ought to be marked
        :return:                self
        r   r   rZ   r   r   rt   r   r   r   rK   rL   rA   )rR   r   r   rE   rF   r   r   r   r   r   r   r   rG   r   r   r6   r6   r7   "add_map_of_the_united_states_slide  r   z0SlideTemplate.add_map_of_the_united_states_slidec                 C   r   )
a  
        This function adds a slide to this SlideTemplate containing a map of the world (on the left side)
        and a title, subtitle and text (on the right side)
        :param marked_countries the countries that ought to be marked
        :param subtitle:        the subtitle
        :param text:            the title
        :param title:           the text
        :return:                self
        rr   r   r   r   r   r   rV   rL   rA   )rn   r	   r   rE   rF   r   r   r   r   r   r   rG   r   r   r6   r6   r7   #add_map_of_the_world_and_text_slide  r   z1SlideTemplate.add_map_of_the_world_and_text_slidec                 C   s   |   }ttjtjtjtdtdtdtdtdtdd	}|j	tdtdd}|D ]
}|j
tj|d q-|j|ttd	td	td
tdd | S )a!  
        This function adds a slide to this SlideTemplate containing a map of the world
        as big as it can be, centered horizontally and vertically on the page
        :param marked_countries     the countries that ought to be marked
        :return:                    self
        r   r   rZ   r   r   rt   r   r   r   rK   rL   rA   )rR   r	   r   rE   rF   r   r   r   r   r   r   r   rG   r   r   r6   r6   r7   add_map_of_the_world_slide  r   z(SlideTemplate.add_map_of_the_world_slide
list_itemsc           	   
   C      | j |||d}ttjtjtj D ]A}z:ttdtdtdtdd}|D ]}|t	|dt|tj
d q'||ttdtdtdtd W  | S    Y q| S )	a  
        This function adds a slide to this SlideTemplate containing an ordered list (on the left side)
        and a title, subtitle and text (on the right side)
        :param list_items:      the items in the list
        :param subtitle:        the subtitle
        :param text:            the text
        :param title:           the title
        :return:                self
        rr   rZ   r\   r]   rv   r^   r   r   r;   r<   r   rV   rL   )rn   rd   r   r%   r&   r'   r   r   addr   r   rG   r   	r5   r   rS   rT   rU   rI   r;   ollir6   r6   r7   add_ordered_list_and_text_slide  s>   z-SlideTemplate.add_ordered_list_and_text_slidec              
   C      |   }ttjtjtj D ]A}z:ttdtdtdtdd}|D ]}|t	|dt|tj
d q#||ttdtdtdtd W  | S    Y q| S )z
        This function adds a slide to this SlideTemplate containing an ordered list
        as big as it can be, centered horizontally and vertically on the page
        :param list_items:  the items in the list
        :return:            self
        rZ   r   r   r   r   rK   rL   )rR   rd   r   r%   r&   r'   r   r   r   r   r   rG   r   r5   r   rI   r;   r   r   r6   r6   r7   add_ordered_list_slide2  s>   z$SlideTemplate.add_ordered_list_slidec              	      s   | j |||d}ddl}|jjdd\}}	t fddtdt D }
|	j ||
d |jd	d
 t	|jt
dt
dt
dt
dt
dt
ddj|tt
dt
dt
dt
dd | S )a  
        This function adds a slide to this SlideTemplate containing a piechart (on the left side)
        and a title, subtitle and text (on the right side)
        :param xs           the x-data series
        :param labels       the labels of the series
        :param subtitle:    the subtitle
        :param text:        the title
        :param title:       the text
        :return:            self
        rr   r   Nr   r   c                    $   g | ]} | t  krd ndqS r:   r   max.0rH   ro   r6   r7   
<listcomp>{     $ z=SlideTemplate.add_piechart_and_text_slide.<locals>.<listcomp>rp   exploder   r   rZ   rs   rt   ru   rV   rL   rA   )rn   rw   rx   ry   tuplerd   lenpier   r   r   rG   r   )r5   ro   rp   rS   rT   rU   rI   r|   r}   r~   should_exploder6   r   r7   add_piechart_and_text_slide`  s0   z)SlideTemplate.add_piechart_and_text_slidec              	      s   |   }ddl}|jjdd\}}t fddtdt D }|j ||d |jdd	 t	|jt
d
t
d
t
d
t
d
t
dt
ddj|tt
dt
dt
dt
dd | S )a*  
        This function adds a slide to this SlideTemplate containing a piechart
        as big as it can be, centered horizontally and vertically on the page
        :param xs           the x-data series
        :param labels       the labels of the series
        :return:            self
        r   Nr   r   c                    r   r   r   r   r   r6   r7   r     r   z4SlideTemplate.add_piechart_slide.<locals>.<listcomp>r   r   r   rZ   r   rt   ru   rK   rL   rA   )rR   rw   rx   ry   r   rd   r   r   r   r   r   rG   r   )r5   ro   rp   rI   r|   r}   r~   r   r6   r   r7   add_piechart_slide  s0   z SlideTemplate.add_piechart_slidedatac                 C   sv   | j |||d}t|tjtjtjtjt	dt	dt	dt	dt	dt	ddj
|tt	dt	dt	dt	dd | S )	a  
        This function adds a slide to this SlideTemplate containing a QR code (on the left side)
        and a title, subtitle and text (on the right side)
        :param data:        the data to be encoded in the QR code (e.g. a URL)
        :param subtitle:    the subtitle
        :param text:        the text
        :param title:       the title
        :return:            self
        rr   in  rZ   
typer=   r>   rX   rN   rO   r\   r]   rv   r^   r   rV   rL   rA   )rn   r
   r   QRr   rE   rF   r   r   r   rG   r   )r5   r   rS   rT   rU   rI   r6   r6   r7   add_qr_code_and_text_slide  s*   z(SlideTemplate.add_qr_code_and_text_slidec                 C   sn   |   }t|tjtjtjtjt	dt	dt	dt	dt	dt	ddj
|tt	dt	dt	dt	dd | S )a  
        This function adds a slide to this SlideTemplate containing a QR code
        as big as it can be, centered horizontally and vertically on the page
        :param data:    the data to be encoded in the QR code (e.g. a URL)
        :return:        self
        i  rZ   r   r   rK   rL   rA   )rR   r
   r   r   r   rE   rF   r   r   r   rG   r   )r5   r   rI   r6   r6   r7   add_qr_code_slide  s*   zSlideTemplate.add_qr_code_slidequote_author
quote_textc                 C   s   | j |||d}ttjtjtj D ]R}zKtddtdtdtdtddt	|t
jt
jt
jdt|tjdt	|t
jt
jdtd	tjd
 |ttdtdtdtd W  | S    Y q| S )a  
        This function adds a slide to this SlideTemplate containing a quote and its author (on the left side)
        and a title, subtitle and text (on the right side)
        :param quote_author     the author of the quote
        :param quote_text       the text of the quote
        :param subtitle:        the subtitle
        :param text:            the title
        :param title:           the text
        :return:                self
        rr   r:   r,   rZ   )number_of_columnsnumber_of_rowsr\   r]   rv   r^   r   text_alignmentr=   r>   r   r;   r<   Helvetica-Obliquer!   r=   r>   r   r;   r<   r   rV   rL   )rn   rd   r   r%   r&   r'   r   r   r   r   r   	JUSTIFIEDrE   rF   r   RIGHT
no_bordersrG   r   )r5   r   r   rS   rT   rU   rI   r;   r6   r6   r7   add_quote_and_text_slide  s`   
z&SlideTemplate.add_quote_and_text_slidec                 C   s   |   }ttjtjtj D ]V}zOtddtdtdtdtdtj	tj
dt|tjtj	tj
dt|tjdt|tjtj
dtdtjd	 |ttd
td
tdtd W  | S    Y q| S )aE  
        This function adds a slide to this SlideTemplate containing a quote and its author
        as big as it can be, centered horizontally and vertically on the page
        :param quote_author     the author of the quote
        :param quote_text       the text of the quote
        :return:                self
        r:   r,   rZ   )r   r   r\   r]   rv   r^   r=   r>   r   r   r   r!   r   r   rK   rL   )rR   rd   r   r%   r&   r'   r   r   r   rE   rF   r   r   r   r   r   r   rG   r   )r5   r   r   rI   r;   r6   r6   r7   add_quote_slideW  s`   	

zSlideTemplate.add_quote_slidenrc              
   C   s>  |   }tg d}t|tdtddj|ttdtdtdtdd tt	ttdtdtdtdt
jt
jdj|ttdtdtdtdd td	d
tjtjtdtdtdtddt|dt
jtdtddt|tddt|t
jd j|ttdtdtdtdd | S )a;  
        This function adds a slide to this SlideTemplate containing a section title.
        The slide is styled with an image, and a color accent
        :param nr           the nr (e.g. '2b')
        :param subtitle     the subtitle
        :param title        the title
        :return:            self
        )z9https://images.unsplash.com/photo-1551041181-cacd7047d18dz9https://images.unsplash.com/photo-1555859623-1caf19ff9bbbz9https://images.unsplash.com/photo-1560174038-da43ac74f01bz9https://images.unsplash.com/photo-1561700398-b25aeb4454fcz<https://images.unsplash.com/photo-1439337153520-7082a56a81f4z<https://images.unsplash.com/photo-1476891626313-2cecb3820a69z<https://images.unsplash.com/photo-1490004531003-9bda21d243dbz<https://images.unsplash.com/photo-1495745713439-7efd16a9555cz<https://images.unsplash.com/photo-1504019853082-9a4cb128c1efz<https://images.unsplash.com/photo-1521035227181-90af4feddc6cz<https://images.unsplash.com/photo-1524230572899-a752b3835840z<https://images.unsplash.com/photo-1527576539890-dfa815648363z<https://images.unsplash.com/photo-1527698334848-f475f9d99449z<https://images.unsplash.com/photo-1532374281774-97f9514fcfeaz<https://images.unsplash.com/photo-1574492956703-638af28b0065z<https://images.unsplash.com/photo-1582140161604-0b909c97653cz<https://images.unsplash.com/photo-1605986740387-0ea0d9168f19zBhttps://plus.unsplash.com/premium_photo-1661880452033-a41bd5e32eaeg     y@rL   rM   r   rA      rW   r:      rZ   r   r   r>   r=   r\   r]   rv   r^   r   r#   r!   )r   r<   rv   r;      )r;   )r<   )rR   randomchoicer   r   rG   r   r   r   r`   r   r   r   r   rF   rE   r   r   r   r   )r5   r  rS   rU   rI   r   r6   r6   r7   add_section_title_slide  sn   	z%SlideTemplate.add_section_title_slidec              
   C   sD  |   }td}d}|durDt|ttjtdtdtdd}|j|ttdtdtdtdd | }|dus>J | }d	}|durt|tj	ttj
|rVtdntdtdtdd
}|j|ttdtdtd|d | }|dus~J | }d	}ttttdtdtdtdtjtjdj|ttdtdtdtdd d}	t| j  ptd}
td|
D ]}| j||kr|}	 nq|	dusJ | j|	 ttjtjtj D ]7}z0t||rtdnt|tdtdtdt|tjdj|ttdtdtd|d W  | S    Y q| S )a&  
        This function adds a slide to this SlideTemplate containing a single column of text
        as big as it can be
        :param subtitle:        the subtitle
        :param text:            the title
        :param title:           the text
        :return:                self
        rL   TNrZ   r[   r   rK   rA   Fr_   r?   r@   rW   )rT   r\   r^   r]   rv   r;   r   )rR   r   r   r   r1   rG   r   rf   rg   r   r/   r   r   r`   r   ra   r3   rb   rc   rd   rD   r4   re   r)   r+   r-   r   r   )r5   rT   rS   rU   rI   rj   rk   rl   rm   rh   ri   rH   r;   r6   r6   r7   add_single_column_text_slide  s   

z*SlideTemplate.add_single_column_text_slideFTtabular_data
header_col
header_rowc           
   	   C   s   | j |||d}ttjtjtj D ]c}z\tj|||tjt	dt
|d}	t
d|	_t
d|	_t
d|	_t
d|	_tj|	_tj|	_|	t
|d t
|d t
|d t
|d  |	j|tt
dt
dt
dt
dd	 W  | S    Y q| S )
a&  
        This function adds a slide to this SlideTemplate containing a table (on the left side)
        and a title, subtitle and text (on the right side)
        :param tabular_data     the tabular data
        :param header_col       whether the first column ought to be marked as a header
        :param header_row       whether the first row ought to be marked as a header
        :param subtitle:        the subtitle
        :param text:            the title
        :param title:           the text
        :return:                self
        rr   r   r  r  header_background_colorheader_font_colorr;   rZ   r  r   rV   rL   rA   )rn   rd   r   r)   r+   r-   r   from_2d_arrayr   r   r   _padding_top_padding_right_padding_bottom_padding_leftr   rE   _horizontal_alignmentrF   _vertical_alignmentset_padding_on_all_cellsrG   r   )
r5   r  r  r  rS   rT   rU   rI   r;   tr6   r6   r7   add_table_and_text_slideg  sL   







z&SlideTemplate.add_table_and_text_slidec              	   C   s   |   }ttjtjtj D ]c}z\tj|||tjt	dt
|d}|t
|d t
|d t
|d t
|d  t
d|_t
d|_t
d|_t
d|_tj|_tj|_|j|tt
dt
dt
dt
dd W  | S    Y q| S )	a  
        This function adds a slide to this SlideTemplate containing a table
        as big as it can be, centered horizontally and vertically on the page
        :param tabular_data     the tabular data
        :param header_col       whether the first column ought to be marked as a header
        :param header_row:      whether the first row ought to be marked as a header
        :return:                self
        r   r  r  rZ   r   rK   rL   rA   )rR   rd   r   r)   r+   r-   r   r  r   r   r   r  r  r  r  r  r   rE   r  rF   r  rG   r   )r5   r  r  r  rI   r;   r  r6   r6   r7   add_table_slide  sL   







zSlideTemplate.add_table_slideauthordateversionc              
   C   sf  |   }ttttdtdtdtdtjtjdj|ttdtdtdtdd ttttdtdtdtdtjtjdj|ttdtdtdtdd t	ddt
jt
jtd	td	td	td	d
t|dt
jtjtddt|t
jtjtddt| d| tdt
jtjd j|ttdtdtdtdd | S )az  
        This function adds a title slide to this SlideTemplate. The title slide contains
        a title, subtitle, author, version and date
        :param author:      the author
        :param date:        the date
        :param subtitle:    the subtitle
        :param title:       the title
        :param version:     the version
        :return:            self
        r   r  rL   rW   rA   rK   r:   r  rZ   r  r   (   )r   r=   r<   r;   r!   )r=   r<   r;   z, r#   )r;   r=   r<   )rR   r   r   r`   r   r   r   r   rG   r   r   rF   rE   r   r   r   r   r   )r5   r  r  rS   rU   r  rI   r6   r6   r7   add_title_slide  s   	&zSlideTemplate.add_title_slide	text_left
text_rightc              	   C   s  |   }td}d}|durDt|ttjtdtdtdd}|j|ttdtdtdtdd | }	|	dus>J |	 }d	}|durt|tj	ttj
|rVtdntdtdtdd
}|j|ttdtdtd|d | }	|	dus~J |	 }d	}ttttdtdtdtdtjtjdj|ttdtdtdtdd d}
t| j  ptd}td|D ]}| j||kr|}
 nq|
dusJ | j|
 ttjtjtj D ]W}zPtddtd|rtdnt|tdtddtt|t|tjdtddtt|t|tjdtdd j|ttdtdtd|d W  | S    Y q| S )aR  
        This function adds a slide to this SlideTemplate containing two columns of text
        :param text_left        the text on the left side
        :param text_right       the text on the right side
        :param subtitle:        the subtitle
        :param text:            the title
        :return:                self
        rL   TNrZ   r[   r   rK   rA   Fr_   r?   r@   rW   r,   r:   )r   r   r^   r\   rv   r]   )r;   r      )r]   )r^   ) rR   r   r   r   r1   rG   r   rf   rg   r   r/   r   r   r`   r   ra   r3   rb   rc   rd   rD   r4   re   r)   r+   r-   r   r   r   r   r   r   )r5   r!  r"  rS   rU   rI   rj   rk   rl   rm   rh   ri   rH   r;   r6   r6   r7   add_two_column_text_slide6  s   



&z'SlideTemplate.add_two_column_text_slidec           	   
   C   r   )	a  
        This function adds a slide to this SlideTemplate containing an unordered list (on the left side)
        and a title, subtitle and text (on the right side)
        :param list_items:      the items in the list
        :param subtitle:        the subtitle
        :param text:            the text
        :param title:           the title
        :return:                self
        rr   rZ   r   r   r   r   rV   rL   )rn   rd   r   r%   r&   r'   r   r   r   r   r   rG   r   r   r6   r6   r7   !add_unordered_list_and_text_slide  s>   z/SlideTemplate.add_unordered_list_and_text_slidec              
   C   r   )a   
        This function adds a slide to this SlideTemplate containing an unordered list
        as big as it can be, centered horizontally and vertically on the page
        :param list_items:  the items in the list
        :return:            self
        rZ   r   r   r   r   rK   rL   )rR   rd   r   r%   r&   r'   r   r   r   r   r   rG   r   r   r6   r6   r7   add_unordered_list_slide  s>   
z&SlideTemplate.add_unordered_list_slidec                 C   s0   |    t }t|| j |d | S )z
        This function returns the bytes representing this SlideTemplate.
        It does so by saving this SlideTemplate to an io.BytesIO buffer,
        and returning its bytes.
        :return:    the bytes representing this SlideTemplate
        r   )rJ   ioBytesIOr   dumpsr3   seekgetvalue)r5   bufferr6   r6   r7   bytes$  s
   
zSlideTemplate.bytespath_or_strc                 C   sF   |    t|d}t|| j W d   | S 1 sw   Y  | S )z
        This function stores this SlideTemplate at the given path
        :param path_or_str:     the path or str representing the location at which to store this SlideTemplate
        :return:                self
        wbN)rJ   openr   r)  r3   )r5   r.  pdf_file_handler6   r6   r7   save1  s   
zSlideTemplate.save)r9   N)NNNNr2   )NNN)r   )NNNNN)NN)FTNNN)FT)K__name__
__module____qualname____doc__r   r   r   __annotations__r   r   r    ra   r"   r$   r%   r&   r'   r)   r+   r-   r/   r0   r1   r8   rJ   r   rR   typingOptionalstrrn   Listfloatr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r	  r
  Anyboolr  r  r   r$  r%  r&  r-  UnionpathlibPathr2  r6   r6   r6   r7   r   -   s6  
 

x
8
1
3+

2,
'	

=
6
-
&
5
.
)
&
)
&
5
2
3
0
*
(
I?
`
w
C
9
Z
 
6
-"r   )7r6  r'  r  r8  decimalr   r@  #borb.pdf.canvas.layout.shape.shapesr   borb.pdf.canvas.color.colorr   r   "borb.pdf.canvas.geometry.rectangler   .borb.pdf.canvas.layout.geography.map_of_europer   9borb.pdf.canvas.layout.geography.map_of_the_united_statesr   1borb.pdf.canvas.layout.geography.map_of_the_worldr	   $borb.pdf.canvas.layout.image.barcoder
   r   "borb.pdf.canvas.layout.image.chartr   "borb.pdf.canvas.layout.image.imager   %borb.pdf.canvas.layout.layout_elementr   (borb.pdf.canvas.layout.list.ordered_listr   *borb.pdf.canvas.layout.list.unordered_listr   ,borb.pdf.canvas.layout.shape.connected_shaper   5borb.pdf.canvas.layout.table.fixed_column_width_tabler   "borb.pdf.canvas.layout.table.tabler   r   'borb.pdf.canvas.layout.table.table_utilr   >borb.pdf.canvas.layout.text.codeblock_with_syntax_highlightingr   %borb.pdf.canvas.layout.text.paragraphr   )borb.pdf.canvas.line_art.line_art_factoryr   borb.pdf.document.documentr   borb.pdf.page.pager   borb.pdf.pdfr   r   r6   r6   r6   r7   <module>   s@   