How to make LibreOffice Calc automatically print after scanning a barcode in a cell

Hi everyone, I connected a scanner to a Raspberry Pi 3 B+. The Pi was connected to a printer for printing the sheet.

I expect that the sheet will be automatically printed out after I scan a barcode to enter data in a specific cell (for example A1) on the sheet. I then don’t need to manually print.

Appreciate if anyone would have suggestions!

You need add code in event Content changed in events sheet.

Sub content_changed(source)

    If source.ImplementationName <> "ScCellObj" Then
        Exit Sub
    End If

    ca = source.CellAddress
    rem Cell A1
    If ca.Column = 0 And ca.Row = 0 Then
        ThisComponent.Print(Array())
    End If

End Sub

CAUTION: Your print area in your sheet should be correctly set

Thanks a lot! I have no coding experiences. Need to learn a lot!