Aspose.Words version 20.3.0.0

I need to find which versions of Windows are supported by Aspose.Words version 20.3.0.0. I use this as an API in a WinForms application. Without changing any of my code, after updating to Windows 10 Enterprise, 21H2, 19044.1645, my customer now gets this message when trying to print:
System.Drawing.Printing.InvalidPrinterException; Settings to access printer 'our network printer name here' are not valid.

Aside from updating Windows, it is possible that a new security policy was applied.
Many thanks.

@kim.neville I do not think the problem is related to Aspose.Words. Most likely this is a printer access problem. Please make sure printer setting passes to Document.Print method are valid and the printer is accessible.

That is an interesting point. My debug environment won’t let me see if the printer is available - different domains, different physical locations of office. However, your point about the printer being accessible is good. Since no code has changes and the only thing that has changed is hardware, is it possible that the printer needs to be accessible to a security group? Maybe our IT has made a change to security on our new laptops?

The printer is accessible in all other programs - Word, Excel, notepad, etc.

@kim.neville You can try using the following simple code to test whether printer works:

PrintDocument printDocument = new PrintDocument();
printDocument.PrintPage += PrintDocument_PrintPage;
printDocument.PrinterSettings = new PrinterSettings();
// Put your printer name here
printDocument.PrinterSettings.PrinterName = "Microsoft XPS Document Writer";
printDocument.Print();
private static void PrintDocument_PrintPage(object sender, PrintPageEventArgs e)
{
    e.Graphics.FillRectangle(Brushes.Blue, new Rectangle(100, 150, 250, 250));
}

The code does not use Aspose.Words. If it works on your side with your network printer, the Document.Print method should also work fine. Also, you can check PrinterSettings.IsValid property, if it’s value is false printer name is specified improperly.

Thank you for your response. Printing to the network printer from all non-Aspose functions work fine. Since no code has changed, and no printers have changed, and the printer works correctly everywhere else, this leads me to this:
After upgrading from Windows 10 Enterprise 1402 to Windows 10 Enterprise 1404, on new hardware, documents do not print when using the Aspose API. My guess is it is a security setting. I need to find out how to have a phone call with Aspose. I called their sales person for my area to ask what kind of support I have and they did not return my call.

It’s pretty frustrating when something that worked yesterday no longer works today.

@kim.neville Thank you for additional information. Internally Aspose.Words uses a similar code I provided for testing. Could you please try using the following simple code:

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.Write("Hello, World!");

PrinterSettings settings = new PrinterSettings();
// Put your printer name here
settings.PrinterName = "Microsoft XPS Document Writer";

doc.Print(settings);

The exception you have mentioned occurs on my side if printer name is specified improperly.

Unfortunately, I have no way of testing this particular printer as it is in an office in another city and I have no access to their network. Since it was working yesterday and has been for many years, I believe the code is correct. However, I don’t know if, on the the new computer, the name is supposed to be listed differently. The printer name that is used in PrinterSettings is “HP LaserJet 600 M601 M602 M603 PCL6”. To me this seemed odd, but I checked the user’s settings and this has been their printer name since 2015. Strange, yes? I would expect something like “HP LaserJet 600 M602”. I’m not a printer expert (which you have had probably figured out by now :slight_smile: )

Thank you again for your help.

I have an update. I think we are not finding the printer on the network, which supports the above advice. I’m still leaning towards a policy change on the computer.

The earlier advice is greatly appreciated.
Thanks.

@kim.neville You can check the installed printers on your side using the following code:

string pkInstalledPrinters;
for (int i = 0; i < PrinterSettings.InstalledPrinters.Count; i++)
{
    pkInstalledPrinters = PrinterSettings.InstalledPrinters[i];
    Console.WriteLine(pkInstalledPrinters);
}

Check if your network printer is listed.
Could you please also clarify whether this code throws an exception on your side:

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.Write("Hello, World!");

PrinterSettings settings = new PrinterSettings();
// Put your printer name here
settings.PrinterName = "Microsoft XPS Document Writer";

doc.Print(settings);

and this code does not:

PrintDocument printDocument = new PrintDocument();
printDocument.PrintPage += PrintDocument_PrintPage;
printDocument.PrinterSettings = new PrinterSettings();
// Put your printer name here
printDocument.PrinterSettings.PrinterName = "Microsoft XPS Document Writer";
printDocument.Print();
private static void PrintDocument_PrintPage(object sender, PrintPageEventArgs e)
{
    e.Graphics.FillRectangle(Brushes.Blue, new Rectangle(100, 150, 250, 250));
}