问候,
我试图尽可能地缩小代码。基本上我们使用Adobe Acrobat标准6 Com库进行打印。它与我见过的任何批量pdf打印解决方案一样有效,但我似乎无法使其与Citrix一起使用。 Citrix似乎重新映射了netowrk打印位置,我似乎无法使用现有解决方案。所有代码都在Citirix上运行,它不会打印任何内容。当它在本地运行时,它运行并打印得很好。
非常感谢任何帮助,
谢谢你, 布莱恩
private void btnTest_Click(object sender, EventArgs e)
{
try
{
Cursor.Current = Cursors.WaitCursor;
PrintDialog PrintDialog1 = new PrintDialog();
PrintDialog1.ShowDialog();
CAcroAVDoc acroDoc = null;
const string fileName = @"SomeFile.pdf";
var acroApp = instantiateAcrobat();
acroDoc = GetAcrobatAVDoc();
acroDoc.Open(fileName, "");
CAcroPDDoc pdDoc = (CAcroPDDoc)acroDoc.GetPDDoc();
int numPages = pdDoc.GetNumPages();
UnManagedMethods.SetDefaultPrinter(PrintDialog1.PrinterSettings.PrinterName);
acroDoc.PrintPagesSilent(0, numPages - 1, 2, 1, 0);
MessageBox.Show("Printed!!");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private static CAcroAVDoc GetAcrobatAVDoc()
{
Type acroApp = Type.GetTypeFromProgID("AcroExch.AVDoc", true);
return (CAcroAVDoc)Activator.CreateInstance(acroApp);
}
private static CAcroApp instantiateAcrobat()
{
killAllAcrobatProcesses();
Type acroApp = Type.GetTypeFromProgID("AcroExch.App", true);
return (CAcroApp)Activator.CreateInstance(acroApp);
}
private static void killAllAcrobatProcesses()
{
Process[] acrobatProcesses = Process.GetProcessesByName("Acrobat");
if (acrobatProcesses.Length > 0)
{
foreach (Process process in acrobatProcesses)
{
process.Kill();
}
}
Process[] acroRd32Processes = Process.GetProcessesByName("AcroRd32");
if (acroRd32Processes.Length > 0)
{
foreach (Process process in acroRd32Processes)
{
process.Kill();
}
}
}
答案 0 :(得分:0)
如果有人对此感兴趣,可以通过在Citrix外部的Citrix盒上安装打印机来解决此问题。诀窍是远程桌面进入Citrix盒安装打印机让应用程序工作,所以它将打印。然后,当您通过Citrix打印登录工作正常。回想起来似乎非常明显。