/////////////////////////////////////////////////////////////////////
        // create pdf417 barcode image file
        /////////////////////////////////////////////////////////////////////

        private void OnEncode(object sender, EventArgs e)
        {
            // get bar width
            if (!int.TryParse(BarWidthTextBox.Text.Trim(), out int BarWidth) || BarWidth < 1 || BarWidth > 20)
            {
                MessageBox.Show("Narrow bar width must be 1 to 20 pixels");
                return;
            }

            // get row height
            if (!int.TryParse(RowHeightTextBox.Text.Trim(), out int RowHeight) || RowHeight < 3 * BarWidth || RowHeight > 60)
            {
                MessageBox.Show("Row height must be 3 times bar width or more in pixels");
                return;
            }

            // get quiet zone
            if (!int.TryParse(QuietZoneTextBox.Text.Trim(), out int QuietZone) || QuietZone < 2 * BarWidth || RowHeight > 40)
            {
                MessageBox.Show("Quiet zone must be 2 times bar width or more in pixels");
                return;
            }

            // get default data columns
            if (!int.TryParse(DefDataColTextBox.Text.Trim(), out int DefDataColumns) || DefDataColumns < 1 || DefDataColumns > 30)
            {
                MessageBox.Show("Number of data columns must be 1 to 30");
                return;
            }

            // disable buttons
            EnableButtons(false);

            // clear current image
            Pdf417Bitmap = null;

            // trap encoding errors
            try
            {
                // encoding request
                Encoder.EncodingControl = (EncodingControl)EncodingComboBox.SelectedIndex;

                // error correction request
                Encoder.ErrorCorrection = (ErrorCorrectionLevel)ErrorCorrectionComboBox.SelectedIndex;

                // language or character set
                int Part = CharacterSetComboBox.SelectedIndex;
                if (Part == 10)
                {
                    Part = 15;
                }
                else if (Part == 9)
                {
                    Part = 13;
                }
                else
                {
                    Part++;
                }
                Encoder.GlobalLabelIDCharacterSet = string.Format("ISO-8859-{0}", Part);

                // narrow bar width
                Encoder.NarrowBarWidth = BarWidth;

                // row height
                Encoder.RowHeight = RowHeight;

                // quiet zone
                Encoder.QuietZone = QuietZone;

                // default data columns
                Encoder.DefaultDataColumns = DefDataColumns;

                // load barcode data
                Encoder.Encode(DataTextBox.Text);

                // create bitmap image
                Pdf417Bitmap = Encoder.CreateBarcodeBitmap();

                // update screen labels
                WidthHeightLabel.Text = ((double)Encoder.ImageWidth / Encoder.ImageHeight).ToString("0.0");
                DataRowsLabel.Text    = Encoder.DataRows.ToString();
                DataColumnsLabel.Text = Encoder.DataColumns.ToString();


#if DEBUG
                string ArgLine = string.Format("-Col:{0} -Error:{1} -Width:{2} -Height:{3} -Quiet:{4} -t \"{5}\" \"{6}\"",
                                               10, 7, 6, 20, 15, "TestFile.txt", "Test Image.png");
                Pdf417CommandLine.Encode(ArgLine);
#endif
            }

            catch (Exception Ex)
            {
                MessageBox.Show("Encoding exception.\r\n" + Ex.Message);
            }

            // enable buttons
            EnableButtons(true);

            // repaint panel
            Invalidate();
            return;
        }