Skip to content

How to crop pdf file as image and save in C# winform ?

Ajit More

Ajit More

Asked Mar 10, 2015, 8:54 PM EDT1 answer
Share
LinkedInX
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  lianghong
    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");             }


    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

    0