HTML의 사용자 지정 글꼴을 PDF로 변환
자산이 로드되는 데 시간이 필요한 경우 올바르게 렌더링하려면 waitFor 클래스를 사용하여 렌더 지연을 지정하는 것이 중요합니다. 여기에는 JavaScript, 글꼴, 네트워크 리소스와 같은 자산이 포함됩니다.
시작할 준비 되셨나요?
버전: 2026.6 방금 출시
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, 글꼴, 네트워크 리소스와 같은 자산이 포함됩니다.