hello experts
datagridview having columns for picture file path and picture related to a number called as bill_key also shown in column
i want to merge at either top or bottom of image bill_key so after print user knows that printed picture belongs to which bill_key
i tried following , but cant see the bill_key any where
can somebody help to get this done.
Thanks in advance.
foreach (DataGridViewRow dgvrPdiTc in dgvPdiTc.SelectedRows)
{
if (dgvrPdiTc.Cells["report"].Value.ToString().Trim().Equals("tc"))
{
//print image from file
string billnumber = dgvrPdiTc.Cells["bill_key"].Value.ToString();
//string testName = "Microsoft C# Deveoper Practice Test";
//string testDate = "Thursday, November 10, 2016";
//string score = "Score 33 / 33";
Bitmap bitmap = (Bitmap)Image.FromFile(dgvrPdiTc.Cells["tc_path"].Value.ToString());
//const int dotsPerInch = 75; // define the quality in DPI
//http://stackoverflow.com/questions/11699219/save-an-image-as-a-bitmap-without-losing-quality
//bitmap.SetResolution(dotsPerInch, dotsPerInch);
using (Graphics graphics = Graphics.FromImage(bitmap))
{
//graphics.SmoothingMode = SmoothingMode.AntiAlias; //line A
//graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; //line B
//graphics.PixelOffsetMode = PixelOffsetMode.HighQuality; //line C
graphics.DrawString(billnumber, new Font("Times-Roman", 0.1f, FontStyle.Regular, GraphicsUnit.Inch), Brushes.Black, 350f, 350f);
//graphics.DrawString(testName, new Font("Times-Roman", 0.06f, FontStyle.Regular, GraphicsUnit.Inch), Brushes.Black, 180f, 420f);
//graphics.DrawString(testDate, new Font("Times-Roman", 0.05f, FontStyle.Regular, GraphicsUnit.Inch), Brushes.Black, 350f, 490f);
//graphics.DrawString(score, new Font("Times-Roman", 0.06f, FontStyle.Regular, GraphicsUnit.Inch), Brushes.Black, 350f, 550f);
//string fileName = "result3600.PNG";
//bitmap.Save(imageBaseFilePath + fileName);
using (var pd = new PrintDocument())
{
pd.PrintPage += (_, e1) =>
{
e1.Graphics.DrawImage(bitmap, e1.PageBounds);
};
pd.Print();
}
}
//string file = dgvrPdiTc.Cells["tc_path"].Value.ToString();
//using (var pd = new PrintDocument())
//{
// pd.PrintPage += (_, e) =>
// {
// var img = Image.FromFile(file);
// e.Graphics.DrawImage(img, e.PageBounds);
// };
// pd.Print();
//}
//Process p = new Process();
//p.StartInfo.FileName = dgvrPdiTc.Cells["tc_path"].Value.ToString();
//p.StartInfo.Verb = "Print";
//p.Start();
}
}