问候,
我试图尽可能地缩小代码。基本上我们使用 Adobe Acrobat 标准 6 Com 库进行打印。它与我见过的任何批量 pdf 打印解决方案一样有效,但我似乎无法使其与 Citrix 一起使用。Citrix 似乎重新映射了网络打印位置,我似乎无法在没有现有解决方案的情况下使其工作。所有代码都在 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();
}
}
}