使用itextsharp从pdf获取文本段落

时间:2013-06-14 05:39:11

标签: c# asp.net itextsharp pdf-parsing

有没有使用itextsharp从pdf文件中获取段落文本的逻辑?我知道pdf只支持文本的运行,很难确定哪些文本运行与哪个段落相关,而且我知道没有任何{ {1}}标签或其他标签来确定pdf中的段落。但是我试图获得文本运行的坐标来从其坐标构建段落但没有运气:(。 我的代码片段在这里:

<p>

是否有任何机构有与此问题相关的逻辑?

1 个答案:

答案 0 :(得分:1)

using (MemoryStream ms = new MemoryStream())
{
   Document document = new Document(PageSize.A4, 25, 25, 30, 30);
   PdfWriter writer = PdfWriter.GetInstance(document, ms);
   document.Open();
   document.Add(new Paragraph("Hello World"));
   document.Close();
   writer.Close();
   Response.ContentType = "pdf/application";
   Response.AddHeader("content-disposition", 
   "attachment;filename=First PDF document.pdf");
   Response.OutputStream.Write(ms.GetBuffer(), 0, ms.GetBuffer().Length);
}

here are some samples which ll help you on this....

这可能不是您想要的,但它可能对您有所帮助..

相关问题