Click here to Skip to main content
15,913,773 members
Please Sign up or sign in to vote.
2.33/5 (2 votes)
See more:
Plz give me the idea or source code to convert the pdf to excel in c#.
Posted

 
Share this answer
 
using System;
using System.Diagnostics;
using System.IO;
using PdfSharp;
using PdfSharp.Drawing;
using PdfSharp.Pdf;
using PdfSharp.Pdf.IO;
using PdfSharp.Pdf.Advanced;
namespace WorkOnPdfObjects
{
class Program
{
static void Main()
{
const string filename = "Portable Document Format.pdf";
File.Copy(Path.Combine("../../../../../PDFs/", filename),
Path.Combine(Directory.GetCurrentDirectory(), filename), true);
PdfDocument document = PdfReader.Open(filename);
PdfDictionary dict = new PdfDictionary(document);
dict.Elements["/S"] = new PdfName("/GoTo");
PdfArray array = new PdfArray(document);
dict.Elements["/D"] = array;
PdfReference iref = PdfInternals.GetReference(document.Pages[2]);
array.Elements.Add(iref);
array.Elements.Add(new PdfName("/FitV"));
array.Elements.Add(new PdfInteger(-32768));
document.Internals.AddObject(dict);
document.Internals.Catalog.Elements["/OpenAction"] =
PdfInternals.GetReference(dict);
document.Save(filename);
Process.Start(filename);
}
}
}


Try this i think it will help you
 
Share this answer
 
Comments
Mohan Gopi 11-Dec-13 4:54am    
Hi Maheswar,

Where i can get using.PdfSharp; dll. can you provide the dll download links.
declan_c 16-Mar-16 4:57am    
You can add it is a nuget package reference. Right click your project and select "Manage Nuget Packages" search for PdfSharp and then choose install.
Member 2391237 27-Nov-21 2:42am    
This code duplicates pdf file. Where ic converting function to Excel ?
Abdulla Shaik 14-Apr-23 7:43am    
any refrence i want to add or not
 
Share this answer
 
Comments
Guillermo_Rodriguez 12-Dec-17 14:59pm    
ES: Creo que esto te sujeta a tener Microsoft Office instalado, ¿conoces alguna alternativa con librerías Open Source?

EN: I think this subjects you to have Microsoft Office installed, do you know any alternative with Open Source libraries?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900