我試圖從一個winform的web瀏覽器控制application.The無論是它設置信默認紙張大小,但我需要A4打印設置紙張尺寸和無邊距打印。另外它會自動設置一些頁邊距錯誤,我可以將它們設置爲手動更正設置,但我想以編程方式進行設置。如何從Web瀏覽器控制
這怎麼可能?
這是我的打印代碼。
private void metroButton1_Click(object sender, EventArgs e)
{
loadprintData();
// Create a WebBrowser instance.
WebBrowser webBrowserForPrinting = new WebBrowser();
// Add an event handler that prints the document after it loads.
wa.DocumentCompleted +=
new WebBrowserDocumentCompletedEventHandler(ShowPrintDocument);
wa.ShowPrintPreviewDialog();
reloadpage();
}
private void ShowPrintDocument(object sender,WebBrowserDocumentCompletedEventArgs e)
{
// Print the document now that it is fully loaded.
((WebBrowser)sender).ShowPrintPreviewDialog();
// Dispose the WebBrowser now that the task is complete.
// ((WebBrowser)sender).Dispose();
reloadpage();
}
private void PrintDocument(object sender, WebBrowserDocumentCompletedEventArgs e)
{
// Print the document now that it is fully loaded.
((WebBrowser)sender).Print();
// Dispose the WebBrowser now that the task is complete.
// ((WebBrowser)sender).Dispose();
}
所有的答案在這裏:https://stackoverflow.com/questions/19098571/webbrowser-print-settings –