Android 图像到pdf的转换。为Nexus s及以上分辨率/大小设备剪切pdf文件:-

Android 图像到pdf的转换。为Nexus s及以上分辨率/大小设备剪切pdf文件:-,android,Android,我正在拍摄当前屏幕的快照,将其存储在sd卡中,然后将其转换为pdf格式。如果我在NexusOne上测试的话一切都很好,但是当我选择更高分辨率的设备NexusS,GalaxyNexus时,转换后的pdf并没有显示全屏截图,而是被切碎了。我已经提前在下面分享了我使用的代码.Thanx 我的截屏方法: public Bitmap takeScreenshot() { View rootView = findViewById(android.R.id.content).getRoo

我正在拍摄当前屏幕的快照,将其存储在sd卡中,然后将其转换为pdf格式。如果我在NexusOne上测试的话一切都很好,但是当我选择更高分辨率的设备NexusS,GalaxyNexus时,转换后的pdf并没有显示全屏截图,而是被切碎了。我已经提前在下面分享了我使用的代码.Thanx

我的截屏方法:

public Bitmap takeScreenshot() {
           View rootView = findViewById(android.R.id.content).getRootView();
           rootView.setDrawingCacheEnabled(true);
           return rootView.getDrawingCache();
        }
    public void saveBitmap(Bitmap bitmap) {
        File imagePath = new File(Environment.getExternalStorageDirectory() + "/screenshot.png");
        FileOutputStream fos;
        try {
            fos = new FileOutputStream(imagePath);
            bitmap.compress(CompressFormat.JPEG,100, fos);
            fos.flush();
            fos.close();
        } catch (FileNotFoundException e) {
            Log.e("GREC", e.getMessage(), e);
        } catch (IOException e) {
            Log.e("GREC", e.getMessage(), e);
        }
    }
我的pdf转换方法:-

void Pdfconverter() throws Exception
       {                  
            Document document=new Document();
            PdfWriter.getInstance(document,new FileOutputStream("mnt/sdcard/FirstPdf.pdf"));
            document.open();
            Image image = Image.getInstance (Environment.getExternalStorageDirectory() + "/screenshot.png");
            document.add(new Paragraph("Heading for the Image"));
            document.add(image);               
            document.close(); 
       }