Spaces:
Paused
Paused
nkw
commited on
Update index.js
Browse files
index.js
CHANGED
|
@@ -29,7 +29,22 @@ async function MdtoPdf(md, type) {
|
|
| 29 |
const browser = await initBrowser;
|
| 30 |
const page = await browser.newPage();
|
| 31 |
const htmlContent = convertMarkdownToHTML(md);
|
| 32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
const pdfBuffer = await page.pdf({
|
| 34 |
format: type || "A4",
|
| 35 |
printBackground: true,
|
|
|
|
| 29 |
const browser = await initBrowser;
|
| 30 |
const page = await browser.newPage();
|
| 31 |
const htmlContent = convertMarkdownToHTML(md);
|
| 32 |
+
const fullHtmlContent = `
|
| 33 |
+
<html>
|
| 34 |
+
<head>
|
| 35 |
+
<style>
|
| 36 |
+
@font-face {
|
| 37 |
+
font-family: 'OpenSans';
|
| 38 |
+
src: url('https://raw.githubusercontent.com/edx/edx-fonts/refs/heads/master/open-sans/fonts/Semibold/OpenSans-Semibold.ttf') format('truetype');
|
| 39 |
+
font-weight: 600; /* SemiBold */
|
| 40 |
+
font-style: normal;
|
| 41 |
+
}
|
| 42 |
+
</style>
|
| 43 |
+
</head>
|
| 44 |
+
<body>${htmlContent}</body>
|
| 45 |
+
</html>
|
| 46 |
+
`;
|
| 47 |
+
await page.setContent(fullHtmlContent, { waitUntil: "domcontentloaded" });
|
| 48 |
const pdfBuffer = await page.pdf({
|
| 49 |
format: type || "A4",
|
| 50 |
printBackground: true,
|