IRONSOFTWAREHOME
Adding HTML Content Efficiently
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
Adding HTML Content Efficiently

Adding HTML Content Efficiently

IronPDF offers a wide variety of stamps, including HTML, text, image, and barcode stamps. You can specify the position of each stamp with both vertical and horizontal coordinates. Vertical and horizontal offsets can then be used to fine-tune the precise location with pixel accuracy.

HTML stamping is achieved using an input HTML fragment with the power of full inline CSS styling for design. For more information on how to utilize HTML stamping effectively, visit the IronPDF Stamping Guide.

Text stamping can be a fast alternative to HTML if you don't need fancy fonts that require online loading. Discover the efficiency of text stamping by exploring the IronPDF Text Stamping Documentation.

Image stamping is ideal for adding a logo as a quick final touch to the PDF document. Each stamp also has rotation and opacity properties that can be adjusted to change its appearance. Image stamps can be configured as watermark stamps. Learn more about image and watermark stamping by reviewing the IronPDF Watermark Tutorial.

Barcode stamping generates and adds barcodes to the given PDF document, providing a perfect finishing touch to the document. For instructions on barcode use and customization, check out the IronPDF Barcode Stamping Instructions.

Explore HTML Stamping Examples on GitHub
View on GitHub

Ready to Get Started?

Version:2026.8just released

Key in blue circle

Get your free 30-day Trial Key instantly.

Your trial license will be sent to your email address

No limitations. 100% unlocked. No credit card.

bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
Book your free Live Demo
Booking Badge

Trusted by Millions of Engineers Worldwide

Iron Software's customer logos
Get Your No-Obligation Consult
Complete the form below or email sales@ironsoftware.com
Your details will always be kept confidential.
Trusted by Millions of Engineers Worldwide
Iron Software's customer logos
Get your free 30-day Trial Key instantly.
No credit card or account creation required