Показать сообщение отдельно
Старый 04.11.2011, 17:12   #1  
Blog bot is offline
Blog bot
Участник
 
25,643 / 848 (80) +++++++
Регистрация: 28.10.2006
palleagermark: Print images directly from AX without user interaction
Источник: http://palleagermark.blogspot.com/20...x-without.html
==============

I have written one other post on doing this by calling WinApi::ShellExecute directly, but here is a more elaborate sample using .NET.

The sample prints an image (in this case a TIFF image) to your default printer without prompting first. You need to add a reference to System.Printing in AX to use the sample.

static void PrintImage(Args _args)
{
System.Printing.PrintServer localPrintServer = new System.Printing.LocalPrintServer();
System.Printing.PrintQueue printQueue = System.Printing.LocalPrintServer::GetDefaultPrintQueue();
System.Diagnostics.Process printProcess = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo processStartInfo;
str arguments;
Filename fileName = @'C:\TESTFILE.TIF';
;

processStartInfo = printProcess.get_StartInfo();

processStartInfo.set_Verb("Print");
processStartInfo.set_FileName(@"C:\WINDOWS\System32\rundll32.exe");

arguments = @'C:\WINDOWS\System32\shimgvw.dll,ImageView_PrintTo /pt ';
arguments += @'"';
arguments += filename;
arguments += @'" ';
arguments += @'"';
arguments += ClrInterop::getAnyTypeForObject(localPrintServer.get_Name()) + @'\' + ClrInterop::getAnyTypeForObject(printQueue.get_Name());
arguments += @'" ';
arguments += @'"%3" "%4"';

processStartInfo.set_Arguments(arguments);

processStartInfo.set_UseShellExecute(false);

printProcess.Start();
printProcess.Close();
}



Источник: http://palleagermark.blogspot.com/20...x-without.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.