屏幕截图无法复制

3
这个略有些令人困惑...
我正在使用Adobe的PDF Viewer控件来查看PDF,但我希望用户能够将图像拖放到PDF上,然后当他们单击保存时,将图像添加到该位置的PDF中。
实现PDF浏览器非常困难,但最终我决定使用Adobe的控件,拍照片,然后允许用户在PDF图片之上绘制图像。当他们单击保存时,一旦我确定了图像的位置,我将使用PDFSharp将其放入PDF中,但我目前遇到的问题是无法获取PDF的图片。
以下代码用于获取图片,但连接到它的面板只出现带有红色“X”和边框的白色背景...
using (Bitmap bitmap = new Bitmap(adobePDFViewer1.Width, adobePDFViewer1.Height))
                {
                    using (Graphics g = Graphics.FromImage(bitmap))
                    {
                        g.CopyFromScreen(new Point(adobePDFViewer1.Left, adobePDFViewer1.Top), Point.Empty, adobePDFViewer1.Size);
                    }
                    panelOverPdfViewer.BackgroundImage = bitmap;
                }

我不认为这是最好的方法,但是我找不到其他方法。任何帮助将不胜感激!
编辑:
根据下面非常有帮助的答案,这是可行的代码:
以下是我使用的代码:
Bitmap printscreen = new Bitmap(adobePDFViewer1.Width, adobePDFViewer1.Height);
                Graphics graphics = Graphics.FromImage(printscreen as Image);
                int left = this.Left + 396;
                int top = this.Top + 30;
                graphics.CopyFromScreen(left, top, 0, 0, printscreen.Size);
                pictureBoxOverPDFView.Image = printscreen;
1个回答

4

请看这个Print-Screen,它与CopyFromScreen的测试工作相关。

private void PrintScreen()

{  

Bitmap printscreen = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);

Graphics graphics = Graphics.FromImage(printscreen as Image);

graphics.CopyFromScreen(0, 0, 0, 0, printscreen.Size);

printscreen.Save(@"C:\Temp\printscreen.jpg", ImageFormat.Jpeg);

} 

非常感谢 - 这正是我想要的!!我稍微修改了一下,以便按照我想要的方式工作,但除此之外完美无缺! - Compunutter

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接