I have investigated a bit further. Aspose seams to ignore the papersource-settings when printing. We now have experienced the same behavior in Apose.Words and Apose.Pdf! We need a solution for Word and Pdf.
I made the tests with the newest version of Apose.Word and Apose.Pdf (18.12.0.0). I am using .NET 4.7 (newest version), Visual Studio 2012 and a Brother HL-4150CDN series Printer. We are developing console-applications
This is the enumeration the papersources of out printer:
0: Papersouce ‘Automatisch auswählen’, RawKind 15
1: Papersouce ‘Automatische Schachtaus’, RawKind 261
2: Papersouce ‘Fach 1’, RawKind 260
3: Papersouce ‘Fach 2’, RawKind 259
4: Papersouce ‘MP-Fach’, RawKind 258
5: Papersouce ‘Manuell’, RawKind 257
If have written two small test programs called “wordtest” and “pdftest” to test the printing to different papersources for Apose.Words and Apose.Pdf. You will find the full C#-projects in the attached ZIP-file. They take 3 arguments (filename, printername, papersource (0-5 for my printer). In both cases the papersource is ignored. Files are always printed on paper from the default source.
This is the test program for Apose.Word:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Aspose.Words ;
namespace wordtest
{
class Program
{
static void Main(string[] args)
{
if (args.Count() != 3)
{
Console.WriteLine("Usage: wordtest <wordfile_to_print> ");
}
else
{
Aspose.Words.Document myDoc = new Aspose.Words.Document(args[0]);
System.Drawing.Printing.PrinterSettings objPrinterSettings = new System.Drawing.Printing.PrinterSettings();
objPrinterSettings.PrinterName = args[1];
objPrinterSettings.DefaultPageSettings.PaperSource = objPrinterSettings.PaperSources[System.Convert.ToInt32(args[2])];
myDoc.Print(objPrinterSettings);
}
}
}
}
This is the test program for Apose.Pdf:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Aspose.Pdf;
namespace pdftest
{
class Program
{
static void Main(string[] args)
{
if (args.Count() != 3)
{
Console.WriteLine("Usage: pdftest <pdffile_to_print> ");
}
else
{
Aspose.Pdf.Document myDoc = new Aspose.Pdf.Document(args[0]);
System.Drawing.Printing.PrinterSettings objPrinterSettings = new System.Drawing.Printing.PrinterSettings();
objPrinterSettings.PrinterName = args[1];
objPrinterSettings.DefaultPageSettings.PaperSource = objPrinterSettings.PaperSources[System.Convert.ToInt32(args[2])];
Aspose.Pdf.Facades.PdfViewer viewer = new Aspose.Pdf.Facades.PdfViewer();
viewer.BindPdf(myDoc );
viewer.PrintDocumentWithSettings(objPrinterSettings);
}
}
}
}
To proof that it is not a general problem of my printer,.NET or windows, I have also tried to print something with the plain printing-functions from .NET to paper from different papersources. This is working fine!!! In the following example the text is first printed on paper from the “2: Papersouce ‘Fach 1’, RawKind 260” then the text is printed to paper from then “5: “Papersouce ‘Manuell’, RawKind 257”
printFont = new Font("Arial", 10);
PrintDocument pd = new PrintDocument();
System.Drawing.Printing.PrinterSettings objPrinterSettings = new System.Drawing.Printing.PrinterSettings();
objPrinterSettings.PrinterName = "Brother HL-4150CDN series Printer";
objPrinterSettings.DefaultPageSettings.PaperSource= objPrinterSettings.PaperSources[2];
pd.PrinterSettings = objPrinterSettings;
pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
pd.Print ();
objPrinterSettings.DefaultPageSettings.PaperSource = objPrinterSettings.PaperSources[5];
pd.PrinterSettings = objPrinterSettings;
pd.Print();
Thank you for ready. Hoping for a solution – our customer is waiting…
Sven