I would like to set the Page orientation to LandScape for printing excel worksheet from my excel Vsto project. Manually page orientation is set from the Printer Preferen
You can try something like the following below should work for you
public void CustPrinting()
{
try
{
strPrint = new StreamReader (filePath);
try
{
printFont = new Font("Arial", 10);
PrintDocument pd = new PrintDocument();
pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
pd.PrinterSettings.PrinterName = printer;
// Set the page orientation to landscape.
pd.DefaultPageSettings.Landscape = true;
pd.Print();
}
finally
{
strPrint.Close() ;
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}