mirror of
https://github.com/JOYCEQL/magic-resume.git
synced 2026-07-03 14:07:11 +02:00
fix: pdf font
This commit is contained in:
@@ -17,8 +17,7 @@ export async function POST(req: Request) {
|
||||
"--no-sandbox",
|
||||
"--disable-setuid-sandbox",
|
||||
"--font-render-hinting=none",
|
||||
"--disable-web-security",
|
||||
"--font-family=Microsoft YaHei"
|
||||
"--disable-web-security"
|
||||
],
|
||||
// defaultViewport: chrome.defaultViewport,
|
||||
executablePath: await chrome.executablePath(
|
||||
@@ -29,7 +28,17 @@ export async function POST(req: Request) {
|
||||
|
||||
const page = await browser.newPage();
|
||||
|
||||
await page.evaluate(() => document.fonts.ready);
|
||||
await page.addStyleTag({
|
||||
content: `
|
||||
@font-face {
|
||||
font-family: 'GeistMonoVF';
|
||||
src: url('/fonts/GeistMonoVF.woff') format('woff');
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
`
|
||||
});
|
||||
await page.evaluateHandle("document.fonts.ready");
|
||||
|
||||
await page.setContent(content);
|
||||
|
||||
@@ -50,20 +59,6 @@ export async function POST(req: Request) {
|
||||
waitUntil: ["domcontentloaded", "networkidle0"]
|
||||
});
|
||||
|
||||
// 加入fonts文件夹加入的字体
|
||||
await page.addStyleTag({
|
||||
content: `
|
||||
@font-face {
|
||||
font-family: 'GeistMonoVF';
|
||||
src: url('/fonts/GeistMonoVF.woff') format('woff');
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
`
|
||||
});
|
||||
|
||||
await page.evaluateHandle("document.fonts.ready");
|
||||
|
||||
await browser.close();
|
||||
|
||||
return new NextResponse(pdf, {
|
||||
|
||||
@@ -37,15 +37,6 @@ export function PdfExport() {
|
||||
const content = `
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
@font-face {
|
||||
font-family: 'Noto Sans SC';
|
||||
src: url('https://fonts.googleapis.com/css2?family=Noto+Sans+SC&display=swap');
|
||||
}
|
||||
body {
|
||||
font-family: 'Noto Sans SC', sans-serif;
|
||||
}
|
||||
</style>
|
||||
<style>${styles}</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
Reference in New Issue
Block a user