Hi,
Hi edgar,
for sharing the detail. Please note that Aspose.Words print document pages using the standard .NET printing infrastructure.
Aspose.Words reads values from document in Raw
format (i.e. as int) and after Print method is called, a function
compares the Raw value of PaperTray of current page and values in
PrinterSettings.PaperSources and if it doesn’t find coincidence,
function returns “Automatic” value. Then it passes the value for
PaperTray to underlying Windows function that actually sends document to
printer.
should also note that paper tray numbers are printer specific. I
suppose the problem might occur because paper trays numbers specified in
your document do not match paper tray numbers of the printer running on
your local environment. So, first of all you should make sure that
paper trays in your document are specified correctly.
Hope this answers your query. Please let us know if you have any more queries.
Hi Tahir,
Also, I would like to reiterate that the exact same code in terms of assigning PaperSource and printing works in Cells.
It appears that I have got it working, however I still do believe that my earlier code should work on its own. In order to make it work, I had to add the following red code:
Hi edgar,
Please note that Microsoft
Word stores printer specific values for paper trays in a Word document
and therefore, only printing on the same printer model as the one that
was selected when the user specified the paper trays will result in
printing from the correct trays. If you print a document on a different
printer, then most likely the default paper tray will be used, not the
trays specified in the document.
Following code example changes all sections in a document to use the default paper tray of the selected printer.
Document doc = new
Document(MyDir + “in.docx”);
// Find the printer that will be used for printing this document. In this case it is the default printer.
// You can define a specific printer using PrinterName.
System.Drawing.Printing.PrinterSettings settings = new System.Drawing.Printing.PrinterSettings();
// The paper tray value stored in documents is completely printer specific. This means
// The code below resets all page tray values to use the current printers default tray.
// You can enumerate PrinterSettings.PaperSources to find the other valid paper tray values of the selected printer.
foreach (Section section in doc.Sections)
{
section.PageSetup.FirstPageTray = settings.DefaultPageSettings.PaperSource.RawKind;
section.PageSetup.OtherPagesTray = settings.DefaultPageSettings.PaperSource.RawKind;
}
Yeah, notice, I set the printer name based on what I have stored in a local DB, same with the tray. This is of course presuming, as you rightly alluded to, that the printer model with that name was present when the data was stored in the DB and is still present when documents need to be printed.
Hi edgar,