Papersource Section not working when printing


#1

Hallo,

we want to use Aspose.Word for printing files. We have to print differnt pages of the document to diffrent papertrays containing different kinds of paper.

The problem is that the papersource selection is not working at all. Everything is always printed to the first/default papertray.

This is an exanmple from our code:
wordDoc.Sections[0].PageSetup.FirstPageTray =260;
wordDoc.Sections[0].PageSetup.OtherPagesTray = 260;
System.Drawing.Printing.PrinterSettings objPrinterSettings = new System.Drawing.Printing.PrinterSettings();
objPrinterSettings.PrinterName = ConfigurationManager.AppSettings[“Drucker”];
objPrinterSettings.DefaultPageSettings.PaperSource= objPrinterSettings.PaperSources[2];
wordDoc.Save(strDateiNameWordDatei);
wordDoc.Print(objPrinterSettings,strDrucker);

Either the gloabl papersource settings when calling the print-function as well as the papersource settings for the sections in the wordfile are ignored, when aspose prints the document.

Our example code saves the word-dokument. If I open the saved file with MS-Word and print it, the doument is printed to the correct papertray.

This image shows our papertrays for our printer:
image.png (31.3 KB)

We use a Brother HL4150CDN printer for our tests. The oserve the same behavior with the Minolta Printer of our customer.

And ideas how we can solve out this realy frustrating issue?

Sven


#2

@tgjas,

Have you tried the latest version of Aspose.Words for .NET i.e. 18.12 on your end?

In case the problem still remains, please ZIP and upload your sample input Word document you are getting this problem with here for testing.

Please also run the following code on your end and share the output here for our reference.

PrinterSettings settings = new PrinterSettings();
settings.PrinterName = "name of your multi-tray printer";

foreach (PaperSource source in settings.PaperSources)
    Console.WriteLine(source.RawKind);

Please also create a standalone simple console application (source code without compilation errors) that helps us to reproduce your current problem on our end and attach it here for testing

We will then investigate the issue on our end and provide you more information.


#3

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


#4

@tgjas,

Thanks for the details. But, I am afraid, we do not see any attachments (sample documents + console app) in this thread.

If your ZIP file size is big then you can upload the ZIP file to Dropbox and share the Download link here for testing.


#5

The ZIP-file is big. So I uploaded it as public to my google-drive

https://drive.google.com/file/d/109bD3_uUoU5n9QwtmIdv-AEs0gNbramV/view?usp=sharing

Sven


#6

@tgjas,

Please also provide the Word and PDF documents (you are getting this problem with during printing) here for testing. Thanks for your cooperation.


#7

The problem occurs with every PDF- or Word-document. But I provide to example-dcouments as attachment,

Svena_anschreiben.pdf (12.8 KB)
documents.zip (77.3 KB)


#8

@tgjas

Thank you for sharing requested data.

We have logged an investigation ticket with ID PDFNET-45820 to further investigate it with Aspose.PDF perspective. We will let you know as soon as some significant updates will be available.

About Aspose.Words for .NET API, we are checking the scenario and will share our findings with you soon.


#9

@tgjas,

Regarding the issue you are facing with Aspose.Words for .NET API, we have logged your problem in our issue tracking system. Your ticket number is WORDSNET-17912. We will further look into the details of this problem and will keep you updated on the status of the linked issue.