本文整理汇总了C#中System.Windows.Controls.PrintDialog.PrintDocument方法的典型用法代码示例。如果您正苦于以下问题:C# PrintDialog.PrintDocument方法的具体用法?C# PrintDialog.PrintDocument怎么用?C# PrintDialog.PrintDocument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.PrintDialog
的用法示例。
在下文中一共展示了PrintDialog.PrintDocument方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoPrint
public override void DoPrint(FlowDocument document)
{
var ph = document.PageHeight;
var pw = document.PageWidth;
var pp = document.PagePadding;
var cg = document.ColumnGap;
var cw = document.ColumnWidth;
var q = PrinterInfo.GetPrinter(Printer.ShareName);
var pd = new PrintDialog { PrintQueue = q };
if (pd.PrintQueue.FullName == Printer.ShareName || pd.ShowDialog().GetValueOrDefault(false))
{
document.PageHeight = pd.PrintableAreaHeight;
document.PageWidth = pd.PrintableAreaWidth;
document.PagePadding = new Thickness(25);
document.ColumnGap = 0;
document.ColumnWidth = (document.PageWidth -
document.ColumnGap -
document.PagePadding.Left -
document.PagePadding.Right);
pd.PrintDocument(((IDocumentPaginatorSource)document).DocumentPaginator, "");
}
document.PageHeight = ph;
document.PageWidth = pw;
document.PagePadding = pp;
document.ColumnGap = cg;
document.ColumnWidth = cw;
}
示例2: btnPrint_Click
private void btnPrint_Click(object sender, EventArgs e)
{
//REFACTOR ME
dtgParentReport.Update();
System.Windows.Controls.PrintDialog printDialog = new System.Windows.Controls.PrintDialog();
Nullable<bool> print = printDialog.ShowDialog();
if (print == true)
{
try
{
XpsDocument xpsDocument = new XpsDocument("C:\\FixedDocumentSequence.xps", FileAccess.ReadWrite);
FixedDocumentSequence fixedDocSeq = xpsDocument.GetFixedDocumentSequence();
printDialog.PrintDocument(fixedDocSeq.DocumentPaginator, "Test print job");
}
catch (UnauthorizedAccessException e1)
{
const string message =
"Unauthoried to access that printer.";
const string caption = "Unauthoried Access";
var result = MessageBox.Show(message, caption,
MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
catch (PrintDialogException e2)
{
const string message =
"Unknow error occurred.";
const string caption = "Error Printing";
var result = MessageBox.Show(message, caption,
MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
}
示例3: cmdPrintCustom_Click
private void cmdPrintCustom_Click(object sender, RoutedEventArgs e)
{
PrintDialog printDialog = new PrintDialog();
if (printDialog.ShowDialog() == true)
{
FlowDocument doc = docReader.Document;
// Save all the existing settings.
double pageHeight = doc.PageHeight;
double pageWidth = doc.PageWidth;
Thickness pagePadding = doc.PagePadding;
double columnGap = doc.ColumnGap;
double columnWidth = doc.ColumnWidth;
// Make the FlowDocument page match the printed page.
doc.PageHeight = printDialog.PrintableAreaHeight;
doc.PageWidth = printDialog.PrintableAreaWidth;
doc.PagePadding = new Thickness(50);
// Use two columns.
doc.ColumnGap = 25;
doc.ColumnWidth = (doc.PageWidth - doc.ColumnGap
- doc.PagePadding.Left - doc.PagePadding.Right) / 2;
printDialog.PrintDocument(((IDocumentPaginatorSource)doc).DocumentPaginator, "A Flow Document");
// Reapply the old settings.
doc.PageHeight = pageHeight;
doc.PageWidth = pageWidth;
doc.PagePadding = pagePadding;
doc.ColumnGap = columnGap;
doc.ColumnWidth = columnWidth;
}
}
示例4: printOrder
public static void printOrder( Order o )
{
PrintDialog printDlg = new PrintDialog();
String textToPrint = "";
textToPrint += "\t\t Τραπέζι "+o.Table_id+"\n\n";
textToPrint += "Παραγγελία : \n";
String orderName = "";
foreach (Items i in DBController.LoadItems())
{
if (i.Id == o.Items_id)
orderName = i.Name;
}
orderName += o.CharacteristicsInfo;
textToPrint += "\t1 "+orderName+"\n";
textToPrint += "\n\n";
String waiterName = "";
foreach (User u in DBController.LoadUsers())
{
if (u.User_id == o.User_id)
waiterName = u.Name;
}
textToPrint += "Σερβιτόρος : "+waiterName+"\n";
textToPrint += "Ώρα : " + DateTime.Now.ToString("dd/MM/yyyy h:mm:ss tt");
FlowDocument doc = new FlowDocument(new Paragraph(new Run(textToPrint)));
doc.Name = "FlowDoc";
IDocumentPaginatorSource idpSource = doc;
printDlg.PrintDocument(idpSource.DocumentPaginator, "smart order");
}
示例5: DoPrint
public override void DoPrint(FlowDocument document)
{
var ph = document.PageHeight;
var pw = document.PageWidth;
var pp = document.PagePadding;
var cg = document.ColumnGap;
var cw = document.ColumnWidth;
var fm = document.FontFamily;
var bg = document.Background;
var q = PrinterInfo.GetPrinter(Printer.ShareName);
var pd = new PrintDialog { PrintQueue = q };
if (q != null || pd.PrintQueue.FullName == Printer.ShareName || Printer.ShareName.ToLower() == "default" || Printer.ShareName.Contains("/") || pd.ShowDialog().GetValueOrDefault(false))
{
document.Background = Brushes.Transparent;
document.FontFamily = new FontFamily(LocalSettings.PrintFontFamily);
document.PageHeight = pd.PrintableAreaHeight;
document.PageWidth = pd.PrintableAreaWidth;
document.PagePadding = new Thickness(25);
document.ColumnGap = 0;
document.ColumnWidth = (document.PageWidth -
document.ColumnGap -
document.PagePadding.Left -
document.PagePadding.Right);
pd.PrintDocument(((IDocumentPaginatorSource)document).DocumentPaginator, "");
}
document.Background = bg;
document.FontFamily = fm;
document.PageHeight = ph;
document.PageWidth = pw;
document.PagePadding = pp;
document.ColumnGap = cg;
document.ColumnWidth = cw;
}
示例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: PrintCommand
public void PrintCommand()
{
PrintDialog printDlg = new PrintDialog();
FlowDocument doc = new FlowDocument(new Paragraph(new Run(WebAddress))) {Name = "Directions"};
IDocumentPaginatorSource idpSource = doc;
printDlg.PrintDocument(idpSource.DocumentPaginator, "Directions Printing.");
}
示例8: ButtonOk_Click
private void ButtonOk_Click(object sender, RoutedEventArgs e)
{
this.TextBoxRealReportNumber.Text = this.TextBoxRealReportNumber.Text.ToUpper();
this.TextBoxDummyReportNumber.Text = this.TextBoxDummyReportNumber.Text.ToUpper();
if (this.TextBoxRealReportNumber.Text.Length < 4)
{
MessageBox.Show("The real report number does not appear to be a valid number.\n\nPlease check it and try again.", "Invalid report number", MessageBoxButton.OK);
return;
}
string lastName = this.GetPatientLastName();
if (lastName.Length == 0)
{
MessageBox.Show("The report number does not appear to be a valid number.\n\nPlease check it and try again.", "Case not found", MessageBoxButton.OK);
return;
}
YellowstonePathology.UI.Login.CytologySlideLabelDocument cyologySlideLabelDocument = new CytologySlideLabelDocument(this.TextBoxDummyReportNumber.Text, lastName, false);
System.Windows.Controls.PrintDialog printDialog = new System.Windows.Controls.PrintDialog();
System.Printing.PrintQueue printQueue = YellowstonePathology.UI.PrintQueueFactory.GetSlideLabelPrintQueue(YellowstonePathology.Properties.Settings.Default.CytologySlideLabelPrinterName);
printDialog.PrintQueue = printQueue;
printDialog.PrintDocument(cyologySlideLabelDocument.DocumentPaginator, "Slide Labels");
Close();
}
示例9: Print
public static void Print(FlowDocument printedPage)
{
PrintDialog dialog = new PrintDialog();
dialog.PrintTicket = dialog.PrintQueue.DefaultPrintTicket;
dialog.PrintTicket.PageOrientation = PageOrientation.Portrait;
dialog.PrintTicket.OutputQuality = OutputQuality.High;
dialog.PrintTicket.PageBorderless = PageBorderless.None;
dialog.PrintTicket.PageMediaSize = new PageMediaSize(PageMediaSizeName.ISOA4);
if (dialog.ShowDialog() == true)
{
double pageHeight = printedPage.PageHeight;
double pageWidth = printedPage.PageWidth;
Thickness pagePadding = printedPage.PagePadding;
double columnGap = printedPage.ColumnGap;
double columnWidth = printedPage.ColumnWidth;
printedPage.PageHeight = dialog.PrintableAreaHeight;
printedPage.PageWidth = dialog.PrintableAreaWidth;
printedPage.PagePadding = new Thickness(50);
dialog.PrintDocument(((IDocumentPaginatorSource)printedPage).DocumentPaginator, "");
printedPage.PagePadding = pagePadding;
printedPage.PageHeight = pageHeight;
printedPage.PageWidth = pageWidth;
printedPage.ColumnWidth = columnWidth;
printedPage.ColumnGap = columnGap;
}
}
示例10: btnPrint_Click
private void btnPrint_Click(object sender, RoutedEventArgs e)
{
//Show a Print Dialog
PrintDialog dialog = new PrintDialog();
dialog.MaxPage = this.pdfViewer1.PageCount > 0 ? (uint)this.pdfViewer1.PageCount : 1;
dialog.MinPage = 1;
dialog.UserPageRangeEnabled = true;
bool? result = dialog.ShowDialog();
if (result.Value)
{
try
{
//Set print parnameters.
this.pdfViewer1.PrintDialog = dialog;
//Get the PrintDocument.
dialog.PrintDocument(pdfViewer1.PrintDocument.DocumentPaginator, "Print Document");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
}
示例11: Print_Click
private void Print_Click(object sender, RoutedEventArgs e)
{
//If you reduce the size of the view area of the window, so the text does not all fit into one page, it will print separate pages
PrintDialog printDialog = new PrintDialog();
if (printDialog.ShowDialog() == true)
printDialog.PrintDocument(((IDocumentPaginatorSource)flowDocument).DocumentPaginator, "This is a Flow Document");
}
示例12: print_btn_Click
private void print_btn_Click(object sender, RoutedEventArgs e)
{
try
{
report.report_cr_dr p = new BMS.report.report_cr_dr();
p.lst_balance.ItemsSource = dr;
p.r_date.Content = DateTime.Now.Date.ToShortDateString();
p.r_name.Content = "Top Debitors";
PrintDialog pd = new PrintDialog();
FixedDocument document = new FixedDocument();
document.DocumentPaginator.PageSize = new Size(96 * 8.5, 96 * 11);
FixedPage page1 = new FixedPage();
page1.Width = document.DocumentPaginator.PageSize.Width;
page1.Height = document.DocumentPaginator.PageSize.Height;
Canvas can = p.layout;
page1.Children.Add(can);
PageContent page1Content = new PageContent();
((IAddChild)page1Content).AddChild(page1);
document.Pages.Add(page1Content);
pd.PrintDocument(document.DocumentPaginator, "My first document");
}
catch (Exception ex)
{
MessageBox.Show("Sorry some system error has occour please try again");
}
}
示例13: cmdPrint_Click
private void cmdPrint_Click(object sender, RoutedEventArgs e)
{
PrintDialog pd = new PrintDialog();
if (pd.ShowDialog().GetValueOrDefault())
{
PrintTicket ticket = pd.PrintTicket;
if (cmboOrientation.SelectedIndex == 0)
{
ticket.PageOrientation = PageOrientation.Landscape;
}
else
{
ticket.PageOrientation = PageOrientation.Portrait;
}
pd.PrintTicket = ticket;
mDoc.PageHeight = pd.PrintableAreaHeight;
mDoc.PageWidth = pd.PrintableAreaWidth;
mDoc.PagePadding = new Thickness(50);
mDoc.ColumnGap = 0;
mDoc.ColumnWidth = pd.PrintableAreaWidth;
IDocumentPaginatorSource dps = mDoc;
pd.PrintDocument(dps.DocumentPaginator, title);
}
}
示例14: DoPrint
public override void DoPrint(FlowDocument document)
{
var ph = document.PageHeight;
var pw = document.PageWidth;
var pp = document.PagePadding;
var cg = document.ColumnGap;
var cw = document.ColumnWidth;
var q = PrinterInfo.GetPrinter(Printer.ShareName);
var pd = new PrintDialog { PrintQueue = q };
if (pd.PrintQueue.FullName == Printer.ShareName || pd.ShowDialog().GetValueOrDefault(false))
{
document.FontFamily = new System.Windows.Media.FontFamily(LocalSettings.PrintFontFamily);
document.Typography.EastAsianWidths = FontEastAsianWidths.Half;
document.PageHeight = pd.PrintableAreaHeight;
document.PageWidth = pd.PrintableAreaWidth;
document.PagePadding = new Thickness(25);
document.ColumnGap = 0;
document.ColumnWidth = (document.PageWidth -
document.ColumnGap -
document.PagePadding.Left -
document.PagePadding.Right);
pd.PrintDocument(((IDocumentPaginatorSource)document).DocumentPaginator, "");
}
document.PageHeight = ph;
document.PageWidth = pw;
document.PagePadding = pp;
document.ColumnGap = cg;
document.ColumnWidth = cw;
}
示例15: btnPrint_Click_1
private void btnPrint_Click_1(object sender, RoutedEventArgs e)
{
var printControl = new SummaryControl();
printControl.DataContext = _reservation;
printControl.Width = 8.27 * 96;
printControl.Height = 11.69 * 96;
//Create a fixed Document and Print the document
FixedDocument fixedDoc = new FixedDocument();
PageContent pageContent = new PageContent();
FixedPage fixedPage = new FixedPage();
fixedPage.Height = 11.69 * 96;
fixedPage.Width = 8.27 * 96;
fixedPage.Children.Add(printControl);
((System.Windows.Markup.IAddChild)pageContent).AddChild(fixedPage);
fixedDoc.Pages.Add(pageContent);
PrintDialog dialog = new PrintDialog();
if (dialog.ShowDialog() == true)
{
//dialog.PrintVisual(_PrintCanvas, "My Canvas");
dialog.PrintDocument(fixedDoc.DocumentPaginator, "Print label");
}
}