Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

TdxPDFPages.Delete(Integer) Method

Deletes a specified PDF document page.

#Declaration

Delphi
procedure Delete(AIndex: Integer); overload;

#Parameters

Name Type Description
AIndex Integer

A target page index.

#Remarks

Call the Delete procedure to delete an individual document page.

#Code Example: Delete the First Two Document Pages

The following code example loads a PDF document from the Demo.pdf file, deletes the first two pages of the loaded document, and saves the resulting document to a different file (Result.pdf):

uses
  dxPDFDocument;  // This unit declares the TdxPDFDocument class
// ...
var
  ADocument: TdxPDFDocument;
begin
  ADocument := TdxPDFDocument.Create;
  try
    ADocument.LoadFromFile('Data\Demo.pdf');
    ADocument.BeginUpdate;  // Initiates the following batch change
    try
      ADocument.Pages.Delete(0);
      ADocument.Pages.Delete(0);
    finally
      ADocument.EndUpdate;  // Calls EndUpdate regardless of the batch operation's success
    end;
    ADocument.SaveToFile('Data\Result.pdf');
  finally
    ADocument.Free;  // Releases the created document container to avoid memory leaks
  end;
See Also