/// <summary> /// Desenha a imagem do boleto em um coponente de imagem COM do Windows hDC /// </summary> public void Desenha(IntPtr hDC) { try { if (LinhaDigitavel == "") { CalculaBoleto(); } Impactro.WindowsControls.BoletoForm wBol = new WindowsControls.BoletoForm(this); Graphics g = Graphics.FromHdc(hDC); wBol.Print(g); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); } }
/// <summary> /// Salva a imagem do boleto em um arquivo de imagem ( corrigido por Alexandre Savelli Bencz ) /// </summary> public void Save(string cFileName) { try { if (LinhaDigitavel == "") { CalculaBoleto(); } Impactro.WindowsControls.BoletoForm wBol = new WindowsControls.BoletoForm(this); wBol.PrintType = Impactro.Cobranca.PrintTypes.Image; Bitmap img = NewImage(); img.SetResolution(DPI, DPI); Graphics g = Graphics.FromImage(img); g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality; wBol.Print(g); img.Save(cFileName, ImageSave); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace, "ERRO", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); } }