Next.js Discord

Discord Forum

Pdf

Answered
Polish Tatra Sheepdog posted this in #help-forum
Open in Discord
Polish Tatra SheepdogOP
Hello, could someone please tell me how I can import a PDF file? Every time I try to import it, the file cannot be found.
Answered by "use php"
how are you importing it?
View full answer

18 Replies

Polish Tatra SheepdogOP
I want to display a PDF on my website, but I'm having trouble locating it when I try to import it.
Answer
Your code?
Error messages?
You have barely provided any info, thats what you are not getting a response
Polish Tatra SheepdogOP
I make a variable, wait a second and I will show you
This is how I try to do it import React from 'react';

const PdfViewer = () => {
return (
<div style={{ width: '100%', height: '100vh' }}>
<iframe
src="/sample.pdf"
style={{ width: '100%', height: '100%', border: 'none' }}
title="PDF Viewer"
></iframe>
</div>
);
};

export default PdfViewer;
I am on my phone, sorry because I show it like that
Polish Tatra SheepdogOP
Yes, but it doesn’t find it, wait a second and I will send you a screenshot
The problem it’s with the import
error screenshot
Polish Tatra SheepdogOP
now, after i restart the project it works
sorry for that
I didn't think to restart the project yesterday....
Public files I think might be loaded on build? Can’t remember. So you may have to restart when you add/remove from it.
Polish Tatra SheepdogOP
Yes, now it's working
sorry for that