本文整理汇总了C#中PrintTicket类的典型用法代码示例。如果您正苦于以下问题:C# PrintTicket类的具体用法?C# PrintTicket怎么用?C# PrintTicket使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PrintTicket类属于命名空间,在下文中一共展示了PrintTicket类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnPrintCommand
/// <summary>
/// Get a print dialog, defaulted to default printer and default printer's preferences.
/// </summary>
protected override void OnPrintCommand()
{
// get a print dialog, defaulted to default printer and default printer's preferences.
PrintDialog printDialog = new PrintDialog();
printDialog.PrintQueue = mPrintQueue;
printDialog.PrintTicket = mPrintTicket;
if (printDialog.ShowDialog() == true)
{
mPrintQueue = printDialog.PrintQueue;
mPrintTicket = printDialog.PrintTicket;
printDialog.PrintDocument(this.Document.DocumentPaginator, "PrintPreviewJob");
}
}
示例2: PrintData
protected void PrintData(string username, PrintTicket ticket, string printername, string jobname, byte[] data, string driver)
{
using (Ghostscript gs = new Ghostscript())
{
if (driver != null)
{
byte[] outdata = gs.ProcessData(ticket, data, driver, null, null);
WindowsRawPrintJob pj = new WindowsRawPrintJob
{
JobName = jobname,
PrinterName = printername,
UserName = username,
PrintData = outdata,
RunAsUser = true
};
pj.Print();
}
else
{
gs.PrintData(username, ticket, printername, jobname, data, new string[] { });
}
}
}
示例3: ModifyPrintTicket
public static PrintTicket ModifyPrintTicket(PrintTicket ticket, string featureName, string newValue)
{
if (ticket == null)
{
throw new ArgumentNullException("ticket");
}
var xmlDoc = new XmlDocument();
xmlDoc.Load(ticket.GetXmlStream());
var manager = new XmlNamespaceManager(xmlDoc.NameTable);
manager.AddNamespace(xmlDoc.DocumentElement.Prefix, xmlDoc.DocumentElement.NamespaceURI);
var xpath = string.Format("//psf:Feature[contains(@name, 'InputBin')]/psf:Option", featureName);
var node = xmlDoc.SelectSingleNode(xpath, manager);
if (node != null)
{
node.Attributes["name"].Value = newValue;
}
var printTicketStream = new MemoryStream();
xmlDoc.Save(printTicketStream);
printTicketStream.Position = 0;
var modifiedPrintTicket = new PrintTicket(printTicketStream);
return modifiedPrintTicket;
}
示例4: InternalCreateFileFromXaml
private static CreateXpsFileResult InternalCreateFileFromXaml(FrameworkElement template, object dataContext)
{
string xpsFile = Path.GetTempFileName() + ".xps";
using (var container = Package.Open(xpsFile, FileMode.Create))
using (var document = new XpsDocument(container, CompressionOption.SuperFast))
{
var coupon = template;
coupon.DataContext = dataContext;
coupon.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
coupon.UpdateLayout();
var ticket = new PrintTicket()
{
PageMediaSize = new PageMediaSize(coupon.DesiredSize.Width, coupon.DesiredSize.Height)
};
XpsDocument.CreateXpsDocumentWriter(document).Write(coupon, ticket);
return new CreateXpsFileResult()
{
Path = xpsFile,
Ticket = ticket
};
}
}
示例5: PreparePrinting
public void PreparePrinting(PrintTicket printTicket, Size pageSize)
{
printTicket.PageOrientation = pageSize.Height >= pageSize.Width ? PageOrientation.Portrait : PageOrientation.Landscape;
var printExtension = _reportProvider as IReportPrintExtension;
if (printExtension != null)
printExtension.PreparePrinting(printTicket, pageSize);
}
示例6: PrintDialog
/// <summary>
/// Invokes a System.Windows.Controls.PrintDialog to print the TextEditor.Document with specified title.
/// </summary>
public static void PrintDialog(this TextEditor textEditor, string title)
{
Printing.mDocumentTitle = title;
Printing.InitPageSettings();
System.Windows.Controls.PrintDialog printDialog = new System.Windows.Controls.PrintDialog();
printDialog.PrintQueue = mPrintQueue;
if (mPageSettings.Landscape)
Printing.mPrintTicket.PageOrientation = PageOrientation.Landscape;
printDialog.PrintTicket = mPrintTicket;
printDialog.PrintQueue.DefaultPrintTicket.PageOrientation = mPrintTicket.PageOrientation;
if (printDialog.ShowDialog() == true)
{
Printing.mPrintQueue = printDialog.PrintQueue;
Printing.mPrintTicket = printDialog.PrintTicket;
printDialog.PrintDocument(CreateDocumentPaginatorToPrint(textEditor), "PrintJob");
}
}
示例7: VerifyPrintSettings
/// <summary>
/// Ensure Queue and Ticket prepared
/// </summary>
private void VerifyPrintSettings()
{
if (mPrintQueue == null)
mPrintQueue = DefaultPrintQueue();
if (mPrintTicket == null)
mPrintTicket = DefaultPrintTicket();
}
示例8: PrintData
public void PrintData(string username, PrintTicket ticket, string printername, string jobname, byte[] data, string[] inargs)
{
string[] devsetup = SetDeviceCommand("%printer%" + printername, jobname, "mswinpr2").ToArray();
string[] extraargs = new string[] { "-dNOSAFER" };
SetupUserPrinter(username, printername);
ProcessData(username, ticket, data, inargs, extraargs, devsetup);
}
示例9: ProcessPCL
protected PaginatedPrintData ProcessPCL(byte[] rawdata, Dictionary<string, string> pjljobattribs, PrintTicket ticket)
{
PCLXLPrintJob pcljob = new PCLXLPrintJob(rawdata);
return new PaginatedPrintData
{
Prologue = PJLHelper.GetPJL(pjljobattribs, ticket, "PCLXL").Concat(pcljob.Prologue).ToArray(),
PageData = pcljob.PageData.ToArray(),
Epilogue = pcljob.Epilogue.Concat(PJLHelper.GetEndJobPJL()).ToArray(),
};
}
示例10: GetPJL
public static byte[] GetPJL(Dictionary<string, string> jobattribs, PrintTicket ticket, string language)
{
Dictionary<string, string> pjlsettings = new Dictionary<string, string>
{
{ "DUPLEX", ticket.Duplexing == Duplexing.OneSided ? "OFF" : "ON" },
{ "BINDING", ticket.Duplexing == Duplexing.TwoSidedShortEdge ? "SHORTEDGE" : "LONGEDGE" },
{ "COPIES", (ticket.CopyCount ?? 1).ToString() },
{ "RENDERMODE", ticket.OutputColor == OutputColor.Color ? "COLOR" : "GRAYSCALE" },
{ "STAPLE", GetStapling(ticket.Stapling) }
};
return GetPJL(jobattribs, pjlsettings, language);
}
示例11: DocumentPaginatorWrapper
/// <summary>
/// Class constructor
/// </summary>
/// <param name="paginator"></param>
/// <param name="pageSettings"></param>
/// <param name="printTicket"></param>
/// <param name="headerFooterfontFamily"></param>
public DocumentPaginatorWrapper(DocumentPaginator paginator, PageSettings pageSettings, PrintTicket printTicket, FontFamily headerFooterfontFamily)
{
m_Margins = ConvertMarginsToPx(pageSettings.Margins);
if (pageSettings.Landscape)
m_PageSize = new Size((int)printTicket.PageMediaSize.Height, (int)printTicket.PageMediaSize.Width);
else
m_PageSize = new Size((int)printTicket.PageMediaSize.Width, (int)printTicket.PageMediaSize.Height);
m_Paginator = paginator;
m_Paginator.PageSize = new Size(m_PageSize.Width - m_Margins.Left - m_Margins.Right, m_PageSize.Height - m_Margins.Top - m_Margins.Bottom);
m_Typeface = new Typeface(headerFooterfontFamily, FontStyles.Normal, FontWeights.Normal, FontStretches.Normal);
}
示例12: Print
public void Print(string username, byte[] data, string printername, string jobname, PrintTicket ticket)
{
PopplerGDIPrintJob pj = new PopplerGDIPrintJob
{
PrintData = data,
PrinterName = printername,
PrintTicket = ticket,
JobName = jobname,
RunAsUser = username != null,
UserName = username
};
pj.Print();
}
示例13: PrintOnClick
void PrintOnClick(object sender, RoutedEventArgs args)
{
PrintDialog dlg = new PrintDialog();
if (prnqueue != null)
dlg.PrintQueue = prnqueue;
if (prntkt != null)
dlg.PrintTicket = prntkt;
if (dlg.ShowDialog().GetValueOrDefault())
{
prnqueue = dlg.PrintQueue;
prntkt = dlg.PrintTicket;
DrawingVisual vis = new DrawingVisual();
DrawingContext dc = vis.RenderOpen();
Pen pn = new Pen(Brushes.Black, 1);
Rect rectPage = new Rect(marginPage.Left, marginPage.Top,
dlg.PrintableAreaWidth - (marginPage.Left + marginPage.Right),
dlg.PrintableAreaHeight - (marginPage.Top + marginPage.Bottom));
dc.DrawRectangle(null, pn, rectPage);
FormattedText formtxt = new FormattedText(
String.Format("Hello, Printer! {0} x {1}", dlg.PrintableAreaWidth/96, dlg.PrintableAreaHeight/96),
CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface(
new FontFamily("Times New Roman"), FontStyles.Italic, FontWeights.Normal, FontStretches.Normal),
48, Brushes.Black);
Size sizeText = new Size(formtxt.Width, formtxt.Height);
Point ptText = new Point(rectPage.Left + (rectPage.Width - formtxt.Width) / 2,
rectPage.Top + (rectPage.Height - formtxt.Height) / 2);
dc.DrawText(formtxt, ptText);
dc.DrawRectangle(null,pn, new Rect(ptText, sizeText));
dc.Close();
dlg.PrintVisual(vis, Title);
}
}
示例14: PrintData
protected void PrintData(string username, PrintTicket ticket, string printername, string jobname, byte[] data, Dictionary<string, string> pjljobattribs)
{
using (Ghostscript gs = new Ghostscript())
{
string driver = ticket.OutputColor == OutputColor.Color ? "pxlcolor" : "pxlmono";
byte[] pcldata = gs.ProcessData(ticket, data, driver, null, null);
PaginatedPrintData pcljob = ProcessPCL(pcldata, pjljobattribs, ticket);
WindowsRawPrintJob job = new WindowsRawPrintJob
{
PagedData = pcljob,
JobName = jobname,
PrinterName = printername,
UserName = username,
RunAsUser = true
};
job.Print();
}
}
示例15: PrintOnExecuted
void PrintOnExecuted(object sender, ExecutedRoutedEventArgs args)
{
PrintDialog dlg = new PrintDialog();
// Get the PrintQueue and PrintTicket from previous invocations.
if (prnqueue != null)
dlg.PrintQueue = prnqueue;
if (prntkt != null)
dlg.PrintTicket = prntkt;
if (dlg.ShowDialog().GetValueOrDefault())
{
// Save PrintQueue and PrintTicket from dialog box.
prnqueue = dlg.PrintQueue;
prntkt = dlg.PrintTicket;
// Create a PlainTextDocumentPaginator object.
PlainTextDocumentPaginator paginator =
new PlainTextDocumentPaginator();
// Set the paginator properties.
paginator.PrintTicket = prntkt;
paginator.Text = txtbox.Text;
paginator.Header = strLoadedFile;
paginator.Typeface =
new Typeface(txtbox.FontFamily, txtbox.FontStyle,
txtbox.FontWeight, txtbox.FontStretch);
paginator.FaceSize = txtbox.FontSize;
paginator.TextWrapping = txtbox.TextWrapping;
paginator.Margins = marginPage;
paginator.PageSize = new Size(dlg.PrintableAreaWidth,
dlg.PrintableAreaHeight);
// Print the document.
dlg.PrintDocument(paginator, Title);
}
}