Flexible PDF Reporting in .NET Using IronPDF and Razor Views

Поділитися
Вставка
  • Опубліковано 27 січ 2025

КОМЕНТАРІ • 102

  • @MilanJovanovicTech
    @MilanJovanovicTech  10 місяців тому +3

    Get the source code for this video for FREE → the-dotnet-weekly.ck.page/html-to-pdf
    Want to master Clean Architecture? Go here: bit.ly/3PupkOJ
    Want to unlock Modular Monoliths? Go here: bit.ly/3SXlzSt

  • @drhdev
    @drhdev 10 місяців тому +13

    QuestPDF has been one of the best tools I’ve ever worked with. Saved us sooo much money for reports and invoice layouts

    • @MilanJovanovicTech
      @MilanJovanovicTech  10 місяців тому

      That's awesome. Did you run into any roadblocks with QuestPDF given that it's C# -> PDF?

    • @drhdev
      @drhdev 10 місяців тому

      @@MilanJovanovicTech Honestly not at all, the one issue at first was file size but they have since fixed that issue. It's incredibly fast to create new reports/layouts, is pretty intuitive once you learn about the flow, and the hot-reload previewer is amazing

    • @okharev8114
      @okharev8114 9 місяців тому

      but isn't quest pdf a paid library ?

    • @drhdev
      @drhdev 9 місяців тому

      @@okharev8114 it’s free for companies with under $1mm revenue

  • @kodindoyannick5328
    @kodindoyannick5328 10 місяців тому +2

    It's amazing. Personally i never used IronPDF neither another PDF library. After view this video I'll test IronPDF. Thanks Milan.

  • @AshrafTarek
    @AshrafTarek 10 місяців тому +8

    IronPDF uses Chromium under the hood. You can achieve the same result without paying 1 cent for the tool. A more lightweight option would be wkhtml2pdf (little bit outdated though, in terms of CSS features), which could cover simple cases, like shown in the video.

    • @MilanJovanovicTech
      @MilanJovanovicTech  10 місяців тому +3

      Little bit outdated? 😅

    • @AshrafTarek
      @AshrafTarek 10 місяців тому +3

      @@MilanJovanovicTech Yes, the last update was in 2020 😬

    • @flobuilds
      @flobuilds 10 місяців тому +2

      Still a good Option for simple stuff i mean 2020 is still pretty new and mostly nobody needs the new features and this way you can create a fully free pdf creation service for many things. My team and i through of using something like this

    • @AshrafTarek
      @AshrafTarek 10 місяців тому +2

      @@flobuilds Yes it is. I used it a lot in my previous job. We could handle any case, like invoices, tickets with QR codes and customized badges in formats like A6.
      In my new job we decided to use Puppeteer with Chromium, where the browser runs in a docker container in headless mode, listening on a websocket for print jobs. This approach also allows you to scale PDF generation seperately and removes some load from your main application.

  • @adamsilzell4968
    @adamsilzell4968 10 місяців тому +4

    It would be cool to be able to have a footer per page with the html renderer.

    • @MilanJovanovicTech
      @MilanJovanovicTech  10 місяців тому +1

      I'll cover that in an article next few weeks

    • @Regan-iron
      @Regan-iron 10 місяців тому

      Yes, IronPdf supports rendering headers and footers in PDF documents. You can easily add text or HTML headers and footers to your PDFs, allowing for customization such as including page numbers, logos, or other relevant information.

  • @AbuBakrSadiqi-b7t
    @AbuBakrSadiqi-b7t 2 місяці тому

    Some days ago I came across a video (I guess that was your or maybe Nick Chapsa video) that was using blazor to create html template and then send on email or print as pdf. If was your video then kindly put it's link to me cause I was not able to find.
    And I have a question regarding that. I have a microservices architecture web apis, is that a good practice to create a separate project of blazor and create dynamic html template and send in email, or print as pdf? I want to avoid using libraries?

  • @aqz5905
    @aqz5905 8 днів тому

    Is razor view is enough to build UI in large application instead of react Or angular? What’s your thoughts on this ?

    • @MilanJovanovicTech
      @MilanJovanovicTech  8 днів тому

      Yes, Razor is pretty good. The "how it works" part is why most people go for SPAs

    • @aqz5905
      @aqz5905 8 днів тому

      @ Razor Pages + HTML+ HTMX + AlpineJS . It’s works pretty well for partial rendering. Have you ever tried? Is it good to use these stack for large application ?

    • @aqz5905
      @aqz5905 8 днів тому

      @@MilanJovanovicTech ?

  • @BissultanYernazar
    @BissultanYernazar 10 місяців тому +1

    Thank you for making these amazing videos! And, yes, I promise to stay 'awesome' until the next time)

  • @michaels8336
    @michaels8336 10 місяців тому +1

    Any good libraries for reading/parsing a PDF document to get the data out of it?

    • @MilanJovanovicTech
      @MilanJovanovicTech  10 місяців тому

      Other than IronPDF?

    • @michaels8336
      @michaels8336 10 місяців тому

      @@MilanJovanovicTechit seems that the reading is very basic, I don’t want all text, I want to be able to say get the text from this table cell etc

    • @kbreabtsegai2224
      @kbreabtsegai2224 2 місяці тому

      Sautinsoft.Document is a good one

  • @TopBabymonkeys
    @TopBabymonkeys 10 місяців тому +1

    can we it with blazor web Assembly

  • @joseduque2406
    @joseduque2406 4 місяці тому

    I have a license that is about a year or two years old of IronPdf library, but when you deploy your applications it is a hassle because some libraries have to be installed in the server. So if you are deploying to Linux, you may run into an issue where these libraries don’t get installed and you need up creating symbols to match the version it needs, very painful.

    • @MilanJovanovicTech
      @MilanJovanovicTech  4 місяці тому

      Yeah, that part sucks

    • @joseduque2406
      @joseduque2406 4 місяці тому

      I don’t know if they have fixed this issue yet, but it also deploys all the languages. In the version I have there was no way to select what languages to deploy. It would just deploy everything. By the way I really like you share a lot of your experience. Thank you!

  • @emiliowildberger7151
    @emiliowildberger7151 6 місяців тому

    I can't decide, generate pdf in blazor wasm with the JsPdf library or generate in my webapi and view in blazor, the AI ​​doesn't recommend me in the webapi due to traffic, friend, what do you recommend me to generate in the frontend or in the backend?. Greetings from Paraguay.

    • @emiliowildberger7151
      @emiliowildberger7151 6 місяців тому

      I forgot to mention that not all libraries work in Blazor Wasm

    • @MilanJovanovicTech
      @MilanJovanovicTech  6 місяців тому +1

      Do you need to just display it to the user? It's probably fine doing it in WASM

  • @haraheiquedossantos4283
    @haraheiquedossantos4283 10 місяців тому

    On a real project, which endpoint resource group (controller) would you put this route to generate those invoices?
    /invoices
    /invoices-report (As you've shown us)
    /reports
    Which routes / resources would you usually put those reports generations?
    I have some "patterns" and thoughts around that, but I'd like to see your POV

  • @DrHeinzDoofenshmirtz
    @DrHeinzDoofenshmirtz 10 місяців тому +3

    I have looked into IronPdf a lot, and even though they are fairly good, their Chrome identical renderer is not completely Chrome identical, and it is super expensive.

    • @MilanJovanovicTech
      @MilanJovanovicTech  10 місяців тому

      What did you end up choosing?

    • @DrHeinzDoofenshmirtz
      @DrHeinzDoofenshmirtz 10 місяців тому

      @@MilanJovanovicTech I ended up with a solution where I use RazorLight for templating, and then I use Browserless which exposes Puppeteer as an API to turn HTML into a PDF file. It works great, but it is a bit slow to render the HTML before it saves it to a PDF.

  • @Ziirf
    @Ziirf 10 місяців тому

    Where I work we needed the presision which HTML just can't provide, therefore we went with QuestPDF, and it have been great. Sometimes you can feel from the lack of options that it is a 1 man project, but the options you don't have available isn't something you can't make yourself. We also had some issues with an update, which broke support for linux for a few days. But after reporting the problem to the dev, it got solved rather quickly, and he also seem to be pretty responsive to questions and problems that come in, can only recommend.
    We also tried IronPDF to see if it was good enough, due to its simplicity, but it wasn't due to the nature of html to pdf conversion. But if all you need to do is print out invoices and money isn't an issue, it is very simple to setup.

    • @MilanJovanovicTech
      @MilanJovanovicTech  10 місяців тому +1

      Interesting. What was your use case that HTML couldn't solve from a precision standpoint?
      There's always the risk of betting on a one-man project, though.

  • @mikellouis100
    @mikellouis100 5 місяців тому

    can we use it in a ClassLibrary project

  • @robotinike
    @robotinike 10 місяців тому +1

    Ual, sensacional!
    amazing!!!!!!

  • @sunzhang-d9v
    @sunzhang-d9v 10 місяців тому

    What to do with fresh chapters

  • @Dustyy01
    @Dustyy01 10 місяців тому +2

    Nice Video and approach but sadly IronPDF is very expensive. A good alternative is QuestPDF but that's C# code to PDF. What is also working is using Razor Components (not views)

    • @rustamhajiyev
      @rustamhajiyev 10 місяців тому

      QuestPDF is great library, I use it when I need to create PDFs, absolutely recommend it :)

    • @mateuszadamowicz770
      @mateuszadamowicz770 10 місяців тому +1

      As everything it depends. If you know you would have constant structure of pdf file, you can use quest pdf and try to format file with quest pdf c# code. But there are some business cases when you need flexibility in customizing file template without deploying new version of the application (multitenancy for example)

    • @Dustyy01
      @Dustyy01 10 місяців тому +1

      @@mateuszadamowicz770 yea i totally agree, that's why I mentioned that questpdf is c# code to pdf. It is more difficult to make flexible but has the same functionalities in generating the output pdf.

    • @MAHDIHESARI
      @MAHDIHESARI 10 місяців тому

      How to add fields to the PDF so the users can type in them?

    • @MilanJovanovicTech
      @MilanJovanovicTech  10 місяців тому +1

      QuestPDF is an excellent tool, I enjoyed it

  • @DaminGamerMC
    @DaminGamerMC 10 місяців тому

    how to make excel reports?

  • @jithin.johnson
    @jithin.johnson 10 місяців тому

    Milan, Can you do a video on using options pattern with a custom provider, say a sqlite database?

    • @MilanJovanovicTech
      @MilanJovanovicTech  10 місяців тому +1

      That'd be interesting idea, adding it to my content list

    • @jithin.johnson
      @jithin.johnson 10 місяців тому

      @@MilanJovanovicTech Thanks, appreciate it.

  • @codingbloke
    @codingbloke 10 місяців тому +1

    I'm not convinced html -> pdf is good fit for this use case. This can be seen by the poor layout of multi page example at the end of the video.

  • @elpe21
    @elpe21 10 місяців тому +3

    Well. such a interesting topic to cover and this time you video is just an ad :( 1. There are better 'paid' option: Syncfusion html to pdf with community license if you work for company with revenue under $1 million. 2. Quest PDF is such a great library to that a bit differentely. Lastly, you did not produced proper invoice document. No header, no page number, no nothing starting from page 2. Sorry ! I know you can do better, but you haven't in this video!

    • @MilanJovanovicTech
      @MilanJovanovicTech  10 місяців тому

      Sorry for not implementing a production ready solution in 15 min, I guess. 🤷‍♂️ But this is more of a proof of concept, that can be extended further.
      As for the invoice structure, we can be nitpicky. It will depend on what you need to do. My invoices are way simpler than this, and I'm doing just fine. It doesn't have to be shiny.
      I didn't know about Syncfusion, will check it out. QuestPDF would have taken much more code to pull something like this off, p)us there's a learning curve to the library. Most teams will have someone good with HTML that could extend the implementation I showed.

    • @elpe21
      @elpe21 10 місяців тому

      @@MilanJovanovicTech That's why I've mentioned syncfusion as it offers the same functionality. Using HTML table with / would not take longer than using divs but would've resolved a lot of issues. As a matter of fact, html table is the way to implement any kind of printed document ( official company's document ) and that should've been said as most important thing in the video no matter what tool it's being used to convert HTML to PDF. I agree that Quest PDF requires some practivce / kwnoledge.

  • @alegntayeyilma9564
    @alegntayeyilma9564 10 місяців тому +14

    Very expensive commercial product 👎

    • @MilanJovanovicTech
      @MilanJovanovicTech  10 місяців тому +4

      Developers are typically much more expensive 😅 That being said, what if it's the only solution to your problem? I bet you'd happily pay. Of course, it's an open market, and there are many other alternatives.

    • @DJOrangeJoe
      @DJOrangeJoe 10 місяців тому +2

      True. I have seen so many cases where the company did not want to pay for such a product and paid way more eventually by developing it themselves.

    • @VincentYang024
      @VincentYang024 10 місяців тому +1

      Is there anything come with no cost? We should support a good software that does the job well and help the business save the cost instead of writing some low quality and maintainable code to proof the existence of development.

    • @_JustBeingCasual
      @_JustBeingCasual 10 місяців тому

      ​@@MilanJovanovicTechwhile its an interesting tool, but you could have let people know about the licensing, first before continuing showing it off. For smaller projects not interesting, for hobby projects also not interesting; for bigger companies sure.

    • @BSDrumming
      @BSDrumming 10 місяців тому

      @@VincentYang024pdfsharp/migradoc

  • @sunzhang-d9v
    @sunzhang-d9v 10 місяців тому +2

    It is better to introduce the free ones😂

    • @MilanJovanovicTech
      @MilanJovanovicTech  10 місяців тому +1

      I think I'll do a blog post reviewing a few libraries.

    • @jeffersantosss
      @jeffersantosss 6 місяців тому

      @@MilanJovanovicTechwould love that 🎉

  • @grumpydeveloper69
    @grumpydeveloper69 10 місяців тому

    This and most solutions using (Razor) Views and models work best with fixed data structures. We have a solution that generates documents on structures where we don't know the fields, and don't know the content. The customer does know content and structure so we made our own field merging engine that can still be used with any type of template and is rendersed to pdf ultimately with EssentialObjects pdf (and just recently I added support for IronPdf as well). Our content could also generate export files with very variable length, and could even use several file based templates to generated compound documents.
    Because of the nature of our "models" we cannot use the very nice Model support that Razor has. If anyone has any ideas on how to use Models with unknown datastructures, perhaps even anonymous types I would love some direction because we could remove a lot of complex custom code :-) and rely more on standard libraries

    • @MilanJovanovicTech
      @MilanJovanovicTech  10 місяців тому

      That sounds pretty cool. 😁
      If it works don't try to fix it?

  • @MaximT
    @MaximT 10 місяців тому

    Just use seal report. It has payed converters but they are cheaper

  • @ruwantharatnayake5004
    @ruwantharatnayake5004 7 місяців тому

    RazorLightEngineBuilder to generate html template
    NReco.PdfGenerator to convert html to pdf

    • @MilanJovanovicTech
      @MilanJovanovicTech  7 місяців тому

      Never heard of RazorLightEngineBuilder, interesting.

  • @nove1398
    @nove1398 10 місяців тому +3

    D/M/Y is the only way! lol, you might have just started an issue, but I agree there🤜🏼

    •  10 місяців тому +3

      only accepted date format should be the ISO :D
      anyways, no matter how you separate them, but we should keep going from larger units to smaller units as with every other thing in life. hours:minutes:seconds, millions,thousands,dollars.

    • @MilanJovanovicTech
      @MilanJovanovicTech  10 місяців тому +1

      This is the way!

  • @sanampakuwal
    @sanampakuwal 10 місяців тому +1

    cool

  • @petropzqi
    @petropzqi 10 місяців тому

    Great video. It's good you are not a FE developer

    • @MilanJovanovicTech
      @MilanJovanovicTech  10 місяців тому +1

      Lol 🤣 Doesn't matter, my website still looks pretty decent. 😁

  • @muhammadkamran-mx7yo
    @muhammadkamran-mx7yo 10 місяців тому

    Please Make it with webapi and angular plz plz

  • @joga_bonito_aro
    @joga_bonito_aro 10 місяців тому +1

    I like yyyy/MM/dd way more. It can be sorted in a more meaningful way I think.
    On the topic. Can be done using OSS, but the implementation is mostly forced upon the programmer. It's not as simple as just calling one static method. Especially page brakes are a pain in the butt. I would guess that IronPDF is using the Chromium engine under the hood. So you could basically create IronPDF yourself, but the amount of work you have to put into it... brotha

  • @ВасилийКабанчиков
    @ВасилийКабанчиков 6 місяців тому

    Used DinkToPdf because its free

    • @MilanJovanovicTech
      @MilanJovanovicTech  6 місяців тому

      There are better free options

    • @qurb-e-elahi
      @qurb-e-elahi Місяць тому

      Kindly name some. That can run on the Linux production too. Because Linux does not support System.Drawing.dll