Back to Devexpress

TdxPDFDocument.Pages Property

vcl-dxpdfdocument-dot-tdxpdfdocument-a6b3e022.md

latest3.1 KB
Original Source

TdxPDFDocument.Pages Property

Provides access to the document structure.

Declaration

delphi
property Pages: TdxPDFPages read;

Property Value

TypeDescription
TdxPDFPages

A PDF document page manager.

|

Remarks

You can use the Pages property to manage the document structure.

Available Options

Call Pages.Add, Pages.Insert, Pages.Delete, and Pages.Move procedures to add, delete, and rearrange document pages.

Refer to the TdxPDFPages class description for detailed information on all available options.

Batch Document Structure Changes

Every document structure change raises the OnChanged event. Enclose multiple structure changes between BeginUpdate and EndUpdate calls to avoid redundant change notifications and improve performance.

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):

delphi
uses
  dxPDFDocument; // 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;
cpp
#include "dxPDFDocument.hpp" // Declares the TdxPDFDocument class
// ...
  TdxPDFDocument *ADocument = new TdxPDFDocument();
  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
    }
    ADocument->SaveToFile("Data\\Result.pdf");
  }
  __finally
  {
    delete ADocument; // Releases the created document container to avoid memory leaks
  }

See Also

TdxPDFDocument.FileAttachments Property

TdxPDFDocument.PageInfo Property

TdxPDFDocument Class

TdxPDFDocument Members

dxPDFDocument Unit