C sharp script help

Q and A about functionality and how to solve a special task for your application.

Moderator: Support

Post Reply
danielkim
Posts: 7
Joined: 20 Mar 2015, 13:29

C sharp script help

Post by danielkim » 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();
}
}
}

User avatar
Karol
Posts: 605
Joined: 10 Jan 2012, 12:07

Re: C sharp script help

Post by Karol » 19 Aug 2015, 08:51

And what is your problem?

danielkim
Posts: 7
Joined: 20 Mar 2015, 13:29

Re: C sharp script help

Post by danielkim » 20 Aug 2015, 01:28

Thank you.

Problem solved.

Post Reply