delphi c# 使用Aspost将PDF转Excel

 近来,因工作需要,必须解决Delphi写的主程序调用C#写的dll的问题。在网上一番搜索,又经过种种试验,最终证明有以下方法可行:

这里先把需要的资源贴在前面,我这里使用的编辑软件是delphi+VS 

这里用到的资源是Aspose.pdf.dll

使用参考地址:http://blog.csdn.net/genispan/article/details/4294487

资源下载地址:https://download.csdn.net/download/ovivalavida/9457365

 Aspose网盘下载:链接: https://pan.baidu.com/s/1TgPkGNLSSsfx8usqpNg90g 提取码: tyuc

首先下载好ASPOST.PDF

 把Aspost.pdf.dll拿出来,用vs编成exe文件

VS新建控制台应用

添加引用,选择刚刚下载的dll文件,

 

然后编辑代码

 

using System;
using System.Collections.Generic;
using System.Text;
using Aspose.Pdf;

namespace PdFToXlsModel1
{
    class Program
    {
        static void Main(string[] args)
        {
            Document pdfDocument = new Document(args[0]);
            //Aspose.Pdf.
            // Instantiate ExcelSave Option object
            Aspose.Pdf.ExcelSaveOptions excelsave = new ExcelSaveOptions();
            // Save the output in XLS format
            pdfDocument.Save(args[1], SaveFormat.Excel);
        }
    }
}

  生成exe

 然后找到编译后的exe文件以及同在exe文件下的dll

把exe放到dephi编译后的exe同级目录

接下来打开delphi

编写启动exe

function TPSI_File.PdfToXls(const pdfFileName, xlsFileName: string): string;
var sRst, sContent: string;
begin
  Result := '';
  sContent := Format('PdfToXls.exe %s %s', [pdfFileName, xlsFileName]);
  Result := RunCommand(sContent, sRst);
  if Result = '' then
    Result := sRst;
end; 

 传入pdf路径和生成后的xls路径,

执行

效果:

猜你喜欢

转载自www.cnblogs.com/ClaireWu/p/12468191.html
今日推荐