ftos.files.pdf.insertImage
Starting with v24.3.0, this is renamed from insertImageOnFile to ftos.files.pdf.insertImage.
Inserts an image in a PDF and saves the resulting file to the file upload location using a specified file name.
This is a business logic method for business service components.
Syntax
function ftos.files.pdf.insertImage(sourceRealName: string, imageRealName: string, outputFileName: string, imageWidth: number, imageHeight: nuber, pageNumber: number, adjustXposition : number, adjustYposition :number): string
| Parameter | Description |
|---|---|
sourceRealName
|
Unique internal ID of the source PDF file (real name). |
imageRealName
|
Unique internal ID of the image you wish to insert in the PDF (real name). |
outputFileNmae
|
File name assigned to the resulting PDF. |
imageWidth
|
Number of pixels to which the inserted image will be resized horizontally. |
imageHeight
|
Number of pixels to which the inserted image will be resized vertically. |
pageNumber
|
Page in the PDF where you wish to insert the image. |
adjustXposition
|
Number of pixels to the right of the page's left margin where the image is inserted. |
adjustYposition
|
Number of pixels above the page's bottom margin where the image is inserted. |
To determine the pixel sizes of a PDF page, multiply the page sizes by its pixel resolution. For instance, a Letter page (8.5 x 11 inches) rendered at a resolution of 72 ppi (pixels per inch) will have a width of 612 pixels (8.5 inches x 72 ppi) and a height of 792 pixels (11 inches x 72 ppi).
Some of the most popular page pixel sizes are listed below.
| Resolution | ||||
|---|---|---|---|---|
| Page Size | 72 PPI | 96 PPI | 150 PPI | 300 PPI |
| A4 | 595 x 842 | 794 x 1123 | 1240 x 1754 | 2480 x 3508 |
| A5 | 420 x 595 | 559 x 794 | 874 x 1240 | 1748 x 2480 |
| Letter | 612 x 792 | 816 x 1056 | 1275 x 1650 | 2550 x 3300 |
| Legal | 612 x 1008 | 816 x 1344 | 1275 x 2100 | 2550 x 4200 |
Return Value
Returns a string containing the saved PDF's real name.
Examples
In this example:
- We insert a company logo stored in a file called logo_d02b2f36-b0ce-4b85-abe6-bffa55ddb429.png on the cover (page 1) of the offer_d6eb4bf6-8b91-4482-91e4-477c4dfad98c.pdf file.
- The logo will be resized to 213 x 25 pixels.
- We save the resulting document in a file called offer_logoed.pdf.
- We position the logo in the top left corner of the page. This means 0 pixels away from the left margin and 767 pixels away from the bottom of the page (792 pixels which is the height of the page minus 25 pixels which is the height of the resized logo).
- We store the real name of the resulting 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.
var message = ftos.files.pdf.insertImage('offer_d6eb4bf6-8b91-4482-91e4-477c4dfad98c.pdf', 'logo_d02b2f36-b0ce-4b85-abe6-bffa55ddb429.png', 'offer_logoed.pdf', 213, 25, 1, 0, 767);
ftos.context.response.setMessage(message);