Skip to content

A one-of-a-kind resume builder that keeps your privacy in mind. Completely secure, customizable, portable, open-source and free forever. Try it out today!

fix(pdf): normalize standard font path to forward slashes in semantic tests (#3587)

Hoàng Anh Tuấnb3d8266c5e8f
diff --git a/packages/pdf/src/semantic/test/rasterize-pdf.ts b/packages/pdf/src/semantic/test/rasterize-pdf.ts
index 92a67ae0c..2eafd88ed 100644
--- a/packages/pdf/src/semantic/test/rasterize-pdf.ts
+++ b/packages/pdf/src/semantic/test/rasterize-pdf.ts
@@ -18,9 +18,14 @@ type RasterCanvasFactory = {
};
export async function rasterizePdf(bytes: Uint8Array): Promise<readonly RasterizedPdfPage[]> {
+ const standardFontDataPath = fileURLToPath(
+ new URL("standard_fonts/", import.meta.resolve("pdfjs-dist/package.json")),
+ ).replaceAll("\\", "/");
+ const standardFontDataUrl = standardFontDataPath.endsWith("/") ? standardFontDataPath : `${standardFontDataPath}/`;
+
const loadingTask = getDocument({
data: bytes,
- standardFontDataUrl: fileURLToPath(new URL("standard_fonts/", import.meta.resolve("pdfjs-dist/package.json"))),
+ standardFontDataUrl,
});
const pages: RasterizedPdfPage[] = [];