PDF Viewer Printing Blanks

I currently have the PDF Viewer setup, working and displaying a PDF from MS Azure Blob.  I'm unable to get it to print.  When clicking the print button from within the control, it makes multiple request to the ServiceUrl/Load for each page in the PDF.  Not sure why but it does. This prepares the document for printing. It then opens the print dialog and display all pages but each one is blank.   I'm unable to locate any supporting document for the printing process and for the extra calls to the Service URL.  When reviewing the post back response in Google developer tools it seems as though the PDF is being returned just not displayed in the print dialog.  I've provided the code below related to this issue.  Thanks and I look forward to your response and any suggestions.  

VIEW

<div style="width:100%;height:780px;">
            @Html.EJ().PdfViewer("pdfviewer").ServiceUrl("/_test").PdfService(Syncfusion.JavaScript.PdfViewerEnums.PdfService.Local)
        </div>

CONTROLLER (ServiceUrl) ACTION (load)

[HttpPost]
        public object Load(jsonObjects results)
        {
            try
            {
                PdfViewerHelper helper = new PdfViewerHelper();
                var jsonResult = JsonConverterstring(results);

                if (jsonResult.ContainsKey("isInitialLoading"))
                {
                    CloudBlockBlob blob = Storage.Blob.GetBlob("hwareprivate", "user-0e6e0a88-7d9a-4bb3-b642-a8b22aef2073",
                    "reports/ttb/2017/08/636462752988681174.pdf", true);
                    blob.FetchAttributes();
                    MemoryStream ms = new MemoryStream();
                    blob.DownloadToStream(ms);
                    ms.Seek(0, SeekOrigin.Begin);
                    PdfLoadedDocument ldoc = new PdfLoadedDocument(ms);
                    ldoc.Form.Flatten = true;
                
                    MemoryStream ms2 = new MemoryStream();
                    ldoc.Save(ms2);
                    helper.Load(ms2);
                }

                return Content(JsonConvert.SerializeObject(helper.ProcessPdf(jsonResult)));
            }
            catch (Exception ex)
            {
                var ai = new TelemetryClient();
                ai.TrackException(ex);
                return null;
            }
        }

3 Replies

SA Sabari Anand Senthamarai Kannan Syncfusion Team December 5, 2017 10:39 AM UTC

Hi Shawn, 

Thank you for using Syncfusion products. 

Please find the details for your queries in the following table. 

Query 
Details 
When clicking the print button from within the control, it makes multiple request to the ServiceUrl/Load for each page in the PDF.  Not sure why but it does. 
The PDF viewer control will access the web service for loading the each page of the PDF document using the AJAX request and the data for PDF page will be returned as a JSON object. So when the printing process is initiated in the PDF viewer, the web service will be accessed for each PDF page rendering if the PDF document is not fully loaded. 
This prepares the document for printing. It then opens the print dialog and display all pages but each one is blank.   I'm unable to locate any supporting document for the printing process and for the extra calls to the Service URL.  When reviewing the post back response in Google developer tools it seems as though the PDF is being returned just not displayed in the print dialog. 
From your code snippet, we came to know that you are using an MVC controller as a web service for the PDF viewer control. We tried to reproduce the reported issue with the MVC controller and we are unable to reproduce the issue “The printed output document is blank” in our end.  

Please find the sample below in which we have tried to reproduce the issue. 


Please modify the above sample to reproduce the issue and share the same to us. The reported issue may also be specific to the PDF document which may have different file structure. So please share us the PDF document in which the issue is reproduced. It will be helpful for us to analyze further and assist you better. 

Please let us know if you need any further assistance. 

Regards, 
Sabari Anand 



SP Shawn Patrick December 5, 2017 02:00 PM UTC

Thanks for your reply.  Most of what you sent me I already knew and have read.   I was unable to run your solution due to dozens of errors plus I had to downgrade my development workstation to MVC 4 just to load the project.   

Below is the block of code that's different from your solution.  Everything else is exactly the same.  I've also attached a sample PDF document that I'm using to test your PDF Viewer.  Please let me know what's wrong with the code below that causes it to print blank pages.  I appreciate your quick response and working solution.

Uri fileUri = new Uri("https://hwarepublic.blob.core.windows.net/user-0e6e0a88-7d9a-4bb3-b642-a8b22aef2073/reports/ttb/2017/08/636462752988681174.pdf");  
CloudBlockBlob blob = new CloudBlockBlob(fileUri); 
blob.FetchAttributes();
MemoryStream ms = new MemoryStream();
blob.DownloadToStream(ms);
ms.Seek(0, SeekOrigin.Begin);
PdfLoadedDocument ldoc = new PdfLoadedDocument(ms);
ldoc.Form.Flatten = true;
MemoryStream ms2 = new MemoryStream();
ldoc.Save(ms2);
 ms2.Seek(0, SeekOrigin.Begin);
helper.Load(ms2);


Thanks.


SA Sabari Anand Senthamarai Kannan Syncfusion Team December 6, 2017 10:14 AM UTC

Hi Shawn, 

Thank you for your update. 

We have created a new incident under your account for further follow-up in your queries. We request you to follow the same for further updates. You can log in to our support system using the following link, 
     
   
Please let us know if you need any further assistance. 

Regards, 
Sabari Anand 


Loader.
Up arrow icon