anaralabs / anaralabs/lector

PDF source not found

未關閉
#64 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
TypeScript
星號
395
分支
39
平均合併
7 小時 7 分鐘
30 天內合併 PR
12

描述

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;

```

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。