최신커밋
This commit is contained in:
@@ -18,11 +18,21 @@ import {
|
||||
} from "@ant-design/icons";
|
||||
import html2canvas from "html2canvas";
|
||||
import {PDFDocument, PDFPage} from "pdf-lib";
|
||||
import {PasswordException} from "pdfjs-dist/types/src/shared/util";
|
||||
import { jsPDF } from "jspdf";
|
||||
|
||||
const PdfjsVersion:string = "3.11.174";
|
||||
GlobalWorkerOptions.workerSrc = `https://unpkg.com/pdfjs-dist@${PdfjsVersion}/build/pdf.worker.min.js`;
|
||||
const currentUrl = getCurrentUrl();
|
||||
console.log(currentUrl);
|
||||
GlobalWorkerOptions.workerSrc = `${currentUrl}/pdf.worker.js`;
|
||||
|
||||
function getCurrentUrl(): string {
|
||||
// window.location 객체를 통해 현재 URL 정보에 접근
|
||||
const { protocol, hostname, port } = window.location;
|
||||
|
||||
// 포트가 80이 아닌 경우에만 포트를 포함한 URL 반환
|
||||
const portSuffix = (port === '80' || port === '443') ? '' : `:${port}`;
|
||||
|
||||
// 조합된 URL 반환
|
||||
return `${protocol}//${hostname}${portSuffix}/pdfwiz/pdfjs`;
|
||||
}
|
||||
|
||||
interface PdfViewerProps {
|
||||
fileUrl: string;
|
||||
@@ -43,7 +53,7 @@ async function loadPage(pdf:PDFDocumentProxy, pageNum:number, scale:number, rota
|
||||
|
||||
const loadingImage = document.createElement("img");
|
||||
|
||||
loadingImage.setAttribute("src", "pdf-loading.svg");
|
||||
loadingImage.setAttribute("src", "pdfwiz/image/loading.svg");
|
||||
const textLayer = isRenderText ? document.createElement("div") : null;
|
||||
if (textLayer)
|
||||
{
|
||||
@@ -152,8 +162,8 @@ export const PDFViewer = (props: PdfViewerProps) => {
|
||||
, waterMarkText, fileName} = props;
|
||||
|
||||
const [modalVisible, setModalVisible] = useState<boolean>(false);
|
||||
const downloadUrl = downloadFileUrl || fileUrl;
|
||||
const fileTitle= fileName||fileUrl;
|
||||
//const downloadUrl = downloadFileUrl || fileUrl;
|
||||
//const fileTitle= fileName||fileUrl;
|
||||
const [threshold, setThreshold] = useState<number>(0.7);
|
||||
const [scaleValue, setScaleValue] = useState<number>(scale || 1.5);
|
||||
const [currentPage, setCurrentPage] = useState<number>(1);
|
||||
@@ -322,6 +332,8 @@ export const PDFViewer = (props: PdfViewerProps) => {
|
||||
onClick: handleRatioMenuClick,
|
||||
};
|
||||
|
||||
|
||||
|
||||
function enterFullScreen(elementId: string): void {
|
||||
const element = document.getElementById(elementId) as HTMLElement & {
|
||||
requestFullscreen?: () => Promise<void>;
|
||||
@@ -945,7 +957,7 @@ export const PDFViewer = (props: PdfViewerProps) => {
|
||||
|
||||
const loadOption: any = {
|
||||
url: fileUrl,
|
||||
cMapUrl: `https://unpkg.com/pdfjs-dist@${PdfjsVersion}/cmaps/`,
|
||||
cMapUrl: `${currentUrl}/cmaps/`,
|
||||
cMapPacked: true,
|
||||
enableXfa: true,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user