我正在尝试使用iTextSharp阅读PDF文档。阅读该文件,但不知何故,我注意到该名称是缩写。例如。如果名称是“采购定义文档”,则将名称缩写为“Proc def doc”。我不确定我做错了什么,但我不想缩短名称。
以下是我的代码:
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports iTextSharp.text
Imports iTextSharp.text.pdf
Public Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim oReader As New iTextSharp.text.pdf.PdfReader("C:\4012014.pdf")
Dim sOut As StringBuilder = New StringBuilder()
For i = 1 To oReader.NumberOfPages
Dim its As New iTextSharp.text.pdf.parser.SimpleTextExtractionStrategy
Dim strLineText As String = iTextSharp.text.pdf.parser.PdfTextExtractor.GetTextFromPage(oReader, i, its)
strLineText = Encoding.UTF8.GetString(ASCIIEncoding.Convert(Encoding.Default, Encoding.UTF8, Encoding.Default.GetBytes(strLineText)))
sOut.Append(strLineText)
Next
oReader.Close()
sOut.Append("<br/>")
txtTest1.Text = sOut.ToString()
End Sub
End Class