メインコンテンツへスキップ

透かしを追加 Word

PDF4me 透かしを追加 Word は REST ページのテキストの背後に画像透かしをスタンプするエンドポイント Word 書類。 POST .docxファイルと透かし画像 Base64 に office/ApiV2Word/AddWatermarkスケール、透明度、配置を調整し、透かし入りのファイルをデコードします。 JSON 応答。 PNG、 JPG、 JPEGBMPおよびGIF画像がサポートされています。

このエンドポイントの機能

取る Word ドキュメントに画像を追加し、その画像が各セクションのテキストの背後にスタンプされた同じドキュメントを返します。ロゴ、機密バナー、下書きスタンプなどです。サイズ(正確なポイントまたは拡大縮小率)、50%の透明度の切り替え、中央または左上の配置を制御できます。応答は JSON 結果として Base64 コンテンツ。

関連ブログ記事
この機能に関するブログ記事はまだありません。近日公開予定です。
その間、PDF4me ブログを閲覧して、あらゆるプラットフォームのチュートリアルやワークフローをご覧ください。
ブログをご覧ください →

認証 API リクエスト​

毎 PDF4me REST 電話にはあなたの API キー Authorization ヘッダーを基本認証として設定します。開発者ダッシュボードからキーを取得またはローテーションしてください。

終点​

POSToffice/ApiV2Word/AddWatermark

見逃してはならない重要な事実​

回答は Base64 JSONファイルではなく
透かし入りの文書は Base64 内部のストリング JSON ボディ fileName、 success、 そして エラーメッセージ保存する前にデコードしてください。生のレスポンスは有効な .docx ファイルではありません。
幅と高さはスケールを上書きします
サイズ設定の優先順位は正確です 幅/身長 まずポイントで、次に 規模すると、元の画像サイズが返されます。1つの寸法だけを送信すると、もう1つの寸法は縦横比を維持するように計算されます。
本文の背後にあるすべてのセクションで
画像は文書コンテンツの背景としてすべてのセクションとヘッダーにスタンプされるため、テキストは読みやすくなります。 PNG プラス 半透明: true クラシックでさりげないスタンプのような印象を与えます。

HTTP 設定​

方法: POST
URL: https://api.pdf4me.com/office/ApiV2Word/AddWatermark
コンテンツタイプ: アプリケーション/json
Authorization: 基本 <あなたの PDF4me API キー>

回答は JSON: チェック success フラグを立てて、それから Base64-返されたドキュメントの内容をデコードして保存します .docx 拡大。

透かしのサイズ設定における優先順位はどのように機能するのですか?​

サイズ決定の入力項目は3つあり、厳密に順位付けされています。 API 実際に送信された入力の中で最も優先度の高いものを使用し、それ以外は無視します。

入力サイズと動作の比較該当する場合透かしが得るもの
width そして height (ポイント)最優先; 上書き scale 存在する場合指定した寸法と全く同じです。1つの寸法だけでアスペクト比が維持されます。
scale (0.1~10.0)幅または高さが送信されない場合にのみ使用されます。元の画像サイズに係数を乗じた値:0.5は半分のサイズ、2.0は2倍のサイズ
どちらも送信しなかった後退するアップロードされた画像の元のピクセル寸法

API ボディフィールド​

パラメータ必須その機能例
documentRequiredSource file. `Name` must end in `.docx` or `.doc`.{ "Name": "document.docx" }
document.NameRequiredFile name including its extension. Type: string.{ "Name": "document.docx" }
docContentRequiredThe source file, base64-encoded. Type: string.UEsDBBQABgAIAAAA...
isAsyncOptionalProcess the request in the background. The call returns `202 Accepted`; poll the `Location` URL (`GetActionStatus`) for the result. Type: boolean.
watermarkFileContentRequiredThe image, base64-encoded. Type: string.iVBORw0KGgo...
watermarkFileNameOptionalThe image file name. Type: string.watermark.png
widthOptionalImage width in points. If only one of `width`/`height` is set, the other keeps the image's proportions. Type: number.200
heightOptionalImage height in points. Type: number.150
scaleOptionalResize factor, used only when `width` and `height` are not set. Type: number.1.5
semiTransparentOptionalShow the image at 50% opacity. Type: boolean.true
alignImageOptional`true` centers the image; `false` places it at the top-left. Type: boolean.true

サンプルペイロード​

必要最低限のリクエスト(必須項目のみ)​

{
"document": { "Name": "document.docx" },
"docContent": "UEsDBBQABgAIAAAA...",
"watermarkFileName": "watermark.png",
"watermarkFileContent": "iVBORw0KGgoAAAANSUhEUgAA..."
}

サイズ指定、半透明、中央揃え​

{
"document": { "Name": "contract-draft.docx" },
"docContent": "UEsDBBQABgAIAAAA...",
"watermarkFileName": "confidential.png",
"watermarkFileContent": "iVBORw0KGgoAAAANSUhEUgAA...",
"width": 200,
"height": 150,
"semiTransparent": true,
"alignImage": true,
"cultureName": "en-US"
}

郵便配達員の集荷に関するヒント​

Headers
Content-Type: application/json + Authorization: Basic <apiKey>.
Body
raw JSON with TWO Base64 fields: docContent for the Word file and watermarkFileContent for the image. Both must be encoded separately.
Sizing
Send width/height OR scale, not both. If you send both, the exact dimensions win and scale is silently ignored.
Response
JSON with a success flag and Base64 document content. Decode the document field before saving as .docx.

curlの例​

curl -X POST https://api.pdf4me.com/office/ApiV2Word/AddWatermark \
-H "Content-Type: application/json" \
-H "Authorization: Basic YOUR_API_KEY" \
-d '{
"document": { "Name": "document.docx" },
"docContent": "'"$(base64 -w 0 document.docx)"'",
"watermarkFileName": "watermark.png",
"watermarkFileContent": "'"$(base64 -w 0 watermark.png)"'",
"semiTransparent": true
}' \
--output response.json

何が API 戻る?​

A JSON 透かし入りの文書が結果として Base64。

分野タイプ内容物
documentString (Base64)The watermarked Word document content. Decode to bytes and save with a .docx extension.
fileNameStringOutput filename for the watermarked document.
successBooleantrue when watermarking succeeded. Check this before decoding content.
errorMessageStringPopulated when success is false: invalid Base64, a corrupted document or image, or out-of-range sizing values.

非同期動作 (202 Accepted 世論調査で URL で Location ヘッダー) は、リクエストボディパラメータではなく、サーバー構成によって制御されます。202 が到着したら、ポーリングします。 Location URL と GET 200件のリクエストを受け取るまで OK 同じ JSON 形。

コードサンプル​

Word オフィスエンドポイントは、サンプルリポジトリのエンドポイントごとのサンプルフォルダにはまだ含まれていません。 PDF4me エンドポイントファミリー:

よくある質問​

Which image formats can I use as a Word watermark?+
PNG, JPG, JPEG, BMP, and GIF. A PNG with a transparent background gives the cleanest result because the image is stamped behind the document text on every page.
Is the response the Word file itself?+
No. The API returns JSON containing the watermarked document as a Base64 string plus fileName, success, and errorMessage fields. Decode the document field to bytes before saving as .docx.
What happens if I send both scale and width or height?+
Width and height win. Exact dimensions in points always override the scale factor. If you provide only one of the two, the other is calculated automatically to preserve the image aspect ratio.
Does the watermark cover the document text?+
No. The watermark is placed behind the text, in every section of the document, so the content stays readable. Set semiTransparent to true for a subtle 50 percent opacity effect.
Can this endpoint add text watermarks like DRAFT or CONFIDENTIAL?+
This endpoint stamps images. For text stamps use the Add Text Watermark to Word endpoint, or render your text as a transparent PNG and pass it here as the watermark image.
Where does the watermark appear in the document?+
Across all sections and their headers, behind the content. alignImage true centers it on the page; false places it top-left within the margins. Per-page or per-range placement is not part of this action.
Does adding a watermark protect the document from editing?+
No. A watermark is a visual marker, not a security control; anyone who can edit the file can remove it. To restrict editing or require a password, chain the Secure Word Document endpoint after this one.

なぜ透かしを追加するのか API 手動でではなく Word?​

手動ルートは 画像に透かしを入れる Word各ファイルを開き、デザイン タブ、透かし、カスタム透かし、画像を選択して保存し、これを繰り返します。これは、すべての送信ドラフトに透かしを入れる契約パイプラインには対応できません。 API ファイルごとに 1 つの決定論的リクエストとして同じテキストの背後のスタンプを適用し、正確なポイントサイズで Word ダイアログは公開しません。結果は標準です デジタル透かし 出所およびステータス表示のために、パイプラインの速度で適用されます。

関連アクション​

他のプラットフォームでも同じタスクを実行​

ヘルプが必要な場合​