skuskusas
skuskusas

Reputation: 93

Dynamic ax 2012 R2 Send pdf file to printer on server side

I am trying send pdf file to printer using soap client from web.
Using job in ax works fine. I'am tried:
winAPI::shellExecute(adobeExe, adobeParm);
Enable AOS printing on the AOS server
http://www.artofcreation.be/2014/01/27/how-to-print-any-file-in-ax/

But does not work for me. Maybe for someone has managed to do it? Maybe need with ghostScript or sumatraPDF ? or...?
Thanks in advance.

Upvotes: 1

Views: 1592

Answers (2)

skuskusas
skuskusas

Reputation: 93

#File   //File macro
System.Diagnostics.ProcessStartInfo processInfo;
System.Diagnostics.Process process;
System.Exception interopException;

// Parameters
Filename    fileName    = @"C:\test\test.pdf";
PrinterName printername = UserPrinterHandler::getDefaultPrinter();
;

printerName = '"' + printerName + '"';

try
{
    // assert permissions
    new InteropPermission(InteropKind::ClrInterop).assert();

    process = new System.Diagnostics.Process();

    processInfo = process.get_StartInfo();

    processInfo.set_UseShellExecute(true);
    processInfo.set_CreateNoWindow(true);
    processInfo.set_FileName(fileName);

    // the argument is the printer name
    processInfo.set_Arguments(printerName);

    // set the verb to printto
    processInfo.set_Verb('printto');
    processInfo.set_WindowStyle(System.Diagnostics.ProcessWindowStyle::Hidden);

    process.Start();

    // revert asserted permissions
    CodeAccessPermission::revertAssert();
}

Upvotes: 1

Alex Kwitny
Alex Kwitny

Reputation: 11544

Log into the server as the AOS user account and make sure the printer is added, or re-add it. Can't hurt to do it again as your user account too.

Upvotes: 0

Related Questions