开发者

how to convert pdf file to text file using c#.net

currently i have been using the following code and i am using some dll files from pdfbox

        FileInfo file = 开发者_C百科new FileInfo("c://aa.pdf");

        PDDocument doc = PDDocument.load(file.FullName);

        PDFTextStripper pdfStripper = new PDFTextStripper();
        string text = pdfStripper.getText (doc);
        richTextBox1.Text = qq;

using this code i can able to get text file but not in a correct format plz give me a some ideas


Extracting the text from a pdf file is anything but trivial.

To quote from th iTextSharp tutorial.

"The pdf format is just a canvas where text and graphics are placed without any structure information. As such there aren't any 'iText-objects' in a PDF file. In each page there will probably be a number of 'Strings', but you can't reconstruct a phrase or a paragraph using these strings. There are probably a number of lines drawn, but you can't retrieve a Table-object based on these lines. In short: parsing the content of a PDF-file is NOT POSSIBLE with iText."

There are several commercial applications which claim to be able to do it. Caveat Emptor.

There is also a free software library called Poppler http://poppler.freedesktop.org/ which is used by the pdf viewers of GNOME and KDE. It has a function called pdftotext() but I have no experience with it. It may be your best free option.


There is a blog article explaining the issues with PDF text extraction in general at http://pdf.jpedal.org/java-pdf-blog/bid/12670/PDF-text

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜