以编程方式将PDF数据导入到Sharepoint列表 [英] Import PDF Data To Sharepoint list programatically
本文介绍了以编程方式将PDF数据导入到Sharepoint列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个使用Adobe Acrobat X创建的pdf可填写表格,
I have a pdf fillable form created using Adobe Acrobat X,
该表单已作为附件上传到信息路径列表.
The form has been uploaded as attachment to an infopath list.
我想以编程方式提取数据并将其导入到共享点列表中.
I would like to programatically extract the data and import into a sharepoint list.
推荐答案
我们可以使用iTextSharp程序集读取PDF数据:
We can read PDF data with iTextSharp assembly:
using TextSharp.text;
using iTextSharp.text.pdf;
using iTextSharp.text.pdf.parser;
private string GetTextFromPDF()
{
StringBuilder text = new StringBuilder();
using (PdfReader reader = new PdfReader("D:\\RentReceiptFormat.pdf"))
{
for (int i = 1; i <= reader.NumberOfPages; i++)
{
text.Append(PdfTextExtractor.GetTextFromPage(reader, i));
}
}
return text.ToString();
}
有关使用iTextSharp从PDF获取数据的更多信息,请参考:
More information about getting data from PDF with iTextSharp, please refer:
然后将获取的值与SharePoint对象模型一起插入SharePoint列表:
Then insert the value got into SharePoint List with SharePoint Object Model:
try
{
using(SPSite site = new SPSite(SPContext.Current.Web.Url))
{
using(SPWeb web = site.OpenWeb())
{
SPList list = web.Lists.TryGetList("Employee Registration");
if(list!=null)
{
SPListItem NewItem = list.Items.Add();
{
web.AllowUnsafeUpdates = true;
NewItem["Employee Name"] = txtempname.Text;
NewItem["Designation"] =drpdesg.SelectedItem.ToString();
NewItem["Address"] =txtaddr.Text;
NewItem["Email"] =txtemail.Text;
NewItem["Contact No"] = txtcontact.Text;
NewItem.Update();
Alert.Text = "Registration Successful";
}
}
else
{
Alert.Text = "List not found";
}
}
}
}
catch(Exception ex)
{
Alert.Text = ex.Message.ToString();
}
已在此处完成代码演示:
Completed Code demo here:
谢谢
最好的问候
这篇关于以编程方式将PDF数据导入到Sharepoint列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文