Docs de PDFiumVCL

ImportNPagesToOne method

Esta entrada API conserva identificadores, firmas, bloques de código y términos PDF en su forma original.
Component: TPdf  ·  Unit: PDFium
Builds a brand-new TPdf whose pages are NumX×NumY composites of the source document's pages, suitable for N-up printing layouts.

Syntax

function ImportNPagesToOne(
  OutputWidth, OutputHeight: Single;
  NumX, NumY : Cardinal): TPdf;

Description

ImportNPagesToOne composes pages from THIS document into a new output PDF where each output page lays out NumX × NumY source pages in a grid. The source pages are scaled to fit their cell preserving their original aspect ratio; cells that would extend past the output page bounds are clipped.

OutputWidth and OutputHeight are in PDF user units (1 unit = 1/72 inch). For an A4 landscape output page, pass 842 × 595. Each row is filled left-to-right, then row by row top-to-bottom, mirroring the conventional printer N-up layout.

The function returns a fresh TPdf instance. The caller owns the returned object and must Free it (or set Active := False before assigning to another variable). Returns nil if PDFium rejected the arguments (zero axis count, OOM, etc.). The source document (this TPdf) must be Active.

The returned document carries one composite page per ceil(SourcePages / (NumX×NumY)). The last composite page may be partially filled if the source page count is not an exact multiple of the cell count.

Remarks

Example

var
  Composite: TPdf;
begin
  Pdf1.FileName := 'C:\Slides.pdf';
  Pdf1.Active := True;
  // 4-up landscape: 842 x 595 pt, 2 columns x 2 rows
  Composite := Pdf1.ImportNPagesToOne(842, 595, 2, 2);
  try
    if Composite <> nil then
      Composite.SaveAs('C:\Slides_4up.pdf');
  finally
    Composite.Free;
  end;
end;

See Also

ImportPages, ImportPagesByIndex, MovePages