Thanks for your reply….
1. 1. Is it possible to convert the pdf to json?
Eg: https://help.syncfusion.com/js/webapi/pdfviewer
2. 2. After is it correct to assign that converted json to spreadsheet datasource?
spreadsheet.openFromJson({ file: jsonData });
3. 3. We saw your syncfusion kb documentation, in this way can you implement our scenario in spreadsheet?
Eg: https://www.syncfusion.com/kb/8889/how-to-convert-the-pdf-document-into-excel
https://www.syncfusion.com/kb/9851/how-to-convert-tables-in-pdf-document-to-excel-file
4. 4. If ours requirement can't achieve by ej2 spreadsheet please give solution in ej1 spreadsheet?
I really hope you give a workaround for asked requirement.
|
created: (): void => {
fetch('http://localhost:51635/Home/CreateDocument')
.then(response => response.json())
.then(data => {
console.log(data);
spreadsheet.openFromJson({ file: data });
});
}
}
public IActionResult CreateDocument()
{
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Uses the Syncfusion.EJ2.PdfViewer assembly
PdfRenderer pdfExportImage = new PdfRenderer();
//Loads the PDF document
pdfExportImage.Load("pdf.pdf");
//Exports the PDF document pages into images
Bitmap bitmapimage = pdfExportImage.ExportAsImage(0);
//Save the exported image in disk
bitmapimage.Save("Image" + ".png"); // convert the PDF file to image file
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet worksheet = workbook.Worksheets[0];
// Adding Text to A1 cell
worksheet.Range["A1"].Text = "PDF TO Excel";
//Adding a picture
FileStream imageStream = new FileStream("Image.png", FileMode.Open, FileAccess.Read);
IPictureShape shape = worksheet.Pictures.AddPicture(1, 1, imageStream);
FileStream filePath = new FileStream("Sample.xlsx", FileMode.Create); // saved the converted image file to excel
workbook.SaveAs(filePath);
imageStream.Dispose();
filePath.Close();
workbook.Close();
OpenRequest open = new OpenRequest();
FileStream inputStream1 = new FileStream("Sample.xlsx", FileMode.Open);
IFormFile formFile = new FormFile(inputStream1, 0, inputStream1.Length, "", "Sample" + ".xlsx"); // converting MemoryStream to IFormFile
open.File = formFile;
var content = Workbook.Open(open); // load the created excel in spreadsheet
inputStream1.Dispose();
return Content(content);
}
} |