Replies: 2 comments
-
I'm using Deno, and got a similar error: code:import { createCanvas } from "jsr:@gfx/[email protected]";
import { getDocument } from "npm:[email protected]";
import { Err, Ok, Result } from "@src/lib/result.ts";
export async function loadImageDocument(
storagePath: string,
) {
console.info("Loading file", storagePath);
const fileBlob = await Result.wrapAsync<Blob, Error>(async () => {
const response = await fetch(new URL(storagePath));
return await response.blob();
});
if (fileBlob.isErr()) {
return Err(fileBlob.error);
}
const file = await fileBlob.value.arrayBuffer();
getDocument(file).promise
.then(async (pdf) => {
const page = await pdf.getPage(1);
const viewport = page.getViewport({ scale: 1.0 });
const canvas = createCanvas(
Math.floor(viewport.width),
Math.floor(viewport.height),
);
await page.render({
canvasContext: canvas.getContext("2d"),
viewport,
}).promise;
canvas.save("image.png");
});
return Ok.EMPTY;
} Loading file file:/home/kalleby/projects/my-project/examples/file.pdf
Warning: fetchStandardFontData: failed to fetch file "FoxitSerif.pfb" with "UnknownErrorException: The standard font "baseUrl" parameter must be specified, ensure that the "standardFontDataUrl" API parameter is provided.".
Warning: fetchStandardFontData: failed to fetch file "FoxitSerif.pfb" with "UnknownErrorException: The standard font "baseUrl" parameter must be specified, ensure that the "standardFontDataUrl" API parameter is provided.".
Warning: fetchStandardFontData: failed to fetch file "FoxitSerifBold.pfb" with "UnknownErrorException: The standard font "baseUrl" parameter must be specified, ensure that the "standardFontDataUrl" API parameter is provided.".
Warning: fetchStandardFontData: failed to fetch file "FoxitSerifItalic.pfb" with "UnknownErrorException: The standard font "baseUrl" parameter must be specified, ensure that the "standardFontDataUrl" API parameter is provided.".
I already tried to specify the getDocument({
data: file,
standardFontDataUrl:
"https://github.com/mozilla/pdf.js/raw/master/external/standard_fonts/",
// "https://cdn.jsdelivr.net/npm/[email protected]/standard_fonts/"
// Donwload the files to a local folder and use relative location to it
}) But always got |
Beta Was this translation helpful? Give feedback.
-
For me, I was able to get it working in a docker container by copying the standard_fonts folder in and using the folder path as the standardFontDataUrl. Eg COPY ./standard_fonts /etc/standard_fonts And then getDocument({data:file, standardFontDataUrl: "/etc/standard_fonts/"}) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm getting this weird warning whenever I load a pdf. How do I fix this?
Second Question:
I'm using
pdfjs-dist
on node js environment and I want to modify and remove the field values from all the fields on a page and save the resulting pdf. Please let me know how can I achieve that 🙏Beta Was this translation helpful? Give feedback.
All reactions