E3.Utility/PrintService.cs
(开头部分) 4KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing.Printing;
using System.Windows.Forms;
using System.IO;
namespace E3.Utility
{
public class Printservice
{
/// <summary>
/// PrintService 的摘要说明。
/// </summary>
public Printservice()
{
//
// TODO: 在此处添加构造函数逻辑
//
this.docToPrint.PrintPage += new PrintPageEventHandler(docToPrint_PrintPage);
}//将事件处理函数添加到PrintDocument的PrintPage中
// Declare the PrintDocument object.
private System.Drawing.Printing.PrintDocument docToPrint = new System.Drawing.Printing.PrintDocument();//创建一个PrintDocument的实例
private System.IO.Stream streamToPrint;
string streamType;
// This method will set properties on the PrintDialog object and
// then display the dialog.
public void StartPrint(Stream streamToPrint, string streamType)
{
this.streamToPrint = streamToPrint;
this.streamType = streamType;
// Allow the user to choose the page range he or she would
// like to print.
System.Windows.Forms.PrintDialog PrintDialog1 = new PrintDialog();//创建一个PrintDialog的实例。
PrintDialog1.AllowSomePages = true;
// Show the help button.
PrintDialog1.ShowHelp = true;
// Set the Document property to the PrintDocument for
// which the PrintPage Event has been handled. To display the
// dialog, either this property or the PrinterSettings property
// must be set
PrintDialog1.Document = docToPrint;//把PrintDialog的Document属性设为上面配置好的PrintDocument的实例
DialogResult result = PrintDialog1.ShowDialog();//调用PrintDialog的ShowDialog函数显示打印对话框
// If the result is OK then print the document.
if (result == DialogResult.OK)
{
PageSettings pageSet = new PageSettings();
//pageSet.Landscape = false; //打印方向为纵向
pageSet.Margins.Top = 1; //设置顶部页边距
pageSet.Margins.Left = 1; //设置左部页边距
docToPrint.DefaultPageSettings = pageSet;//当前打印页面为上面设置的打印页面
docToPrint.Print();//开始打印
}
}
// The PrintDialog will print the document
// by handling the document's PrintPage event.
private void docToPrint_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)//设置打印机开始打印的事件处理函数
后面还有 43 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。