1
我試圖儘可能地縮小代碼。基本上我們使用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();
}
}
}
你爲什麼讓這個wiki? – 2010-08-30 18:05:03
您能否顯示您的方法UnManagedMethods.SetDefaultPrinter(PrintDialog1.PrinterSettings.PrinterName); 呢?我正在尋找執行類似的功能。 – mservidio 2011-12-16 18:24:29