Victor2018 / DocViewer

android DocViewer support view word excel ppt pdf txt image in sdcard & uri & assets & url
32 stars 8 forks source link

Convert Office #5

Open DevTrinh opened 8 months ago

DevTrinh commented 8 months ago

Hey man, can I ask you something, let's say I have a docx file, with 3 pages, how can I output each page as a bitmap or image (returns a list of bitmaps? ). With your code given:

private void initControl() {
        control = new MainControl(this);
        control.setOffictToPicture(new IOfficeToPicture() {
            public Bitmap getBitmap(int componentWidth, int componentHeight) {
                if (componentWidth == 0 || componentHeight == 0) {
                    return null;
                }
                if (bitmap == null
                        || bitmap.getWidth() != componentWidth
                        || bitmap.getHeight() != componentHeight) {
                    // custom picture size
                    if (bitmap != null) {
                        bitmap.recycle();
                    }
                    bitmap = Bitmap.createBitmap((int) (componentWidth), (int) (componentHeight), Bitmap.Config.ARGB_8888);
                }
                return bitmap;
            }

            public void callBack(Bitmap bitmap) {
                saveBitmapToFile(bitmap);
            }

            private Bitmap bitmap;

            @Override
            public void setModeType(byte modeType) {

            }

            @Override
            public byte getModeType() {
                return VIEW_CHANGE_END;
            }

            @Override
            public boolean isZoom() {
                return false;
            }

            @Override
            public void dispose() {

            }
        });
    }

desired image as: public void callBack(Bitmap bitmap) { saveBitmapToFile(bitmap); } How to make the result return a bitmap list, I tried to fix it but my level does not allow me to complete this yet. Hope you can update it in the future. Thank you for the great project

Victor2018 commented 8 months ago

yes,you can get all page bitmap by public void callBack(Bitmap bitmap) { saveBitmapToFile(bitmap); } to add bitmap in list so diplay in other view

DevTrinh commented 8 months ago

What I mean is that it will return a bitmap list, with each item in this list being each page of the word or pptx file. Currently, it only returns a single page when it is displayed, and initialized.