Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Missing iframe's allow-scripts permission #288

Open
frodo-cs opened this issue Sep 2, 2024 · 1 comment
Open

Error: Missing iframe's allow-scripts permission #288

frodo-cs opened this issue Sep 2, 2024 · 1 comment

Comments

@frodo-cs
Copy link

frodo-cs commented Sep 2, 2024

When trying to load a PDF file I get the following error:

Screenshot 2024-09-02 at 15 10 16 Screenshot 2024-09-02 at 15 00 19

Here is the code:

import { Card } from "react-bootstrap";
import "./styles.scss";
import DocViewer, { DocViewerRenderers } from "@cyntler/react-doc-viewer";

const DocumentsContainer = () => {
  return (
    <Card className="shadow">
      <DocViewer
        documents={[
          {
            uri: "./pdf-test.pdf",
          },
        ]}
        pluginRenderers={DocViewerRenderers}
      />
    </Card>
  );
};

export default DocumentsContainer;
@devAbreu
Copy link

Hello @frodo-cs

Ensure that ./pdf-test.pdf is being correctly served by your server. Sometimes relative paths can cause issues if the file is not in the correct location or is not being served.

If the PDF file is in the public directory of your project, you can directly reference it using a relative URL:

const docs = [
   { uri: "/pdf-test.pdf" }
 ];

The public directory is directly served at the root of your app, so referencing /pdf-test.pdf should work without additional configuration.

If the file is in the src directory, you can import it using require or import:

const docs = [
  { uri: require("./folder-files/pdf-test.pdf") }
];

This will ensure that the file is bundled when your app is compiled. However, this approach may not work well for large files, so serving from the public folder is often a better approach.

Basic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants