Download as PDF

Hi.


I have a blazor (razor) page and the following code on it:

        <div id='documenteditor_titlebar' class="e-de-ctn-title">

            <div class="single-line" id="documenteditor_title_contentEditor" style="border: 1px solid transparent;" title="Document Name." contenteditable="false">

                <label id="documenteditor_title_name" class="doc-edit-title"> @documentName</label>

            </div>

            <div style="float: right">

                <SfButton IconCss="e-de-icon-Download" CssClass="title-bar-btn" @onclick="OnExport">Exportar PDF</SfButton>

            </div>

        </div>

        <div>

            <SfDocumentEditorContainer EnableToolbar="false"

                                       ShowPropertiesPane="false"

                                       EnableComment="false"

                                       EnableTrackChanges="false"

                                       EnableCsp="false"

                                       EnableLocalPaste="false"

                                       RestrictEditing="true"

                                       EnablePersistence="false"

                                       EnableRtl="false"

                                       EnableSpellCheck="false"

                                       @ref="container"

                                       Height="590px">

                <DocumentEditorContainerEvents Created="OnCreated"></DocumentEditorContainerEvents>

            </SfDocumentEditorContainer>

        </div>


On code I have:

    public async void OnExport(object args)

    {

        SfDocumentEditor documentEditor = container.DocumentEditor;

        await documentEditor.SaveAsync(documentName, FormatType.Docx);

    }

It's works fine. But I need to download in PDF format. I already found a link that shows a possible solution:

https://blazor.syncfusion.com/documentation/document-editor/how-to/export-document-as-pdf


But at least for me it didn't work (I don't know why, just appeared a lot of errors). Is there another solution?


18 Replies

SK Selvaprakash Karuppusamy Syncfusion Team August 14, 2023 09:55 AM UTC

Hi Wilton,


We have prepared a sample for your reference, and in this sample, we have exported the document as a pdf. Please find the attached sample for your reference. 


Regards,

Selvaprakash K


Attachment: server_(2)_fdc36020.zip


SK Selvaprakash Karuppusamy Syncfusion Team August 16, 2023 06:02 AM UTC

Hi Wilton,


We saw the given video, and could you please share the image string you used to insert the image and also the input document (used jsonstring to open a document) you used to export the pdf? Thereby, we will analyse further and provide you with the appropriate solution at the earliest.



WW Wilton Wonrath August 16, 2023 07:26 PM UTC

Hi.


See the attached file and if you need anything else just let me know.


Thanks.


Attachment: code_5501728.zip


SK Selvaprakash Karuppusamy Syncfusion Team August 17, 2023 09:44 AM UTC

Hi Wilton, 


#exporting issue

We have tried to replicate the issue with the given SFDT data but couldn’t reproduce the issue. and we have attached the sample we used to try to replicate the issue. Please use the attached sample to check the exporting issue, and if the issue persists, could you please modify the attached sample to reproduce it and send it back? Thereby, we will analyze further and provide you with the appropriate solution at the earliest.


#image rendering issue

We have checked the given image string, and we suspect the given image string is not a proper base64 image string, so please share how you get this base64 string and refer to the attached HTML file.


Attachment: sample_c8488246.zip


WW Wilton Wonrath August 17, 2023 09:57 PM UTC

About the exporting issue I'm still working out and I will send news to you soon.


About the image rendering issue I found the problem and the solution but know I have another problem. 

It only works if I let the document editable. So I'm replacing everything that I need the the OnCreated Function. At the end of this I put: 

container.RestrictEditing = true;

But it's not working. There is a place where I can put this code? 

Something like AfterLoad?



WW Wilton Wonrath August 17, 2023 11:20 PM UTC

About the exporting issue could you please give me a working sample Blazor WebAssembly App?


Because I already isolated everything and I'm still facing the problem.


I attached one but it needs some adjusts.




Attachment: BlazorAppSyncFusion_1ea0348.zip


SK Selvaprakash Karuppusamy Syncfusion Team August 18, 2023 01:34 PM UTC

Hi Wilton, 


Currently, we are preparing the sample in Blazor WebAssembly and will update the details on August 21.



SK Selvaprakash Karuppusamy Syncfusion Team August 22, 2023 02:38 PM UTC

Hi Wilton, 

We have prepared a sample in Blazor WebAssembly to export a document as a pdf. Please refer to the attached sample.



Attachment: blazorApp_(2)_de6c0571.zip


WW Wilton Wonrath August 22, 2023 07:44 PM UTC

Hi.


Just changed the license key.


Problem reproduced without changing the code. 


See the attached video please.




Attachment: Recording_47_9737e796.zip


SK Selvaprakash Karuppusamy Syncfusion Team August 23, 2023 02:53 PM UTC

Hi Wilton, 


We were unable to reproduce the reported issue, and we have attached the video for your reference. Could you please try cleaning your project, deleting the bin\obj folders, and rebuilding your application, then check whether it resolves the issue?


Attachment: media1_fd553cee.zip


WW Wilton Wonrath August 23, 2023 03:44 PM UTC

Hi. 

Same problem. 

Cleaned, rebuilded, tried on firefox, chrome, edge and opera and same problems happens.


I'm using Visual Studio 2022 with your code and my license key (see below):


Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("Ngo9BigBOggjHTQxAR8 / V1NGaF1cWGhAYVJyWmFZfV1gdV9DYlZQTGY / P1ZhSXxQdk1iXn5ddHdQT2dcUEw =");


Any ideas?



SK Selvaprakash Karuppusamy Syncfusion Team August 24, 2023 02:11 PM UTC

Hi Wilton, 


We couldn't reproduce the issue on our end with the given key. This issue is not related to the license key. and we suspect the issue occurred due to the fact that the dll wasn't properly referenced, so please refer to the below UG documentation to know about exporting the document as a pdf using webassembly with a step-by-step process. Please refer to the below UG and try.

 

Convert Word to PDF in Blazor | DocIO | Syncfusion





WW Wilton Wonrath August 24, 2023 06:57 PM UTC

Trying to solve the problem I also asked on StackOverflow and a comment appeared saying that will not work on WASM. 


https://stackoverflow.com/questions/76971511/syncfusion-blazor-word-to-pdf


Is that right?



SK Selvaprakash Karuppusamy Syncfusion Team August 25, 2023 01:54 PM UTC

Hi Wilton, 


We already shared a Blazor web assembly sample, and that is working properly on our end. We also shared the video in the previous update. Could you please share your system environment details? Based on that, we will check the reported issue in that same environment and share the details as soon as possible. additionally, please refer to our KB documentation to know about how to convert Word to PDF in the Blazor WASM app.

https://www.syncfusion.com/kb/13871/how-to-convert-word-to-pdf-in-blazor-webassembly-wasm 



WW Wilton Wonrath August 28, 2023 02:23 PM UTC

I decided to try another approach. Sended everything to the server and worked there. Now I think it's working the way I expected. 

If I need any extra help I will let you know.


Thank you.



SK Selvaprakash Karuppusamy Syncfusion Team August 29, 2023 01:04 PM UTC

Hi Wilton, 

Thanks for your update. Please let us know if you need any further assistance.



AP AP April 24, 2024 09:26 PM UTC

I've also got this issue trying to export to PDF. I've attached the error that I'm getting below. Was anyone able to figure out a solution or is sending it to a server the only way to handle it?

Image_4291_1713993841799



RT Ragu Thanigasalam Syncfusion Team April 26, 2024 06:31 AM UTC

AP,

The reason for this issue is that the 'SkiaSharp' NuGet package is missing. Referencing this NuGet package should resolve the problem. Please refer the UG documentation.

https://help.syncfusion.com/file-formats/docio/convert-word-document-to-pdf-in-blazor#word-to-pdf-in-blazor-wasm-app

We recommend you upgrade the latest version (v25.1.41) packages. Please upgrade and try on your end. Please cross-check that and let us know if there are any other issues or if you need further assistance.


Loader.
Up arrow icon