ftos.files.pdf.getPages
IMPORTANT!
Starting with v24.3.0, this is renamed from extractDocument to ftos.files.pdf.getPages.
Starting with v24.3.0, this is renamed from extractDocument to ftos.files.pdf.getPages.
Extracts a page range from a stored PDF file and saves it to a new PDF file in the file upload location.
This is a business logic method for business service components.
Syntax
function ftos.files.pdf.getPages(sourceRealName: string, destinationName: string, startPage: number, endPage: number): string
| Parameter | Description |
|---|---|
sourceRealName
|
Unique internal ID of the source PDF file (real name). |
destinationName
|
File name assigned to the extracted PDF. |
startPage
|
Page number of the source PDF file where the page range extraction starts. |
endPage
|
Page number of the source PDF file where the page range extraction ends. |
NOTE
If you wish to extract a single page, enter the same value for
If you wish to extract a single page, enter the same value for
startPage and endPage.Return Value
Returns a string containing the extracted PDF's real name.
Examples
In this example:
- We extract the pages 5 through 8 of the Contract_f4340f5d-d639-4769-9a8e-5db40328d449.pdf file.
- We save the extracted pages in a file called contract5_8.pdf.
- We save the real name of the extracted file in a variable called message.
- We display the message variable on screen. For details on how to display messages, see ftos.context.response.setMessage.
message = ftos.files.pdf.getPages('Contract_f4340f5d-d639-4769-9a8e-5db40328d449.pdf', 'contract5_8', 5, 8);
ftos.context.response.setMessage(message);
In this example:
- We extract the cover page (page range 1 through 1) of the Contract_f4340f5d-d639-4769-9a8e-5db40328d449.pdf file.
- We save the extracted pages in a file called contract_cover.pdf.
- We save the real name of the extracted file in a variable called message.
- We display the message variable on screen. For details on how to display messages, see ftos.context.response.setMessage.
message = ftos.files.pdf.getPages('Contract_f4340f5d-d639-4769-9a8e-5db40328d449.pdf', 'contract_cover', 1, 1);
ftos.context.response.setMessage(message);
In this example:
- We extract the contents (page range 2 through the total page count) of the Contract_f4340f5d-d639-4769-9a8e-5db40328d449.pdf file. For details on how to get the page count of a PDF file, see ftos.files.pdf.getPagesCount.
- We save the extracted pages in a file called contract_contents.pdf.
- We save the real name of the extracted file in a variable called message.
- We display the message variable on screen. For details on how to display messages, see ftos.context.response.setMessage.
message = ftos.files.pdf.getPages('Contract_f4340f5d-d639-4769-9a8e-5db40328d449.pdf', 'contract_contents', 1, ftos.files.pdf.getPagesCount('Contract_f4340f5d-d639-4769-9a8e-5db40328d449.pdf'));
ftos.context.response.setMessage(message);