Printing to a print queue with a document name

I want to print my Words document to a print queue by specifying the name of the printer AND i want to be able to name the document in the print queue. The overloads of the Print method dont seeem to allow this.

@aultmike

To print a Word document to a specific printer and also set a custom name for the document in the print queue, you can utilize the Print method of the Aspose.Words Document class. This method allows you to specify printer settings and a custom document name.

Here’s a code example demonstrating how to achieve this:

using System;
using System.Drawing.Printing;
using Aspose.Words;

class Program
{
    static void Main()
    {
        // Load the document
        Document doc = new Document("YourDocument.docx");

        // Create PrinterSettings object
        PrinterSettings printerSettings = new PrinterSettings();
        
        // Specify the printer name
        printerSettings.PrinterName = "YourPrinterName";

        // Set the print range if needed
        printerSettings.PrintRange = PrintRange.SomePages;
        printerSettings.FromPage = 1;
        printerSettings.ToPage = 1;

        // Print the document with a custom name in the print queue
        doc.Print(printerSettings, "My Custom Document Name");
    }
}

In this example:

  • Replace "YourDocument.docx" with the path to your Word document.
  • Set "YourPrinterName" to the name of the printer you want to use.
  • The Print method is called with the PrinterSettings object and a custom name for the document in the print queue.

This approach allows you to control both the printer selection and the document name as it appears in the print queue, fulfilling your requirements effectively.

For more detailed information, you can refer to the official documentation on printing documents with Aspose.Words here which provides additional context and examples.

If you have any further questions or need additional assistance, feel free to ask!

1 Like

PUUUUURRRRRFECT! Thanks!

1 Like