anaralabs / anaralabs/lector

PDF source not found

Aperta
#64 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
TypeScript
Stelle
395
Fork
39
Merge medio
7h 7m
PR unite (30g)
12

Descrizione

I tried to search it in documentation, but didn't found any information about it. Is there any API handler, if PDF resource is not found? Similar like loading state? If source not found, i would like to inform that PDF file is not found. Currently I am just stuck in loading state.

![Image](https://github.com/user-attachments/assets/cf6b3266-f431-4038-93af-ebab86a3e46b)

```
"use client";
import {
Root,
Pages,
Page,
CanvasLayer,
ZoomOut,
CurrentZoom,
ZoomIn,
} from "@anaralabs/lector";
import { GlobalWorkerOptions } from "pdfjs-dist";
import "pdfjs-dist/web/pdf_viewer.css";
import { useEffect, useState } from "react";
import { loadApsLocation } from "@/actions/job-all-actions";
import "pdfjs-dist/web/pdf_viewer.css";

// @ts-ignore
import * as PDFJS from "pdfjs-dist/build/pdf.min.mjs";
const workerSrc = `//cdnjs.cloudflare.com/ajax/libs/pdf.js/${PDFJS.version}/pdf.worker.min.mjs`;
PDFJS.GlobalWorkerOptions.workerSrc = workerSrc;

// Set up the worker
GlobalWorkerOptions.workerSrc = workerSrc;

type Props = {
apsId: number;
};

const fileServer: string = process.env.NEXT_PUBLIC_FILE_SERVER!;

const NewFullPdfViewer = ({ apsId }: Props) => {
const [location, setLocation] = useState(null);

const loadLocation = async () => {
const apsLocation = await loadApsLocation(apsId);
if (apsLocation === "NONE") {
setLocation("NONE");
} else {
setLocation(fileServer + apsLocation);
}
};

useEffect(() => {
loadLocation();
}, []);

if (!location) {
return

loading...

;
}

return (
Loading...}
zoomOptions={{ minZoom: 0.5, maxZoom: 3.0 }}
zoom={2.0}
>


Zoom
-

+







);
};

export default NewFullPdfViewer;

```

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.