资源简介

O2S.Components.PDFRender4NET.dll 真正无水印版,已经测试过,完全可用,能够直接将pdf转化为图片的DLL。并附有Demo,下载直接修改路径就可运行;本人项目就使用这个。

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using O2S.Components.PDFRender4NET;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;

namespace pdf2image.O2S.Components.PDFRender4NET
{
    public static class Program
    {
        public enum Definition
        {
            One = 1 Two = 2 Three = 3 Four = 4 Five = 5 Six = 6 Seven = 7 Eight = 8 Nine = 9 Ten = 10
        }

        /// 
        /// 将PDF文档转换为图片的方法
        /// 

        /// PDF文件路径
        /// 图片输出路径
        /// 生成图片的名字
        /// 从PDF文档的第几页开始转换
        /// 从PDF文档的第几页开始停止转换
        /// 设置所需图片格式
        /// 设置图片的清晰度,数字越大越清晰
        public static void ConvertPDF2Image(string pdfInputPath string imageOutputPath
            string imageName int startPageNum int endPageNum ImageFormat imageFormat Definition definition)
        {
            PDFFile pdfFile = PDFFile.Open(pdfInputPath);

            if (!Directory.Exists(imageOutputPath))
            {
                Directory.CreateDirectory(imageOutputPath);
            }

            // validate pageNum
            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
            for (int i = startPageNum; i <= endPageNum; i++)
            {
                Bitmap pageImage = pdfFile.GetPageImage(i - 1 56 * (int)definition);
                pageImage.Save(imageOutputPath + imageName + i.ToString() + “.“ + imageFormat.ToString() imageFormat);
                pageImage.Dispose();
            }

            pdfFile.Dispose();
        }

        public static void Main(string[] args)
        {
            ConvertPDF2Image(“C:\\FileServer\\test.pdf“ “C:\\FileServer\\“ “test“ 1 5 ImageFormat.Jpeg Definition.One);
        }

    }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件     745472  2015-07-23 23:02  pdf2image.O2S.Components.PDFRender4NET\bin\Debug\O2S.Components.PDFRender4NET.dll

     文件       6656  2015-07-23 23:05  pdf2image.O2S.Components.PDFRender4NET\bin\Debug\pdf2image.O2S.Components.PDFRender4NET.exe

     文件      13824  2015-07-23 23:05  pdf2image.O2S.Components.PDFRender4NET\bin\Debug\pdf2image.O2S.Components.PDFRender4NET.pdb

     文件      11608  2018-09-10 15:57  pdf2image.O2S.Components.PDFRender4NET\bin\Debug\pdf2image.O2S.Components.PDFRender4NET.vshost.exe

     文件        490  2017-09-29 21:43  pdf2image.O2S.Components.PDFRender4NET\bin\Debug\pdf2image.O2S.Components.PDFRender4NET.vshost.exe.manifest

     文件     745472  2015-07-23 23:02  pdf2image.O2S.Components.PDFRender4NET\O2S.Components.PDFRender4NET.dll

     文件       6221  2018-09-10 15:57  pdf2image.O2S.Components.PDFRender4NET\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件       1261  2018-09-10 15:57  pdf2image.O2S.Components.PDFRender4NET\obj\Debug\pdf2image.O2S.Components.PDFRender4NET.csproj.FileListAbsolute.txt

     文件      10263  2015-07-23 23:05  pdf2image.O2S.Components.PDFRender4NET\obj\Debug\pdf2image.O2S.Components.PDFRender4NET.csprojResolveAssemblyReference.cache

     文件       6656  2015-07-23 23:05  pdf2image.O2S.Components.PDFRender4NET\obj\Debug\pdf2image.O2S.Components.PDFRender4NET.exe

     文件      13824  2015-07-23 23:05  pdf2image.O2S.Components.PDFRender4NET\obj\Debug\pdf2image.O2S.Components.PDFRender4NET.pdb

     文件       3166  2015-07-23 23:04  pdf2image.O2S.Components.PDFRender4NET\pdf2image.O2S.Components.PDFRender4NET.csproj

     文件       2560  2018-09-10 15:57  pdf2image.O2S.Components.PDFRender4NET\pdf2image.O2S.Components.PDFRender4NET.suo

     文件       2576  2015-07-23 22:22  pdf2image.O2S.Components.PDFRender4NET\Program.cs

     文件       1384  2015-07-23 22:22  pdf2image.O2S.Components.PDFRender4NET\Properties\AssemblyInfo.cs

     目录          0  2015-01-19 11:26  pdf2image.O2S.Components.PDFRender4NET\obj\Debug\TempPE

     目录          0  2018-09-10 15:57  pdf2image.O2S.Components.PDFRender4NET\bin\Debug

     目录          0  2015-07-23 23:05  pdf2image.O2S.Components.PDFRender4NET\obj\Debug

     目录          0  2015-07-23 22:26  pdf2image.O2S.Components.PDFRender4NET\bin

     目录          0  2015-07-23 22:26  pdf2image.O2S.Components.PDFRender4NET\obj

     目录          0  2015-07-23 22:26  pdf2image.O2S.Components.PDFRender4NET\Properties

     目录          0  2018-09-10 15:57  pdf2image.O2S.Components.PDFRender4NET

----------- ---------  ---------- -----  ----

              1571433                    22


评论

共有 条评论