Signin/Signup with: 
Welcome, Guest
Username: Password: Remember me
Questions about Android development and PDF
  • Page:
  • 1

TOPIC:

Rendering of preview of page 9 years 3 months ago #8265

  • petr.sklenicka
  • petr.sklenicka's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 36
  • Thank you received: 0
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.

Please Log in or Create an account to join the conversation.

Last edit: by sanyu erisa. Reason: Add some information

Rendering of preview of page 9 years 3 months ago #8266

  • radaee
  • radaee's Avatar
  • Offline
  • Moderator
  • Moderator
  • Posts: 1123
  • Thank you received: 73
how you rendering previews of pages?
may you give piece of codes?

Please Log in or Create an account to join the conversation.

Rendering of preview of page 9 years 3 months ago #8267

  • petr.sklenicka
  • petr.sklenicka's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 36
  • Thank you received: 0
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

Please Log in or Create an account to join the conversation.

Rendering of preview of page 9 years 3 months ago #8268

  • radaee
  • radaee's Avatar
  • Offline
  • Moderator
  • Moderator
  • Posts: 1123
  • Thank you received: 73
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;
}

Please Log in or Create an account to join the conversation.

Last edit: by .
  • Page:
  • 1
Powered by Kunena Forum