practical-aspnetcore icon indicating copy to clipboard operation
practical-aspnetcore copied to clipboard

Mini App for Printing in PDF

Open dodyg opened this issue 3 years ago • 14 comments

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

dodyg avatar Jun 15 '21 07:06 dodyg

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

??

lohithgn avatar Jun 16 '21 11:06 lohithgn

Yeah - this is a very popular problem

dodyg avatar Jun 16 '21 15:06 dodyg

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

dodyg avatar Jun 25 '21 10:06 dodyg

@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/

lohithgn avatar Jun 28 '21 02:06 lohithgn

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?

Kralizek avatar Jun 28 '21 07:06 Kralizek

@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.

lohithgn avatar Jun 28 '21 07:06 lohithgn

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).

dodyg avatar Jun 28 '21 07:06 dodyg

Understood

lohithgn avatar Jun 28 '21 07:06 lohithgn

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 avatar Jun 28 '21 08:06 dodyg

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

dodyg avatar Sep 22 '21 12:09 dodyg

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

shaijut avatar Oct 04 '21 14:10 shaijut

@shaijut go for it, it's yours.

dodyg avatar Oct 04 '21 14:10 dodyg

https://github.com/QuestPDF/QuestPDF

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

dodyg avatar Nov 09 '21 15:11 dodyg

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.

lohithgn avatar Nov 10 '21 12:11 lohithgn