私はPDFをテキストに変換しています。 PDFからテキストを正しく取得できますが、テーブル構造が複雑です。私はPDFがテーブル構造をサポートしていないことを知っているが、私はそこに正しくセルを取得する方法があると思う。さて、例えば:iTextSharp PDFファイルの表を読むには
> This is first example.
> This is second example.
しかし、私はテキストにPDFに変換する際に、theese件のデータがこのように見える:
私はこのようなテキストに変換したい
> This is This is
> first example. second example.
値を正しく取得するにはどうすればよいですか?
--edit:ここ
私はテキストにPDFに変換なかった方法です:私のコメント実際の答えにするために
OpenFileDialog ofd = new OpenFileDialog();
string filepath;
ofd.Filter = "PDF Files(*.PDF)|*.PDF|All Files(*.*)|*.*";
if (ofd.ShowDialog() == DialogResult.OK)
{
filepath = ofd.FileName.ToString();
string strText = string.Empty;
try
{
PdfReader reader = new PdfReader(filepath);
for (int page = 1; page < reader.NumberOfPages; page++)
{
ITextExtractionStrategy its = new iTextSharp.text.pdf.parser.LocationTextExtractionStrategy();
string s = PdfTextExtractor.GetTextFromPage(reader, page, its);
s = Encoding.UTF8.GetString(ASCIIEncoding.Convert(Encoding.Default, Encoding.UTF8, Encoding.Default.GetBytes(s)));
strText += s;
}
reader.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
あなたはそのテキストを取得するために使用しているコードを共有できますか? – Bassie
@Bassieありがとう、私は自分の投稿を更新しました。 – pseudocode
これはデフォルトでは可能ではないようですが、これをチェックして解決策を探してください:http://stackoverflow.com/questions/7513209/using-locationtextextractionstrategy-in-itextsharp-for-text-coordinate/7515625#7515625 – Bassie