First reference O2S.Components.PDFRender4NET
(Cloud disk ready: link: https://pan.baidu.com/s/16l5ktVGdJeqdW1_ceydm4g extraction code: xqmh)
Then the tag introduced
using O2S.Components.PDFRender4NET;
Core code
// picture sharpness, the larger the number the more clear public enum Definition { One = . 1 , Two = 2 , Three = . 3 , Four = . 4 , Five = . 5 , Six = . 6 , Seven = . 7 , Eight = . 8 , Nine = . 9 , Ten = 10 } // determines whether a file exists Private BOOL FileIsExists ( String path) { iF (System.IO.File.Exists (path)) return to true ; the else return to false ; } /// <the Summary> /// convert PDF documents to image method /// </ the Summary> /// <param name = "pdfInputPath"> PDF File Path </ param> /// <param name = " imageOutputPath "> picture output path </ param> /// <param name =" imageName "> the name of generated image </ param> /// // <param name =" startPageNum "> starting from the first few pages of a PDF document conversion </ param> /// // <param name = "endPageNum"> from the first few pages of a PDF document conversion start stop </ param> /// // <param name = "definition"> set the picture sharpness the larger the number the more clear </param> ///// <param name="imageFormat">Setting the desired image format </ param> Private String ConvertPDF2Image ( String pdfInputPath, String imageOutputPath, String imageName) { // For testing purposes, the number of fixed parameters // format ImageFormat imageFormat = ImageFormat.Jpeg; // definition Definition = Definition Definition.Ten; // beginning and ending page int startPageNum = 1 ; int endPageNum = 1 ; // generate the image name // String imageName = "the Test"; pdfFile pdfFile = PDFFile.Open(pdfInputPath); if (!Directory.Exists(imageOutputPath)) { Directory.CreateDirectory(imageOutputPath); } if (startPageNum <= 0) { startPageNum = 1; } if (endPageNum > pdfFile.PageCount) { endPageNum = pdfFile.PageCount; } if (startPageNum > endPageNum) { int tempPageNum = startPageNum; startPageNum = endPageNum; endPageNum= StartPageNum; } // Start to Convert each Page // multi-page image generating sequential String imageOutputRet = "" ; for ( int I = startPageNum; I <= endPageNum; I ++ ) { Bitmap pageImage = pdfFile.GetPageImage (I - . 1 , 56 is * ( int ) Definition); imageOutputRet = imageOutputPath + imageName i.ToString + () + " . " + imageFormat.ToString (); /// / preventing duplicate image file temporarily with [] // int. 1 = Sign; / /while(this.FileIsExists(imageOutputRet))//存在 //{ // imageOutputRet = imageOutputPath + imageName + i.ToString() +"_"+sign.ToString() + "." + imageFormat.ToString(); // sign++; //} pageImage.Save(imageOutputRet, imageFormat); pageImage.Dispose(); } pdfFile.Dispose(); return imageOutputRet; }