---
sourceDocument: オーストラリア API リファレンス
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/ja-JP/api-reference

 Release :

    - australia

ft:locale :

    - ja-JP

ft:publication_title :

    - オーストラリア API リファレンス

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# イメージ:スコープ対象、グローバル

# イメージ:スコープ対象、グローバル {#ariaid-title1}

* リリースバージョン: Australia
* 
* 更新日 2026年03月12日
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 所要時間：9分

PDF での画像とそのレイアウト挿入を表す Image オブジェクトを作成します。スケール、配置、境界線の色などの属性を定義できます。

この API は ServiceNow PDF 生成ユーティリティプラグイン (com.snc.apppdfgenerator) の一部であり、 `sn_pdfgeneratorutils` 名前空間内で提供されます。このプラグインはデフォルトでアクティブ化されています。

この API は、PDF を生成するために [ドキュメント API](https://servicenow-prod.fluidtopics.net/7tzXFAmYeA9VuU2eCM9cJQ#DocumentBothAPI "ドキュメント API は、PDF を初期化し、コンテンツを追加し、PDF を閉じるためのメソッドを提供します。コンテンツを追加した後、ドキュメントをターゲットレコードに添付できます。") で使用されるコンポーネントです。  
次のいずれかの方法を使用して、PDF に画像を追加できます。

* [セル -- addImage(画像画像)](https://servicenow-prod.fluidtopics.net/J2yBdk1lCwz_HNj~Rpk1Hw#Cell-addImage_O "テーブルセルに画像を追加します。") -- テーブルセルに画像を追加します
* [テーブル -- addImageCell(画像画像)](https://servicenow-prod.fluidtopics.net/8xluTpvsugsFPpe~3epwTA#Table-addImageCell_O "画像を含むセルをテーブルに追加します。") -- 画像を含むセルをテーブルに追加します。
* [ドキュメント -- addImage(画像画像)](https://servicenow-prod.fluidtopics.net/7tzXFAmYeA9VuU2eCM9cJQ#Document-addImage_O "ドキュメントに画像を追加します。") - ページに画像を追加します
{#ImageBothAPI__ul_jkh_55q_s4b}

## イメージ:Image(文字列 attachmentSysId) {#ariaid-title2}

新しい Image オブジェクトをインスタンス化します。画像添付ファイルが存在し、変更可能かどうかを確認するために使用されます。
{#Image-Image_S__table_twm_hjk_34b__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| attachmentSysId | 文字列 | 添付ファイル \[sys_attachment\] テーブル内の画像のSys_id。 |
[表 : 1. パラメーター]

{#Image-Image_S__table_twm_hjk_34b}  
次の例は、 Image オブジェクトの作成方法を示しています。

    var image = new sn_pdfgeneratorutils.Image("<sys_id>");

## 画像 -- scaleAbsolute(数値の幅、数値の高さ) {#ariaid-title3}

画像を絶対的な幅と高さのサイズに拡大縮小します。この設定では、画像の幅と高さの比率は保持されず、設定が正確でない場合、望ましくない引き伸ばしが発生する可能性があります。
画像の幅と高さの比率を保持する絶対サイズに拡大縮小するには、 [scaleToFit()](https://servicenow-prod.fluidtopics.net/leeT~ILmDFEYmdhg9LJF8Q#Image-scaleToFit_N_N "幅と高さの比率を維持しながら、画像を絶対サイズに拡大縮小します。") メソッドを使用します。
{#Image-scaleAbsolute_N_N__table_vv5_52h_44b__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| 幅 | 番号 | 画像の幅 (ポイント)。 |
| 高さ | 番号 | 画像の高さ (ポイント単位)。 |
[表 : 2. パラメーター]

{#Image-scaleAbsolute_N_N__table_vv5_52h_44b} {#Image-scaleAbsolute_N_N__table_wv5_52h_44b__entry__2}

| タイプ | 説明 |
|-|-|
| なし |   |
[表 : 3. 返される内容]

{#Image-scaleAbsolute_N_N__table_wv5_52h_44b}  
次の例は、絶対幅と絶対高さの設定を使用して PDF に画像を追加する方法を示しています。

    var pageSize = new sn_pdfgeneratorutils.PdfPage("LETTER");
    var document = new sn_pdfgeneratorutils.Document.createDocument(pageSize);

    var scaleAbsPic = new sn_pdfgeneratorutils.Image("<img_sys_id>");
    scaleAbsPic.scaleAbsolute(25,50);

    document.addImage(scaleAbsPic);

    document.saveAsAttachment("incident", "<record_sys_id>", "docWithImg.pdf");

## 画像 -- scaleToFit(数値の幅, 数値の高さ) {#ariaid-title4}

幅と高さの比率を維持しながら、画像を絶対サイズに拡大縮小します。
結果として得られる出力は、画像のアスペクト比によって異なります。幅と高さのパラメーター値が画像のアスペクト比と一致しない場合、1 つの値が指定された値よりも小さく出力でレンダリングされます。
{#Image-scaleToFit_N_N__table_vv5_52h_44b__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| 幅 | 番号 | 最大画像幅 (ポイント単位)。 |
| 高さ | 番号 | 画像の最大高さ (ポイント単位)。 |
[表 : 4. パラメーター]

{#Image-scaleToFit_N_N__table_vv5_52h_44b} {#Image-scaleToFit_N_N__table_wv5_52h_44b__entry__2}

| タイプ | 説明 |
|-|-|
| なし |   |
[表 : 5. 返される内容]

{#Image-scaleToFit_N_N__table_wv5_52h_44b}  
次の例は、 [Cell -- addImage()](https://servicenow-prod.fluidtopics.net/J2yBdk1lCwz_HNj~Rpk1Hw#Cell-addImage_O "テーブルセルに画像を追加します。") メソッドを使用して、サイズに合わせて拡大縮小された画像を挿入する方法を示しています。

    var pageSize = new sn_pdfgeneratorutils.PdfPage("LETTER");
    var document = new sn_pdfgeneratorutils.Document.createDocument(pageSize);
     
    // add a table
    var table = new sn_pdfgeneratorutils.Table([1,3],false);

    // text for the left column
    var text = "sample image";

    // add a table cell for the image in the right column
    var imgCell = new sn_pdfgeneratorutils.Cell(1, 1);

    // add an image and set it scale-to-fit
    var scaleToFitPic = new sn_pdfgeneratorutils.Image("<img_sys_id>");
    scaleToFitPic.scaleToFit(90,175);

    // add the image to the cell
    imgCell.addImage(scaleToFitPic);
     
    table.addTextCell(text);
    table.addCell(imgCell);

    // Here's a paragraph
    var para = new sn_pdfgeneratorutils.Paragraph("The following table image uses scale to fit.");

    document.addParagraph(para);
    document.addTable(table);

    document.saveAsAttachment("incident", "<record_sys_id>", "imgScaleToFit.pdf");

## 画像:setAutoScale(ブール値) {#ariaid-title5}

サイズを維持したまま、幅と高さをページまたはセルに合わせて拡大縮小できるようにします。
{#Image-setAutoScale_B__table_vv5_52h_44b__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| value | ブーリアン | 画像を自動的に拡大/縮小するかどうかを示すフラグ。 有効な値： * true:画像を自動的に拡大縮小します * false:画像は拡大縮小されません {#Image-setAutoScale_B__ul_drr_bbr_s4b} デフォルト値：false |
[表 : 6. パラメーター]

{#Image-setAutoScale_B__table_vv5_52h_44b} {#Image-setAutoScale_B__table_wv5_52h_44b__entry__2}

| タイプ | 説明 |
|-|-|
| なし |   |
[表 : 7. 返される内容]

{#Image-setAutoScale_B__table_wv5_52h_44b}  
次の例は、自動スケーリングを使用して PDF に画像を追加する方法を示しています。画像は、 [Table -- addImageCell()](https://servicenow-prod.fluidtopics.net/8xluTpvsugsFPpe~3epwTA#Table-addImageCell_O "画像を含むセルをテーブルに追加します。") メソッドを使用して追加されます。

    var pageSize = new sn_pdfgeneratorutils.PdfPage("LETTER");
    var document = new sn_pdfgeneratorutils.Document.createDocument(pageSize);

    // Add a table
    var table = new sn_pdfgeneratorutils.Table([1,2],false);

    // Text in left column
    var text = "sample image";

    // Image in right column
    var autoScaledPic = new sn_pdfgeneratorutils.Image("<image_sys_id>");
    autoScaledPic.setAutoScale(true);

    table.addTextCell(text);
    table.addImageCell(autoScaledPic);

    document.addTable(table);
    document.saveAsAttachment("incident", "<record_sys_id>", "imgAutoScale.pdf");

## 画像 -- setColoredBorder(Color color, Number width) {#ariaid-title6}

指定した色で PDF の境界線を設定します。
{#Image-setColoredBorder_O_N__table_vv5_52h_44b__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| 色 | [色](https://servicenow-prod.fluidtopics.net/cQByAnB6EX~xRtKxQb54Aw#ColorBothAPI "PDF 内の要素に適用できる色属性を定義するために使用される Color オブジェクトを作成します。セル、テーブル、行など。") | 画像の境界色。 |
| 幅 | 番号 | 境界線の幅 (ポイント単位)。 |
[表 : 8. パラメーター]

{#Image-setColoredBorder_O_N__table_vv5_52h_44b} {#Image-setColoredBorder_O_N__table_wv5_52h_44b__entry__2}

| タイプ | 説明 |
|-|-|
| なし |   |
[表 : 9. 返される内容]

{#Image-setColoredBorder_O_N__table_wv5_52h_44b}  
次の例は、画像に 5 ポイントの赤色の境界線を設定する方法を示しています。

    var pageSize = new sn_pdfgeneratorutils.PdfPage("LETTER");
    var document = new sn_pdfgeneratorutils.Document.createDocument(pageSize);

    var borderColor = new sn_pdfgeneratorutils.Color([1.0,0.0,0.0]);
     
    // declare image using sys attachment
    var image = new sn_pdfgeneratorutils.Image("<imgAttachment_sys_id>");

    image.setColoredBorder(borderColor, 5);

    document.addImage(image);
    document.saveAsAttachment("incident", "<record_sys_id>", "docWithBorderedImage.pdf");

## 画像:setHorizontalAlignment(文字列配置) {#ariaid-title7}

画像の水平配置を設定します。
{#Image-setHorizontalAlignment_S__table_vv5_52h_44b__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| 位置調整 | 文字列 | ページまたはブロック要素上に画像の配置を配置します。 有効な値： * センター * 左 * 右 {#Image-setHorizontalAlignment_S__ul_rn3_wvq_s4b} デフォルト:左 |
[表 : 10. パラメーター]

{#Image-setHorizontalAlignment_S__table_vv5_52h_44b} {#Image-setHorizontalAlignment_S__table_wv5_52h_44b__entry__2}

| タイプ | 説明 |
|-|-|
| なし |   |
[表 : 11. 返される内容]

{#Image-setHorizontalAlignment_S__table_wv5_52h_44b}  
次の例は、PDF ページに中央に配置された画像を追加する方法を示しています。

    var pageSize = new sn_pdfgeneratorutils.PdfPage("LETTER");
    var document = new sn_pdfgeneratorutils.Document.createDocument(pageSize);
     
    // declare image using sys attachment
    var image = new sn_pdfgeneratorutils.Image("<imgAttachment_sys_id>");

    String alignment = "Center";
    image.setHorizontalAlignment(alignment);

    document.addImage(image);
    // save pdf as attachment to target record in the Incident table
    document.saveAsAttachment("incident", "<sys_id>", "docWithImageCentered.pdf");

## 画像 -- setNoBorder() {#ariaid-title8}

画像に境界線なしを設定します。
{#Image-setNoBorder__table_vv5_52h_44b__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| なし |   |   |
[表 : 12. パラメーター]

{#Image-setNoBorder__table_vv5_52h_44b} {#Image-setNoBorder__table_wv5_52h_44b__entry__2}

| タイプ | 説明 |
|-|-|
| なし |   |
[表 : 13. 返される内容]

{#Image-setNoBorder__table_wv5_52h_44b}  
次の例は、境界線なしでドキュメントに画像を追加する方法を示しています。

    var pageSize = new sn_pdfgeneratorutils.PdfPage("LETTER");
    var document = new sn_pdfgeneratorutils.Document.createDocument(pageSize);
     
    // declare image using sys attachment
    var image = new sn_pdfgeneratorutils.Image("<imgAttachment_sys_id>");

    image.setNoBorder();

    document.addImage(image);
    document.saveAsAttachment("incident", "<sys_id>", "docWithImgNoBorder.pdf");


