本文介绍了如何在iTextSharp PdfReader中将sharepoint pdf作为字符串传递。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
当我从物理路径使用以下语句阅读pdf文件时,我已成功阅读。
Hi all,
While I am reading the pdf file using below statement from physical path I am successfully able to read.
PdfReader pdfFileReader = new PdfReader(@"D:\Test\MyPdftest.pdf")
我正在尝试同样的事情通过在PdfReader中传递文件url来读取sharepoint pdf文件,它无法正常工作。如果我们传递字节数组它的工作。我不希望传递作为字符串数组我需要传递为字符串,因为我将从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?
推荐答案
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...
}
}
}
}
这篇关于如何在iTextSharp PdfReader中将sharepoint pdf作为字符串传递。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!