PDFium Component Docs

MovePages Methode

Dieser API-Eintrag behält Bezeichner, Signaturen, Codeblöcke und PDF-Begriffe in ihrer Originalform.
Komponente: TPdf  ·  Unit: PDFium
Ordnet die Seiten dieses Dokuments vor Ort nach nullbasiertem Index neu an und hält die Seitenanzahl konstant

Syntax

function MovePages(
  const PageIndices: array of Integer;
  DestPageIndex : Integer): Boolean;

Beschreibung

MovePages reorders pages of THIS document. PageIndices lists the zero-based indices of the pages to move (any order, any count up to PageCount); DestPageIndex is the destination index for the FIRST moved page after the move completes. Other pages shift around the moved block so the document length stays the same.

Example: in a 5-page document with pages numbered [0, 1, 2, 3, 4], MovePages([2, 3], 0) produces [2, 3, 0, 1, 4] — pages 2 and 3 are lifted out, page 0 shifts to position 2 (where page 2 was), page 1 shifts to position 3, and page 4 stays put.

Returns True on success. Returns False if any index in PageIndices is out of range, if DestPageIndex is out of range, or if PageIndices contains duplicates.

This is the right call for "move selected thumbnails up / down" / drag-and-drop page reordering in a UI. To copy a subset of pages from another document, use ImportPagesByIndex; to delete pages, use DeletePage.

Hinweise

Beispiel

// In a 5-page document, move pages 2 and 3 to the start.
// Result: [2, 3, 0, 1, 4]
if not Pdf1.MovePages([2, 3], 0) then
  ShowMessage('Invalid indices passed to MovePages');

// Reverse the entire document
var
  I: Integer;
  Indices: array of Integer;
begin
  SetLength(Indices, Pdf1.PageCount);
  for I := 0 to High(Indices) do
    Indices[I] := High(Indices) - I;
  Pdf1.MovePages(Indices, 0);
end;

Siehe auch

ImportPagesByIndex, ImportNPagesToOne, DeletePage, AddPage