本文整理汇总了C#中System.Windows.Forms.WebBrowser.ShowPrintPreviewDialog方法的典型用法代码示例。如果您正苦于以下问题:C# WebBrowser.ShowPrintPreviewDialog方法的具体用法?C# WebBrowser.ShowPrintPreviewDialog怎么用?C# WebBrowser.ShowPrintPreviewDialog使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.WebBrowser
的用法示例。
在下文中一共展示了WebBrowser.ShowPrintPreviewDialog方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PrintPage
public static void PrintPage(Form caller, string html)
{
WebBrowser webBrowserForPrinting = new WebBrowser();
webBrowserForPrinting.Size = Size.Empty;
webBrowserForPrinting.Visible = false;
webBrowserForPrinting.DocumentCompleted += (sender, e) =>
{
webBrowserForPrinting.ShowPrintPreviewDialog();
caller.Controls.Remove(webBrowserForPrinting);
};
webBrowserForPrinting.DocumentText = html;
caller.Controls.Add(webBrowserForPrinting);
}
示例2: repIn_Click
private void repIn_Click(object sender, EventArgs e)
{
DataRow row = layoutView1.GetDataRow(layoutView1.FocusedRowHandle);
PrintDocument thePrint = new PrintDocument();
PrintDialog print = new PrintDialog();
print.Document = thePrint;
thePrint.PrintPage += new PrintPageEventHandler(thePrint_PrintPage);
Path_new = FrameworkParams.TEMP_FOLDER + @"\" + row["TEN_FILE"].ToString();
byte[] a = row["NOI_DUNG"] as byte[];
if (a == null || a.Length == 0) return;
HelpByte.BytesToFile(a, Path_new);
try
{
pic = Image.FromFile(Path_new);
}
catch
{ pic = null; }
read = new System.IO.StreamReader(Path_new, System.Text.Encoding.Default, true);
#region print word file
if (Path.GetExtension(Path_new).ToLower().Equals(".doc")
|| Path.GetExtension(Path_new).ToLower().Equals(".docx"))
{
Microsoft.Office.Interop.Word.Application wordApp = new Microsoft.Office.Interop.Word.Application();
object fileName = Path_new;
object nullobj = Missing.Value;
wordApp.Visible = true;
Microsoft.Office.Interop.Word.Document doc = wordApp.Documents.Open(
ref fileName, ref nullobj, ref nullobj, ref nullobj,
ref nullobj, ref nullobj, ref nullobj, ref nullobj,
ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj,
ref nullobj, ref nullobj, ref nullobj);
doc.PrintPreview();
}
#endregion
#region print excel file
else if (Path.GetExtension(Path_new).ToLower().Equals(".xls")
|| Path.GetExtension(Path_new).ToLower().Equals(".xlsx"))
{
Microsoft.Office.Interop.Excel.Application ExcelApp = new Microsoft.Office.Interop.Excel.Application();
ExcelApp.Visible = true;
ExcelApp.DisplayAlerts = false;
Microsoft.Office.Interop.Excel.Workbook WBook = ExcelApp.Workbooks.Open(Path_new, Missing.Value,
Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value,
Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value);
object obj = true;
WBook.PrintPreview(obj);
WBook.Close(false, Missing.Value, Missing.Value);
ExcelApp.Quit();
}
#endregion
#region print .pdf file
else if (Path.GetExtension(Path_new).ToLower().Equals(".pdf"))
{
System.Diagnostics.Process objProcess = new System.Diagnostics.Process();
objProcess.StartInfo.FileName = Path_new; //file to print
objProcess.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
objProcess.StartInfo.UseShellExecute = true;
objProcess.StartInfo.CreateNoWindow = false;
objProcess.StartInfo.ErrorDialog = false;
objProcess.StartInfo.Verb = "print";
objProcess.Start();
}
#endregion
#region print html file
else if (Path.GetExtension(Path_new).ToLower().Equals(".htm")
|| Path.GetExtension(Path_new).ToLower().Equals(".html"))
{
WebBrowser browser = new WebBrowser();
browser.DocumentText = read.ReadToEnd();
while (browser.ReadyState != WebBrowserReadyState.Complete)
{
Application.DoEvents();
}
browser.Parent = this;
browser.ShowPrintPreviewDialog();
browser.Dispose();
}
#endregion
else if (print.ShowDialog() == DialogResult.OK)
{
PrintPreviewDialog ppd = new PrintPreviewDialog();
ppd.Document = thePrint;
((Form)ppd).WindowState = FormWindowState.Maximized;
ppd.ShowDialog();
//thePrint.Print();
}
}
示例3: ShowPrintPreview
public void ShowPrintPreview()
{
WebBrowser x = new WebBrowser();
x.CreateControl();
x.Visible = false;
try
{
x.Navigate(Url);
x.ShowPrintPreviewDialog();
}
catch (System.Net.WebException y)
{
MessageBox.Show(y.Message);
}
}