HTML의 사용자 지정 글꼴을 PDF로 변환
로드 시간이 필요한 자산의 올바른 렌더링을 보장하기 위해, waitFor 클래스를 사용하여 렌더 지연을 지정하는 것이 필수적입니다. 여기에는 JavaScript, 글꼴, 네트워크 리소스와 같은 자산이 포함됩니다.
시작할 준비 되셨나요?
버전: 2026.4 방금 출시되었습니다
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, 글꼴, 네트워크 리소스와 같은 자산이 포함됩니다.