Can I load the ExcelToPdf file directly into PdfViewer

Hi Syncfusion,
Can I load my ExcelToPdf file directly into PdfViewer and save it via PdfViewer?
BRGDS
Ernst

4 Replies 1 reply marked as answer

DM Dhivyabharathi Mohan Syncfusion Team February 2, 2021 04:28 PM UTC

Hi Ernst, 
 
Currently we are checking on this with high priority. We will update the further details on February 3rd, 2021. 
 
Regards, 
Dhivya. 



DM Dhivyabharathi Mohan Syncfusion Team February 3, 2021 05:01 PM UTC

Hi Ernst, 
  
  
In our PDF Viewer, we can convert the excel document to PDF document while loading using below code snippet: 
  
  
Code snippet for load the excel file to PDF document in PDF Viewer: 
  
  
public IActionResult Load([FromBody] Dictionary<string, string> jsonObject) 
        { 
            PdfRenderer pdfviewer = new PdfRenderer(_cache); 
            Stream stream = new MemoryStream(); 
            object jsonResult = new object(); 
            using (ExcelEngine excelEngine = new ExcelEngine()) 
            { 
                IApplication application = excelEngine.Excel; 
                FileStream excelStream = new FileStream("ExcelToPDF.xlsx", FileMode.Open, FileAccess.Read); 
                IWorkbook workbook = application.Workbooks.Open(excelStream); 
  
                //Initialize XlsIO renderer. 
                XlsIORenderer renderer = new XlsIORenderer(); 
  
                //Convert Excel document into PDF document  
                PdfDocument pdfDocument = renderer.ConvertToPDF(workbook); 
                stream.Position = 0; 
                jsonResult = pdfviewer.Load(stream, jsonObject); 
                return Content(JsonConvert.SerializeObject(jsonResult)); 
            } 
             
             
        } 
  
  
  
And in our PDF Viewer, by using the download action the file will be downloaded. We have shared the code snippet for downloading the pdf document. 
  
Code snippet for download: 
  
  
public IActionResult Download([FromBody] Dictionary<string, string> jsonObject) 
        { 
            PdfRenderer pdfviewer = new PdfRenderer(_cache); 
            string documentBase = pdfviewer.GetDocumentAsBase64(jsonObject); 
            return Content(documentBase); 
        } 
  
  
  
Sample: 
  
  
Kindly let us know that the above details matches your criteria. Else kindly share more details about your requirement. It will be helpful for us to investigate further and provide more details. 
  
  
Regards, 
Dhivya. 


Marked as answer

ES Ernst Schomburg February 4, 2021 09:08 AM UTC

Hi Syncfusion,

thanks for the Code snippet.

It' s working!

Thanks a lot!

BRGDS
Ernst


DM Dhivyabharathi Mohan Syncfusion Team February 5, 2021 06:15 AM UTC

Hi Ernst, 
 
Thank you for your update. We are glad to know that the reported issue is resolved. 
 
Regards, 
Dhivya.

Loader.
Up arrow icon