IRONSOFTWAREHOME
HTMLからPDFへのカスタムフォント
import {PdfDocument, WaitForType} from "@ironsoftware/ironpdf";

(async () => {
    // Define the HTML content with a custom font from Google Fonts
    const htmlWithFont = `
        <h1>Google Font</h1>
        <link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet">
        <p style="font-family: 'Lobster', serif; font-size:30px;">Hello Google Fonts</p>
    `;

    // Configure render options
    const options = {
        // Delay render to finish font loading
        waitFor: {
            type: WaitForType.RenderDelay,
            maxWaitTime: 500,
        },
    };

    // Render HTML content with the custom font to a PDF
    const doc = await PdfDocument.fromHtml(htmlWithFont, { renderOptions: options });

    // Save the PDF
    await doc.saveAs("font.pdf");
})();
npm i @ironsoftware/ironpdf
HTMLからPDFへのカスタムフォント

HTMLからPDFへのカスタムフォント

アセットの正しいレンダリングを確保するためには、waitFor クラスを使用してレンダーディレイを指定することが不可欠です。 これはJavaScript、フォント、ネットワークリソースなどのアセットを含みます。

GitHub で Google Fonts to PDF Example を調べてください。
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

世界中の数百万人のエンジニアから信頼されています。

ライセンスはより安く
義務のない相談を受ける
下記のフォームを記入するか、sales@ironsoftware.comにメールしてください。
あなたの詳細は常に守秘されます。
世界中の数百万人のエンジニアから信頼されています。
ライセンスはより安く
あなたの無料30日間の試用キーをすぐに入手。
クレジットカードやアカウントの作成は不要です。
Node.js モジュールダウンロード for PDF
npmでインストール

バージョン: 2026.6

  1. ダウンロードしてNode.js 12+をインストール。
  2. 上記のコマンドをターミナルで実行します。

ライセンスは$999から