IRONSOFTWAREHOME
高效新增 HTML 內容
import {PdfDocument, HorizontalAlignment, VerticalAlignment, MeasurementUnit, BarcodeType} from "@ironsoftware/ironpdf";

(async () => {
    // Import existing PDF
    const pdf = await PdfDocument.fromFile("unstamped.pdf");

    // Define HTML stamp options
    const htmlStampOptions = {
        verticalOffset: {
            unit: MeasurementUnit.pixel,
            value: -200,
        },
        horizontalOffset: {
            unit: MeasurementUnit.pixel,
            value: -200,
        },
    };

    await pdf.stampHtml("<h1>Html stamp</h1>", {htmlStampOptions: htmlStampOptions})

    // Define text stamp options
    const textStampOptions = {
        fontFamily: "Bungee Spice",
        useGoogleFont: true,
        fontSize: 30,
    };

    await pdf.stampText("Hello World! Stamp One Here!", {imageStampOptions: textStampOptions})

    // Define image stamp options
    const imageStampOptions = {
        minWidth: {
            unit: MeasurementUnit.Percentage,
            value: 250,
        },
        minHeight: {
            unit: MeasurementUnit.Percentage,
            value: 250,
        },
    };

    await pdf.stampImage("logo.png", {imageStampOptions: imageStampOptions})

    // Define barcode stamp options
    const barcodeStampOptions = {
        barcodeType: BarcodeType.code39,
        maxHeight: {
            unit: MeasurementUnit.Percentage,
            value: 5,
        },
        verticalAlignment: VerticalAlignment.Bottom,
        horizontalAlignment: HorizontalAlignment.Left,
    };

    await pdf.stampBarcode("IronPDF", {options: barcodeStampOptions})

    // Save the stamped PDF
    await pdf.saveAs("Stamped.pdf");
})();
npm i @ironsoftware/ironpdf
高效新增 HTML 內容

高效新增 HTML 內容

IronPDF提供多種蓋章選擇,包括HTML、文字、圖片和條碼蓋章。 您可以透過垂直和水平座標指定每個蓋章的位置。 然後可以使用垂直和水平偏移來微調位置達到像素級精準。

HTML蓋章是透過使用包含完整內嵌CSS設計能力的HTML片段來實現的。 若要了解如何有效利用HTML蓋章,請參訪IronPDF 蓋章指南。

如果您不需要需要線上載入的高級字體,文字蓋章可以是一個快速的HTML替代方案。 透過瀏覽IronPDF 文字蓋章文件來探索文字蓋章的效率。

圖片蓋章非常適合用來在PDF文件上快速新增標誌作為最後點綴。 每個蓋章還擁有opacity屬性,可調整其外觀。 圖片蓋章可以配置為浮水印蓋章。 通過檢閱IronPDF 浮水印教程了解更多關於圖片和浮水印蓋章的內容。

條碼蓋章在給定的PDF文件中生成並新增條碼,為文件提供完美的最後點綴。 欲了解條碼使用和自訂化的說明,請參閱IronPDF 條碼蓋章說明。

在GitHub上探索HTML蓋章範例
在 GitHub 上查看

準備好開始了嗎?

版本:2026.6剛剛發布

Key in blue circle

立即免費取得 30 天試用金鑰。

Your trial license will be sent to your email address

無任何限制。100% 解鎖。無需信用卡。

OR
bullet_checked無需信用卡或建立帳號無任何限制。100% 解鎖。無需信用卡。
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried Iron Suite
預訂您的免費線上演示
Booking Badge

獲得來自全球數百萬工程師的信賴

Iron Software的客戶徽標
獲取您的無義務諮詢
填寫以下表格或發送電子郵件至sales@ironsoftware.com
您的資料將始終保密。
獲得來自全球數百萬工程師的信賴
Iron Software的客戶徽標
立即獲取您的30天試用金鑰。
無需信用卡或帳戶建立
Node.js模組下載PDF
使用npm安裝

版本: 2026.6

  1. 下載並安裝Node.js 12+。
  2. 在終端機中執行上述命令。

授權從$999起