如何使用Android中iText库来阅读PDF [英] How to read a pdf using itext library in android

查看:146
本文介绍了如何使用Android中iText库来阅读PDF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Android的世界是一个新手。我厌倦了使用Eclipse创建一个IDE Android项目,其中我试图读取与iText库的帮助PDF文件。
这PGM没有显示任何output.Please告诉我如何纠正code,这样我可以提取存储在Assets文件夹中的项目的PDF文件中的文本。

I am a newbie in android world. I tired to create a android project using eclipse IDE, in which i tried reading a pdf file with the help of itext library. This pgm is not showing any output.Please tell me how to correct the code,so that i can extract the text from pdf file stored in Assets folder in the project.

程序code是给出如下:

The program code is given as :

public class hello extends Activity {
    /** Called when the activity is first created. */
    public static final String LOG_TAG="Fifth";
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        AssetManager assetManager =getAssets();
        InputStream istr = null;
        PdfReader reader=null;
        String str=null;
        int n=0;
        try {
            istr =(InputStream) assetManager.open("FirstPdf");


             reader=new PdfReader(istr);
             n=reader.getNumberOfPages();
            Log.v(LOG_TAG,"n value:" +n);
         str=reader.getPageContent(2).toString();
        }
        catch (Exception e)
        {
            e.printStackTrace();
        } 

        TextView tv = new TextView(this);
        tv.setText(n);
        setContentView(tv);
    }
}

问候
托马斯

Regards Thomas

推荐答案

不支持!

Android的运行时间是不太JME。 iText的是从来没有移植到JME摆在首位。

Android's runtime isn't quite JME. iText was never ported to JME in the first place.

说了这么多,有一对夫妇iText->的Andr​​oid端口左右浮动。但是,这仅仅是通过谁已经撕去了很大一部分少数知情人士这样做,他们就不必端口一切的一个子集的一子集加一些-其他-的东西,是Android运行。

Having said that, there are a couple iText->Android ports floating around. But this has only been done by a few Knowledgeable Individuals who have ripped out large portions so they wouldn't have to port Everything to a subset-of-a-subset-plus-some-other-stuff that is the Android Runtime.

据我了解,iText的正确(这件事)的某个端口是在作品中,但不知道它是否会永远去任何地方,或者当人们将能够获得它自己的手中。

I understand that a port of iText Proper (the whole thing) is In The Works, but have no idea if it'll ever go anywhere, or when folks will be able to get their hands on it.

这篇关于如何使用Android中iText库来阅读PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆