MudBlazor / MudBlazor

Blazor Component Library based on Material design with an emphasis on ease of use. Mainly written in C# with Javascript kept to a bare minimum it empowers .NET developers to easily debug it if needed.
http://mudblazor.com
MIT License
8.09k stars 1.28k forks source link

[Feature] Printing canvas component #6263

Closed Luk164 closed 1 year ago

Luk164 commented 1 year ago

Feature request type

New component

Component name

MudPrintContainer

Is your feature request related to a problem?

I would like to ask if a dedicated component for printing could be added. I want my users to be able to print data using pre-made .razor templates but I am having trouble with that, especially with headers and footers.

Describe the solution you'd like

Something like this:

<MudPrintContainer>
    <MudPrintHeader>
        Header stuff goes here
    </MudPrintHeader>
    <MudPrintContent>
        Content to be printed
    </MudPrintContent>
    <MudPrintFooter>
        Footer stuff goes here
    </MudPrintFooter>
    <MudPrintElement>
        Element is an independent tag that does not get headers or footers, useful for first and last page for example
    </MudPrintElement>
</MudPrintContainer>

The content is to be separated into multiple pages as needed but every page will receive a header and footer of its own.

Have you seen this feature anywhere else?

There are many JS libraries though they are often unsuitable, like PrintJS(dead) and also tools like WeasyPrint and PDFReactor(cloud based and paid) and many others. See: This article and click on the playground link

One of the problems I had with WeasyPrint is there does not seem to be a way to print only a specific element of the page and also it understandably does not support printing blazor pages even with pre-rendering.

Describe alternatives you've considered

For now the only solution for me seems to be using a separate .cshtml template together with WeasyPrint and then returning the resulting pdf file to user, either to download or to preview.

Pull Request

Code of Conduct

HClausing commented 1 year ago

I recommend you take a look here: QuestPDF.

I like it a lot.

Luk164 commented 1 year ago

I recommend you take a look here: QuestPDF.

I like it a lot.

How did I not find this before? But I still believe having a component would be helpful. Thank you

ScarletKuro commented 1 year ago

Hi.

This is out of scope for MudBlazor. We believe it's better to use external packages for this, since this is way too complex and big development. We also have a policy not to use 3rd party libraries or making wrappes around js(like PrintJS), not even saying that most PDF generators are usually not MIT compatible therefore making our own solution would be too challenging.