Introduction:

Debenu Quick PDF Library(PDF programming development tool) provides a comprehensive set of PDF API functions to help you process PDF files quickly and easily. From the basic operation of document properties to the creation of your own PDF viewer and pdf editor, this software meets all your needs. Quick PDF Library is a SDK for PDF developers. It is powerful and royalty free, including more than 500 functions. It can be used in Delphi, C, C, C + +, ASP, VB6, VB.NET, VBScript, PHP, PowerBASIC, etc. it uses ActiveX, DLL, LIB or Delphi libraries

 

Official help documents: https://www.debenu.com/docs/pdf_library_reference/FunctionGroups.php

You can reference (extract text and images and insert new PDF s): http://quickpdf.org/forum/extract-text-and-images-and-insert-into-new-pdf_topic1308.html

Installation:   

First, download the library on the official website, http://www.debenu.com/. The version used in this article is 11.11. After downloading, we get an EXE file: Foxit? Quick? PDF? Library? En.exe. Double click the EXE file to install the control library. During the installation process, you will be required to enter the installation directory and select the appropriate directory to complete the installation.

 

 


The file GettingStarted.pdf describes some of the preparations that need to be done before using the control library. First run the command prompt as an administrator and switch to the installation directory, then enter the following command to complete the registration of the control. (I have two versions installed here, so there are 1131 versions)

 

Then add DebenuPDFLibraryDLL1111.dll and DebenuPDFLibraryDLL1111.pas to Delphi project

 

 

Instance program

Use debenupdflibrarydll1111

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, SynPdf, StdCtrls, DebenuPDFLibraryDLL1111;

type
  TForm1 = class(TForm)
    btn1: TButton;
    edt1: TEdit;
    edt2: TEdit;
    lbl1: TLabel;
    procedure btn1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

// read pdf Text content and pictures
function ReadPdf(const fileName, saveImagePath: string; var text: string;
  var imageFiles: string): string;
var
  rPdf: TDebenuPDFLibraryDLL1111;
  imageCount, i, j, num, keyStatus, FH, PR: Integer;
begin
  Result := '';
  num := 0;
  if Trim(fileName) = '' then
  begin
    Result := 'Path cannot be empty';
    Exit;
  end;
  if (Trim(saveImagePath) <> '') and (not DirectoryExists(saveImagePath)) then
  begin
    ForceDirectories(saveImagePath); // Create directory
  end;

  rPdf := TDebenuPDFLibraryDLL1111.Create('DebenuPDFLibraryDLL1111.dll'); // library
  keyStatus := rPdf.UnlockKey('**********'); // Key secret key can be purchased or asked for by me
  if keyStatus <> 1 then
  begin
    Result := 'The library cannot be loaded or unlocked fails';
    Exit;
  end;
  try
    rPdf.LoadFromFile(Trim(fileName), '');
    // Open the file in direct access mode and store the file handle
    FH := rPdf.DAOpenFile(fileName, '');
    for i := 1 to rPdf.DAGetPageCount(FH) do
    begin
      rPdf.SelectPage(i); // Selection page
      text := text + rPdf.GetPageText(8); // Get text8:More accurate text extraction algorithm
      if Trim(saveImagePath) <> '' then
      begin
        imageCount := rPdf.GetPageImageList(0); // Get pictures
        for j := 1 to rPdf.GetImageListCount(imageCount) do // Traverse all pictures in the current page
        begin
          rPdf.SaveImageListItemDataToFile(imageCount, j, 0,
            saveImagePath + '\' + IntToStr(num) + '.png');
          imageFiles := imageFiles + saveImagePath + '\' + IntToStr(num)
            + '.png ; ';
          inc(num);
        end;
      end;
    end;
  finally
    rPdf.Free;
  end;
end;

// write pdf
function WritePdf(const fileName, text: string): string;
var
  wPdf: TDebenuPDFLibraryDLL1111;
  num, wStatus: Integer;
begin
  Result := '';
  if Trim(fileName) = '' then
  begin
    Result := 'Path cannot be empty';
    Exit;
  end;
  try
    wPdf := TDebenuPDFLibraryDLL1111.Create('DebenuPDFLibraryDLL1111.dll'); // library
    try
      wStatus := wPdf.UnlockKey('*************'); // secret key 
      if wStatus = 1 then
      begin
        num := wPdf.AddTrueTypeSubsettedFont('FangSong', text, 0);
        wPdf.SelectFont(num);
        wPdf.DrawWrappedText(50, 750, 500, text);
        wPdf.SaveToFile(fileName);
      end
      else
      begin
        Result := 'The library cannot be loaded or unlocked fails';
      end;
    finally
      wPdf.Free;
    end;
  except
    on e: Exception do
      Result := e.Message;
  end;
end;



procedure TForm1.btn1Click(Sender: TObject);
var
  text, imageFiles: string;
begin
  text := '';
  imageFiles := '';
  // showmessage(WritePdf(edt1.Text,edt2.Text));
  ShowMessage(ReadPdf(edt1.text, edt2.text, text, imageFiles));
  lbl1.Caption := text;
  ShowMessage(text);
  ShowMessage(imageFiles);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  //readAndWritePDf();
end;

end.

Function:

Extracted:

 

Original pdf: