How to crop pdf file as image and save in C# winform ?
How to crop pdf file as image using coordinate and save as image and then print that image ?
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
shi lianghong48 pointsPosted Mar 19, 2015, 11:21 PM EDT
0
I could recommend U a API to extract image from PDF. Download a hotfix then add reference,the code :
Python
//Instantiate an object of Spire.Pdf.PdfDocument PdfDocument doc = new PdfDocument(); //Load a PDF file doc.LoadFromFile("sample.pdf"); List ListImage = new List(); for (int i = 0; i < doc.Pages.Count; i++) { // Get an object of Spire.Pdf.PdfPageBase PdfPageBase page = doc.Pages[i]; // Extract images from Spire.Pdf.PdfPageBase Image[] images = page.ExtractImages(); if (images != null && images.Length > 0) { ListImage.AddRange(images); } } if (ListImage.Count > 0) { for (int i = 0; i < ListImage.Count; i++) { Image image = ListImage[i]; image.Save("image" + (i + 1).ToString() + ".png", System.Drawing.Imaging.ImageFormat.Png); } System.Diagnostics.Process.Start("image1.png"); }
shi lianghong48 pointsPosted Mar 19, 2015, 11:21 PM EDT
Download a hotfix then add reference,the code :
//Instantiate an object of Spire.Pdf.PdfDocument PdfDocument doc = new PdfDocument(); //Load a PDF file doc.LoadFromFile("sample.pdf"); List ListImage = new List(); for (int i = 0; i < doc.Pages.Count; i++) { // Get an object of Spire.Pdf.PdfPageBase PdfPageBase page = doc.Pages[i]; // Extract images from Spire.Pdf.PdfPageBase Image[] images = page.ExtractImages(); if (images != null && images.Length > 0) { ListImage.AddRange(images); } } if (ListImage.Count > 0) { for (int i = 0; i < ListImage.Count; i++) { Image image = ListImage[i]; image.Save("image" + (i + 1).ToString() + ".png", System.Drawing.Imaging.ImageFormat.Png); } System.Diagnostics.Process.Start("image1.png"); }Refer this article:http://www.e-iceblue.com/Tutorials/Spire.PDF/Spire.PDF-Program-Guide/How-to-Extract-Image-From-PDF-in-C.html
Painting with Images, Drawings, and Visuals