C sharp script help
Posted: 19 Aug 2015, 05:18
hi all,
i try to print in ventuz. ?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Drawing.Printing;
namespace print
{
public partial class Print : Form
{
/// <summary>
/// 변수 선언
/// </summary>
private PrintDocument printDoc = new PrintDocument();
private PageSettings pgSettings = new PageSettings();
private PrinterSettings prtSettings = new PrinterSettings();
public Print()
{
InitializeComponent();
}
private void printPreviewBtn_Click(object sender, EventArgs e)
{
printDoc.PrinterSettings = prtSettings;
printDoc.DefaultPageSettings = pgSettings;
PrintPreviewDialog dlg = new PrintPreviewDialog();
printDoc.PrintPage += new PrintPageEventHandler(printDoc_PrintPage);
dlg.Document = printDoc;
dlg.ShowDialog();
}
private void printDoc_PrintPage(object sender, PrintPageEventArgs e)
{
String textToPrint = ".Net Printing is Easy";
Font printFont = new Font("Courier New", 40);
int leftMargin = e.MarginBounds.Left;
int topMargin = e.MarginBounds.Top;
float width = e.PageSettings.PaperSize.Width;
float height = e.PageSettings.PaperSize.Height;
// 이미지는 각자 경로로 바꿔주십시오~
Image img = Image.FromFile(@"G:\ppp.jpg");
e.Graphics.DrawImage(img, 0, 0, (int)width, (int)height);
e.Graphics.DrawString(textToPrint, printFont, Brushes.Red, 50, 100);
//throw new NotImplementedException();
}
private void printSettingBtn_Click(object sender, EventArgs e)
{
PageSetupDialog psd = new PageSetupDialog();
psd.AllowPrinter = true;
psd.AllowOrientation = true;
psd.AllowMargins = true;
psd.PageSettings = pgSettings;
psd.PrinterSettings = prtSettings;
psd.ShowDialog();
}
private void printBtn_Click(object sender, EventArgs e)
{
printDoc.PrinterSettings = prtSettings;
printDoc.DefaultPageSettings = pgSettings;
PrintDialog dlg = new PrintDialog();
dlg.Document = printDoc;
if (dlg.ShowDialog() == DialogResult.OK)
printDoc.Print();
}
}
}
i try to print in ventuz. ?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Drawing.Printing;
namespace print
{
public partial class Print : Form
{
/// <summary>
/// 변수 선언
/// </summary>
private PrintDocument printDoc = new PrintDocument();
private PageSettings pgSettings = new PageSettings();
private PrinterSettings prtSettings = new PrinterSettings();
public Print()
{
InitializeComponent();
}
private void printPreviewBtn_Click(object sender, EventArgs e)
{
printDoc.PrinterSettings = prtSettings;
printDoc.DefaultPageSettings = pgSettings;
PrintPreviewDialog dlg = new PrintPreviewDialog();
printDoc.PrintPage += new PrintPageEventHandler(printDoc_PrintPage);
dlg.Document = printDoc;
dlg.ShowDialog();
}
private void printDoc_PrintPage(object sender, PrintPageEventArgs e)
{
String textToPrint = ".Net Printing is Easy";
Font printFont = new Font("Courier New", 40);
int leftMargin = e.MarginBounds.Left;
int topMargin = e.MarginBounds.Top;
float width = e.PageSettings.PaperSize.Width;
float height = e.PageSettings.PaperSize.Height;
// 이미지는 각자 경로로 바꿔주십시오~
Image img = Image.FromFile(@"G:\ppp.jpg");
e.Graphics.DrawImage(img, 0, 0, (int)width, (int)height);
e.Graphics.DrawString(textToPrint, printFont, Brushes.Red, 50, 100);
//throw new NotImplementedException();
}
private void printSettingBtn_Click(object sender, EventArgs e)
{
PageSetupDialog psd = new PageSetupDialog();
psd.AllowPrinter = true;
psd.AllowOrientation = true;
psd.AllowMargins = true;
psd.PageSettings = pgSettings;
psd.PrinterSettings = prtSettings;
psd.ShowDialog();
}
private void printBtn_Click(object sender, EventArgs e)
{
printDoc.PrinterSettings = prtSettings;
printDoc.DefaultPageSettings = pgSettings;
PrintDialog dlg = new PrintDialog();
dlg.Document = printDoc;
if (dlg.ShowDialog() == DialogResult.OK)
printDoc.Print();
}
}
}