C# 如何复制pdf的全部内容?

C# 如何复制pdf的全部内容?,c#,pdf,copy-paste,transfer,C#,Pdf,Copy Paste,Transfer,你好 我想使用.NET3.5将pdf文件传输到我的c#程序。我知道,这是有自由裁量权的,但我不允许使用这样的自由裁量权。所以我想出了一个主意,手动复制pdf文件的内容,然后将其转换为我的datatable。因为我想让它自动工作,所以我使用以下代码: Process Adope = new Process(); Adope.StartInfo.FileName = fd.FileName.ToString(); Adope.StartInfo.Arguments = fd.FileName.ToS

你好

我想使用.NET3.5将pdf文件传输到我的c#程序。我知道,这是有自由裁量权的,但我不允许使用这样的自由裁量权。所以我想出了一个主意,手动复制pdf文件的内容,然后将其转换为我的datatable。因为我想让它自动工作,所以我使用以下代码:

Process Adope = new Process();
Adope.StartInfo.FileName = fd.FileName.ToString();
Adope.StartInfo.Arguments = fd.FileName.ToString();
Adope.Start();
IntPtr Adobe_handler = IntPtr.Zero;


while (elapsed_Time.ElapsedMilliseconds <= 5000) {
    Adobe_handler = FindWindow("AcrobatSDIWindow", fd.SafeFileName + " - Adobe Reader");
        if (Adobe_handler != IntPtr.Zero) {
            break; 
        }
        System.Threading.Thread.Sleep(200);
}
if (Adobe_handler == IntPtr.Zero) {
    MessageBox.Show("Adobe is not running");
    return;
}

elapsed_Time.Stop();

Clipboard.Clear();

SetForegroundWindow(Adobe_handler);
elapsed_Time.Start();
while (pdf_Info.Equals("")&&elapsed_Time.ElapsedMilliseconds<=10000) {
    Clipboard.Clear();
    SendKeys.SendWait("^a");
    SendKeys.SendWait("^c");
    pdf_Info = Clipboard.GetText().ToString();
}
elapsed_Time.Stop();
Adope.Close();
Process Adope=new Process();
Adope.StartInfo.FileName=fd.FileName.ToString();
Adope.StartInfo.Arguments=fd.FileName.ToString();
Adope.Start();
IntPtr Adobe_handler=IntPtr.Zero;

虽然(已过_Time.elapsedmillyses)它可以工作…有时…当它不工作时会发生什么?有错误吗?没有。pdf文件会打开。但有时我会收到一条错误消息,指出将其复制到剪贴板时出现问题,有时adobe reader会冻结,必须通过任务管理器终止