PDFViewer don't return SaveAsBlob or ExportAnnotationsToObject

Hey Guys!

I'm start following the Getting Start PDV Viewer code.

I just add the PDV Viewer control on single page (like the code attached).

The control works fine, I can add annotations, print and Export/Import Annotation, for example.

But on the code, some async Tasks never ends (and I didn't find any error message), like: 

myVar = await viewer.ExportAnnotationsAsObject(); or
myBlob = await viewer.SaveAsBlob();

I tried with versions V.18.1.0.52 until 59. With all .Net Core 3.1 libs updated

Any ideia what can I do?

Thanks!!!
@page "/counter"
 
 
<input type="button" @onclick="OnClick" value="Salvar" />
 
<div class="control-section">
    <SfPdfViewerServer @ref="viewer" DocumentPath="@DocumentPath" Height="640px" Width="100%"></SfPdfViewerServer>
</div>
 
<label>@resultado</label>
 
 
@code {
    SfPdfViewerServer viewer;
 
    object result;
 
    private string DocumentPath { get; set; } = "wwwroot/data/250x180mm.pdf";
 
    public void OnClick()
    {
        result = viewer.SaveAsBlob().Result; //I tried with viewer.ExportAnnotationsAsObject().Result; but the system don't return 
.     } }

8 Replies

MS Mohan Selvaraj Syncfusion Team June 26, 2020 02:12 PM UTC

Hi Denilson, 

We are unable to reproduce the reported issue in our end with the provided details. We have created the sample with saveasblob and exportannotationasobject using button click. Kindly download it from the below link. 



Please provide the sample in which you are facing the issue or modify the provided sample. So that would be helpful for us to analysis more and assist you better 

Regards, 
Mohan S 



ST Stefan June 29, 2020 12:44 AM UTC

I have the same problem but with document editor. As the program just terminates after save as a blob. In the given code example Mohan Selvaraj if i click save, it doesnt saves the file and the changes. But if i try to download it, it works great.



AA Akshaya Arivoli Syncfusion Team June 29, 2020 11:33 AM UTC

Hi Stefan, 

Thank you for contacting Syncfusion support. 

Please find the details of your query from the below, 

Query 
Details  
I have the same problem but with document editor. As the program just terminates after save as a blob. 
We couldn’t reproduce this scenario. kindly check with the below sample.  
 
 
kindly ensure whether you have added below codes in ConfigureServices function in startup.cs file. If not please add the below codes and ensure the reported scenario.  
 
// This method gets called by the runtime. Use this method to add services to the container.  
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940  
        public void ConfigureServices(IServiceCollection services)  
        {  
            services.AddRazorPages();  
            services.AddServerSideBlazor();  
            services.AddSingleton<WeatherForecastService>();  
            services.AddServerSideBlazor().AddHubOptions(o =>  
            {  
                o.MaximumReceiveMessageSize = 102400000;  
            });  
            services.AddSyncfusionBlazor();  
        }  
  
If you still facing the reported scenario, please share us simple sample or modify the provided sample to reproduce the reported scenario in our end. It will be helpful for us to proceed further on this.  

In the given code example Mohan Selvaraj if i click save, it doesnt saves the file and the changes. But if i try to download it, it works great. 
In the previously provided sample, clicking in the ‘Save’ button will return the PDF document as ‘SaveAsBlob()’ and the same will be stored in the ‘wwwroot-> Data folder’ location of the project. 

Please revert us with more details if you need any further assistance on this. 

Regards, 
Akshaya 



ST Stefan June 30, 2020 09:21 AM UTC

That didnt fix the problem. When i load the document it doesnt give a problem. Then when i want to save i use this code:
        DocumentEditorModule editor = container.GetDocumentEditor();
        object base64Data = await editor.SaveAsBlob(FormatType.Docx); - code stops here, and doesnt trows errors.
        Dictionary<string, string> documentContent = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, string>>(base64Data.ToString());
        byte[] data = Convert.FromBase64String(documentContent["data"]);

        using (MemoryStream stream = new MemoryStream(data))
        {

           //Azure file stuff
        }


DA Denilson Alexandre replied to Denilson Alexandre June 30, 2020 01:56 PM UTC

Hey Guys!

I'm start following the Getting Start PDV Viewer code.

I just add the PDV Viewer control on single page (like the code attached).

The control works fine, I can add annotations, print and Export/Import Annotation, for example.

But on the code, some async Tasks never ends (and I didn't find any error message), like: 

myVar = await viewer.ExportAnnotationsAsObject(); or
myBlob = await viewer.SaveAsBlob();

I tried with versions V.18.1.0.52 until 59. With all .Net Core 3.1 libs updated

Any ideia what can I do?

Thanks!!!
@page "/counter"
 
 
<input type="button" @onclick="OnClick" value="Salvar" />
 
<div class="control-section">
    <SfPdfViewerServer @ref="viewer" DocumentPath="@DocumentPath" Height="640px" Width="100%"></SfPdfViewerServer>
</div>
 
<label>@resultado</label>
 
 
@code {
    SfPdfViewerServer viewer;
 
    object result;
 
    private string DocumentPath { get; set; } = "wwwroot/data/250x180mm.pdf";
 
    public void OnClick()
    {
        result = viewer.SaveAsBlob().Result; //I tried with viewer.ExportAnnotationsAsObject().Result; but the system don't return 
.     } }

Hey guys!

Hey guys,

Maybe the problem is on Blazor, at ".Result" used in async methods.

Using this kind of method (void and no async) the process stop at .Result return:

public void OnExportClick(MouseEventArgs args)
    {
        object exportedAnnotation = PDFViewer1.ExportAnnotationsAsObject().Result;
    }


After change to async method, the component works well with "await" way.

Correct mode:
public async void OnExportClick(MouseEventArgs args)
{
    object exportedAnnotation = await PDFViewer1.ExportAnnotationsAsObject();
}
I think this information is good for others with same problem on SaveAsBlob()

Best regards!


AA Akshaya Arivoli Syncfusion Team July 1, 2020 02:28 PM UTC

Hi Stefan, 

Can you please confirm whether you are facing the same issue in provided sample?. Which version of word processor you are using and are you facing this issue when saving any particular document? If so, kindly share that document. We will check on it and update you further details.  

Regards, 
Akshaya


ST Stefan July 2, 2020 10:07 AM UTC

I opened a separate issue so as not to clog the topic


AA Akshaya Arivoli Syncfusion Team July 2, 2020 10:42 AM UTC

Hi Stefan, 

Thank you for your update. Our technical team will address in the respective forum. 

Regards, 
Akshaya 


Loader.
Up arrow icon