RadaeePDF.com :: Topic: Rendering of preview of page (1/1)
Welcome, Guest
Username: Password: Remember me

Signin/Signup with:

Questions about Android development and PDF

TOPIC: Rendering of preview of page

Rendering of preview of page 2 years 6 months ago #8265

Hi,
I have a problem with rendering previews of pages. There is a one page in my PDF document, which causes hard crash when rendering preview of this page. The rendering of previews works fine for all other pages, but this one page causes some hard error.
This is a link for this page: www.dropbox.com/s/fw2j5occ3ss3ojb/Page.pdf?dl=0
I am able to display this page, but I am not able to render the preview of this page.
Can you please give me an advice, what is wrong or how can I solve it?
Many thanks, Petr.

UPDATE:
I am using the newest version of native library.
Last Edit: 2 years 6 months ago by sanyu erisa. Reason: Add some information
The administrator has disabled public write access.

Rendering of preview of page 2 years 6 months ago #8266

  • radaee
  • radaee's Avatar
  • OFFLINE
  • Moderator
  • Posts: 825
  • Thank you received: 10
  • Karma: 43
how you rendering previews of pages?
may you give piece of codes?
The administrator has disabled public write access.

Rendering of preview of page 2 years 6 months ago #8267

I am using this piece of code:
PDFVPage page = mPages[numberOfPage];
...
// get width and height of page
...

// Rendering process
page.thumbPrepare(width, height, scale);
        Bitmap bitmap = mRenderThread.renderThumb(page.m_thumb, width, height);
        page.m_thumb.clear();

        if (bitmap != null) {
            return bitmap;
        } else {
            throw new IOException("The bitmap has not been rendered");
        }

where method renderThumb looks like this:
public Bitmap renderThumb(PDFVThumb thumb, int width, int height) {
        return thumb.render(width, height);
    }

and code for render method:
protected Bitmap render(int width, int height) {
        m_page = m_doc.GetPage(m_pageno);
        if (m_bmpw > 0 && m_bmph > 0) {
            try {
                Bitmap bmp = Bitmap.createBitmap(width, height, Config.ARGB_8888);
                bmp.eraseColor(0xFFFFFFFF);
                Matrix mat = new Matrix(m_scale, -m_scale, 0, m_bmph);                
                m_page.RenderToBmp(bmp, mat);
                mat.Destroy();
                return bmp;
            } catch (Exception e) {
                return null;
            }
        }
        return null;
    }

Then, I need to save preview into the file. I am using this: www.androidpdf.mobi/forum/Android-develo...f-page-into-the-file
The administrator has disabled public write access.

Rendering of preview of page 2 years 6 months ago #8268

  • radaee
  • radaee's Avatar
  • OFFLINE
  • Moderator
  • Posts: 825
  • Thank you received: 10
  • Karma: 43
codes modified so much...
in last version, there are no PDFVThumb class.
i think codes like this:
protected Bitmap render(int width, int height)
{
Page page = m_doc.GetPage(m_pageno);
if (m_bmpw > 0 && m_bmph > 0) {
try {
Bitmap bmp = Bitmap.createBitmap(width, height, Config.ARGB_8888);
bmp.eraseColor(0xFFFFFFFF);
Matrix mat = new Matrix(m_scale, -m_scale, 0, m_bmph);                
page.RenderToBmp(bmp, mat);
mat.Destroy();
page.Close();
return bmp;
} catch (Exception e) {
if(bmp != null) bmp.recycle();
page.Close();
return null;
}
}
if(bmp != null) bmp.recycle();
page.Close();
return null;
}
Last Edit: 2 years 6 months ago by .
The administrator has disabled public write access.
Powered by Kunena Forum