HTML의 사용자 지정 글꼴을 PDF로 변환
로드하는 데 시간이 필요한 에셋이 제대로 렌더링되도록 하려면 waitFor 클래스를 사용하여 렌더링 지연 시간을 지정하는 것이 필수적입니다. 여기에는 자바스크립트, 글꼴, 네트워크 리소스와 같은 자산이 포함됩니다.
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 클래스를 사용하여 렌더링 지연 시간을 지정하는 것이 필수적입니다. 여기에는 자바스크립트, 글꼴, 네트워크 리소스와 같은 자산이 포함됩니다.