Esempio n. 1
0
def _create_pdf(invoice_buffer, legal_case,
                brief_of_evidence_record_of_interviews):
    every_page_frame = Frame(
        PAGE_MARGIN,
        PAGE_MARGIN,
        PAGE_WIDTH - 2 * PAGE_MARGIN,
        PAGE_HEIGHT - 2 * PAGE_MARGIN,
        id='EveryPagesFrame',
    )  #showBoundary=Color(0, 1, 0))
    every_page_template = PageTemplate(
        id='EveryPages',
        frames=[
            every_page_frame,
        ],
    )
    doc = BaseDocTemplate(
        invoice_buffer,
        pageTemplates=[
            every_page_template,
        ],
        pagesize=A4,
    )  # showBoundary=Color(1, 0, 0))

    # Common
    col_width_head = [
        85 * mm,
        25 * mm,
        85 * mm,
    ]
    col_width_details = [27 * mm, 27 * mm, 71 * mm, 30 * mm, 36 * mm]
    col_width_for_court = [
        27 * mm, 24 * mm, 18 * mm, 58 * mm, 47 * mm, 17 * mm
    ]
    FONT_SIZE_L = 11
    FONT_SIZE_M = 10
    FONT_SIZE_S = 8

    styles = StyleSheet1()
    styles.add(
        ParagraphStyle(
            name='Normal',
            fontName='Helvetica',
            fontSize=FONT_SIZE_M,
            spaceBefore=7,  # space before paragraph
            spaceAfter=7,  # space after paragraph
            leading=12))  # space between lines
    styles.add(
        ParagraphStyle(name='BodyText', parent=styles['Normal'],
                       spaceBefore=6))
    styles.add(
        ParagraphStyle(name='Italic',
                       parent=styles['BodyText'],
                       fontName='Helvetica-Italic'))
    styles.add(
        ParagraphStyle(name='Bold',
                       parent=styles['BodyText'],
                       fontName='Helvetica-Bold',
                       alignment=TA_CENTER))
    styles.add(
        ParagraphStyle(name='Right',
                       parent=styles['BodyText'],
                       alignment=TA_RIGHT))
    styles.add(
        ParagraphStyle(name='Centre',
                       parent=styles['BodyText'],
                       alignment=TA_CENTER))
    elements = []
    for boe in brief_of_evidence_record_of_interviews:
        offender = boe.offender.person
        offence = boe.offence
        if not offender or not offence:
            continue

        # Generate texts
        accused_text = offender.get_full_name()
        accused_dob_text = offender.dob.strftime(
            '%d/%m/%Y') if offender.dob else ''
        accused_address_text = offender.residential_address
        offence_period = offence.occurrence_datetime_from.strftime("%d/%m/%Y")
        if offence.occurrence_from_to:
            offence_period += ' to ' + offence.occurrence_datetime_to.strftime(
                "%d/%m/%Y")
        offence_place = str(offence.location)
        offence_description = offence.details

        # Head (col, row)
        invoice_table_style = TableStyle([
            ('VALIGN', (0, 0), (-1, -1), 'TOP'),
            ('GRID', (0, 0), (-1, -1), 0, colors.white),
            ('ALIGN', (0, 0), (-1, -1), 'LEFT'),
        ])
        style_tbl_left = TableStyle([
            ('VALIGN', (0, 0), (-1, -1), 'TOP'),
            ('GRID', (0, 0), (-1, -1), 0.5, colors.black),
            ('ALIGN', (0, 0), (-1, -1), 'LEFT'),
        ])
        style_tbl_right = TableStyle([
            ('VALIGN', (0, 0), (-1, -1), 'MIDDLE'),
            ('GRID', (0, 0), (-1, -1), 0.5, colors.black),
            ('ALIGN', (0, 0), (-1, -1), 'LEFT'),
        ])
        data_left = Table([[
            Paragraph(
                'MAGISTRATES COURT of WESTERN<br />'
                'AUSTRALIA<br />'
                '<strong><font size="' + str(FONT_SIZE_L) +
                '">PROSECUTION NOTICE</font></strong><br />'
                '<i>Criminal Procedure Act 2004</i><br />'
                'Criminal Procedure Regulations 2005 - Form 3',
                styles['Centre']),
        ]],
                          style=style_tbl_left)
        data_right = Table([
            [Paragraph('Court number', styles['Normal']), ''],
            [Paragraph('Magistrates court at', styles['Normal']), ''],
            [Paragraph('Date lodged', styles['Normal']), ''],
        ],
                           style=style_tbl_right,
                           rowHeights=[
                               7.8 * mm,
                               7.8 * mm,
                               7.8 * mm,
                           ])
        tbl_head = Table(
            [[data_left, '', data_right]],
            style=invoice_table_style,
            colWidths=col_width_head,
        )

        # Details of alleged offence
        rowHeights = [6 * mm, 6 * mm, 6 * mm, 30 * mm, 6 * mm]
        style_tbl_details = TableStyle([
            ('VALIGN', (0, 0), (0, 0), 'TOP'),
            ('VALIGN', (1, 0), (-1, -1), 'MIDDLE'),
            ('GRID', (0, 0), (-1, -1), 0.5, colors.black),
            ('ALIGN', (0, 0), (-1, -1), 'LEFT'),
            ('SPAN', (0, 0), (0, 4)),
            ('SPAN', (2, 0), (4, 0)),
            ('SPAN', (2, 1), (4, 1)),
            ('SPAN', (2, 2), (4, 2)),
            ('SPAN', (2, 3), (4, 3)),
            ('SPAN', (2, 4), (4, 4)),
        ])

        data = []
        data.append([
            Paragraph(
                '<strong>Details of alleged offence</strong><br />'
                '<i><font size="' + str(FONT_SIZE_S) +
                '">[This description must comply with the CPA Schedule 1 clause 5.]</font></i>',
                styles['Normal']),
            Paragraph('Accused', styles['Normal']),
            Paragraph(get_font_str(accused_text), styles['Normal']),
            '',
            '',
        ])
        data.append([
            '',
            Paragraph('Date or period', styles['Normal']),
            Paragraph(get_font_str(offence_period), styles['Normal']), '', ''
        ])
        data.append([
            '',
            Paragraph('Place', styles['Normal']),
            Paragraph(get_font_str(offence_place), styles['Normal']), '', ''
        ])
        data.append([
            '',
            Paragraph('Description', styles['Normal']),
            Paragraph(get_font_str(offence_description), styles['Normal']), '',
            ''
        ])
        data.append(
            ['', Paragraph('Written law', styles['Normal']), '', '', ''])
        tbl_details = Table(data,
                            style=style_tbl_details,
                            colWidths=col_width_details,
                            rowHeights=rowHeights)

        # Notice to accused
        style_tbl_notice = TableStyle([
            ('VALIGN', (0, 0), (-1, -1), 'TOP'),
            ('GRID', (0, 0), (-1, -1), 0.5, colors.black),
            ('ALIGN', (0, 0), (-1, -1), 'LEFT'),
            ('SPAN', (1, 0), (4, 0)),
        ])
        data = []
        data.append([
            Paragraph('<strong>Notice to accused</strong>', styles['Normal']),
            Paragraph(
                'You are charged with the offence described above, or the offences described in any attachment to this notice. The charge(s) will be dealt with by the above court.',
                styles['Normal']),
            '',
            '',
            '',
        ])
        tbl_notice = Table(data,
                           style=style_tbl_notice,
                           colWidths=col_width_details)

        # Accused's Details
        rowHeights = [4.5 * mm, 6 * mm, 6 * mm]
        style_tbl_accused = TableStyle([
            ('VALIGN', (0, 0), (0, -1), 'TOP'),
            ('VALIGN', (1, 0), (-1, -1), 'MIDDLE'),
            ('GRID', (0, 0), (-1, -1), 0.5, colors.black),
            ('ALIGN', (0, 0), (-1, -1), 'LEFT'),
            ('SPAN', (0, 0), (0, 2)),
            ('SPAN', (1, 0), (4, 0)),
            ('SPAN', (3, 1), (4, 1)),
            ('SPAN', (2, 2), (4, 2)),
        ])
        data = []
        data.append([
            Paragraph('<strong>Accused\'s Details</strong>', styles['Normal']),
            Paragraph(
                '<i><font size="' + str(FONT_SIZE_S) +
                '">[This description must comply with the CPA Schedule 1 clause 4.]</font></i>',
                styles['Normal']),
            '',
            '',
            '',
        ])
        data.append([
            '',
            Paragraph('Date of Birth', styles['Normal']),
            Paragraph(get_font_str(accused_dob_text), styles['Normal']),
            Paragraph('Male / Female', styles['Normal']),
            '',
        ])
        data.append([
            '',
            Paragraph('Address', styles['Normal']),
            Paragraph(get_font_str(accused_address_text), styles['Normal']),
            '',
            '',
        ])
        tbl_accused = Table(data,
                            style=style_tbl_accused,
                            colWidths=col_width_details,
                            rowHeights=rowHeights)

        # Prosecutor
        rowHeights = [
            4.5 * mm, 6 * mm, 6 * mm, 6 * mm, 15 * mm, 4.5 * mm, 15 * mm,
            6 * mm
        ]
        style_tbl_prosecutor = TableStyle([
            ('VALIGN', (0, 0), (0, -1), 'TOP'),
            ('VALIGN', (1, 0), (-1, -1), 'MIDDLE'),
            ('GRID', (0, 0), (-1, -1), 0.5, colors.black),
            ('ALIGN', (0, 0), (-1, -1), 'LEFT'),
            ('VALIGN', (2, 6), (-1, 6), 'BOTTOM'),
            ('SPAN', (0, 0), (0, 1)),  # col: Prosecutor
            ('SPAN', (0, 2), (0, 6)),  # col: Person issuing this notice
            ('SPAN', (1, 5), (1, 6)),  # col: Witness's signature
            ('SPAN', (1, 0), (4, 0)),
            ('SPAN', (1, 1), (4, 1)),
            ('SPAN', (2, 4), (4, 4)),
            ('SPAN', (2, 5), (4, 5)),
            ('SPAN', (2, 6), (4, 6)),
            ('SPAN', (1, 7), (4, 7)),
        ])
        data = []
        data.append([
            Paragraph('<strong>Prosecutor</strong>', styles['Normal']),
            Paragraph(
                '<i><font size="' + str(FONT_SIZE_S) +
                '">[Identify the prosecutor in accordance with the CPA Schedule 1 clause 3.]</font></i>',
                styles['Normal']),
            '',
            '',
            '',
        ])
        data.append([
            '',
            '',
            '',
            '',
            '',
        ])
        data.append([
            Paragraph('<strong>Person issuing this notice</strong>',
                      styles['Normal']),
            Paragraph('Full name', styles['Normal']),
            '',
            Paragraph('official title', styles['Normal']),
            '',
        ])
        data.append([
            '',
            Paragraph('Work address', styles['Normal']),
            '',
            Paragraph('Work telephone', styles['Normal']),
            '',
        ])
        data.append([
            '',
            Paragraph('Signature', styles['Normal']),
            '',
            '',
            '',
        ])
        data.append([
            '',
            Paragraph('Witness\'s Signature', styles['Normal']),
            Paragraph(
                '<i><font size="' + str(FONT_SIZE_S) +
                '">[A witness may not be needed. See the CPA section 23.]</font></i>',
                styles['Normal']),
            '',
            '',
        ])
        data.append([
            '',
            '',
            Paragraph(
                '<font size="' + str(FONT_SIZE_S) +
                '">Justice of the Peace or Prescribed Court Officer</font>',
                styles['Normal']),
            '',
            '',
        ])
        data.append([
            Paragraph('<strong>Date</strong>', styles['Normal']),
            Paragraph('This prosecution notice is signed on',
                      styles['Normal']),
            '',
            '',
            '',
        ])
        tbl_prosecutor = Table(data,
                               style=style_tbl_prosecutor,
                               colWidths=col_width_details,
                               rowHeights=rowHeights)

        # For Court Use Only
        rowHeights_court = [
            6 * mm, 10 * mm, 6 * mm, 6 * mm, 6 * mm, 6 * mm, 6 * mm, 6 * mm,
            6 * mm, 6 * mm, 23 * mm, 17 * mm
        ]
        style_tbl_for_court = TableStyle([
            ('VALIGN', (0, 0), (-1, -1), 'MIDDLE'),
            ('VALIGN', (3, 11), (5, 11), 'BOTTOM'),
            ('VALIGN', (0, 10), (2, 11), 'TOP'),
            ('GRID', (0, 0), (-1, -1), 0.5, colors.black),
            ('SPAN', (0, 0), (5, 0)),
            ('SPAN', (3, 1), (4, 1)),
            ('SPAN', (3, 2), (4, 2)),
            ('SPAN', (3, 3), (4, 3)),
            ('SPAN', (3, 4), (4, 4)),
            ('SPAN', (3, 5), (4, 5)),
            ('SPAN', (3, 6), (4, 6)),
            ('SPAN', (1, 7), (2, 7)),  # Guilty / not guilty
            ('SPAN', (1, 8), (2, 8)),
            ('SPAN', (1, 9), (2, 9)),  # Convicted / acquitted
            ('SPAN', (3, 7), (5, 10)),  # Penalty and other orders
            ('SPAN', (4, 11), (5, 11)),
            ('SPAN', (0, 10), (2, 11)),  # <== This has a bug...?
        ])
        data = []
        data.append([
            Paragraph('<i>For Court User Only</i>', styles['Bold']), '', '',
            '', '', ''
        ])
        data.append([
            Paragraph('Date', styles['Centre']),
            Paragraph('Appearance by accused', styles['Centre']),
            Paragraph('Counsel', styles['Centre']),
            Paragraph('Record of court proceedings', styles['Centre']),
            '',
            Paragraph('Judicial officer', styles['Centre']),
        ])
        data.append(['', Paragraph('Y / N', styles['Bold']), '', '', '', ''])
        data.append(['', Paragraph('Y / N', styles['Bold']), '', '', '', ''])
        data.append(['', Paragraph('Y / N', styles['Bold']), '', '', '', ''])
        data.append(['', Paragraph('Y / N', styles['Bold']), '', '', '', ''])
        data.append(['', Paragraph('Y / N', styles['Bold']), '', '', '', ''])
        data.append([
            Paragraph('Plea', styles['Bold']),
            Paragraph('Guilty / not guilty', styles['Bold']),
            '',
            [
                Paragraph('Penalty and other orders', styles['Centre']),
                Paragraph('<strong>Fine</strong>', styles['Normal']),
                Paragraph('<strong>Costs</strong>', styles['Normal']),
                Paragraph('<strong>Other</strong>', styles['Normal'])
            ],
            '',
            '',
        ])
        data.append([
            Paragraph('Date of plea', styles['Bold']),
            '',
            '',
            '',
            '',
            '',
        ])
        data.append([
            Paragraph('<strong>Judgement</strong>', styles['Centre']),
            Paragraph('<strong>Conficted / acquitted</strong>',
                      styles['Centre']),
            '',
            '',
            '',
            '',
        ])
        data.append([
            Paragraph('<strong>Victim impact statement available</strong>',
                      styles['Centre']), '', '', '', '', ''
        ])
        data.append([
            '',
            '',
            '',
            Paragraph('<strong>Judicial officer</strong>', styles['Centre']),
            Paragraph('<strong>Date:</strong>', styles['Normal']),
            '',
        ])
        tbl_for_court = Table(data,
                              style=style_tbl_for_court,
                              colWidths=col_width_for_court,
                              rowHeights=rowHeights_court)

        #############
        # PageBreak #
        #############

        # Court Number
        rowHeights = [
            10 * mm,
        ]
        col_width_court_number = [
            30 * mm,
            70 * mm,
        ]
        style_tbl_for_court_number = TableStyle([
            ('VALIGN', (0, 0), (-1, -1), 'MIDDLE'),
            ('GRID', (0, 0), (-1, -1), 0.5, colors.black),
        ])
        data = []
        data.append([Paragraph('Court number', styles['Normal']), ''])
        tbl_for_court_number = OffsetTable(data,
                                           x_offset=45.5 * mm,
                                           style=style_tbl_for_court_number,
                                           colWidths=col_width_court_number,
                                           rowHeights=rowHeights)

        # Table above
        style_array = [
            ('VALIGN', (0, 0), (-1, -1), 'MIDDLE'),
            ('GRID', (0, 0), (-1, -1), 0.5, colors.black),
        ]
        for row_num in range(0, 29):
            style_array.append(('SPAN', (3, row_num), (4, row_num)))
        style_tbl_above = TableStyle(style_array)
        data = []
        data.append([
            Paragraph('Date', styles['Centre']),
            Paragraph('Appearance by accused', styles['Centre']),
            Paragraph('Counsel', styles['Centre']),
            Paragraph('Record of court proceedings', styles['Centre']),
            '',
            Paragraph('Judicial officer', styles['Centre']),
        ])
        for row_num in range(0, 28):
            data.append([
                '',
                Paragraph('<strong>Y / N</strong>', styles['Centre']), '', '',
                '', ''
            ])
        tbl_above = Table(data,
                          style=style_tbl_above,
                          colWidths=col_width_for_court)

        # Table below
        style_array = [
            ('VALIGN', (0, 0), (-1, -1), 'MIDDLE'),
            ('GRID', (0, 0), (-1, -1), 0.5, colors.black),
        ]
        for row_num in range(0, 8):
            style_array.append(('SPAN', (2, row_num), (5, row_num)))
        style_tbl_below = TableStyle(style_array)
        data = []
        data.append([
            Paragraph('Date', styles['Centre']),
            Paragraph('Clerk\'s Initial', styles['Centre']),
            Paragraph('Registry record', styles['Centre']),
            '',
            '',
            '',
        ])
        for row_num in range(0, 7):
            data.append(['', '', '', '', '', ''])
        tbl_below = Table(data,
                          style=style_tbl_below,
                          colWidths=col_width_for_court,
                          rowHeights=8.5 * mm)

        # Append tables to the elements to build
        gap_between_tables = 1.5 * mm
        elements.append(tbl_head)
        elements.append(tbl_details)
        elements.append(Spacer(0, gap_between_tables))
        elements.append(tbl_notice)
        elements.append(Spacer(0, gap_between_tables))
        elements.append(tbl_accused)
        elements.append(Spacer(0, gap_between_tables))
        elements.append(tbl_prosecutor)
        elements.append(Spacer(0, gap_between_tables))
        elements.append(tbl_for_court)
        elements.append(PageBreak())
        elements.append(tbl_for_court_number)
        elements.append(Spacer(0, gap_between_tables))
        elements.append(tbl_above)
        elements.append(Spacer(0, gap_between_tables))
        elements.append(tbl_below)

    doc.build(elements)
    return invoice_buffer
Esempio n. 2
0
def _create_pdf(invoice_buffer, legal_case, offenders):
    every_page_frame = Frame(
        PAGE_MARGIN,
        PAGE_MARGIN,
        PAGE_WIDTH - 2 * PAGE_MARGIN,
        PAGE_HEIGHT - 2 * PAGE_MARGIN,
        id='EveryPagesFrame',
    )  #showBoundary=Color(0, 1, 0))
    every_page_template = PageTemplate(
        id='EveryPages',
        frames=[
            every_page_frame,
        ],
    )
    doc = BaseDocTemplate(
        invoice_buffer,
        pageTemplates=[
            every_page_template,
        ],
        pagesize=A4,
    )  # showBoundary=Color(1, 0, 0))

    # Common
    col_width_head = [
        95 * mm,
        15 * mm,
        85 * mm,
    ]
    col_width_details = [28 * mm, 28 * mm, 71 * mm, 23 * mm, 41 * mm]
    FONT_SIZE_L = 12
    FONT_SIZE_M = 10
    FONT_SIZE_S = 8
    topLeftTableRowHeights = [
        23.5 * mm,
    ]
    topRightTableRowHeights = [
        7.8 * mm,
        15.6 * mm,
    ]

    styles = StyleSheet1()
    styles.add(
        ParagraphStyle(
            name='Normal',
            fontName='Helvetica',
            fontSize=FONT_SIZE_M,
            spaceBefore=2,  # space before paragraph
            spaceAfter=2,  # space after paragraph
            leading=11))  # space between lines
    styles.add(
        ParagraphStyle(name='BodyText', parent=styles['Normal'],
                       spaceBefore=6))
    styles.add(
        ParagraphStyle(name='Italic',
                       parent=styles['BodyText'],
                       fontName='Helvetica-Italic'))
    styles.add(
        ParagraphStyle(name='Bold',
                       parent=styles['BodyText'],
                       fontName='Helvetica-Bold',
                       alignment=TA_CENTER))
    styles.add(
        ParagraphStyle(name='Right',
                       parent=styles['BodyText'],
                       alignment=TA_RIGHT))
    styles.add(
        ParagraphStyle(name='Centre',
                       parent=styles['BodyText'],
                       alignment=TA_CENTER))

    court_date_qs = legal_case.court_proceedings.court_dates.all().order_by(
        'court_datetime')
    court_date_obj = None
    if court_date_qs:
        # Retrieve earliest one
        court_date_obj = court_date_qs[0]

    elements = []
    for offender in offenders:
        offender_full_name = ''
        court_date_txt = ''
        court_time_txt = ''
        court_place_txt = ''

        if offender.person:
            offender_full_name = offender.person.get_full_name()
        if court_date_obj and court_date_obj.court_datetime:
            local_datetime = court_date_obj.court_datetime.astimezone(
                pytz.timezone(TIME_ZONE))
            court_date_txt = local_datetime.strftime('%d/%m/%Y')
            court_time_txt = local_datetime.strftime('%H:%M')
        if court_date_obj and court_date_obj.court:
            court_place_txt = court_date_obj.court.location

        ###
        # 1st page
        ###

        # Header small text
        header_small_text_p1 = ParagraphOffeset(
            '<font size="' + str(FONT_SIZE_S) +
            '">Copy to be attached to court copy of prosecution notice</font>',
            styles['Right'],
            x_offset=-3 * mm,
            y_offset=0)

        # Head (col, row)
        invoice_table_style = TableStyle([
            ('VALIGN', (0, 0), (-1, -1), 'TOP'),
            ('GRID', (0, 0), (-1, -1), 0, colors.white),
            ('ALIGN', (0, 0), (-1, -1), 'LEFT'),
        ])
        style_tbl_left = TableStyle([
            ('VALIGN', (0, 0), (-1, -1), 'MIDDLE'),
            ('GRID', (0, 0), (-1, -1), 0.5, colors.black),
            ('ALIGN', (0, 0), (-1, -1), 'LEFT'),
        ])
        style_tbl_right = TableStyle([
            ('VALIGN', (0, 0), (-1, -1), 'MIDDLE'),
            ('GRID', (0, 0), (-1, -1), 0.5, colors.black),
            ('ALIGN', (0, 0), (-1, -1), 'LEFT'),
        ])
        data_left = Table([[
            Paragraph(
                'MAGISTRATES COURT of WESTERN<br />'
                'AUSTRALIA<br />'
                '<strong><font size="' + str(FONT_SIZE_L) +
                '">COURT HEARING NOTICE</font></strong><br />'
                '<i>Criminal Procedure Act 2004</i><br />'
                'Criminal Procedure Regulations 2005 - Form 5',
                styles['Centre']),
        ]],
                          style=style_tbl_left,
                          rowHeights=topLeftTableRowHeights)
        data_right = Table([
            [Paragraph('Court number', styles['Normal']), ''],
            [Paragraph('Magistrates court at', styles['Normal']), ''],
        ],
                           style=style_tbl_right,
                           rowHeights=topRightTableRowHeights)
        tbl_head = Table(
            [[data_left, '', data_right]],
            style=invoice_table_style,
            colWidths=col_width_head,
        )

        # Accused's Details, etc
        rowHeights = [6 * mm, 6 * mm, 6 * mm, 30 * mm, 6 * mm]
        style_tbl_accused_details = TableStyle([
            ('VALIGN', (0, 0), (0, 0), 'MIDDLE'),
            ('GRID', (0, 0), (-1, -1), 0.5, colors.black),
            ('ALIGN', (0, 0), (-1, -1), 'LEFT'),
            ('SPAN', (0, 0), (0, 1)),
            ('SPAN', (2, 0), (4, 0)),
            ('SPAN', (2, 1), (4, 1)),
        ])
        data = []
        data.append([
            Paragraph('<strong>Accused\'s Details</strong><br />',
                      styles['Normal']),
            Paragraph('Full name', styles['Normal']),  # ,
            Paragraph(get_font_str(offender_full_name), styles['Normal']),
            '',
            '',
        ])
        data.append([
            '',
            Paragraph('Address', styles['Normal']),
            '',
            '',
            '',
        ])
        tbl_accused_details = Table(
            data,
            style=style_tbl_accused_details,
            colWidths=col_width_details,
        )  # rowHeights=rowHeights)

        # Hearing details, etc
        style_tbl_hearing_details = TableStyle([
            ('VALIGN', (0, 0), (-1, -1), 'MIDDLE'),
            ('GRID', (0, 0), (-1, -1), 0.5, colors.black),
            ('ALIGN', (0, 0), (-1, -1), 'LEFT'),
            ('SPAN', (1, 0), (4, 0)),
            ('SPAN', (1, 2), (4, 2)),
        ])
        data = []
        data.append([
            Paragraph('<strong>Hearing details</strong>', styles['Normal']),
            Paragraph(
                'The charge(s) in the attached prosecution notice dated [insert date]<br />will be first dealt with by the above court at the time, date and place stated below.',
                styles['Normal']),
            '',
            '',
            '',
        ])
        data.append([
            Paragraph('<strong>Date and time</strong>', styles['Normal']),
            Paragraph('Date', styles['Normal']),
            Paragraph(get_font_str(court_date_txt), styles['Normal']),
            Paragraph('Time', styles['Normal']),
            Paragraph(get_font_str(court_time_txt), styles['Normal']),
        ])
        data.append([
            Paragraph('<strong>Place</strong>', styles['Normal']),
            Paragraph(get_font_str(court_place_txt), styles['Normal']),
            '',
            '',
            '',
        ])
        tbl_hearing_details = Table(
            data,
            style=style_tbl_hearing_details,
            colWidths=col_width_details,
        )  # rowHeights=rowHeights)

        # Notice to accused
        col_width_notice_to_accused = [
            28 * mm,
            163 * mm,
        ]
        style_tbl_notice_to_accused = TableStyle([
            ('VALIGN', (0, 0), (-1, -1), 'MIDDLE'),
            ('VALIGN', (0, 0), (0, -1), 'TOP'),
            ('GRID', (0, 0), (-1, -1), 0.5, colors.black),
            ('ALIGN', (0, 0), (-1, -1), 'LEFT'),
        ])
        data = []
        data.append([
            Paragraph('<strong>Notice to accused</strong>', styles['Normal']),
            Paragraph(
                '<strong>Your options are set out below. You should read them carefully.</strong><br />If you do not know what to do, you should get advice from a lawyer, the Legal Aid Commission or the Aboriginal Legal Service. If you will need an interpreter in court, please contact the court',
                styles['Normal']),
        ])
        data.append([
            Paragraph('<strong>Options</strong>', styles['Normal']),
            Paragraph(
                '1. You can attend the above hearing. <br />'
                '2. You can do nothing. <br />'
                '3. You can plead <u>not guilty</u> in writing. <br />'
                '4. You can plead <u>guilty</u> in writing. <br />'
                '<strong>Options 2, 3 and 4 are explained below.</strong>',
                styles['Normal']),
        ])
        data.append([
            [
                Paragraph('<strong>Doing nothing</strong>', styles['Normal']),
                Spacer(0, 5 * mm),
                Paragraph('<strong>[Options 2]</strong>', styles['Normal']),
            ],
            [
                Paragraph(
                    'If you do not appear at the above hearing and you do not send the court a written plea in time, the court may determine the charge(s) at the above hearing in your absence.',
                    styles['Normal']),
                Paragraph(
                    'In some cases the court can take as proved any allegation in the attached prosecution notice without hearing evidence.',
                    styles['Normal']),
                Paragraph(
                    'The court may decide to summons you to court or have you arrested and brought before the court.',
                    styles['Normal']),
                Paragraph(
                    'If the court finds you guilty, it may fine you and order you to pay court costs and the prosecutor’s costs.',
                    styles['Normal']),
            ],
        ])
        data.append([
            [
                Paragraph('<strong>Pleading not guilty in writing</strong>',
                          styles['Normal']),
                Spacer(0, 5 * mm),
                Paragraph('<strong>[Option 3]</strong>', styles['Normal']),
            ],
            [
                Paragraph(
                    'Pleading <u>not guilty</u> to a charge in the prosecution notice means you do not admit the charge.',
                    styles['Normal']),
                Paragraph(
                    'If you send the court a written plea of <u>not guilty</u>, you need not attend the above hearing. If the court receives your written plea in time it will send you a notice of another hearing, at which the court will deal with the charge(s) (in your absence if you are not there) and hear any evidence you wish to give and any witnesses you call.',
                    styles['Normal']),
                Paragraph(
                    'To send the court a written plea of not guilty, fill out page 2 of this form and send page 2 to the address on it at least three days before the above hearing date.',
                    styles['Normal']),
            ],
        ])
        data.append([
            [
                Paragraph('<strong>Pleading guilty in writing</strong>',
                          styles['Normal']),
                Spacer(0, 5 * mm),
                Paragraph('[Option 4]', styles['Normal']),
            ],
            [
                Paragraph(
                    'Pleading <u>guilty</u> to a charge in the prosecution notice means you admit the charge.',
                    styles['Normal']),
                Paragraph(
                    'If you send the court a written plea of <u>guilty</u>, you need not attend the above hearing unless you want to tell the court something.',
                    styles['Normal']),
                Paragraph(
                    'If the court receives your written plea in time it will deal with the charge(s) at the above hearing (in your absence if you are not there) and may fine you and order you to pay court costs and the prosecutor’s costs.',
                    styles['Normal']),
                Paragraph(
                    'To send the court a written plea of guilty, fill out page 2 of this form, include any written explanation or information you want the court to consider, and send it all to the address on the form at least three days before the above hearing date.',
                    styles['Normal']),
                Paragraph(
                    'The court might not accept your plea of guilty if what you tell the court suggests you do not admit the charge. If that happens you will be notified.',
                    styles['Normal']),
            ],
        ])
        tbl_notice_to_accused = Table(data,
                                      style=style_tbl_notice_to_accused,
                                      colWidths=col_width_notice_to_accused)

        # Issuing details
        col_width_issuing_details = col_width_notice_to_accused
        style_tbl_issuing_details = TableStyle([
            ('VALIGN', (0, 0), (-1, -1), 'MIDDLE'),
            ('GRID', (0, 0), (-1, -1), 0.5, colors.black),
            ('ALIGN', (0, 0), (-1, -1), 'LEFT'),
        ])
        data = []
        data.append([
            Paragraph('<strong>Issuing details</strong>', styles['Normal']),
            [
                Paragraph('This notice is issued on [date]', styles['Normal']),
                Spacer(0, 8 * mm),
                BrokenLine(50 * mm),
                Paragraph('<i>[Title of person issuing notice]</i>',
                          styles['Normal']),
            ]
        ])
        tbl_issuing_details = Table(data,
                                    style=style_tbl_issuing_details,
                                    colWidths=col_width_issuing_details)

        # Service details
        col_width_service_details = col_width_notice_to_accused
        style_tbl_service_details = TableStyle([
            ('VALIGN', (0, 0), (-1, -1), 'MIDDLE'),
            ('GRID', (0, 0), (-1, -1), 0.5, colors.black),
            ('ALIGN', (0, 0), (-1, -1), 'LEFT'), ('SPAN', (0, 0), (0, 1))
        ])
        data = []
        data.append([
            [
                Paragraph('<strong>Service details</strong>',
                          styles['Normal']),
                Spacer(0, 5 * mm),
                Paragraph('[*Police only]', styles['Normal']),
            ],
            Paragraph(
                '<i>[Service must be in one of the manners in the CPA Schedule 2 clauses 2, 3 or 4 (see s. 33(3)). Insert here whichever manner of service was used.]</i>',
                styles['Normal'])
        ])
        tbl_style_internal = TableStyle([
            ('VALIGN', (0, 0), (-1, -1), 'MIDDLE'),
        ])
        data.append([
            '',
            [
                Paragraph(
                    'On' + gap(30) + '20' + gap(10) +
                    ', the accused was served with a copy of this notice and the prosecution notice referred to above in the following manner:',
                    styles['Normal']),
                Table([
                    [
                        Paragraph('Name of server:', styles['Normal']),
                        Paragraph('*Registered No:', styles['Normal'])
                    ],
                    [
                        Paragraph('Signature:', styles['Normal']),
                        Paragraph(gap(1) + 'Station:', styles['Normal'])
                    ],
                ],
                      style=tbl_style_internal,
                      rowHeights=[
                          8 * mm,
                          8 * mm,
                      ])
            ]
        ])
        tbl_service_details = Table(data,
                                    style=style_tbl_service_details,
                                    colWidths=col_width_service_details)

        ###
        # 2nd page
        ###
        # Head (col, row)
        data_left_p2 = Table([[
            Paragraph(
                'MAGISTRATES COURT of WESTERN<br />'
                'AUSTRALIA<br />'
                '<strong><font size="' + str(FONT_SIZE_L) +
                '">WRITTEN PLEA BY ACCUSED</font></strong><br />'
                '<i>Criminal Procedure Act 2004</i><br />'
                'Criminal Procedure Regulations 2005 - Form 5 page 2',
                styles['Centre']),
        ]],
                             style=style_tbl_left,
                             rowHeights=topLeftTableRowHeights)
        data_right_p2 = Table([
            [Paragraph('Court number', styles['Normal']), ''],
            [Paragraph('Magistrates court at', styles['Normal']), ''],
        ],
                              style=style_tbl_right,
                              rowHeights=topRightTableRowHeights)
        tbl_head_p2 = Table(
            [[data_left_p2, '', data_right_p2]],
            style=invoice_table_style,
            colWidths=col_width_head,
        )

        # Accused's Details
        # This is common among the pages

        # Accused's plea
        col_width_p2 = [28 * mm, 28 * mm, 71 * mm, 23 * mm, 41 * mm]
        tbl_style_p2 = (
            ('VALIGN', (0, 0), (-1, -1), 'MIDDLE'),
            ('VALIGN', (0, 0), (0, -1), 'TOP'),
            ('GRID', (0, 0), (-1, -1), 0.5, colors.black),
            ('ALIGN', (0, 0), (-1, -1), 'LEFT'),
            ('SPAN', (1, 0), (4, 0)),
            ('SPAN', (1, 1), (4, 1)),
            ('SPAN', (1, 2), (4, 2)),
            ('SPAN', (1, 3), (4, 3)),
            ('SPAN', (1, 4), (4, 4)),
            ('SPAN', (1, 5), (4, 5)),
            ('SPAN', (1, 6), (2, 6)),
            ('SPAN', (1, 7), (4, 7)),
            ('SPAN', (0, 5), (0, 6)),
        )
        data = []
        data.append([
            Paragraph('<strong>Accused\'s plea</strong>', styles['Normal']),
            [
                Paragraph(
                    'I have received a prosecution notice dated' + gap(40) +
                    'and a court hearing notice advising me of the hearing on [date]',
                    styles['Normal']),
                Paragraph(
                    'I understand or have had explained to me the charge(s) in the prosecution notice and the contents of the court hearing notice and I understand the effect of this written plea I am sending to the court.',
                    styles['Normal']),
            ],
            '',
            '',
            '',
        ])
        data.append([
            [
                Paragraph('<strong>Plea of guilty</strong>', styles['Normal']),
                Paragraph('[Tick on box]', styles['Normal']),
                Spacer(0, 20 * mm),
                Paragraph('[Tick on box]', styles['Normal']),
            ],
            [
                ParagraphCheckbox(
                    'I plead <u>guilty</u> to the charge(s) in the prosecution notice.',
                    styles['Normal']),
                ParagraphCheckbox(
                    'I plead <u>guilty</u> to the following charges in the prosecution notice.',
                    styles['Normal']),
                Paragraph(
                    '<i>[If the prosecution notice contains more than one charge and you want to plead guilty to only some of them, write the numbers of the charges here.]</i>',
                    styles['Normal']),
                Spacer(0, 8 * mm),
                Paragraph('Attendance at court:', styles['Normal']),
                ParagraphCheckbox(
                    'I will be attending the hearing on the above date.',
                    styles['Normal']),
                ParagraphCheckbox(
                    'I will not be attending the hearing on the above date.',
                    styles['Normal']),
                Paragraph(
                    'I would like the court to take account of the following:',
                    styles['Normal']),
                Paragraph(
                    '<i>[If you are pleading guilty you can (but need not) explain why you committed the offence(s) and give any information that you want the court to consider when deciding what sentence to impose on you.]</i>',
                    styles['Normal']),
                Spacer(0, 10 * mm),
            ],
            '',
            '',
            '',
        ])
        data.append([
            [
                Paragraph('<strong>Plea of not guilty</strong>',
                          styles['Normal']),
                Paragraph('[Tick on box]', styles['Normal']),
                Spacer(0, 20 * mm),
                Paragraph('[Tick on box]', styles['Normal']),
            ],
            [
                ParagraphCheckbox(
                    'I plead not guilty to the charge(s) in the prosecution notice.',
                    styles['Normal']),
                ParagraphCheckbox(
                    'I plead not guilty to the following charges in the prosecution notice.',
                    styles['Normal']),
                Paragraph(
                    '<i>[If the prosecution notice contains more than one charge and you want to plead not guilty to only some of them, write the numbers of them here]</i>',
                    styles['Normal']),
                Spacer(0, 8 * mm),
                Paragraph('Attendance at court:', styles['Normal']),
                ParagraphCheckbox(
                    'I will be attending the hearing on the above date.',
                    styles['Normal']),
                ParagraphCheckbox(
                    'I will not be attending the hearing on the above date.',
                    styles['Normal']),
                Paragraph(
                    'At the trial of the charge(s) I intend to call' +
                    gap(40) + 'witnesses (including myself).',
                    styles['Normal']),
                Paragraph(
                    '<i>[Please insert the number of witnesses to assist the court in deciding how long the trial might last]</i>',
                    styles['Normal']),
                Paragraph(
                    'When setting a date for the trial please take account of the following:',
                    styles['Normal']),
                Paragraph(
                    '<i>[Please provide any information that might assist the court when setting the date for the trial such as dates when you will be overseas or in hospital.]</i>',
                    styles['Normal']),
                Spacer(0, 10 * mm),
            ],
            '',
            '',
            '',
        ])
        data.append([
            Paragraph('<strong>Contact details</strong>', styles['Normal']),
            [
                Paragraph('My contact details are:', styles['Normal']),
                Spacer(0, 2 * mm),
                Paragraph('Address (if different to the one above):',
                          styles['Normal']),
                Spacer(0, 2 * mm),
                Paragraph(
                    'Telephone no.' + gap(40) + 'Fax no.' + gap(40) +
                    'Mobile no.', styles['Normal']),
            ],
            '',
            '',
            '',
        ])
        data.append([
            [
                Paragraph('<strong>Lawyer\'s details</strong>',
                          styles['Normal']),
                Paragraph('[If a lawyer will appear for you]',
                          styles['Normal']),
            ],
            [
                Paragraph('Name:', styles['Normal']),
                Paragraph('Firm name', styles['Normal']),
            ],
            '',
            '',
            '',
        ])
        data.append([
            Paragraph('<strong>Accused\'s signature</strong>',
                      styles['Normal']),
            Paragraph(
                '<i>This may be signed by the accused’s lawyer or, if the accused is a corporation, made in accordance with the Criminal Procedure Act 2004 section 154(1).</i>',
                styles['Normal']),
            '',
            '',
            '',
        ])
        data.append([
            '',
            '',
            '',
            Paragraph('Date', styles['Normal']),
            '',
        ])
        data.append([
            Paragraph('<strong>Court address</strong>', styles['Normal']),
            [
                Paragraph('Send this document to:', styles['Normal']),
                Spacer(0, 2 * mm),
                Paragraph('at:', styles['Normal']),
                Spacer(0, 2 * mm),
            ],
            '',
            '',
            '',
        ])
        tbl_main_p2 = Table(
            data,
            style=tbl_style_p2,
            colWidths=col_width_p2,
        )

        ###
        # 3rd page
        ###
        header_small_text_p3 = ParagraphOffeset(
            '<font size="' + str(FONT_SIZE_S) +
            '">Copy to be attached to accused copy of prosecution notice</font>',
            styles['Right'],
            x_offset=-3 * mm,
            y_offset=0)

        ###
        # 4th page
        ###
        # Same as 2nd page

        ###
        # 5th page
        ###
        header_small_text_p5 = ParagraphOffeset(
            '<font size="' + str(FONT_SIZE_S) +
            '">Return of service copy</font>',
            styles['Right'],
            x_offset=-3 * mm,
            y_offset=0)

        ###
        # 6th page
        ###

        gap_between_tables = 1.5 * mm
        odd_page = []
        odd_page.append(tbl_head)
        odd_page.append(tbl_accused_details)
        odd_page.append(Spacer(0, gap_between_tables))
        odd_page.append(tbl_hearing_details)
        odd_page.append(Spacer(0, gap_between_tables))
        odd_page.append(tbl_notice_to_accused)
        odd_page.append(Spacer(0, gap_between_tables))
        odd_page.append(tbl_issuing_details)
        odd_page.append(Spacer(0, gap_between_tables))
        odd_page.append(tbl_service_details)
        even_page = []
        even_page.append(tbl_head_p2)
        even_page.append(tbl_accused_details)
        even_page.append(Spacer(0, gap_between_tables))
        even_page.append(tbl_main_p2)

        # 1st page
        elements.append(header_small_text_p1)
        elements += odd_page
        elements.append(PageBreak())
        # 2nd page
        elements += even_page
        elements.append(PageBreak())
        # 3rd page
        elements.append(header_small_text_p3)
        elements += odd_page
        elements.append(PageBreak())
        # 4th page
        elements += even_page
        elements.append(PageBreak())
        # 5th page
        elements.append(header_small_text_p5)
        elements += odd_page
        elements.append(PageBreak())
        # 6th page
        elements += even_page

    doc.build(elements)
    return invoice_buffer
Esempio n. 3
0
def _create_pdf(invoice_buffer, sanction_outcome):
    PAGE_MARGIN = 5 * mm
    page_frame_1 = Frame(
        PAGE_MARGIN,
        PAGE_MARGIN,
        PAGE_WIDTH - 2 * PAGE_MARGIN,
        PAGE_HEIGHT - 2 * PAGE_MARGIN,
        id='PagesFrame1',
    )  #showBoundary=Color(0, 1, 0))
    PAGE_MARGIN2 = 17 * mm
    page_frame_2 = Frame(
        PAGE_MARGIN2,
        PAGE_MARGIN2,
        PAGE_WIDTH - 2 * PAGE_MARGIN2,
        PAGE_HEIGHT - 2 * PAGE_MARGIN2,
        id='PagesFrame2',
    )  #showBoundary=Color(0, 0, 1))
    page_template_1 = PageTemplate(
        id='Page1',
        frames=[
            page_frame_1,
        ],
    )
    page_template_2 = PageTemplate(
        id='Page2',
        frames=[
            page_frame_2,
        ],
    )
    doc = BaseDocTemplate(
        invoice_buffer,
        pageTemplates=[page_template_1, page_template_2],
        pagesize=A4,
    )  # showBoundary=Color(1, 0, 0))

    # Common
    FONT_SIZE_L = 11
    FONT_SIZE_M = 10
    FONT_SIZE_S = 8

    styles = StyleSheet1()
    styles.add(
        ParagraphStyle(
            name='Normal',
            fontName='Helvetica',
            fontSize=FONT_SIZE_M,
            spaceBefore=7,  # space before paragraph
            spaceAfter=7,  # space after paragraph
            leading=12))  # space between lines
    styles.add(
        ParagraphStyle(name='BodyText', parent=styles['Normal'],
                       spaceBefore=6))
    styles.add(
        ParagraphStyle(name='Italic',
                       parent=styles['BodyText'],
                       fontName='Helvetica-Italic'))
    styles.add(
        ParagraphStyle(name='Bold',
                       parent=styles['BodyText'],
                       fontName='Helvetica-Bold',
                       alignment=TA_CENTER))
    styles.add(
        ParagraphStyle(name='Right',
                       parent=styles['BodyText'],
                       alignment=TA_RIGHT))
    styles.add(
        ParagraphStyle(name='Centre',
                       parent=styles['BodyText'],
                       alignment=TA_CENTER))

    # Logo
    dpaw_header_logo = ImageReader(DPAW_HEADER_LOGO)
    dpaw_header_logo_size = dpaw_header_logo.getSize()
    width = dpaw_header_logo_size[0] / 2
    height = dpaw_header_logo_size[1] / 2
    dbca_logo = Image(DPAW_HEADER_LOGO, width=width, height=height)

    # Table
    invoice_table_style = TableStyle([
        ('VALIGN', (0, 0), (-1, -1), 'TOP'),
        ('GRID', (0, 0), (-1, -1), 1, colors.black),
        ('ALIGN', (0, 0), (-1, -1), 'LEFT'),
        ('SPAN', (0, 0), (1, 0)),

        # Alleged offender
        ('SPAN', (0, 1), (0, 5)),
        ('SPAN', (1, 1), (2, 1)),
        ('SPAN', (1, 2), (2, 2)),
        ('SPAN', (1, 3), (2, 3)),
        ('SPAN', (1, 4), (2, 4)),
        ('SPAN', (1, 5), (2, 5)),

        # When
        ('SPAN', (1, 6), (2, 6)),

        # Where
        ('SPAN', (1, 7), (2, 7)),

        # Alleged offence
        ('SPAN', (0, 8), (0, 9)),
        ('SPAN', (1, 8), (2, 8)),
        # ('SPAN', (1, 9), (2, 9)),
        ('SPAN', (1, 9), (2, 9)),
        # ('SPAN', (1, 10), (2, 10)),

        # Officer issuing notice
        ('SPAN', (0, 10), (0, 12)),
        ('SPAN', (1, 10), (2, 10)),
        ('SPAN', (1, 11), (2, 11)),
        ('SPAN', (1, 12), (2, 12)),

        # Date
        ('SPAN', (1, 13), (2, 13)),

        # Notice to alleged offender
        ('SPAN', (1, 14), (2, 14)),
    ])
    date_str = gap(10) + '/' + gap(10) + '/ 20'
    col_width = [
        40 * mm,
        60 * mm,
        80 * mm,
    ]

    data = []
    data.append([
        Paragraph(
            '<i>Biodiversity Conservation Act 2016</i><br /><strong><font size="'
            + str(FONT_SIZE_L) + '">Caution Notice</font></strong>',
            styles['Normal']), '',
        Paragraph(
            u'Caution<br />notice no. ' +
            get_font_str(sanction_outcome.lodgement_number), styles['Normal'])
    ])

    # Alleged offender
    offender = sanction_outcome.get_offender()
    offender_dob = offender[0].dob.strftime(
        '%d/%m/%Y') if offender[0].dob else ''
    data.append([
        Paragraph('Alleged offender', styles['Bold']),
        Paragraph('Name: Family name: ' + get_font_str(offender[0].last_name),
                  styles['Normal']), ''
    ])
    data.append([
        '',
        Paragraph(
            gap(12) + 'Given names: ' + get_font_str(offender[0].first_name),
            styles['Normal']), ''
    ])
    data.append([
        '',
        Paragraph(
            gap(12) + 'Date of Birth: ' + get_font_str(offender_dob),
            styles['Normal']), ''
    ])
    data.append([
        '',
        [
            Paragraph('<strong>or</strong><br />Body corporate name',
                      styles['Normal']),
            Spacer(1, 25)
        ], ''
    ])
    # data.append(['', [Paragraph('Address', styles['Normal']), Spacer(1, 25), Paragraph('Postcode', styles['Normal'])], ''])
    postcode = offender[0].residential_address.postcode if offender[
        0].residential_address else ''
    data.append([
        '',
        [
            Paragraph('Address: ', styles['Normal']),
            Paragraph(get_font_str(str(offender[0].residential_address)),
                      styles['Normal']),
            Paragraph('Postcode: ' + get_font_str(postcode), styles['Normal']),
        ],
        '',
    ])

    # When
    # data.append([Paragraph('When', styles['Bold']), Paragraph('Date' + date_str + gap(5) + 'Time' + gap(10) + 'am/pm', styles['Normal']), ''])
    offence_datetime = sanction_outcome.offence.offence_occurrence_datetime
    data.append([
        Paragraph('When', styles['Bold']),
        Paragraph(
            'Date: ' + get_font_str(offence_datetime.strftime('%d/%m/%Y')) +
            gap(5) + 'Time: ' +
            get_font_str(offence_datetime.strftime('%I:%M %p')),
            styles['Normal']), ''
    ])

    # Where
    # data.append([Paragraph('Where', styles['Bold']), [Paragraph('Location of offence', styles['Normal']), Spacer(1, 25)], ''])
    offence_location = sanction_outcome.offence.location
    offence_location_str = str(offence_location) if offence_location else ''
    data.append([
        Paragraph('Where', styles['Bold']),
        [
            Paragraph('Location of offence', styles['Normal']),
            Paragraph(get_font_str(offence_location_str), styles['Normal']),
            Spacer(1, 25)
        ],
        '',
    ])

    # Alleged offence
    data.append([
        Paragraph('Alleged offence', styles['Bold']),
        [
            Paragraph('Description of offence', styles['Normal']),
        ], ''
    ])  # row index: 8
    # data.append(['', rect, ''])
    # data.append(['', '?', ''])
    data.append([
        '',
        Paragraph(
            '<i>Biodiversity Conservation Act 2016 s.</i>' + gap(10) +
            'or<br /><i>Biodiversity Conservation Regulations 2018 r.</i>',
            styles['Normal']), ''
    ])

    # Officer issuing notice
    # data.append([Paragraph('Officer issuing notice', styles['Bold']), Paragraph('Name', styles['Normal']), ''])  # row index: 12
    data.append([
        Paragraph('Officer issuing notice', styles['Bold']),
        Paragraph(
            'Name: {}'.format(
                get_font_str(
                    sanction_outcome.responsible_officer.get_full_name())),
            styles['Normal']), ''
    ])  # row index: 12
    data.append(['', Paragraph('Signature', styles['Normal']), ''])
    data.append(['', Paragraph('Officer no.', styles['Normal']), ''])

    # Date
    issue_date = get_font_str(
        sanction_outcome.date_of_issue.strftime('%d/%m/%Y'))
    issue_time = get_font_str(
        sanction_outcome.time_of_issue.strftime('%I:%M %p'))
    data.append([
        Paragraph('Date', styles['Bold']),
        Paragraph('Date of notice: ' + issue_date + ' ' + issue_time,
                  styles['Normal']), ''
    ])

    # Notice to alleged offender
    body = []
    body.append(
        Paragraph(
            'It is alleged that you have committed the above offence.</p>',
            styles['Normal']))
    body.append(
        Paragraph(
            'If you object to the issue of this notice you can apply in writing to the Approved Officer at the below address for a review within 28 days after the date of this notice.',
            styles['Normal']))
    body.append(
        Paragraph(
            'Approved Officer — <i>Biodiversity Conservation Act 2016</i><br />Department of Biodiversity, Conservation and Attractions<br />Locked Bag 104<br />Bentley Delivery Centre WA 6983',
            styles['Normal']))
    data.append(
        [Paragraph('Notice to alleged offender', styles['Bold']), body, ''])

    # Create 1st table
    t1 = Table(data, style=invoice_table_style, colWidths=col_width)

    # Append tables to the elements to build
    gap_between_tables = 1.5 * mm
    elements = []
    elements.append(dbca_logo)
    elements.append(Spacer(0, 5 * mm))
    elements.append(t1)
    elements.append(NextPageTemplate([
        'Page2',
    ]))
    elements.append(PageBreak())
    elements.append(dbca_logo)
    elements.append(Spacer(0, 5 * mm))
    # ORIGINAL NOTES OF INCIDENT:
    title_original_notes = Paragraph(
        '<font size="' + str(FONT_SIZE_L) +
        '"><strong>ORIGINAL NOTES OF INCIDENT:</strong></font>',
        styles['Normal'])
    elements.append(title_original_notes)
    elements.append(Spacer(0, 10 * mm))
    for i in range(0, 25):
        elements.append(BrokenLine(170 * mm, 8 * mm))
    elements.append(
        Paragraph(
            '<font size="' + str(FONT_SIZE_L) + '"><strong>Signature: ' +
            gap(80) + 'Date:</strong></font>', styles['Normal']))

    doc.build(elements)
    return invoice_buffer
def _create_pdf(invoice_buffer, sanction_outcome):
    MARGIN_TOP = 5
    MARGIN_BOTTOM = 5
    every_page_frame = Frame(PAGE_MARGIN, MARGIN_TOP, PAGE_WIDTH - 2 * PAGE_MARGIN, PAGE_HEIGHT - (MARGIN_TOP + MARGIN_BOTTOM), id='EveryPagesFrame',)  # showBoundary=Color(0, 1, 0))
    # every_page_frame2 = Frame(PAGE_MARGIN, PAGE_MARGIN, PAGE_WIDTH - 2 * PAGE_MARGIN, PAGE_HEIGHT - 2 * PAGE_MARGIN, id='EveryPagesFrame2',)  # showBoundary=Color(0, 0, 1))
    every_page_template = PageTemplate(id='EveryPages', frames=[every_page_frame,], )
    # every_page_template2 = PageTemplate(id='EveryPages2', frames=[every_page_frame2,], )
    doc = BaseDocTemplate(invoice_buffer, pageTemplates=[every_page_template, ], pagesize=A4,)  # showBoundary=Color(1, 0, 0))
    # doc = BaseDocTemplate(invoice_buffer, pageTemplates=[every_page_template, every_page_template2,], pagesize=A4,)  # showBoundary=Color(1, 0, 0))

    # Logo
    dpaw_header_logo = ImageReader(DPAW_HEADER_LOGO)
    dpaw_header_logo_size = dpaw_header_logo.getSize()
    width = dpaw_header_logo_size[0]/2
    height = dpaw_header_logo_size[1]/2
    dbca_logo = Image(DPAW_HEADER_LOGO, width=width, height=height)

    # 1st page
    t1 = get_infringement_notice_table(sanction_outcome)

    # 2nd page
    title_evidential_notes = Paragraph('<strong>EVIDENTIAL NOTES:</strong>', styles['Normal'])

    # table
    col_width = [40*mm, 35*mm, 22*mm, 31*mm, 37*mm, ]
    invoice_table_style = TableStyle([
        ('VALIGN', (0, 0), (-1, -1), 'MIDDLE'),
        ('GRID', (0, 0), (-1, -1), 0.5, colors.black),
        ('ALIGN', (0, 0), (-1, -1), 'LEFT'),
        ('SPAN', (1, 0), (4, 0)),
        ('SPAN', (1, 1), (4, 1)),
        ('SPAN', (1, 2), (4, 2)),
        ('SPAN', (1, 3), (4, 3)),
        ('SPAN', (2, 5), (3, 5)),
        ('SPAN', (2, 6), (4, 6)),
    ])
    data = []
    rego = sanction_outcome.registration_number if sanction_outcome.registration_number else ''
    data.append([
        Paragraph('<strong>Registration number<br />vehicle/vessel:</strong>', styles['Normal']),
        Paragraph(get_font_str(rego), styles['Normal']),
        '', '', '',
    ])
    data.append([
        Paragraph('<strong>Make:</strong>', styles['Normal']),
        '', '', '', '',
    ])
    data.append([
        Paragraph('<strong>Model:</strong>', styles['Normal']),
        '', '', '', '',
    ])
    data.append([
        Paragraph('<strong>Type: i.e SUV etc</strong>', styles['Normal']),
        '', '', '', '',
    ])

    data.append([
        Paragraph('<strong>Photograph(s) taken:</strong>', styles['Normal']),
        YesNoCheckbox(11, 11, fontName='Helvetica'),
        Paragraph('<strong>Attached:</strong>', styles['Normal']),
        YesNoCheckbox(11, 11, fontName='Helvetica'),
        Paragraph('<strong>Number:</strong>', styles['Normal']),
    ])
    data.append([
        Paragraph('<strong>Gender:<br />Tick relevant box</strong>', styles['Normal']),
        ParagraphCheckbox('Male', styles['Normal'],),
        ParagraphCheckbox('Female', styles['Normal'], ),
        '',
        ParagraphCheckbox('Other/unknown', styles['Normal'], ),
    ])
    data.append([
        Paragraph('<strong>Identification<br />produced:</strong>', styles['Normal']),
        YesNoCheckbox(11, 11, fontName='Helvetica'),
        Paragraph('<strong>If Yes, provide details:</strong>', styles['Normal']),
        '', '',
    ])
    t2 = Table(data, style=invoice_table_style, colWidths=col_width)

    title_original_notes = Paragraph('<strong>ORIGINAL NOTES OF INCIDENT:</strong>', styles['Normal'])

    elements = []
    elements.append(dbca_logo)
    elements.append(t1)
    elements.append(PageBreak())
    elements.append(dbca_logo)
    elements.append(title_evidential_notes)
    elements.append(Spacer(0, 5*mm))
    elements.append(t2)
    elements.append(Spacer(0, 5*mm))
    elements.append(title_original_notes)
    for i in range(0, 23):
        elements.append(SolidLine(440, 0, dashed=True, wrap_height=20))
    elements.append(Spacer(0, 10*mm))
    elements.append(Paragraph('<strong>Signature:</strong>' + gap(50) + '<strong>Date:</strong>', styles['Normal']))

    doc.build(elements)
    return invoice_buffer
def _create_pdf(invoice_buffer, sanction_outcome):
    PAGE_MARGIN = 5 * mm
    page_frame_1 = Frame(
        PAGE_MARGIN,
        PAGE_MARGIN,
        PAGE_WIDTH - 2 * PAGE_MARGIN,
        PAGE_HEIGHT - 2 * PAGE_MARGIN,
        id='PagesFrame1',
    )  #showBoundary=Color(0, 1, 0))
    page_template_1 = PageTemplate(
        id='Page1',
        frames=[
            page_frame_1,
        ],
    )
    doc = BaseDocTemplate(
        invoice_buffer,
        pageTemplates=[
            page_template_1,
        ],
        pagesize=A4,
    )  # showBoundary=Color(1, 0, 0))

    # Common
    FONT_SIZE_L = 11
    FONT_SIZE_M = 10
    FONT_SIZE_S = 8

    styles = StyleSheet1()
    styles.add(
        ParagraphStyle(
            name='Normal',
            fontName='Helvetica',
            fontSize=FONT_SIZE_M,
            spaceBefore=7,  # space before paragraph
            spaceAfter=7,  # space after paragraph
            leading=12))  # space between lines
    styles.add(
        ParagraphStyle(name='BodyText', parent=styles['Normal'],
                       spaceBefore=6))
    styles.add(
        ParagraphStyle(name='Italic',
                       parent=styles['BodyText'],
                       fontName='Helvetica-Italic'))
    styles.add(
        ParagraphStyle(name='Bold',
                       parent=styles['BodyText'],
                       fontName='Helvetica-Bold',
                       alignment=TA_CENTER))
    styles.add(
        ParagraphStyle(name='Right',
                       parent=styles['BodyText'],
                       alignment=TA_RIGHT))
    styles.add(
        ParagraphStyle(name='Centre',
                       parent=styles['BodyText'],
                       alignment=TA_CENTER))

    # Logo
    dpaw_header_logo = ImageReader(DPAW_HEADER_LOGO)
    dpaw_header_logo_size = dpaw_header_logo.getSize()
    width = dpaw_header_logo_size[0] / 2
    height = dpaw_header_logo_size[1] / 2
    dbca_logo = Image(DPAW_HEADER_LOGO, width=width, height=height)

    # Title
    title_remediation_notice = Paragraph(
        '<font size="' + str(FONT_SIZE_L) +
        '"><strong>REMEDIATION NOTICE</strong></font>', styles['Centre'])

    # Table
    invoice_table_style = TableStyle([
        ('VALIGN', (0, 0), (-1, -1), 'TOP'),
        ('GRID', (0, 0), (-1, -1), 1, colors.black),
        ('ALIGN', (0, 0), (-1, -1), 'LEFT'),
    ])
    date_str = gap(10) + '/' + gap(10) + '/ 20'
    col_width = [
        180 * mm,
    ]

    offender = sanction_outcome.get_offender()

    data = []
    p_number = get_font_str(str(offender[0].phone_number) +
                            '(p)') if offender[0].phone_number else ''
    m_number = get_font_str(offender[0].mobile_number +
                            '(m)') if offender[0].mobile_number else ''
    phone_number = ' | '.join(list(filter(None, [p_number, m_number])))
    dob = offender[0].dob.strftime('%d/%m/%Y') if offender[0].dob else ''
    data.append([
        [
            Paragraph(
                'Pursuant to the <i>Biodiversity Conservation Act 2016</i>, the CEO considers that you are a person bound by a relevant instrument.<br />'
                '<strong>Contact details of person to whom this Notice is issued:</strong>',
                styles['Normal']),
            Paragraph(
                'Full name: ' + get_font_str(offender[0].get_full_name()) +
                gap(5) + 'Date of Birth: ' + get_font_str(dob),
                styles['Normal']),
            Paragraph(
                'Postal/Residential address: ' +
                get_font_str(offender[0].residential_address),
                styles['Normal']),
            Paragraph('Telephone number: ' + phone_number, styles['Normal']),
            Paragraph('Email address: ' + get_font_str(offender[0].email),
                      styles['Normal']),
        ],
    ])
    data.append([
        [
            Paragraph(
                'The CEO is of the opinion that you have contravened the relevant instrument listed below:',
                styles['Normal']),
            Table([
                [
                    Paragraph('<strong>Relevant Instrument</strong>',
                              styles['Normal']),
                    Paragraph(
                        '<strong>Reference Number of Instrument/Notice</strong>',
                        styles['Normal'])
                ],
                [
                    Paragraph('Biodiversity Conservation Covenant',
                              styles['Normal']), ''
                ],
                [Paragraph('Environment Pest Notice', styles['Normal']), ''],
                [
                    Paragraph('Habitat Conservation Notice', styles['Normal']),
                    ''
                ],
            ],
                  style=invoice_table_style,
                  rowHeights=[6 * mm, 12 * mm, 12 * mm, 12 * mm])
        ],
    ])
    data.append([
        [
            Paragraph(
                'You are required to undertake one or more of the following action(s) to comply with the named instrument:',
                styles['Normal']),
            Paragraph(
                'a) Stop anything that is being done in contravention of the instrument; and<br />'
                'b) Do anything required by the instrument to be done that has not been done; and<br />'
                'c) Carry out work that is necessary to remedy anything done in contravention of the instrument; and<br />'
                'd) Do anything incidental to action referred to in (a), (b), or (c) above',
                styles['Normal'])
        ],
    ])

    # Actions
    actions = []
    actions.append(
        Paragraph(
            'List the remedial actions necessary to afford compliance with the relevant instrument:',
            styles['Normal']))
    for ra in sanction_outcome.remediation_actions.all():
        actions.append(Paragraph(get_font_str(ra.action), styles['Normal']))
    data.append([
        actions,
    ])
    data.append([
        [
            Paragraph(
                '<strong>IMPORTANT</strong>: You must comply with the remediation action(s) listed above within the period specified in this notice.',
                styles['Normal']),
            Paragraph(
                'If you do not comply within the specified period, the CEO may take any necessary remedial action and may recover the reasonable costs incurred in taking remedial action from you, as a person(s) bound by the relevant instrument, in a court of competent jurisdiction as a debt to the State.',
                styles['Normal']),
            Paragraph(
                'Postal Address of the CEO:<br />Department of Biodiversity, Conservation and Attractions<br />Locked Bag 104<br />Bentley Delivery Centre WA 6983',
                styles['Normal']),
        ],
    ])
    data.append([
        [
            Paragraph('<strong>Notes:</strong>:', styles['Normal']),
            Paragraph(
                'A separate Remediation Notice must be issued to each person bound by the instrument.:',
                styles['Normal'],
                bulletText='-'),
            Paragraph(
                'For the purpose of taking remedial action a wildlife officer may enter on land with or without vehicles, plant or equipment and remain on that land for as long as is necessary to complete the remedial action.',
                styles['Normal'],
                bulletText='-'),
            Paragraph(
                'A wildlife officer must not exercise a power to enter unless they first obtain the consent of the owner or occupier of the land, or the owner/occupier has been given reasonable notice of the proposed entry and has not objected to the entry, or the entry is in accordance with an entry warrant. Section 202 of the Biodiversity Conservation Act 2016 applies. (Occupiers Rights)',
                styles['Normal'],
                bulletText='-',
            )
        ],
    ])

    t1 = Table(data,
               style=invoice_table_style,
               colWidths=col_width,
               rowHeights=[
                   60 * mm,
                   60 * mm,
                   40 * mm,
                   90 * mm,
                   60 * mm,
                   60 * mm,
               ])

    # Append tables to the elements to build
    gap_between_tables = 1.5 * mm
    elements = []
    elements.append(dbca_logo)
    elements.append(title_remediation_notice)
    elements.append(t1)

    doc.build(elements)
    return invoice_buffer
def _create_pdf(invoice_buffer, sanction_outcome):
    PAGE_MARGIN = 5 * mm
    page_frame_1 = Frame(PAGE_MARGIN, PAGE_MARGIN, PAGE_WIDTH - 2 * PAGE_MARGIN, PAGE_HEIGHT - 2 * PAGE_MARGIN, id='PagesFrame1', )  #showBoundary=Color(0, 1, 0))
    page_template_1 = PageTemplate(id='Page1', frames=[page_frame_1, ], )
    doc = BaseDocTemplate(invoice_buffer, pageTemplates=[page_template_1, ], pagesize=A4,)  # showBoundary=Color(1, 0, 0))

    # Common
    FONT_SIZE_L = 11
    FONT_SIZE_M = 10
    FONT_SIZE_S = 8

    styles = StyleSheet1()
    style_normal = ParagraphStyle(name='Normal',
                                  fontName='Helvetica',
                                  fontSize=FONT_SIZE_M,
                                  spaceBefore=7,  # space before paragraph
                                  spaceAfter=7,   # space after paragraph
                                  leading=12)       # space between lines
    styles.add(style_normal)
    styles.add(ParagraphStyle(name='BodyText',
                              parent=styles['Normal'],
                              spaceBefore=6))
    styles.add(ParagraphStyle(name='Italic',
                              parent=styles['BodyText'],
                              fontName='Helvetica-Italic'))
    styles.add(ParagraphStyle(name='Bold',
                              parent=styles['BodyText'],
                              fontName='Helvetica-Bold',
                              alignment = TA_CENTER))
    styles.add(ParagraphStyle(name='Right',
                              parent=styles['BodyText'],
                              alignment=TA_RIGHT))
    styles.add(ParagraphStyle(name='Centre',
                              parent=styles['BodyText'],
                              alignment=TA_CENTER))

    # Logo
    dpaw_header_logo = ImageReader(DPAW_HEADER_LOGO)
    dpaw_header_logo_size = dpaw_header_logo.getSize()
    width = dpaw_header_logo_size[0]/2
    height = dpaw_header_logo_size[1]/2
    dbca_logo = Image(DPAW_HEADER_LOGO, width=width, height=height)

    # Table
    invoice_table_style = TableStyle([
        ('VALIGN', (0, 0), (-1, -1), 'TOP'),
        ('VALIGN', (1, 3), (1, 3), 'MIDDLE'),
        ('GRID', (0, 0), (-1, -1), 0.5, colors.black),
        ('ALIGN', (0, 0), (-1, -1), 'LEFT'),
        ('SPAN', (1, 1), (2, 1)),
        ('SPAN', (0, 2), (0, 3)),
        ('SPAN', (1, 4), (2, 4)),
        ('SPAN', (1, 5), (2, 5)),
        ('SPAN', (1, 6), (2, 6)),
        ('SPAN', (1, 7), (2, 7)),
        ('SPAN', (1, 8), (2, 8)),
    ])
    date_str = gap(10) + '/' + gap(10) + '/'
    col_width = [30*mm, 125*mm, 25*mm, ]

    data = []
    data.append([
        Paragraph('<strong>Western Australia</strong>', style_normal),
        Paragraph('<i>Biodiversity Conservation Act 2016</i><br /><strong>Obtaining Records and Directions</strong>', style_normal),
        Paragraph('<strong>No.</strong><br />' + get_font_str(str(sanction_outcome.lodgement_number)), style_normal),
    ])
    offender = sanction_outcome.get_offender()
    data.append([
        Paragraph('<strong>To</strong>', style_normal),
        [
            Paragraph('Given names: ' + get_font_str(offender[0].first_name), style_normal),
            Paragraph('Surname: ' + get_font_str(offender[0].last_name), style_normal),
            Spacer(0, 3*mm),
        ],
        '',
    ])
    fields = [offender[0].residential_address.line1, offender[0].residential_address.line2, offender[0].residential_address.line3] if offender[0].residential_address else []
    fields = [unicode_compatible(f).encode('utf-8').decode('unicode-escape').strip() for f in fields if f]
    no_and_street = ', '.join(fields)
    postcode = offender[0].residential_address.postcode if offender[0].residential_address else ''
    town_suburb = offender[0].residential_address.locality if offender[0].residential_address else ''
    data.append([
        Paragraph('<strong>Address</strong>', style_normal),
        [
            Paragraph('No and Street: <br />' + get_font_str(str(no_and_street)), style_normal),
            Paragraph('Town/Suburb: <br />' + get_font_str(town_suburb), style_normal),
        ],
        Paragraph('Post Code: <br />' + get_font_str(postcode), style_normal),
    ])
    offender_dob = offender[0].dob.strftime('%d/%m/%Y') if offender[0].dob else ''
    data.append(([
        '',
        Paragraph('Date of Birth: ' + get_font_str(offender_dob), style_normal),
        [
            Paragraph('Gender:', style_normal),
            Paragraph('M' + gap(3) + 'F' + gap(3) + 'U', style_normal),
        ],
    ]))
    data.append([
        Paragraph('<strong>Direction<br /><br />* Delete as appropriate.<br /><br /># Enter details of direction given.</strong>', style_normal),
        [Paragraph('Under the <strong><i>Biodiversity Conservation Act 2016 s204(2) (a), (b), (d)*</i></strong>, I direct you to - #<br />', style_normal),
         Spacer(0, 20*mm),
         Paragraph('Under the <strong><i>Biodiversity Conservation Act 2016 s205(2)</i></strong>, I direct you to - #', style_normal),
         Spacer(0, 20*mm),
         ],
        '',
    ])
    data.append([
        Paragraph('<strong>Warning</strong>', style_normal),
        Paragraph('<strong>If you do not obey this direction you may be liable to a fine of $10,000.00.</strong>', style_normal),
        '',
    ])
    region_district = ' / '.join(list(filter(None, [get_font_str(sanction_outcome.district), get_font_str(sanction_outcome.region)])))
    data.append([
        Paragraph('<strong>Issuing officer’s signature and details</strong>', style_normal),
        [
            Paragraph('I issue this direction on this date and at this time<br />'
                      'Date: ' + get_font_str(sanction_outcome.date_of_issue.strftime('%d/%m/%Y')) + '<br />'
                      'Time: ' + get_font_str(sanction_outcome.time_of_issue.strftime('%I:%M %p')), style_normal),
            Paragraph('Name and AO Number: ' + get_font_str(sanction_outcome.responsible_officer.get_full_name()), style_normal),
            Paragraph('Signature', style_normal),
            Paragraph('District/Region: ' + region_district, style_normal),
        ],
        '',
    ])
    # Paragraph('District/Region: ' + get_font_str(sanction_outcome.district) + ' / ' + get_font_str(sanction_outcome.region), style_normal),
    data.append([
        Paragraph('<strong>Witnessing officer</strong>', style_normal),
        [
            Paragraph('Name and AO Number:', style_normal),
            Paragraph('Signature: ', style_normal),
            Paragraph('District/Region:', style_normal),
        ],
        '',
    ])
    data.append([
        Paragraph('<strong>Recipient\'s signature [Optional]</strong>', style_normal),
        Paragraph('I acknowledge receiving this direction. I understand what it says', style_normal),
        ''
    ])
    t1 = Table(data, style=invoice_table_style, colWidths=col_width, )

    # Table 2
    col_width = [30*mm, 150*mm, ]
    col_width_internal = [15*mm, 130*mm, ]
    invoice_table_style = TableStyle([
        ('VALIGN', (0, 0), (-1, -1), 'TOP'),
        ('GRID', (0, 0), (-1, -1), 0.5, colors.black),
        ('ALIGN', (0, 0), (-1, -1), 'LEFT'),
        ('TOPPADDING', (0, 0), (-1, -1), 2),
        ('BOTTOMPADDING', (0, 0), (-1, -1), 2),
        ('BACKGROUND', (0, 0), (1, 0), (0.8, 0.8, 0.8)),
        ('SPAN', (0, 0), (1, 0)),
        ('SPAN', (0, 1), (1, 1)),
        ('BACKGROUND', (0, 5), (1, 5), (0.8, 0.8, 0.8)),
        ('SPAN', (0, 5), (1, 5)),
        ('SPAN', (0, 6), (1, 6)),
    ])
    data = []
    data.append([
        Paragraph('<strong>Section 204 - Obtaining records:</strong>', styles['Centre']),
        '',
    ])
    data.append([
        Paragraph('For inspection purposes a wildlife officer may do one or more of the following -', styles['Centre']),
        '',
    ])
    tbl_style_internal = TableStyle([
        ('VALIGN', (0, 0), (-1, -1), 'TOP'),
        ('ALIGN', (0, 0), (-1, -1), 'LEFT'),
    ])
    data.append([
        Paragraph('s204(2)(a)', style_normal),
        Table([[
            Paragraph('a)', styles['Right']),
            Paragraph('direct a person who has the custody or control of a record to give the wildlife officer the record or a copy of it;', style_normal),
        ]], style=tbl_style_internal, colWidths=col_width_internal),
    ])
    data.append([
        Paragraph('s204(2)(b)', style_normal),
        Table([[
            Paragraph('b)', styles['Right']),
            Paragraph('direct a person who has the custody or control of a record, computer or thing to make or print out a copy of the record or to operate the computer or thing;', style_normal),
        ]], style=tbl_style_internal, colWidths=col_width_internal),
    ])
    data.append([
        Paragraph('s204(2)(d)', style_normal),
        Table([[
            Paragraph('d)', styles['Right']),
            Paragraph('direct a person who is or appears to be in control of a record that the wildlife officer reasonably suspects is a relevant record to give the wildlife officer a translation, code, password or other information necessary to gain access to or interpret and understand the record.', style_normal),
        ]], style=tbl_style_internal, colWidths=col_width_internal),
    ])
    data.append([
        Paragraph('<strong>Section 205 - Directions</strong>', styles['Centre']),
        '',
    ])
    data.append([
        Paragraph('A wildlife officer may do one or more of the following -', styles['Centre']),
        '',
    ])
    data.append([
        Paragraph('s205(2)(a)(i)<br />s205(2)(a)(ii)', style_normal),
        [ Paragraph('For inspection purposes direct an occupier of a place or vehicle, or a person who is or appears to be in possession or control of a thing, to give to the wildlife officer, orally or in writing -', style_normal),
            Table([
                [
                    Paragraph('(i)', styles['Right']),
                    Paragraph(
                        'any information in the person’s possession or control as to the name and address of the owner of the place, vehicle or thing; and',
                        style_normal),
                ],
                [
                    Paragraph('(ii)', styles['Right']),
                    Paragraph(
                        'any other information in the person’s possession or control that is relevant to an inspection',
                        style_normal),
                ],
            ], style=tbl_style_internal, colWidths=col_width_internal),
        ],
    ])
    data.append([
        Paragraph('s205(2)(b)', style_normal),
        Paragraph('For inspection purposes direct a person who is or appears to be in possession or control of an organism or potential carrier to give the wildlife officer any information in the person’s possession or control as to the name and address of any person from whom the organism or potential carrier or to whom a similar organism or potential carrier has been supplied;', style_normal),
    ])
    data.append([
        Paragraph('s205(2)(c)', style_normal),
        Paragraph('For inspection purposes direct an occupier of a place or vehicle to answer questions;', style_normal),
    ])
    data.append([
        Paragraph('s205(2)(d)', style_normal),
        Paragraph('For inspection purposes direct an occupier of a place or vehicle to produce a specified thing or a thing of a specified kind;', style_normal),
    ])
    data.append([
        Paragraph('s205(2)(e)', style_normal),
        Paragraph('For inspection purposes direct an occupier of a place or vehicle to open or unlock any thing in or on the place or vehicle to which the wildlife officer requires access;', style_normal),
    ])
    data.append([
        Paragraph('s205(2)(f)', style_normal),
        Paragraph('Direct an occupier of a place or vehicle to give the wildlife officer a plan, or access to a plan, of the place or vehicle;', style_normal),
    ])
    data.append([
        Paragraph('s205(2)(g)', style_normal),
        Paragraph('Direct an occupier of a place or vehicle, or a person who is or appears to be in possession or control of a thing, to give the wildlife officer any assistance that the wildlife officer reasonably needs to carry out the wildlife officer’s functions in relation to the place, vehicle or thing;', style_normal),
    ])
    data.append([
        Paragraph('s205(2)(h)', style_normal),
        Paragraph('Direct an occupier of a vehicle to move the vehicle to a specified place for inspection or treatment;', style_normal),
    ])
    data.append([
        Paragraph('s205(2)(i)', style_normal),
        Paragraph('direct a person who is or could be carrying an organism or potential carrier to go to a specified place for inspection or treatment;', style_normal),
    ])
    data.append([
        Paragraph('s205(2)(j)', style_normal),
        Paragraph('Direct a person who is or appears to be in control of a consignment of goods or a potential carrier to move the consignment or potential carrier to a specified place for inspection or treatment;', style_normal),
    ])
    data.append([
        Paragraph('s205(2)(k)', style_normal),
        Paragraph('Direct a person who is or appears to be in control of an organism to do anything necessary to identify the organism;', style_normal),
    ])
    data.append([
        Paragraph('s205(2)(l)', style_normal),
        Paragraph('Direct a person who is or appears to be in control of an animal to restrain, muster, round up, yard, draft or otherwise move or handle the animal or to remove the animal to a specified place for inspection or treatment;', style_normal),
    ])
    data.append([
        Paragraph('s205(2)(m)', style_normal),
        Paragraph('Direct a person who is or appears to be in control of any goods, vehicle, package or container to label it;', style_normal),
    ])
    data.append([
        Paragraph('s205(2)(n)', style_normal),
        Paragraph('Direct a person who is or appears to be in control of an organism, potential carrier or other thing prohibited, controlled, regulated or managed under this Act to keep that organism, potential carrier or other thing in the possession of that person until further directed by the wildlife officer;', style_normal),
    ])
    data.append([
        Paragraph('s205(2)(o)', style_normal),
        Paragraph('Direct a person who is or appears to be in control of an organism, potential carrier or other thing prohibited, controlled, regulated or managed under this Act to leave that organism, potential carrier or other thing at a specified place until further directed by the wildlife officer.', style_normal),
    ])
    t2 = Table(data, style=invoice_table_style, colWidths=col_width, )


    # Append tables to the elements to build
    elements = []
    elements.append(dbca_logo)
    elements.append(Spacer(0, 5*mm))
    elements.append(t1)
    elements.append(PageBreak())
    elements.append(Spacer(0, 10*mm))
    elements.append(t2)

    doc.build(elements)
    return invoice_buffer