Skip to content

How to Prompt the User to Choose a PDF File Storage Location in Blazor using QuestPDF #692

Answered by girlpunk
aidrecabrera asked this question in Q&A
Discussion options

You must be logged in to vote

This is fairly out-of-scope for the QuestPDF library, however you could try something like this:

var file = Document.GeneratePdf();

using var streamRef = new DotNetStreamReference(new MemoryStream(file));
await JSRuntime.InvokeVoidAsync(
        "downloadFileFromStream",
        $"{filename}.pdf",
        streamRef
    )
    .ConfigureAwait(false);
async function downloadFileFromStream(fileName, contentStreamReference) {
    const arrayBuffer = await contentStreamReference.arrayBuffer();

    const blob = new Blob([arrayBuffer], { type: "application/pdf" });
    const url = URL.createObjectURL(blob);

    const anchorElement = document.createElement('a');
    anchorElement.href = url;

    

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@aidrecabrera
Comment options

@MarcinZiabek
Comment options

Answer selected by MarcinZiabek
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants