We are trying to show pdf and using annotation features but we are getting some file header exception error.
Also if we are providing extension sepearatly then getting exception for file header not supported.
Providing code snippet :
import React from “react”;
import WebViewer from “@pdftron/pdfjs-express”;
import “./styles.css”;
export default function App() {
const viewer = React.useRef(null);
// if using a class, equivalent of componentDidMount
const funView = () => {
WebViewer(
{
path: “WebViewer/lib”,
initialDoc: “/files/demo.pdf”,
},
viewer.current
).then((instance) => {
// change to dark mode
instance.UI.setTheme(“dark”);
// remove left panel and left panel button from the DOM
instance.UI.disableElements([“leftPanel”, “leftPanelButton”]);
instance.Core.documentViewer.addEventListener(“documentLoaded”, () => {
// add a custom annotation
const rectangleAnnot =
new instance.Core.Annotations.RectangleAnnotation();
rectangleAnnot.PageNumber = 1;
rectangleAnnot.X = 100;
rectangleAnnot.Y = 150;
rectangleAnnot.Width = 200;
rectangleAnnot.Height = 50;
instance.Core.annotationManager.addAnnotation(rectangleAnnot);
});
});
};
return (