/// <summary> /// Encodes a string to be printed in a code 128 barcode format. /// </summary> /// <param name="data">The string to encode.</param> /// <returns>The encoding string.</returns> public string EncodeToCode128(string data) { try { return(m_fontEncoder.Code128(data, 0, false)); } catch (Exception e) { throw new ModuleException("Error encoding Code 128 barcode.", e); } }
} // no header /// <summary> /// Prepares the receipt's body. /// </summary> protected override void PrintBody() { Table playerRaffleInfo = new Table(); playerRaffleInfo.RowGroups.Add(new TableRowGroup()); TableRow row; TableCell cell; // Add the player name row = new TableRow(); row.FontSize = FontBig; row.FontWeight = FontWeightBig; cell = new TableCell(); cell.Blocks.Add(new Paragraph(new Run(m_player.Player.FirstName + " " + m_player.Player.LastName))); row.Cells.Add(cell); playerRaffleInfo.RowGroups[0].Rows.Add(row); // Add the player card if (m_printBarcode && !String.IsNullOrWhiteSpace(m_player.Player.MagneticCardNumber)) { row = new TableRow(); row.FontSize = BARCODE_FONT_SIZE; row.FontFamily = new System.Windows.Media.FontFamily(GTI.Modules.Shared.BarcodeHelper.SmallFontName); cell = new TableCell(); FontEncoder fontEncoder = new FontEncoder(); cell.Blocks.Add(new Paragraph(new Run(fontEncoder.Code128(m_player.Player.MagneticCardNumber)))); row.Cells.Add(cell); playerRaffleInfo.RowGroups[0].Rows.Add(row); } row = new TableRow(); row.FontSize = FontBig; cell = new TableCell(); cell.Blocks.Add(new Paragraph(new Run(m_player.Player.MagneticCardNumber))); row.Cells.Add(cell); playerRaffleInfo.RowGroups[0].Rows.Add(row); // Raffle name if (!String.IsNullOrWhiteSpace(m_raffleName)) { row = new TableRow(); row.FontSize = FontSmall; cell = new TableCell(); cell.Blocks.Add(new Paragraph(new Run( String.Format("Raffle: {0}", m_raffleName) ))); row.Cells.Add(cell); playerRaffleInfo.RowGroups[0].Rows.Add(row); } // Put the print time on it row = new TableRow(); row.FontSize = FontSmall; cell = new TableCell(); cell.Blocks.Add(new Paragraph(new Run( String.Format("Printed: {0}", DateTime.Now.ToString()) ))); row.Cells.Add(cell); playerRaffleInfo.RowGroups[0].Rows.Add(row); // Add everything to the main flow document FlowDoc.Blocks.Add(playerRaffleInfo); }