Click here to Skip to main content
15,890,741 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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);
      }
Posted
Updated 21-Jul-17 7:09am
v2

1 solution

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[^]".
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900