Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

Ax 2012 - get the default printer name

Posted on by Microsoft Employee

Hello,

In AX 2012,

How can I get the default printer name?

Thanks :)

*This post is locked for comments

  • adam260 Profile Picture
    adam260 1,871 on at
    RE: Ax 2012 - get the default printer name

    you can also get it by....

       Microsoft.Dynamics.AX.Framework.Reporting.Shared.PrinterHelper printerHelper;

       Microsoft.Dynamics.AX.Framework.Reporting.Shared.PrinterInfo printerInfo;

       System.Collections.ArrayList names;

       System.Collections.IEnumerator enumerator;

       str name;

       int printerStatus;

       str driverName;

       str portName;

       str comments;

       int jobCountSinceLastReset;

       printerHelper = new Microsoft.Dynamics.AX.Framework.Reporting.Shared.PrinterHelper();

       names = printerHelper.get_PrinterNames();

       if (names != null)

       {

           enumerator = names.GetEnumerator();

           while (enumerator.MoveNext())

           {

               name = enumerator.get_Current();

               printerInfo = printerHelper.GetPrinterInfo(name);

               printerStatus           = CLRInterop::getAnyTypeForObject(printerInfo.get_PrinterStatus());

               driverName              = CLRInterop::getAnyTypeForObject(printerInfo.get_DriverName());

               portName                = CLRInterop::getAnyTypeForObject(printerInfo.get_PortName());

               comments                = CLRInterop::getAnyTypeForObject(printerInfo.get_Comment());

               jobCountSinceLastReset  = CLRInterop::getAnyTypeForObject(printerInfo.get_JobCountSinceLastReset());

           }

       }

  • Verified answer
    adam260 Profile Picture
    adam260 1,871 on at
    RE: Ax 2012 - get the default printer name

    this will get the default printer

       PrintJobSettings printMe = new PrintJobSettings();

       printMe.deviceName()

    this will get all printers on machine

       printJobSettings pjs;

       str printer;

       int i;

       pjs = new printJobSettings();

       for (i=1; i<=pjs.GetNumberOfPrinters(); i++)

       {

           printer = pjs.GetPrinter(i);

           pjs.DeviceName(printer);

           print "printer No. ",i, " has name ",  printer;

       }

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans