Articles in this section
Category / Section

How to convert the PDF document into Excel in WinForms?

2 mins read

Syncfusion Essential PDF is a .NET PDF library 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[0]);
 
IWorksheet sheet = workbook.Worksheets[0];
 
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();

Sample link:
https://www.syncfusion.com/downloads/support/directtrac/general/ze/PdfToExcelConversionSample-2083476702


Note:
  1. 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.
  2. Place the input PDF file and tabula executable jar file in “Resource\target” folder in the previous sample.

 

Conclusion

I hope you enjoyed learning how to convert PDF document into Excel in WinForms.

You can refer to our WinForms PDF Viewer feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our WinForms PDF Viewer example to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied