如何使用带有C#的ASP.NET在PDF中截取图像? [英] How to take screenshot of image in a PDF using ASP.NET with C#?

查看:69
本文介绍了如何使用带有C#的ASP.NET在PDF中截取图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用带有C#的asp.net在PDF中截取图像。我使用adobe acrobat pro开发了一个PDF。我需要从pdf中获取图像作为屏幕截图左右,并使用c#将此图像转换为二进制(base 64)文件。

我可以在代码部分正在运行的情况下拍摄页面的屏幕截图。但无法在PDF文件中获取图像的屏幕截图



我尝试过:



I want to take screenshot of image in a PDF using asp.net with C#. I have developed a PDF using adobe acrobat pro. I need to get the Image from the pdf as a screen shot or so and convert this image to a binary (base 64) file using c# .
I am able to take the screen shot of the page with the code part is running. But the unable to get the screen shot of a image in a PDF File

What I have tried:

public static void Capture(string CapturedFilePath)
      {
          Bitmap bitmap = new Bitmap
        (Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);

          Graphics graphics = Graphics.FromImage(bitmap as System.Drawing.Image);
          graphics.CopyFromScreen(25, 25, 25, 25, bitmap.Size);

          bitmap.Save(CapturedFilePath, ImageFormat.Bmp);
      }

推荐答案

考虑所有ASP.NET代码在Web服务器上而不是在客户端上运行完整,你不能这样做。



你需要一些javascript库才能捕获客户端的屏幕截图,我甚至不确定是考虑到安全问题,可能会出现这种情况。



现在,如果您正在谈论将PDF转换为图像,您需要找到一个可以为您执行此操作的库或呈现图像而不是文件。 Google为 pdf to image library [ ^ ]。
Considering all ASP.NET code runs ENTIRELY on the web server and not on the client, you can't do this.

You would need some javascript library to be able to capture screen shot on the client, which I'm not even entirely sure is possible given the security concerns.

Now, if you're talking about converting a PDF to an Image, you need to find a library that either does this for you or renders to an image instead of a file. Google for "pdf to image library[^]".


这篇关于如何使用带有C#的ASP.NET在PDF中截取图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆