项目中需要这么一个功能:将pdf 文件转化为Image或者Html的形式(变态,但是没办法)
几经努力,搞了个大概,利用PdfSharp和 Ghostscript 完成,最终转换的是图片
但是存在几个问题
1、速度问题,忒慢
2、版本问题,貌似pdf 版本过高的话,有iref 流的异常。虽然可以利用iTextSharp转换,但是忒麻烦!
3、转换的图片不是十分清晰adobe acrobat 转换的图片十分清晰,而且速度可以。但是没有找到相关的文档。
冰天雪地裸体跪求 : 曾经接触过或者现在正在搞这方面的大虾,希望不吝赐教!谢谢!传说中的分不是问题!

解决方案 »

  1.   

    不是有个中国人开的公司很厉害吗,专门做pdf软件的。看看他们有没有什么产品可以用收费的效果可能更好。
      

  2.   

    如果你想用控件,请参考这个网站
    my blog
    http://ufo-crackerx.blog.163.com/
      

  3.   

    O2S.Components.PDFRender4NET.dllLZ也可以去试试
      

  4.   

    adobe acrobat好像有sdk的,官方网站有
      

  5.   

    这个……倒是真没这么想过!貌似生成时过于复杂…,如果哟思路请赐教!悲剧的sdk……加上本人英文是在不咋地!唉
      

  6.   

    adobe acrobat的SDK简直就是一垃圾,用的我蛋疼,劝LZ别用
      

  7.   

    试试把pdf文件作为流来读取?编码很乱。复杂化,先给点分?回头帮你测试下
      

  8.   


    问题依旧……试了试其他的方法
    多半是需要在客户端安装或者注册组件的
    在网上看到一个Ap PDF to IMAGE batch 的小软件.1.3M
    做出来的效果非常好,而且也提供了sdk!奈何是收费软件(不要跟我讲买…………)
    有研究的达人还不快快现身,更待何时??
      

  9.   

    添加COM引用AcrobatAcrobat.AcroAVDoc doc = new Acrobat.AcroAVDoc();
    doc.Open(@"d:\test.pdf", ""); // 要转换的pdf文件object js = (doc.GetPDDoc() as Acrobat.AcroPDDoc).GetJSObject();object[] args = { @"d:\test.jpg", "com.adobe.acrobat.jpeg", "", false, false }; // 要生成的图片名称
    js.GetType().InvokeMember("SaveAs", BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Instance, null, js, args);
      

  10.   


    说的是 adultpdf 产品?呵呵呵,它是非常简单去掉水印
    my blog
    http://ufo-crackerx.blog.163.com/
      

  11.   

    这个我试过,但是貌似客户端必须装东东
    acrobat的sdk 里面就是这么搞的。有没有不用装东西的?
    贴上现在使用的笨方法的代码,提供大家探讨下!
      

  12.   


    PDFConvert converter = new PDFConvert();
            private void PdfConvert(string FileName, string SavePath)
            {
                if (!System.IO.File.Exists(Application.StartupPath + "\\gsdll32.dll"))
                {
                    MessageBox.Show("系统缺少gsdll32.dll,请检查系统!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }
                //检查版本
                GhostScriptRevision version = converter.GetRevision();
                ConvertSingleImage(FileName, SavePath);           
            }private void ConvertSingleImage(string filename, string SavePath)
            {
                bool Converted = false;            
                string filePath = SavePath;
                converter.RenderingThreads = 2;          
                converter.OutputToMultipleFile = true;           
                converter.FitPage = false;
                converter.JPEGQuality = 100;  //质量(0-100)  
                converter.OutputFormat = "jpeg";
                System.IO.FileInfo input = new FileInfo(filename);
                string output = SavePath + @"\pdf.jpg";   
                PdfSharp.Pdf.PdfDocument pdfDoc;
                int iPdfPageCount = 0;            
                try
                {
                    pdfDoc = PdfSharp.Pdf.IO.PdfReader.Open(filename);
                }
                catch (PdfSharp.Pdf.IO.PdfReaderException)
                {
                    filename = WriteCompatiblePdf(filename, SavePath+@"\newPdf.pdf");
                    pdfDoc = PdfSharp.Pdf.IO.PdfReader.Open(filename);
                }
                iPdfPageCount = pdfDoc.PageCount;  //页数
                Converted = converter.Convert(input.FullName, output);  //给我转
    }//转换不能识别的pdf (itextpdf)
     private string WriteCompatiblePdf(string sFilename, string sNewPdf)
            {          
                iTextSharp.text.pdf.PdfReader reader = new iTextSharp.text.pdf.PdfReader(sFilename);
                int n = reader.NumberOfPages;           
                iTextSharp.text.Document document = new iTextSharp.text.Document(reader.GetPageSizeWithRotation(1));          
                iTextSharp.text.pdf.PdfWriter writer = iTextSharp.text.pdf.PdfWriter.GetInstance(document, new System.IO.FileStream(sNewPdf, System.IO.FileMode.Create));
               //转换版本
                writer.SetPdfVersion(iTextSharp.text.pdf.PdfWriter.PDF_VERSION_1_4);       
                document.Open();
                iTextSharp.text.pdf.PdfContentByte cb = writer.DirectContent;
                iTextSharp.text.pdf.PdfImportedPage page;
                int rotation;
                int i = 0;
                while (i < n)
                {
                    i++;
                    document.SetPageSize(reader.GetPageSizeWithRotation(i));
                    document.NewPage();
                    page = writer.GetImportedPage(reader, i);
                    rotation = reader.GetPageRotation(i);
                    if (rotation == 90 || rotation == 270)
                    {
                        cb.AddTemplate(page, 0, -1f, 1f, 0, 0, reader.GetPageSizeWithRotation(i).Height);
                    }
                    else
                    {
                        cb.AddTemplate(page, 1f, 0, 0, 1f, 0, 0);
                    }
                }      
                document.Close();
                return sNewPdf;
            }
    太多了不贴了……方法笨 ,质量还不好!
    具体的补贴了,大概就是调用PdfSharp和Ghostscript  来搞的
      

  13.   

    不知道行不行!看来也只好如此了,像Ap PDF to IMAGE batch  这么nb 的
    搞法估计是没希望了!
      

  14.   


    你设定的限定条件太多了,Ghostscript已经是比较流行的free组件,你又不希望用付费的组件,还不要在客户端上装东西权衡取舍一下吧