THotPDF Page Operation Methods

THotPDF

Top

이 메서드들은 로드된 문서에서 페이지를 삽입, 추출, 복사, 저장, 재정렬하는 워크플로를 제공합니다

 

Delphi syntax:

function HPDFParsePageRange(const PageRange: string; PageCount: Integer): THPDFPageIndexArray;

procedure AppendPagesFromDocument(SourceDoc: THotPDF; const PageRange: string);

procedure InsertPagesFromDocument(SourceDoc: THotPDF; const PageRange: string; InsertAfterPage: Integer);

procedure InsertPagesFromDocument(SourceDoc: THotPDF; const LogicalPageIndices: array of Integer; InsertAfterPage: Integer);

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

procedure ExtractPagesToFile(const OutputFile: TFileName; const PageRange: string);

procedure ExtractPagesToFile(const OutputFile: TFileName; const LogicalPageIndices: array of Integer);

procedure MovePage(PageIndex: Integer; NewPageIndex: Integer);

procedure SaveLoadedDocument(const TargetFile: TFileName);

property OnPageOperationProgress: THPDFPageOperationProgressEvent;

 

Description

HPDFParsePageRange는 1,3-4,6- 같은 1부터 시작하는 범위 문자열을 0부터 시작하는 페이지 인덱스로 변환합니다. 빈 입력은 모든 페이지를 선택합니다. 잘못된 페이지 번호, 내림차순 범위, 형식이 잘못된 토큰은 예외를 발생시킵니다

InsertPagesFromDocument은 로드된 다른 THotPDF 인스턴스의 페이지를 현재 문서로 복사합니다. 기존의 0 기반 배열 호출도 계속 지원하며, 문자열 오버로드는 1 기반 페이지 범위를 받습니다. InsertAfterPage는 0 기반이며, 맨 앞에 삽입하려면 -1을 전달합니다

AppendPagesFromDocument은 같은 1 기반 페이지 범위 구문으로 선택한 원본 페이지를 현재 문서의 끝에 덧붙입니다

CopyPageByPhysicalIndex는 원본 페이지 하나를 0 기반 물리 페이지 인덱스로 지정해, 0 기반 대상 위치로 복사합니다

ExtractPagesToFile은 현재 문서에서 선택한 페이지를 새 PDF 파일로 기록합니다. 기존의 0 기반 배열 호출도 계속 지원하며, 문자열 오버로드는 1 기반 페이지 범위를 받습니다

OnPageOperationProgress는 append, insert, extract, 그리고 앞으로 추가될 merge 계열 페이지 작업의 페이지 단위 진행 상황을 알려 줍니다

MovePage는 0 기반 페이지 하나를 다른 0 기반 위치로 옮겨 현재 문서의 페이지 순서를 바꿉니다. 이 메서드는 로드된 페이지 배열과 루트 페이지 트리를 함께 갱신하므로, 이후의 저장과 추출 호출에는 새 순서가 적용됩니다

SaveLoadedDocument는 페이지 편집, 폼 편집 또는 복사 작업을 마친 뒤 로드된 객체 그래프를 새 파일로 기록합니다

Code Example

BasePDF.LoadFromFile('base.pdf');
InsertPDF.LoadFromFile('insert.pdf');

BasePDF.InsertPagesFromDocument(InsertPDF, '1-2', 0);
BasePDF.AppendPagesFromDocument(InsertPDF, '2');
BasePDF.MovePage(BasePDF.PagesCount - 1, 1);
BasePDF.ExtractPagesToFile('selected-pages.pdf', '2,4');
BasePDF.SaveLoadedDocument('reordered.pdf');