我的应用程序没有在 pdf 中加载图像,并且每次在 pdf 中加载包含图像的页面时都会出错。
这是 LogCat:
06-29 11:07:29.900: E/APV.PDFRenderer(468): image with unsupported colorspace ColorSpace[CMYK]
06-29 11:07:29.900: E/APV.PDFRenderer(468): java.lang.UnsupportedOperationException: image with unsupported colorspace ColorSpace[CMYK]
06-29 11:07:29.900: E/APV.PDFRenderer(468): at com.sun.pdfview.PDFImage.parseData(PDFImage.java:319)
06-29 11:07:29.900: E/APV.PDFRenderer(468): at com.sun.pdfview.PDFImage.getImage(PDFImage.java:225)
06-29 11:07:29.900: E/APV.PDFRenderer(468): at com.sun.pdfview.PDFRenderer.drawImage(PDFRenderer.java:374)
06-29 11:07:29.900: E/APV.PDFRenderer(468): at com.sun.pdfview.PDFImageCmd.execute(PDFPage.java:654)
06-29 11:07:29.900: E/APV.PDFRenderer(468): at com.sun.pdfview.PDFRenderer.iterate(PDFRenderer.java:674)
06-29 11:07:29.900: E/APV.PDFRenderer(468): at com.sun.pdfview.BaseWatchable.run(BaseWatchable.java:101)
06-29 11:07:29.900: E/APV.PDFRenderer(468): at com.sun.pdfview.BaseWatchable.execute(BaseWatchable.java:263)
06-29 11:07:29.900: E/APV.PDFRenderer(468): at com.sun.pdfview.BaseWatchable.go(BaseWatchable.java:197)
06-29 11:07:29.900: E/APV.PDFRenderer(468): at com.sun.pdfview.PDFPage.getImage(PDFPage.java:237)
06-29 11:07:29.900: E/APV.PDFRenderer(468): at net.sf.andpdf.pdfviewer.PdfViewerActivity.showPage(PdfViewerActivity.java:790)
06-29 11:07:29.900: E/APV.PDFRenderer(468): at net.sf.andpdf.pdfviewer.PdfViewerActivity.access$12(PdfViewerActivity.java:769)
06-29 11:07:29.900: E/APV.PDFRenderer(468): at net.sf.andpdf.pdfviewer.PdfViewerActivity$3.run(PdfViewerActivity.java:259)
06-29 11:07:29.900: E/APV.PDFRenderer(468): at java.lang.Thread.run(Thread.java:1096)
这个代码:
第一个.java
package android.pdf.reader;
import java.io.File;
import java.io.FilenameFilter;
import net.sf.andpdf.pdfviewer.PdfViewerActivity;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
public class First extends ListActivity {
String LOGTAG="";
String[] pdflist;
File[] imagelist;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// setContentView(R.layout.main);
File images = Environment.getExternalStorageDirectory();
imagelist = images.listFiles(new FilenameFilter() {
public boolean accept(File dir, String name) {
return ((name.endsWith(".pdf")));
}
});
pdflist = new String[imagelist.length];
for (int i = 0; i < imagelist.length; i++) {
Log.e(LOGTAG,imagelist[i].getName());
pdflist[i] = imagelist[i].getName();
}
this.setListAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, pdflist));
}
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
String path = imagelist[(int) id].getAbsolutePath();
Log.d(LOGTAG,path);
openPdfIntent(path);
}
private void openPdfIntent(String path) {
try {
final Intent intent = new Intent(First.this,Second.class);
intent.putExtra(PdfViewerActivity.EXTRA_PDFFILENAME, path);
startActivity(intent);
} catch (Exception e) {
e.printStackTrace();
}
}
}
二.java
package android.pdf.reader;
import net.sf.andpdf.pdfviewer.PdfViewerActivity;
import android.os.Bundle;
public class Second extends PdfViewerActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
}
public int getPreviousPageImageResource() {
return R.drawable.left_arrow;
}
public int getNextPageImageResource() {
return R.drawable.right_arrow;
}
public int getZoomInImageResource() {
return R.drawable.zoom_in;
}
public int getZoomOutImageResource() {
return R.drawable.zoom_out;
}
public int getPdfPasswordLayoutResource() {
return R.layout.pdf_file_password;
}
public int getPdfPageNumberResource() {
return R.layout.dialog_pagenumber;
}
public int getPdfPasswordEditField() {
return R.id.etPassword;
}
public int getPdfPasswordOkButton() {
return R.id.btOK;
}
public int getPdfPasswordExitButton() {
return R.id.btExit;
}
public int getPdfPageNumberEditField() {
return R.id.pagenum_edit;
}
}
显现
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="android.pdf.reader"
android:versionCode="1"
android:versionName="1.0" >
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".First"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Second"
android:label="@string/app_name" >
</activity>
</application>
<uses-sdk android:minSdkVersion="8" />
</manifest>
有什么建议么?
谢谢