DESIGN PAGES
Form 1 design:
DOT NET CODING
Form 1 Coding:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Configuration;
using System.Collections;
using System.Drawing.Printing;
using System.Globalization;
namespace Ruled_Paper
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Font font1 = new Font("Times New Roman", 9); // Default Text
Font font2 = new Font("Times New Roman", 10); // BillNo, Date & Customer Id & coloum name
Font font3 = new Font("Times New Roman", 10, FontStyle.Bold); // Company Name, Bill Heading [Ex: ESTIMATE]
Font font4 = new Font("Times New Roman", 9); // Header, Footer
Font font5 = new Font("Times New Roman", 10);
Font font6 = new Font("Times New Roman", 14, FontStyle.Bold);
int X, Y, pageWidth, offsetY, rightMargin;
SolidBrush brush = new SolidBrush(Color.Black);
Pen dashPen = new Pen(Color.Black, 1);
Graphics g; Int32 pageHeight;
private void button1_Click(object sender, EventArgs e)
{
PrintDialog prdialog = new PrintDialog();
PrintDocument prdoc = new PrintDocument();
PrinterSettings prsetting = new PrinterSettings();
prdialog.Document = prdoc;
IEnumerable<PaperSize> paperSizes = prsetting.PaperSizes.Cast<PaperSize>();
PaperSize paperSize = new PaperSize("Custom", 480, pageHeight); // 400,500
prdialog.Document.DefaultPageSettings.PaperSize = paperSize;
}
private void printPreviewControl1_Click(object sender, EventArgs e)
{
PrintDialog prdialog = new PrintDialog();
PrintDocument prdoc = new PrintDocument();
PrinterSettings prsetting = new PrinterSettings();
prdialog.Document = prdoc;
IEnumerable<PaperSize> paperSizes = prsetting.PaperSizes.Cast<PaperSize>();
PaperSize paperSize = new PaperSize("Custom", 480, pageHeight); // 400,500
prdialog.Document.DefaultPageSettings.PaperSize = paperSize;
}
}
}
Form 2 Coding:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Printing;
namespace Ruled_Paper
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
int x = 100, y = 100;
Graphics graphics;
private void Form2_Load(object sender, EventArgs e)
{
top();
}
public string hari { get; set; }
Font font1 = new Font("Times New Roman", 11, FontStyle.Bold);
void sam_Printpage(Object sender, PrintPageEventArgs e)
{
graphics = e.Graphics;
Font headerFont = new Font("Times New Roman", 20, FontStyle.Bold);
graphics.DrawString("Date:___/___/______", headerFont, Brushes.Red, 550, 35);
string hariText = "Page No.:___";
Font bodyFont = new Font("Times New Roman", 20, FontStyle.Bold);
graphics.DrawString(hariText,bodyFont, Brushes.Red, 550, 5);
graphics.DrawLine(Pens.Red, 1, 100, 1000, 100);
graphics.DrawLine(Pens.Red, 1, 95, 1000, 95); //horizontal
graphics.DrawLine(Pens.Black, 1, 200, 1000, 200);
graphics.DrawLine(Pens.Black, 1, 150, 1000, 150);
graphics.DrawLine(Pens.Black, 1, 200, 1000, 200);
graphics.DrawLine(Pens.Black, 1, 250, 1000, 250);
graphics.DrawLine(Pens.Black, 1, 300, 1000, 300);
graphics.DrawLine(Pens.Black, 1, 350, 1000, 350);
graphics.DrawLine(Pens.Black, 1, 400, 1000, 400);
graphics.DrawLine(Pens.Black, 1, 450, 1000, 450);
graphics.DrawLine(Pens.Black, 1, 500, 1000, 500);
graphics.DrawLine(Pens.Black, 1, 550, 1000, 550);
graphics.DrawLine(Pens.Black, 1, 600, 1000, 600);
graphics.DrawLine(Pens.Black, 1, 650, 1000, 650);
graphics.DrawLine(Pens.Black, 1, 700, 1000, 700);
graphics.DrawLine(Pens.Black, 1, 750, 1000, 750);
graphics.DrawLine(Pens.Black, 1, 850, 1000, 850);
graphics.DrawLine(Pens.Black, 1, 950, 1000,950);
graphics.DrawLine(Pens.Black, 1, 800, 1000, 800);
graphics.DrawLine(Pens.Black, 1,900, 1000, 900);
graphics.DrawLine(Pens.Black, 1, 1000, 1000, 1000);
graphics.DrawLine(Pens.Black, 1, 1050, 1000, 1050);
graphics.DrawLine(Pens.Black, 1, 1050, 1000, 1050);
graphics.DrawLine(Pens.Black, 1, 1050, 1000, 1050);
graphics.DrawLine(Pens.Black, 1, 950, 1000, 950);
graphics.DrawLine(Pens.Black, 1, 950, 1000, 950);
graphics.DrawLine(Pens.Black, 1, 950, 1000, 950);
graphics.DrawLine(Pens.Black, 1, 950, 1000, 950);
graphics.DrawLine(Pens.Black, 1, 950, 1000, 950);
graphics.DrawLine(Pens.Black, 1, 950, 1000, 950);
graphics.DrawLine(Pens.Black, 1, 950, 1000, 950);
graphics.DrawLine(Pens.Black, 1, 200, 1000, 200);
graphics.DrawLine(Pens.Black, 1, 150, 1000, 150);
graphics.DrawLine(Pens.Black, 1, 200, 1000, 200);
graphics.DrawLine(Pens.Black, 1, 850, 1000, 850);
graphics.DrawLine(Pens.Black, 1, 950, 1000, 950);
graphics.DrawLine(Pens.Black, 1, 800, 1000, 800);
graphics.DrawLine(Pens.Black, 1, 900, 1000, 900);
graphics.DrawLine(Pens.Red,100, 5, 100, 1100);//vertical
graphics.DrawLine(Pens.Red, 105, 5, 105, 1100);
}
public void top()
{
PrintDocument printDocument = new PrintDocument();
printDocument.DefaultPageSettings.PaperSize = new PaperSize("A4", 827, 1169);
printDocument.PrintPage += new PrintPageEventHandler(sam_Printpage);
PrintPreviewDialog printPreviewDialog = new PrintPreviewDialog();
printPreviewDialog.Document = printDocument;
if (printPreviewDialog.ShowDialog() == DialogResult.OK)
{
printDocument.Print();
}
}
}
}
.png)
.png)
.png)
No comments:
Post a Comment