Public
Edited
Nov 13, 2023
Paused
19 stars
Insert cell
Insert cell
pdfjs = {
const version = "4.0";
const lib = await import(`https://cdn.jsdelivr.net/npm/pdfjs-dist@${version}/+esm`);
lib.GlobalWorkerOptions.workerSrc = `https://cdn.jsdelivr.net/npm/pdfjs-dist@${version}/build/pdf.worker.mjs`;
return lib;
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// FileAttachment
attachedFileDoc = pdfjs.getDocument({
data: await FileAttachment("helloworld.pdf").arrayBuffer()
}).promise
Insert cell
// Remote URL (which we'll be using throughout the rest of this notebook)
remoteUrlDoc = pdfjs.getDocument({
url: await FileAttachment("helloworld.pdf").url()
}).promise
Insert cell
page = remoteUrlDoc.getPage(pageNum)
Insert cell
Insert cell
{
const canvas = html`<canvas width=${width} height=500 style="border: 1px solid #aaa">`;
page.render({
canvasContext: canvas.getContext("2d"),
viewport: page.getViewport({scale: 1.5}),
});
return canvas;
}
Insert cell
Insert cell
content = await page.getTextContent({
includeMarkedContent: false,
})
Insert cell
Inputs.table(content.items)
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more