dodyg / practical-aspnetcore

Practical samples of ASP.NET Core 9 RC2, 8.0, 7.0, 6.0, 5.0, 3.1, 2.2, and 2.1,projects you can use. Readme contains explanations on all projects.
MIT License
9.5k stars 1.27k forks source link

Mini App for Printing in PDF #297

Open dodyg opened 3 years ago

dodyg commented 3 years ago

This is a common task that many people will find useful.

lohithgn commented 3 years ago

Is the idea something like:

Lets say we create a page which shows an Invoice (with some header, footer, and then line items) Click a button on the page which says "Print" A controller prepares the PDF and sends it to the browser as FileResult

??

dodyg commented 3 years ago

Yeah - this is a very popular problem

dodyg commented 3 years ago

This looks like a good library to use https://github.com/rdvojmoc/DinkToPdf

lohithgn commented 3 years ago

@dodyg there are many packages for this scenario :) per se this is not the framework/platform ASP.NET core problem. What i mean is - asp.net core out of the box has not ( should not) provided any PDF related things and thats by design. PDF creation is outside of Web framework. So there are many 3rd party packages available and if one needs PDF capability - its left to them to carefully study the packages and use the one which suits them.

My idea is to just create 1 or 2 examples showcasing couple of packages. Then the users get the idea of how to do this - and pick up whatever package they are comfortable with.

I have created 1 sample using GemDocument.Pdf - its an OSS package. Now looking into rotativa - https://gunnarpeipman.com/aspnet-core-pdf/

Kralizek commented 3 years ago

This looks like a good library to use https://github.com/rdvojmoc/DinkToPdf

As a general direction for this repository, what do you think of samples that use third party libraries?

lohithgn commented 3 years ago

@Kralizek good question. i will leave it to @dodyg.

Personally - i would like to stick to what the framework has to offer in this Practical ASP.NET Core repository. If we start putting examples of 3rd party libraries - we may see a flooding of examples from community members. Just my opinion here.

i will wait to hear what @dodyg has to say.

dodyg commented 3 years ago

there are many packages for this scenario :) per se this is not the framework/platform ASP.NET core problem.

Every ASP.NET Core web developer working in business domain will encounter this scenario. Creating samples of other projects within .NET OSS community is fine as long as it related to the domain of web development.

My idea is to just create 1 or 2 examples showcasing couple of packages. Then the users get the idea of how to do this - and pick up whatever package they are comfortable with.

Perfect.

As a general direction for this repository, what do you think of samples that use third party libraries?

We have samples for OrchardCore, CoreWCF, Orleans - they are not part of ASP.NET Core framework but they are relevant. Samples for third party libraries are welcome as long as they are open source and relevant to web development (defined broadly).

lohithgn commented 3 years ago

Understood

dodyg commented 3 years ago

It will be brilliant for example if we have section for EntityFramework or Dapper because I mean, most web development would require database access at some point. It's missing so far simply because I don't use them. It will also take a dedicated work to cover this topic properly.

I am barely able to keep up with the ever growing .NET web related surface APIs and we haven't even touched identity/authorization/security APIs.

dodyg commented 3 years ago

https://github.com/hardkoded/puppeteer-sharp is another good candidate

shaijut commented 3 years ago

Interesting to me , Can i take this opportunity and create a mini app which prints just PDF using puppeteer-sharp ?

dodyg commented 3 years ago

@shaijut go for it, it's yours.

dodyg commented 3 years ago

https://github.com/QuestPDF/QuestPDF

https://www.reddit.com/r/csharp/comments/qq2ff0/questpdf_202111_a_new_version_of_the_opensource/

lohithgn commented 3 years ago

https://github.com/QuestPDF/QuestPDF

https://www.reddit.com/r/csharp/comments/qq2ff0/questpdf_202111_a_new_version_of_the_opensource/

This is a good find.