Category / Section
How to "Take a snapshot" as on Acrobat?
1 min read
We can perform this action from our code behind.
Below is the code snippet to select a particular region and return it as an image that we need to do in the Form.cs
C#
private void Form1_Load(object sender, EventArgs e) { // Create an instance PdfDocumentView PdfDocumentView view = new PdfDocumentView(); // Load the document to be exported as image documentView.Load("../../Data/PDF_Succinctly.pdf"); // ExportAsImage return the bitmap image of any page of the loaded pdf document Bitmap image = documentView.ExportAsImage(0); // Select a region to take snapshot Rectangle newRect = new Rectangle(150, 100, 400, 400); // Use Bitmap.Clone( ) to save the image in local drive System.Drawing.Imaging.PixelFormat format = image.PixelFormat; Bitmap cloneBitmap = image.Clone(newRect, format); cloneBitmap.Save("PDF_Succinctly.png"); }
Sample:
https://www.syncfusion.com/downloads/support/directtrac/general/ze/Sample2116766911