Click here to Skip to main content
15,892,517 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

While I am reading the pdf file using below statement from physical path I am successfully able to read.

C#
PdfReader pdfFileReader = new PdfReader(@"D:\Test\MyPdftest.pdf")

The same thing while I am trying to read the sharepoint pdf file by passing the file url inside PdfReader, its not working. And if we pass the byte array its working. I don't want to pass as byte array I need to pass as string as I will read some specific text from the pdf.How can I do this?
Posted
Comments
CoderPanda 9-Apr-14 13:28pm    
What do you mean by not working? What is the error you get?

1 solution

Hi Rahul48,
This solution worked for me:
C#
private void processFile(SPItemEventProperties properties)
{
    SPFile file = properties.ListItem.File;
    if (file != null)
    {
        string filetype = System.IO.Path.GetExtension(file.Name);
        if (filetype == ".pdf")
        {
            string fileNameAndPath = file.Web.Url + @"/" + file.Url;
            using (PdfReader reader = new PdfReader(fileNameAndPath))
            {
                // Your code here...
            }
        }
    }
}
 
Share this answer
 

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