delphi 读取pdf

//读取PDF
function ReadPdf(const fileName: string; var text: string): string;
var
  rPdf: TDebenuPDFLibraryDLL1115;
   i, j, num, keyStatus, FH, PR: Integer;
begin
  Result := '';

  if Trim(fileName) = '' then
  begin
    Result := 'Path cannot be empty';
    Exit;
  end;


  try
    rPdf := TDebenuPDFLibraryDLL1115.Create('DebenuPDFLibraryDLL1115.dll'); // 库
    keyStatus := rPdf.UnlockKey('j39163i38a653748u9f66rb5y'); // 密钥 秘钥可以购买或者找我要
    if keyStatus <> 1 then
    begin
      text := 'The library cannot be loaded or unlocked fails';
      Exit;
    end;
    rPdf.LoadFromFile(Trim(fileName), '');
    // 以直接访问模式打开文件并存储文件句柄
    FH := rPdf.DAOpenFile(fileName, '');
    for i := 1 to rPdf.DAGetPageCount(FH) do
    begin
      rPdf.SelectPage(i); // 选区页
      text := text + rPdf.GetPageText(8); // 获取文本 8:更准确的文本提取算法
    end;
  finally
    rPdf.Free;
  end;
end;

1.DebenuPDFLibraryDLL1115 在我的资源里免费下载

Guess you like

Origin blog.csdn.net/Listest/article/details/121282462