HTML의 사용자 지정 글꼴을 PDF로 변환
로딩에 시간이 소요되는 리소스가 올바르게 렌더링되도록 하려면 waitFor 클래스를 사용하여 렌더링 지연 시간을 지정하는 것이 필수적입니다. 여기에는 JavaScript, 글꼴, 네트워크 리소스와 같은 자산이 포함됩니다.
시작할 준비 되셨나요?
버전: 2026.5 just released
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");
})();로딩에 시간이 소요되는 리소스가 올바르게 렌더링되도록 하려면 waitFor 클래스를 사용하여 렌더링 지연 시간을 지정하는 것이 필수적입니다. 여기에는 JavaScript, 글꼴, 네트워크 리소스와 같은 자산이 포함됩니다.