using System.Drawing.Printing;
using System.Drawing;
using System.Windows.Forms;
PrintDocument pdoc = null;
protected void Page_Load(object sender, EventArgs e)
{
print();
}
public void print()
{
PrintDialog pd = new PrintDialog();
pdoc = new PrintDocument();
pdoc.PrinterSettings.PrinterName = "Samsung SCX-3200 Series";
PrinterSettings ps = new PrinterSettings();
Font font = new Font("Courier New", 15);
PaperSize psize = new PaperSize("Custom", 100, 200);
//ps.DefaultPageSettings.PaperSize = psize;
pd.Document = pdoc;
pd.Document.DefaultPageSettings.PaperSize = psize;
//pdoc.DefaultPageSettings.PaperSize.Height =320;
pdoc.DefaultPageSettings.PaperSize.Height = 400;
pdoc.DefaultPageSettings.PaperSize.Width = 314;
pdoc.PrintPage += new PrintPageEventHandler(pdoc_PrintPage);
// pdoc.Print();
DialogResult result = pd.ShowDialog();
if (result == DialogResult.OK)
{
PrintPreviewDialog pp = new PrintPreviewDialog();
pp.Document = pdoc;
result = pp.ShowDialog();
if (result == DialogResult.OK)
{
pdoc.Print();
}
}
}
void pdoc_PrintPage(object sender, PrintPageEventArgs e)
{
Graphics graphics = e.Graphics;
Font font = new Font("Courier New", 10);
float fontHeight = font.GetHeight();
int startX = 50;
int startY = 55;
int Offset = 40;
graphics.DrawString("Welcome to MSST", new Font("Courier New", 14), new SolidBrush(Color.Black), startX, startY + Offset);
Offset = Offset + 20;
graphics.DrawString("Ticket No:" + your.TicketNo, new Font("Courier New", 14), new SolidBrush(Color.Black), startX, startY + Offset);
Offset = Offset + 20;
graphics.DrawString("Ticket Date :" + your.ticketDate, new Font("Courier New", 12), new SolidBrush(Color.Black), startX, startY + Offset);
Offset = Offset + 20;
String underLine = "------------------------------------------";
graphics.DrawString(underLine, new Font("Courier New", 10), new SolidBrush(Color.Black), startX, startY + Offset);
Offset = Offset + 20;
String Source= this.source;
graphics.DrawString("From "+yourSource+" To "+yourDestination, new Font("Courier New", 10), new SolidBrush(Color.Black), startX, startY + Offset);
Offset = Offset + 20;
String Grosstotal = "Total Amount to Pay = " + this.amount;
Offset = Offset + 20;
underLine = "------------------------------------------";
graphics.DrawString(underLine, new Font("Courier New", 10), new SolidBrush(Color.Black), startX, startY + Offset);
Offset = Offset + 20;
graphics.DrawString(Grosstotal , new Font("Courier New", 10), new SolidBrush(Color.Black), startX, startY + Offset);
Offset = Offset + 20;
String DrawnBy = this.drawnBy;
graphics.DrawString("Conductor - "+yourDrawnBy, new Font("Courier New", 10), new SolidBrush(Color.Black), startX, startY + Offset);
}
using System.Drawing;
using System.Windows.Forms;
PrintDocument pdoc = null;
protected void Page_Load(object sender, EventArgs e)
{
print();
}
public void print()
{
PrintDialog pd = new PrintDialog();
pdoc = new PrintDocument();
pdoc.PrinterSettings.PrinterName = "Samsung SCX-3200 Series";
PrinterSettings ps = new PrinterSettings();
Font font = new Font("Courier New", 15);
PaperSize psize = new PaperSize("Custom", 100, 200);
//ps.DefaultPageSettings.PaperSize = psize;
pd.Document = pdoc;
pd.Document.DefaultPageSettings.PaperSize = psize;
//pdoc.DefaultPageSettings.PaperSize.Height =320;
pdoc.DefaultPageSettings.PaperSize.Height = 400;
pdoc.DefaultPageSettings.PaperSize.Width = 314;
pdoc.PrintPage += new PrintPageEventHandler(pdoc_PrintPage);
// pdoc.Print();
DialogResult result = pd.ShowDialog();
if (result == DialogResult.OK)
{
PrintPreviewDialog pp = new PrintPreviewDialog();
pp.Document = pdoc;
result = pp.ShowDialog();
if (result == DialogResult.OK)
{
pdoc.Print();
}
}
}
void pdoc_PrintPage(object sender, PrintPageEventArgs e)
{
Graphics graphics = e.Graphics;
Font font = new Font("Courier New", 10);
float fontHeight = font.GetHeight();
int startX = 50;
int startY = 55;
int Offset = 40;
graphics.DrawString("Welcome to MSST", new Font("Courier New", 14), new SolidBrush(Color.Black), startX, startY + Offset);
Offset = Offset + 20;
graphics.DrawString("Ticket No:" + your.TicketNo, new Font("Courier New", 14), new SolidBrush(Color.Black), startX, startY + Offset);
Offset = Offset + 20;
graphics.DrawString("Ticket Date :" + your.ticketDate, new Font("Courier New", 12), new SolidBrush(Color.Black), startX, startY + Offset);
Offset = Offset + 20;
String underLine = "------------------------------------------";
graphics.DrawString(underLine, new Font("Courier New", 10), new SolidBrush(Color.Black), startX, startY + Offset);
Offset = Offset + 20;
String Source= this.source;
graphics.DrawString("From "+yourSource+" To "+yourDestination, new Font("Courier New", 10), new SolidBrush(Color.Black), startX, startY + Offset);
Offset = Offset + 20;
String Grosstotal = "Total Amount to Pay = " + this.amount;
Offset = Offset + 20;
underLine = "------------------------------------------";
graphics.DrawString(underLine, new Font("Courier New", 10), new SolidBrush(Color.Black), startX, startY + Offset);
Offset = Offset + 20;
graphics.DrawString(Grosstotal , new Font("Courier New", 10), new SolidBrush(Color.Black), startX, startY + Offset);
Offset = Offset + 20;
String DrawnBy = this.drawnBy;
graphics.DrawString("Conductor - "+yourDrawnBy, new Font("Courier New", 10), new SolidBrush(Color.Black), startX, startY + Offset);
}
Thanks
ReplyDeleteThanks for sharing. Notwithstanding, text publicizing can be unfathomably fulfilling and in this article, we will research irrefutably the recommended C# SMS gateway integration that will ensure a smooth and productive bulk SMS advertising campaign for your business.
ReplyDeleteNice post it is very useful for all.
ReplyDeleteSMS API C#