Generate a PDF with pdfmake (from SvelteKit)

แชร์
ฝัง
  • เผยแพร่เมื่อ 11 ก.ค. 2024
  • SvelteKit Playlist: • SvelteKit 1.0 with SQL...
    Code: github.com/phartenfeller/svel...
    Demo: sveltekit-demo.hartenfeller.dev/
    This time we will use the "pdfmake" NPM module to generate a PDF of a pages content on the server. The PDF includes different styles, a table, an image, a list and links.
    Follow me:
    Twitter: / phartenfeller
    Mastodon: mastodon.social/@phartenfeller
    Blog: hartenfeller.dev/blog
    LinkedIn: / phartenfeller
    Support me:
    www.buymeacoffee.com/hartenfe...
    paypal.me/phartenfeller
    Timestamps:
    0:00 Intro
    02:39 Install needed modules
    03:21 Add link to PDF download
    04:07 PDF API Endpoint
    06:03 Integrate Fonts for PDF
    07:50 Hello World PDF
    13:50 Add Styles
    16:12 Add Table
    19:25 Add Image
    22:42 Add unordered list with links
    Resources:
    www.npmjs.com/package/pdfmake
    pdfmake.org/playground.html
    fonts.google.com/
    PDF icons created by kliwir art - Flaticon : www.flaticon.com/free-icons/pdf
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 13

  • @hartenfellerdev
    @hartenfellerdev  11 หลายเดือนก่อน +2

    I had a bug where the font files are not included in the build. I fixed this by explicitly providing these assets to the container. See this commit where I resolved the issue: github.com/phartenfeller/sveltekit-1.0-sqlite-demo-app/commit/15e3c11ec6e198df6269a43d61d8fdbaeaf5b7ea

  • @RicardoCamisa
    @RicardoCamisa ปีที่แล้ว +3

    Thank you very much for answering this question of mine. I was thinking about the possibility of creating an API with nodejs. You saved me!

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

    thank you for making this unique tutorial, go forward

  • @amorfati8277
    @amorfati8277 ปีที่แล้ว +1

    Great video ❤. Really helpful

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

    Hi! Thanks for the video and great explanation. I'm trying to generate the pdf following the steps mentioned, but the pdf stays loading and doesn't finish. From the logs on the server it seems that the pdf is being generated, but when it tries to consume from the client, stays loading. Do you know how to solve this? Thanks in advance!

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

    hai can you give me example to generate pdfmake from database / mysql

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

    with svg?

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

    cant get this to work in production, on vercel, keep getting " ENOENT: no such file or directory, open 'src/lib/server/fonts/Roboto-Bold.ttf'" even though i have them in my directory

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

      Hello, I tried to use with Node Adapter, but in production it fails because of __dirname in a dependency module (fontkit)

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

      Sorry for the late reply but I had a bug all along that I finally noticed and fixed. The font files are not included in the build so I had to explicitly provide them: github.com/phartenfeller/sveltekit-1.0-sqlite-demo-app/commit/15e3c11ec6e198df6269a43d61d8fdbaeaf5b7ea

    • @henkbourgonje3344
      @henkbourgonje3344 8 หลายเดือนก่อน +1

      Have you gotten it to work on vercel? I'm running into the same issue

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

      same issue@@henkbourgonje3344