I have tried to use Aspose Words.NET
and Aspose PDF .NET to print documents to a printer with PrinterSettings. I need to specify printing properties such as paper size (A3/A4), Landscape/Portrait orientation, paper tray to use, etc.
I have tried to use PdfViewer.PrintDocumentWithSettings and Aspose.Words.Document.Print, but without success. Here is a code fragment for Aspose.Words.
// I have previously loaded the printer setting options into combo boxes cBSources and cbSizes
System.Drawing.Printing.PaperSize pSize;
System.Drawing.Printing.PaperSource pSource;
PrinterSettings pS = new PrinterSettings();
pS.PrinterName = strPrinterName;
for (i = 0; i <ps.PaperSources.Count; i++)
{
pSource = ps.PaperSources[i];
cbSources.Items.Add(pSource);
}
for (i = 0; i <ps.PaperSizes.Count; i++)
{
pSize = ps.PaperSizes[i];
cbSizes.Items.Add(pSize);
}
// later I want to use selected parameters to print a document
PrinterSettings pS = new PrinterSettings();
Aspose.Words.Document document = new Aspose.Words.Document(strFileName);
pS.PrinterName = strPrinterName;
ps.Duplex = Duplex.Simplex;
ps.DefaultPageSettings.Color = false;
ps.DefaultPageSettings.Landscape = true;
if (cbSources.SelectedIndex != -1)
ps.DefaultPageSettings.PaperSource = ps.PaperSources[cbSources.SelectedIndex];
if (cbSizes.SelectedIndex != -1)
ps.DefaultPageSettings.PaperSize = ps.PaperSizes[cbSizes.SelectedIndex];
document.Print(pS, strFileName);
The document always prints in portrait and A4 size (the printer defaults) no matter what I choose for size, orientation, etc.
I get the same result using Aspose PDF for .NET.
Is there a different method I should use. Do you have a code sample I can use?
Many Thanks