android和itext
我想在android中显示带有下一个/上一个和缩放效果的pdf,我检查了已经存在的库,但是太慢了,我移动到itext。 我安装jar文件和代码以获得总页数。 但问题是我如何显示pdf,我的意思是说采取文本视图,然后我将如何管理pdf的背景,所以有很多查询。 如果有人走过这些台阶,有人能帮我吗android和itext,android,Android,我想在android中显示带有下一个/上一个和缩放效果的pdf,我检查了已经存在的库,但是太慢了,我移动到itext。 我安装jar文件和代码以获得总页数。 但问题是我如何显示pdf,我的意思是说采取文本视图,然后我将如何管理pdf的背景,所以有很多查询。 如果有人走过这些台阶,有人能帮我吗 提前感谢您,我们将提供所有建议。据我所知,iText不是用来显示PDF文件,而是用来操作(如:读取、更改、写入)它们。查看是不可能的。据我所知,iText不是用来显示PDF文件,而是用来操作(如:读取、更改
提前感谢您,我们将提供所有建议。据我所知,iText不是用来显示PDF文件,而是用来操作(如:读取、更改、写入)它们。查看是不可能的。据我所知,iText不是用来显示PDF文件,而是用来操作(如:读取、更改、写入)它们。无法查看。在设备上安装pdf查看器,如Adobe Reader(可在Android MarketPlace上获得)。然后,通过在应用程序中使用此功能,您可以使用意图打开pdf
public void OpenPDF(File f)
{
Uri uri = Uri.parse("file://" + file.getAbsolutePath());
intent.setDataAndType(uri, "application/pdf");
startActivity(intent);
}
在您的设备上安装pdf查看器,如Adobe Reader(可在Android MarketPlace上获得)。然后,通过在应用程序中使用此功能,您可以使用意图打开pdf
public void OpenPDF(File f)
{
Uri uri = Uri.parse("file://" + file.getAbsolutePath());
intent.setDataAndType(uri, "application/pdf");
startActivity(intent);
}
试试看:
private void openFile(String path) {
Intent intent = new Intent();
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setAction(android.content.Intent.ACTION_VIEW);
File f = new File(path);
String type = FileUtil.getMIMEType(f.getName());
intent.setDataAndType(Uri.fromFile(f), type);
startActivity(intent);
}
public static String getMIMEType(String name) {
String type = "";
String end = name.substring(name.lastIndexOf(".") + 1, name.length()).toLowerCase();
end = end.toLowerCase();
if (end.equals("apk")) {
return "application/vnd.android.package-archive";
} else if (end.equals("mp4") || end.equals("avi") || end.equals("3gp")
|| end.equals("rmvb")) {
type = "video";
} else if (end.equals("m4a") || end.equals("mp3") || end.equals("mid") || end.equals("xmf")
|| end.equals("ogg") || end.equals("wav")) {
type = "audio";
} else if (end.equals("jpg") || end.equals("gif") || end.equals("png")
|| end.equals("jpeg") || end.equals("bmp")) {
type = "image";
} else if (end.equals("txt") || end.equals("log") || end.equals("sql")) {
type = "text";
}else {
type = "*";
}
type += "/*";
return type;
}
试试看:
private void openFile(String path) {
Intent intent = new Intent();
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setAction(android.content.Intent.ACTION_VIEW);
File f = new File(path);
String type = FileUtil.getMIMEType(f.getName());
intent.setDataAndType(Uri.fromFile(f), type);
startActivity(intent);
}
public static String getMIMEType(String name) {
String type = "";
String end = name.substring(name.lastIndexOf(".") + 1, name.length()).toLowerCase();
end = end.toLowerCase();
if (end.equals("apk")) {
return "application/vnd.android.package-archive";
} else if (end.equals("mp4") || end.equals("avi") || end.equals("3gp")
|| end.equals("rmvb")) {
type = "video";
} else if (end.equals("m4a") || end.equals("mp3") || end.equals("mid") || end.equals("xmf")
|| end.equals("ogg") || end.equals("wav")) {
type = "audio";
} else if (end.equals("jpg") || end.equals("gif") || end.equals("png")
|| end.equals("jpeg") || end.equals("bmp")) {
type = "image";
} else if (end.equals("txt") || end.equals("log") || end.equals("sql")) {
type = "text";
}else {
type = "*";
}
type += "/*";
return type;
}
谢谢,但是有什么方法可以在应用程序内部查看pdf?谢谢,但是有什么方法可以在应用程序内部查看pdf?是的,但是我想在应用程序一侧打开它,我已经使用vudroid库完成了。是的,但是我想在应用程序一侧打开它,我已经使用vudroid库完成了。