found this function online, which works great... except I can't figure out how to default it to print in landscape.
private void PrintClick(object sender, RoutedEventArgs e)
{
PrintDialog dialog = new PrintDialog();
if (dialog.ShowDialog() == true)
{ dialog.PrintVisual(_PrintCanvas, "My Canvas"); }
}
How does one actually set the default to print my wpf content to landscape mode?
Printers can print in portrait or landscape mode. In portrait mode, which is the default, the printer prints pages that are 8.5″ wide and 11″ tall. In landscape mode, the page is turned on its side. This mode may be useful if you are trying to print a spreadsheet or sign that is wider than it is long.
1. When referring to graphics or printing, landscape mode is a horizontal orientation of a document or image. Landscape mode is commonly used to print charts, wider images, and text that may not fit properly if the page is oriented in portrait mode (vertically).
Edit: Fixed variable name, mentioned by @SHIN JaeGuk
private void PrintClick(object sender, RoutedEventArgs e)
{
PrintDialog dialog = new PrintDialog();
if (dialog.ShowDialog() == true)
{
//Set PageOrientation to Landscape
dialog.PrintTicket.PageOrientation = PageOrientation.Landscape;
dialog.PrintVisual(_PrintCanvas, "My Canvas");
}
}
private void PrintClick(object sender, RoutedEventArgs e)
{
PrintDialog dialog = new PrintDialog();
if (dialog.ShowDialog() == true)
{
dialog.PrintTicket.PageOrientation=System.Printing.PageOrientation.Landscape;
dialog.PrintVisual(this, "First LandScape");
}
}
You need to add a reference to ReachFramework.dll and System.Printing.dll each.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With