第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

將Pdf頁面轉(zhuǎn)換為Android Java中的Bitmap

將Pdf頁面轉(zhuǎn)換為Android Java中的Bitmap

富國滬深 2019-08-13 09:46:04
將Pdf頁面轉(zhuǎn)換為Android Java中的Bitmap我需要將PDF文件(PDF頁面)轉(zhuǎn)換為Android中的位圖(或圖像文件)。1.使用Apache的Pdfbox jar。但是它使用了android中不支持的一些java類。2.嘗試將圖像轉(zhuǎn)換為pdf的Itext jar(我需要它的反向操作)就像我嘗試了很多罐子一樣。但沒有積極的結(jié)果。byte[] bytes;     try {         File file = new File(this.getFilesDir().getAbsolutePath()+"/2010Q2_SDK_Overview.pdf");         FileInputStream is = new FileInputStream(file);         // Get the size of the file         long length = file.length();         bytes = new byte[(int) length];         int offset = 0;         int numRead = 0;         while (offset < bytes.length && (numRead=is.read(bytes, offset, bytes.length-offset)) >= 0) {             offset += numRead;         }         ByteBuffer buffer = ByteBuffer.NEW(bytes);         String data = Base64.encodeToString(bytes, Base64.DEFAULT);         PDFFile pdf_file = new PDFFile(buffer);         PDFPage page = pdf_file.getPage(2);         RectF rect = new RectF(0, 0, (int) page.getBBox().width(),                 (int) page.getBBox().height());       //  Bitmap bufferedImage = Bitmap.createBitmap((int)rect.width(), (int)rect.height(),          //        Bitmap.Config.ARGB_8888);         Bitmap image = page.getImage((int)rect.width(), (int)rect.height(), rect);         FileOutputStream os = new FileOutputStream(this.getFilesDir().getAbsolutePath()+"/pdf.jpg");         image.compress(Bitmap.CompressFormat.JPEG, 80, os);        // ((ImageView) findViewById(R.id.testView)).setImageBitmap(image);否則,使用內(nèi)置在應(yīng)用程序中的函數(shù)在android中顯示pdf文件的任何其他方式?
查看完整描述

4 回答

?
zhangjinhuang

TA貢獻1條經(jīng)驗 獲得超0個贊

有實現(xiàn)了的么?我今天也遇到了這問題,需要將pdf文件解析成bitmap

查看完整回答
反對 回復(fù) 2019-11-08
  • 4 回答
  • 0 關(guān)注
  • 1454 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號