zoukankan      html  css  js  c++  java
  • c# Pdf 转换图片

    1,引入  dll

    itextsharp.dll、

    PDFView.dll、

     把   gsdll32.dll   拷贝在项目 bin目录下  ,注意:它不能  直接引用

       直接上代码:

     1  /// <summary>
     2         /// 将PDF 相应的页转换为图片
     3         /// </summary>
     4         /// <param name="strPDFpath">PDF 路径</param>
     5         /// <param name="Page">需要转换的页页码</param>
     6         private string GetImage(string strPDFpath, string imgDire, ImageFormat imgeF)
     7         {
     8             StringBuilder b = new StringBuilder();
     9 
    10             PdfReader reader = new PdfReader(strPDFpath);
    11             // 获得文档页数
    12             int pageCount = reader.NumberOfPages;
    13 
    14             System.IO.MemoryStream Ms = new MemoryStream();
    15 
    16             b = b.AppendLine("<ul style='azimuth:center; list-style-type:none;' >");
    17 
    18             for (int page = 1; page <= pageCount; page++)
    19             {
    20 
    21                 System.Drawing.Image img = PDFView.ConvertPDF.PDFConvert.GetPageFromPDF(strPDFpath, page,90, "", true);
    22 
    23                 img.Save(Ms, imgeF);
    24 
    25                 Bitmap returnImage = (Bitmap)Bitmap.FromStream(Ms);
    26 
    27                 string strImgPath = Request.MapPath("..\\" + imgDire + "\\" + page.ToString("0000") + ".jpg");
    28 
    29                 returnImage.Save(strImgPath);
    30 
    31                 Ms.Position = 0;
    32 
    33 
    34                 b = b.AppendLine("<li>  <img src='..\\" + imgDire + "\\" + page.ToString("0000") + ".jpg'  />       </li><span>第" + (page) + "页</span>");
    35             }
    36 
    37             Ms.Close();
    38             b = b.AppendLine("</ul>");
    39 
    40             return b.ToString();
    41 
    42 
    43         }

    ok

  • 相关阅读:
    SPOJ SAMER08A
    SPOJ TRAFFICN
    CS Academy Set Subtraction
    CS Academy Bad Triplet
    CF Round 432 C. Five Dimensional Points
    CF Round 432 B. Arpa and an exam about geometry
    SPOJ INVCNT
    CS Academy Palindromic Tree
    身体训练
    简单瞎搞题
  • 原文地址:https://www.cnblogs.com/DamonTang/p/2796431.html
Copyright © 2011-2022 走看看