Brendan Bois
Brendan Bois
  • 1
  • 23 421
Nextjs and React PDF Tutorial: WATCH THIS BEFORE STARTING YOUR PDF
React-PDF tutorial, everything I had to deal with from start to finish and all the agonizing solutions I had to find along the way.
Github link:
github.com/bbois1999/react-pdf
How do I import font into React PDF?
How do I import images into React PDF?
Why isn't react pdf showing up on my browser?
PDFViewer and PDFDownloadLink not working in browser?
Error: PDFDownloadLink is a web specific API. You're either using this component on Node, or your bundler is not loading react-pdf from the appropriate web build.
TypeError: dispatcher.useSyncExternalStore is not a function
PDFDownloadLink TypeError: Cannot read properties of null (reading 'props')
[bug] × TypeError: Cannot read property 'props' of null
PDFDownloadLink work only work when render but hit error when reload page
dispatcher.useSyncExternalStore error PDFDownloadLink
dispatcher.useSyncExternalStore error
Warning: VIEW / is using incorrect casing. Use PascalCase for React components, or lowercase for HTML elements
DOCUMENT / is using incorrect casing. Use PascalCase for React components, or lowercase for HTML elements. [bug help wanted]
Error: Font family not registered: Inter. Please register it calling Font.register() method.
มุมมอง: 23 426

วีดีโอ

ความคิดเห็น

  • @ead5590
    @ead5590 วันที่ผ่านมา

    Its gonna be almost 2 years since this video was uploaded but this solution still holds true and most importantly, works! Thanks a lot for this Brendan! To those reading, if you TH-cam search 'React PDF' and a video shows up by the channel 'Arsalan' titled 'React PDF Basic setup'. DO NOT follow that for setting things up on NextJS. You're gonna error out. Just follow this video and be on your way to creating your PDF.. Thanks again Brendan! A fellow dev saves the day yet again! ✌🏻🫡

  • @josh4play.youtube
    @josh4play.youtube หลายเดือนก่อน

    bro you literally saved my life - i downloaded the video just in case you ever take it down i have some refference

  • @jillasridatta7370
    @jillasridatta7370 หลายเดือนก่อน

    I am using SPFX(SharePoint Framework) with React And I have used react-pdf/renderer and I have done these things and also exactly that I have seen in documentations but I am getting an error in the console stating that bidi is not a function at textkit.js. Help me 🥹

  • @eternl_sunshine22
    @eternl_sunshine22 หลายเดือนก่อน

    make more vids bro

  • @adamczarny6482
    @adamczarny6482 2 หลายเดือนก่อน

    hugeee dose of knowledge

  • @Tsxtasy1
    @Tsxtasy1 4 หลายเดือนก่อน

    I really appreciate the video. I got mine working by importing pdfjs from react-pdf and setting pdfjs.GlobalWorkerOptions.workerSrc to legacy to get rid of the unexpected token error.Then created a types.d.ts file to set .pdf type to :any and added it to the tsconfig so that the application could find the module for import. I came to this video as a quick way to understand the rest of the API imports and how they work. I gotta say, take a breather before hitting record next time. I feel your pain, I was on this for 2 days. But it will reach a wider audience if you take some time before making the video to cool off and rehash the required steps in your head a few times

  • @jonathanadel3831
    @jonathanadel3831 5 หลายเดือนก่อน

    That was really helpful, thank you.

  • @knrking007
    @knrking007 6 หลายเดือนก่อน

    I had an issue with fs not defined or some issues ,this code worked for me module.exports = { webpack: (config, { isServer }) => { if (!isServer) { // Exclude 'fs' module from client-side bundle config.resolve.fallback = { ...config.resolve.fallback, fs: false, }; } return config; }, };

  • @GermansEagle
    @GermansEagle 6 หลายเดือนก่อน

    Ssr false is just removing server side rendering. You are making it a client component. In the new nextjs you don't need to do this. Just "use client"

  • @higorskowronskidesouza1692
    @higorskowronskidesouza1692 6 หลายเดือนก่อน

    Please, new Tutorial with Next - 14 !!

  • @rohanmiscelionius5074
    @rohanmiscelionius5074 6 หลายเดือนก่อน

    Error: PDFDownloadLink is a web specific API. You're either using this component on Node, or your bundler is not loading react-pdf from the appropriate web build. getting this error in production but works fine on local i did ll the steps same as shown in video i am using next js 13

  • @ifeoraokechukwu1346
    @ifeoraokechukwu1346 7 หลายเดือนก่อน

    You are a life-saver ! Thanks a lot 👍🏾👍🏾👍🏾👍🏾👍🏾👍🏾

  • @reactDevelopment
    @reactDevelopment 8 หลายเดือนก่อน

    in latest next js do this work

  • @vncstudio
    @vncstudio 8 หลายเดือนก่อน

    I finally got it to work but it is a hideous mess. It shows the original page as well as a raw text version and then the nav buttons are displayed on a third page. Going to take a look at your code.

  • @vncstudio
    @vncstudio 8 หลายเดือนก่อน

    I had a lot of issues trying to get this work yesterday!

  • @_jackmad
    @_jackmad 9 หลายเดือนก่อน

    For Next.js 14 only write "use client" on top of your page.js file, before the import lines, below these lines, write const styles and const MyDocument functions ,inside page, write the useState and useEffect and inside the return the pdfViewer, to this tag add style={{ 'width': '100%', 'height': '100v' }} so that the PDFViewer is the full size on the page, with this you eliminate the need to place dynamic and create two different components, it works for me :D

    • @dominikfrackowiak4693
      @dominikfrackowiak4693 8 หลายเดือนก่อน

      Thanx a lot

    • @nidhiwankhede5195
      @nidhiwankhede5195 4 หลายเดือนก่อน

      i did this but I am getting error 404: page not found can you help please?

  • @kyraezikeuzor
    @kyraezikeuzor 9 หลายเดือนก่อน

    Thank you so much. Wow this is a big help.

  • @arturoordonez-hernandez8750
    @arturoordonez-hernandez8750 9 หลายเดือนก่อน

    Thanks for making this! I still have to rework this a bit for my use case at work, but thanks for helping me get started! I tried using react-to-pdf but I couldn't get it to work; it makes use of a componentRef and it was just complicating things for me with what I'm doing.

  • @arturoordonez-hernandez8750
    @arturoordonez-hernandez8750 9 หลายเดือนก่อน

    FYI: you'll need to run npm i next for your project to find dynamic, not npm i @next-tools/dynamic. As for the tiny PDF Viewer, try adding in some styles like so in your PDFView component (the one below where you have the <Document> as the root component): <PDFViewer style={{width:"100%", height:"100vh"}}>

  • @hassanbello1535
    @hassanbello1535 11 หลายเดือนก่อน

    Great tutorial! A useful alternative I found was to 'screenshot' whatever component I wanted rendered and render it as an image with react-pdf, with this I could add everything I wanted.

  • @vladimirplyukhin5234
    @vladimirplyukhin5234 11 หลายเดือนก่อน

    Awesome! Do you know how to open a PDF in a new tab?

  • @patrickrios99
    @patrickrios99 ปีที่แล้ว

    thank you

  • @amatir-tutor2421
    @amatir-tutor2421 ปีที่แล้ว

    How to create table?

  • @user-nt3zg4rh4c
    @user-nt3zg4rh4c ปีที่แล้ว

    After git clone, if you see in the left corner white square try to change the font to some default like Font.register({ family: "Helvetica", src: "/path/to/helvetica.ttf" });

  • @yangenmanuel2659
    @yangenmanuel2659 ปีที่แล้ว

    Amazing bro! Did you have the error: PDFViewer is a web specific API. You're either using this component on Node, or your bundler is not loading react-pdf from the appropriate web build. When building the application? I`m having problems with that Thanks for the help!

    • @nevajnosovsem2369
      @nevajnosovsem2369 ปีที่แล้ว

      Hi. Do you know how to turn a PDF into a Blob? i cant take anymore.....

    • @yangenmanuel2659
      @yangenmanuel2659 ปีที่แล้ว

      @@nevajnosovsem2369 got no idea how to do it. If you know how to i will be really thankful.

    • @yangenmanuel2659
      @yangenmanuel2659 ปีที่แล้ว

      @@nevajnosovsem2369 I found the solution! On your next.config file you should add: const nextConfig = { /* all your config */ swcMinify: false, }

  • @huynhkieu5236
    @huynhkieu5236 ปีที่แล้ว

    Thank you so much. You save me <3

    • @nevajnosovsem2369
      @nevajnosovsem2369 ปีที่แล้ว

      Hi. Do you know how to turn a PDF into a Blob? i cant take anymore.....

  • @kyosukefukumoto9382
    @kyosukefukumoto9382 ปีที่แล้ว

    I love how you explain everything haha can you import pdf like you've done with an Image?

  • @shubhamkumbhakar2389
    @shubhamkumbhakar2389 ปีที่แล้ว

    chutiya video

  • @tiifuhamza1397
    @tiifuhamza1397 ปีที่แล้ว

    Hello there. Thank you for this wonderful video. i have struggled over this bug for a month.Thank You and more videos

  • @traam_889
    @traam_889 ปีที่แล้ว

    Almost shot myself, this was driving me crazy lmao

  • @user-mk6qq7qi8u
    @user-mk6qq7qi8u ปีที่แล้ว

    I don't even need to use this packaging, but I stayed to watch because you are awesome! Can feel the 'pain' you went through, thanks for sharing.

  • @ryadallali4340
    @ryadallali4340 ปีที่แล้ว

    i got this err : Error: PDFViewer is a web specific API. You're either using this component on Node, or your bundler is not loading react-pdf from the appropriate web build. This error happened while generating the page. Any console logs will be displayed in the terminal window.

    • @brendanbois5365
      @brendanbois5365 ปีที่แล้ว

      I'm sorry it's been so long since I've done anything with this. If I were you I'd ask chatGPT lol, it legit might know exactly how to fix this

  • @abhisycvirat
    @abhisycvirat ปีที่แล้ว

    I am getting this error Any idea to fix this ./node_modules/@react-pdf/font/lib/index.browser.es.js Attempted import error: 'create' is not exported from 'fontkit' (imported as 'fontkit').

  • @georgesngandeu9115
    @georgesngandeu9115 ปีที่แล้ว

    Thank you, if you want to display the pdf with a larger height and width, just add a class to pdfViewer and set the desired width and height in the class. For small screen use media query to transition

  • @MarvelCodes
    @MarvelCodes ปีที่แล้ว

    “I don’t know what that means, I just know that this works” - The stranger that saved my job.

    • @tuffilaro1565
      @tuffilaro1565 ปีที่แล้ว

      "This knowledge has been passed down for generations" vibe

  • @ramizazhar8891
    @ramizazhar8891 ปีที่แล้ว

    If you guys wondering why your custom font doesn’t work. Just try on style on <View> component, not <Text> component.

  • @Elxroid
    @Elxroid ปีที่แล้ว

    dude legit kekw's in a dev tutorial at 6:23 Thanks for the vid defo let me know of a few pitfalls I didn't realise I was already in

  • @ramizazhar8891
    @ramizazhar8891 ปีที่แล้ว

    you can style the PDFViewer component with 100% width or anything you want.

  • @danieltorres7634
    @danieltorres7634 ปีที่แล้ว

    Gracias por el video. Para la comunidad latina

  • @DaniBZone
    @DaniBZone ปีที่แล้ว

    Is there a way to make it bigger? Instead of zooming in the pdf? It's pretty hard

    • @ramizazhar8891
      @ramizazhar8891 ปีที่แล้ว

      I use tailwind, <PDFViewer className="w-full h-screen"> <PDF /> </PDFViewer>

    • @MarvelCodes
      @MarvelCodes ปีที่แล้ว

      global.css set an iFrame css declaration and give the height and width you want, the Document tag fills it up.

  • @petrsonTD
    @petrsonTD ปีที่แล้ว

    Dude you dont even know how large problem it was for me load image to my pdf. it's always said it cant get to it. Then I remembered that I week ago I watched this video and you said to use folder ...publick/assets. you saved me.

  • @extensus4842
    @extensus4842 ปีที่แล้ว

    Great video, was incredibly helpful. The fix to the size I found is adjusting the width and height in a global stylesheet on the Iframes.

  • @marekchoinski5431
    @marekchoinski5431 ปีที่แล้ว

    Thank you, it was very helpful

  • @faustozambrano4901
    @faustozambrano4901 ปีที่แล้ว

    Thanks for letting me out the gutter, budd

  • @CoderMK
    @CoderMK ปีที่แล้ว

    Hi thanks for help can you help me with challenge I would really appreciate I want to create content table page like we have in books, problem is I don't know how to assign page number to in content table because I don't know how many pages chapter 1 will take and chapter 2 will start at what

  • @shytypes1028
    @shytypes1028 ปีที่แล้ว

    may your days be long and filled with the lustfully desires of all neards and developers all over the world. you just saved my ass.

  • @malaizyogmuzumala7736
    @malaizyogmuzumala7736 ปีที่แล้ว

    Thanks alot man, is it possible to create PDFs with dynamic content, like a receipt or something?

    • @AlexGalo0
      @AlexGalo0 ปีที่แล้ว

      this is what i need to know

  • @gobindsingh212
    @gobindsingh212 ปีที่แล้ว

    I love the enthusiasm and how you're so fired up to share your knowledge. You earned a sub :)

  • @edgarmacas3331
    @edgarmacas3331 ปีที่แล้ว

    hi, when run "npm run build", I get this error "PDFViewer is a web specific API. You're either using this component on Node, or your bundler is not loading react-pdf from the appropriate web build " any solution please.

    • @MarkSchewe
      @MarkSchewe ปีที่แล้ว

      Watch the hole video. The trick is to generate a second view to display the document with disabled SSR

    • @ganatraarpita5982
      @ganatraarpita5982 ปีที่แล้ว

      @@MarkSchewe I did that and still get the error while building my next.js app

  • @mohamedyoussef8835
    @mohamedyoussef8835 ปีที่แล้ว

    Awesome help +++++++++++++++++ Thank You 😀