using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Drawing.Printing;
using System.Drawing;
using System.Windows.Forms;
namespace **** change to your project name *****
{
class MyReports
{
private dbEntities db = new dbEntities();
public MyReports()
{
}
public void AddHeader(PrintPageEventArgs e)
{
Graphics g = e.Graphics;
g.PageUnit = GraphicsUnit.Millimeter;
String message = "הכותרת של ההדפסה בכל דף";
Image newImage = Properties.Resources.header_photo;
//Image.FromFile("Resources/header-photo.jpg");
Point ulCorner = new Point(5, 5);
Point urCorner = new Point(200, 5);
Point llCorner = new Point(5, 25);
Point[] destPara = { ulCorner, urCorner, llCorner };
Font messageFont = new Font("Arial", 10, System.Drawing.GraphicsUnit.Point);
g.DrawString(message, messageFont, Brushes.Black, 90, 15);
e.Graphics.DrawImage(newImage, destPara);
AddHLine(e,10,20);
}
public void AddHLine(PrintPageEventArgs e,int x,int y)
{
Graphics g = e.Graphics;
g.PageUnit = GraphicsUnit.Millimeter;
String message = "___________________________________________________________________";
Font messageFont = new Font("Arial", 14, System.Drawing.GraphicsUnit.Point);
g.DrawString(message, messageFont, Brushes.Green, x, y);
}
public void AddFooter(PrintPageEventArgs e)
{
String message = "";
Graphics g = e.Graphics;
g.PageUnit = GraphicsUnit.Millimeter;
message = message + "055-5555555";
message = message + "XXX";
message = message + "שם העסק";
message = message + "XXX";
message = message + "שם הפרויקט שלכם";
Font messageFont = new Font("Arial", 10, System.Drawing.GraphicsUnit.Point);
g.DrawString(message, messageFont, Brushes.Black, 50, 265);
AddHLine(e, 8, 260);
}
public void PrintTitle(String message, int x,PrintPageEventArgs e)
{
Graphics g = e.Graphics;
g.PageUnit = GraphicsUnit.Millimeter;
Font messageFont = new Font("Arial",18, System.Drawing.GraphicsUnit.Point);
g.DrawString(message, messageFont, Brushes.Black, x, 30);
}
public void CustomerReportHeader(PrintPageEventArgs e)
{
String message = "";
Graphics g = e.Graphics;
Font messageFont = new Font("Arial", 9, System.Drawing.GraphicsUnit.Point);
g.PageUnit = GraphicsUnit.Millimeter;
message = "מס ";
g.DrawString(message, messageFont, Brushes.Black, 180, 43);
message = "שם לקוח";
g.DrawString(message, messageFont, Brushes.Black, 160, 43);
message = "טלפון";
g.DrawString(message, messageFont, Brushes.Black, 120, 43);
message = "מחיר";
g.DrawString(message, messageFont, Brushes.Black, 100, 43);
message = "כמות ";
g.DrawString(message, messageFont, Brushes.Black, 50, 43);
double tt = 0.1;
float w = (float) tt;
Pen p = new Pen(Brushes.Green,w);
g.DrawLine(p , 70, 50, 190, 50);
}
// פעולה שמקבלת מחרוזת, מיקום , גודל פונט ואת אוביקט ההדפסה ומדפיסה את המחרוזת
public void printString(String str, int x, int y,int f_size, PrintPageEventArgs e)
{
Graphics g = e.Graphics;
Font messageFont = new Font("Arial", f_size, System.Drawing.GraphicsUnit.Point);
g.PageUnit = GraphicsUnit.Millimeter;
g.DrawString(str, messageFont, Brushes.Black, x, y);
} // End printString
}
}