We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Rendering Engine Require Aspose.pdf

I may upgrade my Aspose.Words license to use the new rendering engine to convert docs to pdf and print to printers.

  1. Do I need Aspose.pdf for any reason?
  2. Can you show sample code to print to a specific printer, and a specific printer tray. Is this a built in .Net process to get to the printer and tray? It is very easy in Word VBA, where I use code such as:
With objWord.Dialogs(wdDialogFilePrintSetup)
.Printer = ActivePrinterValue
.DoNotSetAsSysDefault = True
End With
objWrdDoc.PageSetup.FirstPageTray = TrayValue
objWrdDoc.PageSetup.OtherPagesTray = TrayValue

I have a program I wrote that uses Word VBA to store the TrayValue in the registry. Do you have sample code on how Aspose can print directly to the printer and tray.
Thank You,

Thanks for your request.

  1. No you don’t need Aspose.Pdf. Currently there are two ways to convert Word document to PDF.
    a. Direct conversion to PDF using Aspose.Words (without using Aspose.Pdf). See the following link for more information:
    here is code:
Document doc = new Document(@"Test012\number_error.doc");
b. Another way is using Aspose.Words and Aspose.Pdf using the following code (Old method):
Document doc = new Document(@"Test012\number_error.doc");
// Save in intermediate AsposePdf format
MemoryStream aPdfStream = new MemoryStream();
doc.Save(aPdfStream, SaveFormat.AsposePdf);
// Create Aspose.Pdf.Pdf document
Aspose.Pdf.Pdf pdf = new Aspose.Pdf.Pdf();
pdf.BindXML(aPdfStream, null);
// Save pdf
  1. You can use PrinterSettings to specify Printer. Please see the following link for more information.
    Also there are corresponding properties FirstPageTray and OtherPagesTray in Aspose.Words Document model. Please see the following links for more information.

Hope this helps.
Best regards.

I can try to explain a bit more about printing in Aspose.Words public API because I was coding it.
All Document.Print methods in Aspose.Words internally use the AsposeWordsPrintDocument class. An important point is that AsposeWordsPrintDocument prints a document the way the document creator wanted it to print. Each section in a document has page setup that specifies paper size, orientation and paper trays for the first and other pages in the section. AsposeWordsPrintDocument honours all these settings during printing.
When AsposeWordsPrintDocument executes, it internally calls Document.GetPageInfo for each page that returns a PageInfo object and that tells what paper size, orientation and paper tray that particular page is supposed to be (all data comes from the section page setup).
The only catch is that paper tray in the current release 6.0 is not calculated properly and will always print to default, but that will be fixed soon. Nevetherless, paper size and orientation work well.
From that I can offer you two ways to achieve what you want:
a. Loop through all sections in the document and set paper trays you want. Then use one of the standard Document.Print methods. Basically when you modify Section.PageSetup paper tray values you tell Aspose.Words how to print.
b. Implement your own class derived from .NET PrintDocument or from AsposeWordsPrintDocument and print to the trays you want or otherwise customize the printing process. This way you can basically print anyway you like, for example many thumbnail pages on one page etc.
A good example for implementing custom printing is here
This code is basically the source of the AsposeWordsPrintDocument class, just renamed to make an example.