THotPDF.CopyPageFromDocument Method

 

THotPDF.CopyPageFromDocument

THotPDF

 

Top  Previous  Next

Copies page from source document  to the current document.

 

Delphi syntax:

procedure CopyPageFromDocument (  SourceDoc: THotPDF;  SourceIndex: Integer;  DestIndex: Integer  );

 

C++ syntax:

void __fastcall CopyPageFromDocument ( THotPDF * SourceDoc, int SourceIndex, int DestIndex );

 

Description

Call CopyPageFromDocument to copy page with number SourceIndex from SourceDoc document to current document page with number DestIndex.

The copied page keeps its page resources and content stream, including embedded CID TrueType fonts, so the method can be used repeatedly when merging pages from several source documents.

PDF name values copied from page dictionaries, resource dictionaries, arrays, and object streams are decoded from ISO 32000-1 #XX escape form before HotPDF writes them again. This prevents source names such as /PANTONE#20216#20CVC or /application#2Fxml from being emitted with a double-escaped number sign.

 

 

Code Example

// Copy page from existing PDF to new PDF
var
  SourcePDF: THotPDF;

begin
  SourcePDF := THotPDF.Create( nil );
  try
    SourcePDF.LoadFromFile( 'c:\Source.pdf' );

    HPDF.BeginDoc;
    HPDF.CopyPageFromDocument( SourcePDF, 1 );   // Copy page 1 from source document
    HPDF.EndDoc;
  finally
    SourcePDF.Free;
  end;
end;