How to convert the PDF document into Excel?
Syncfusion Essential PDF is a used to create, read, and edit PDF documents. PDF Viewer Control does not convert the PDF document into Excel. However, you can convert the PDF document into Excel by using tabula extractor.
Refer to the following code snippet.
//Specify the installation path of java ProcessStartInfo startInfo = new ProcessStartInfo(@"C:\Program Files\Java\jre1.8.0_144\bin\java.exe"); startInfo.WindowStyle = ProcessWindowStyle.Hidden; //Set the input folder path to WorkingDirectory startInfo.WorkingDirectory = InputPath; startInfo.Arguments = "-jar tabula-0.8.0-jar-with-dependencies.jar -p all -o sample.csv sample.pdf"; //The ‘sample.csv’ file has been generated in the specified working directory when started the ProcessStartInfo Process currentProcess=Process.Start(startInfo); currentProcess.WaitForExit(); string files = Directory.GetFiles(InputPath, "*.csv"); ExcelEngine excelEngine = new ExcelEngine(); IApplication application = excelEngine.Excel; IWorkbook workbook = application.Workbooks.Open(files); IWorksheet sheet = workbook.Worksheets; application.DefaultVersion = ExcelVersion.Excel2013; workbook.Version = ExcelVersion.Excel2013; string fileName = "sample.xlsx";//Saves the Excel file into specific location workbook.SaveAs("../../Output/"+fileName,ExcelSaveType.SaveAsXLS); workbook.Close(); excelEngine.Dispose();
- The latest version of Java should be installed in your machine to execute the previous sample and refer to the installation path while creating the ProcessStartInfo.
- Place the input PDF file and tabula executable jar file in “Resource\target” folder in the previous sample.
I hope you enjoyed learning about how to convert PDF to excel in C# and VB.NET.