有没有办法使用矩形从 pdf 创建图像?
我正在使用 syncfusion pdfviewer(使用无限固定费用许可证)。这就是我使用 c# 从 pdf 创建图像的方式
private void ScreenCapture(string fileName, int x, int y, int width, int height)
{
try
{
if (x != 0 && y != 0 && width != 0 && height != 0)
{
Rectangle rect = new Rectangle(x, y, width, height);
Bitmap bmp = new Bitmap(rect.Width, rect.Height, PixelFormat.Format32bppArgb);
Graphics g = Graphics.FromImage(bmp);
g.CopyFromScreen(rect.Left, rect.Top, 0, 0, bmp.Size, CopyPixelOperation.SourceCopy);
bmp.Save(fileName, ImageFormat.Jpeg);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
MessageBox.Show(ex.StackTrace);
}
finally
{
}
}
这是我的附加代码
关于申报
Point startPoint;
鼠标按下
Control control = (Control)sender;
startPoint = control.PointToScreen(new Point(e.X, e.Y));
在我的鼠标上
Point endPoint = ((Control)sender).PointToScreen(new Point(e.X, e.Y));
int width = endPoint.X - startPoint.X;
int height = endPoint.Y - startPoint.Y;
theRectangle = new Rectangle(startPoint.X ,
startPoint.Y, width, height );
我的代码的问题是我正在捕获我的屏幕。所以当我调整我的程序大小时。它将捕获屏幕并导致错误的图像
那么有没有办法使用 c# 获取或将具有矩形的 pdf 页面转换为图像?谢谢你
更新:
如果我的问题不清楚,我很抱歉。
例子。我使用syncfusion的pdfviewer在pdf上画一个矩形
输出将是这样的
https://drive.google.com/open?id=0B45rDxvaXzsmcTZIVVVSUU9Zc0E
https://drive.google.com/open?id=0B45rDxvaXzsmc1cxNTV4UUdOMUE
https://drive.google.com/open?id=0B45rDxvaXzsmSWtDRWhXYkpDT2c
https://drive.google.com/open?id=0B45rDxvaXzsmS214WmJnN3BvcUk
如果我的问题不清楚,我很抱歉